Posts

Showing posts from February, 2015

php - How to create select option from database? -

i'm working on form has 4 different select elements 2 tables of database. haven't done , don't know how it. i have table called "students" need "name" , "class" , table called "books" need "writer" "title" ... 1 select element , has more 2 option values. i've tried 1 sql query , 1 select shows 1 option on site, wether has 6 values in database. my code: $sql = "select class students"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $select_class = "<option value={$row['class']}>{$row['class']}</option>"; } <select id="class" name="class"> <?php print $select_class; ?> </select> how correct? you overwriting $select_class on each while() loop. need concatenate $select_class . change $select_class .= $select_class = ""; while ($row = mysql_fetch_asso

date - PHP Daylight savings bug? -

i ran strange bug has occurs in php running in pacific time (and others). had code first day of week (sunday) given arbitrary date (in unix timestamp) in week: $day = date('w', $date); $start_of_week = date('y-m-d', $date - ($day * 60*60*24)); echo $start_of_week; prints 2014-03-08 this works every single date i've tried, except in week of march 9th, 2014, happens week of daylight savings time in us. those, $start_of_week '2014-03-08', saturday. when run code timezone set gmt, correct output ('2014-03-09'). additionally, when change code following in pst, correct output: $day = date('w', $date); $start_of_week = date('y-m-d', strtotime("-$day day", $date)); echo $start_of_week; prints 2014-03-09 so...wtf? why there difference between strtotime("-1 day", $date) , $date - 60*60*24 ? seems it's jumping between different timezones. codepad example

postgresql - Error with jdbc-river -

i'm trying load data elasticsearch jdbc-river, , i'm getting error. can tell me what's going on? org.elasticsearch.index.mapper.mapperparsingexception: object mapping [foo] tried parse object, got eof, has concrete value been provided it? @ org.elasticsearch.index.mapper.object.objectmapper.parse(objectmapper.java:467) @ org.elasticsearch.index.mapper.documentmapper.parse(documentmapper.java:515) @ org.elasticsearch.index.mapper.documentmapper.parse(documentmapper.java:462) @ org.elasticsearch.index.shard.service.internalindexshard.preparecreate(internalindexshard.java:371) @ org.elasticsearch.action.bulk.transportshardbulkaction.shardindexoperation(transportshardbulkaction.java:400) @ org.elasticsearch.action.bulk.transportshardbulkaction.shardoperationonprimary(transportshardbulkaction.java:153) @ org.elasticsearch.action.support.replication.transportshardreplicationoperationaction$asyncshardoperationaction.performonprimary(transportshar

c - For how long do the recv() functions buffer in UDP? -

my program contains thread waits udp messages , when message received runs functions before goes listening. worried missing message, question along line of, how long possible read message after has been sent? example, if message sent when thread running functions, still possible read if functions short enough? looking guidelines here, answer in microseconds appreciated. when computer receives udp packet (and there @ least 1 program listening on udp port specified in packet), tcp stack add packet's data fixed-size buffer associated socket , kept in kernel's memory space. packet's data stay in buffer until program calls recv() retrieve it. the gotcha if computer receives udp packet , there isn't enough free space left inside buffer fit new udp packet's data, computer throw udp packet away -- it's allowed that, since udp doesn't make guarantees packet arrive. so amount of time program has call recv() before packets start getting thrown away de

php - I want HTACCESS to block only direct access to a specific file -

i have file don't want users able navigate on own accord. however, if click link sends them there, it's okay page work. have htaccess file set so. <files "success.php"> order allow,deny deny </files> success.php name of file, , in directory of success.php , have following in htaccess file: rewriterule /?\.htaccess$ - [f,l] rewriterule ^/?admin/paypal/success\.php$ - [f,l] will users still able success.php if they're directed there, because know you're shown 403 error if try navigate there. if case blocked being directed there, there way can fix this? when type url "success.php" in browser's location bar , hit enter, browser sends request success.php. when go website , click on link takes me "success.php", browser sends request success.php. it's same, because click on link on site vs typing in browser, both requested same. when deny access, deny access. need check "referer" header, b

vb.net - Generate code when correct picturebox is clicked -

i making game kids learn different parts of objects part of 9th grade tech class syllabus. there picture of plane , 6 smaller pictures underneath it. 3 of pictures components of plane, others won't. only when person playing has clicked 3 right components win game. i can't figure out way code program 3 pictures need clicked before program advances. take 7 picturebox saying, suppose main picturebox picturebox1 , underneath ones picturebox2 , picturebox3 , picturebox4 , picturebox5 , picturebox6 , picturebox7 . if correct picturebox 2, 3, 4, then, write following code under click events. private sub form1_load () handles mybase.load textbox1.hide textbox1.text = 0 end sub private sub picturebox2_click () handles picturebox2.click textbox1.text = val(textbox1.text) + 1 end sub private sub picturebox3_click () handles picturebox3.click textbox1.text = val(textbox1.text) + 1 end sub private sub picturebox3_click () handles pictu

bash - Remove escaping sequences automatically while redirecting -

lots of shell tools such grep , ls can print colorful texts in terminal. , when output redirected regular file, escaping sequences representing colors removed , pure texts written file. how achieve that? use: if [ -t 1 ] to test whether stdout connected terminal. if is, print escape sequences, otherwise print plain text.

ios - How to keep Gestures Recognizers from Intercepting Messages for a Child -

i have uiview contains table view. i want user able select items in table view , want able identify taps in parent view, outside table view. if add tab gesture recognizer uiview, user unable select items in table view. how can accomplish task? in case, you've add gesture view , can cancel gesture call method doing if touch happen on tableview below. 1) set tag tableview . self.tableview.tag = tag ; 2) cancel gesture if touch on tableview below - (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldreceivetouch:(uitouch *)touch { id touchview= touch.view; if ([touchview iskindofclass:[uitableview class]] || [touchview iskindofclass:[uitableviewcell class]] ) { if ( ((uiview*)touchview).tag == tag) return no; } return yes; }

Need Jquery Datepicker to show "Month" and "Year" as text in dropdown list -

this need. select menus contain words "year" , "month". (usually please select) demo 1: - jsfiddle1 but should run text box demo1. demo 2: - jsfiddle2 if change last line in source code posted <div id="datepicker"></div> to date: <input type="text" id="datepicker"> then stops prepending text dropdown? source code $(document).ready(function(){ $('#datepicker').datepicker({ changemonth: true, changeyear: true, onchangemonthyear: function (year, month) { $("#startyear").val(year); $("#startmonth").val(month); } }); $(".ui-datepicker-month").prepend("<option value='' selected='selected'>month</option>"); $(".ui-datepicker-year").prepend("<option value='' selected='selected'>year</option>")

i3 window manager - put MATLAB figure window in specific workspace -

i'm using i3 window manager in ubuntu 12.04. work lot matlab, , started wondering if there way make i3 put figures in specific workspace each time plot something. i've read parts of i3 user-guide couldn't figure out way this. the solution problem put following in .i3/config: assign [class="com-mathworks-util-postvminit" title="^fig"] 2 this makes figure windows matlab appear in workspace 2. string "com-mathworks-util-postvminit" class name of matlab figure found using xprop terminal command. to make sure it's figure windows in matlab that's behaving way i've added title="^fig", seperate other matlab windows.

asp.net - Access Session List in javascript -

.aspx.cs: list<someobject> items = whatever.getlist(); session["records"] = items; if access session in javascript file gives me string 'system.collections.generic.list`1[someobject]' .js function: var records = '<%= session["records"] %>'; how can convert session array? thanks you have iterate through array , print right values: var records = []; <% foreach(var item in (list<someobject>)session["records"]) { %> records.push('<%= item.propertyname %>'); <% } %> now got array in script values. to array of objects { property1: "value1", property2: "value2" } , stands same structur of c# object, example, have use reflection.

select - SQL selecting not surely existing column from on table or another -

i use generalisation/specialize table zadavatel (which contains primary key) either table sukromna_osoba or firma (both contains foreign key points on zadavatel). need select sukromna_osoba table if sukromna_osoba.meno = 'string' exists or firma table if firma.nazov_firmy = 'string' exists, both if both conditions true. need in 1 select. create table zadavatel ( id_zadavatela integer, adresa varchar(25) ); create table sukromna_osoba ( id_sukromnej_osoby integer, meno varchar(20), mobil integer, email varchar(20) ); create table firma ( id_firmy integer, nazov_firmy varchar(20), ico integer, bankove_spojenie integer ); id_zadavatela primary key, , id_sukromnej_osoby , id_firmy foreign keys points @ id_zadavatela. i tried this: select pr.id_projektu, pr.popis, zad.id_zadavatela, fi.nazov_firmy projekt pr join zamestnanec zam on pr.manazer = zam.osobne_cislo join zadavatel zad on pr.zadavatel = zad.id_zadavatela join firma fi on zad.id_za

java - Member variable null on function return -

possible duplicate, doesn't apply example: here i have 2 member variables mselectedorderitem , mselectedorderitemid, both of un-initialised , therefore null. (still doesn't work if assign them null in oncreate). there's arraylist morderlist. in list view, if select item, these variables assigned values corresponding item. i want use assigned values in method onclick, onclick sees mselectedorderitem null, regardless of whether initialised in onitemclick , can't figure out why. import java.util.arraylist; import android.support.v4.app.fragment; import android.support.v4.app.fragmenttabhost; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.view.onclicklistener; import android.view.viewgroup; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.button; import android.widget.edittext; import android.widget.linearlayout; import android.widg

java - Mapping Object Hibernate -

i'm trying insert hibernate in project have problem mapping. db contains: - id ->int - question -> varchar - result -> varchar - id_left -> int - id_right -> int here, code of bean @entity @table (name = "node") public class nodes { @id @generatedvalue (strategy = generationtype.identity) @column(name="id") private int id; @column (name = "question") private string question; @column ( name = "result") private string result; @onetoone(fetch= fetchtype.lazy) private nodes left; @onetoone(fetch= fetchtype.lazy) private nodes right; public nodes(int id, string question, string result, nodes left, nodes right) { this.id=id; this.question=question; this.result=result; this.left=left; this.right=right; } public nodes() { } public nodes getleftnodes() { return left; }

arrays - Correct usage of subroutine in commodore basic 4.0? -

i have subroutine fills array "."s in main program trying call subroutine , print array; however, doesn't seem working. think incorrectly calling subroutine? this code: subroutine: 1070 dim a$(x,x) 1080 aa = 0 x 1090 bb = 0 x 2000 a$(x,x)="." 2010 next 2020 next main code: 10 input "please enter number"; x 20 gosub 1070 30 = 1 x 40 j = 1 x 50 print a$(i,j); 60 next 70 print 80 next nothing happens when run; when run in 1 program (not calling gosub) works? any help? in line #2000, believe want a$(aa,bb)="." , otherwise you're hammering same location initialization. also, , more important question, every gosub needs return main line of execution. in case, that's line 2030.

ruby on rails - Guard rspec doesn't run specs -

when spec or model changed, guard options spring rspec shows next output: 04:54:44 - info - running: spec/models/identity_spec.rb version: 1.1.2 usage: spring command [args] commands spring itself: binstub generate spring based binstubs. use --all generate binstub known commands. print available commands. status show current status. stop stop spring processes project. commands application: rails run rails command. following sub commands use spring: console, runner, generate, destroy. rake runs rake command frame number: 0/0 i'm using ruby '2.1.0' , 'rails', '4.1.0.rc1' spring. so, looks doesn't run anything. tried different cmd options. guard :rspec watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } # rails example watch(%r{^app/(.+)\.rb$})

css - Simpliest way of organizing divs, is this it? -

i need #header centered.. i wondering if have gone wrong.. want code simplest possible... should go making 3 div tables left middle right adjusting more fluidly.. http://jsfiddle.net/kdrjl/24/ <iframe width="100%" height="300" src="http://jsfiddle.net/kdrjl/24/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe> you needed basic fundamental knowledge of how , when use display:block, inline, , inline-block. floats i centered header. have sizes , beautification yourself. #header { background: url(https://dl.dropboxusercontent.com/u/63096695/header.png) no-repeat; width:240px; height:100px; margin:20px auto; display:block; } see demo now, far whether best way place divs. not bad, consider more semantic structure. instead of div="header" consider <header> instead <nav><section><aside><footer><address> etc

php - How to change those MySQL codes to PDO ? and how to escape a string with pdo codes? -

$sql = "insert users(user_name, user_pass, user_email, user_date, user_level) values('" . mysql_real_escape_string($_post['user_name']) . "' , '" . sha1($_post['user_pass']) . "' , '" . mysql_real_escape_string($_post['user_email']) . "' , now(), 0)"; $result = mysql_query($sql); // configuration $dbtype = "sqlite"; $dbhost = "localhost"; $dbname = "test"; $dbuser = "root"; $dbpass = "admin"; // database connection $conn = new pdo("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass); $user_name='mohoni'; $user_pass='mohinipass'; $user_email='mohini@yopmail.com'; $user_date='2014-03-21'; $user_level='first'; // query $sql = "insert users (user_name,user_pass,user_email,user

sql - Getting a unique grouping id from related columns -

i have table t 2 columns a, b a b -- -- a1 b1 a1 b2 a2 b1 a3 b1 a3 b4 null b4 a3 null a5 b6 i generate unique grouping related columns. since first 7 rows either directly or indirectly related, should constitute 1 group (g1) , remaining row have own group (g2). trying stay away custom function , seek pure sql solution actual table has on 1 million rows.

c# - Is there a built in type for a lookup/reverse lookup table? -

this question has answer here: bidirectional 1 1 dictionary in c# 8 answers i'm trying implement baudot character encoding. right now, i'm using 2 dictionaries mirrors of each other: dictionary<char, int> lookup = new dictionary<char, int> { { ' ', 0x100100 }, { '-', 0x011000 }, { '/', 0x010111 }, { '0', 0x001101 }, { '1', 0x011101 }, ... }; dictionary<int, char> reverse = new dictionary<int, char> { { 0x100100, ' ' }, { 0x011000, '-' }, { 0x010111, '/' }, { 0x001101, '0' }, { 0x011101, '1' }, ... }; is there built in type handles already? like: var lookup = new lookup<int, char>(); lookup.getbykey(0x100100); lookup.getbyvalue('c'); i couldn't find when searched 'reverse lookup

java - I have to write a fighter class to be used with my assignment program and it is returning errors that I cannot figure out -

import java.util.scanner; public class assignment5 { public static void main(string[] arg) { fighter myfighter, enemyfighter; scanner console = new scanner(system.in); int num1, num2, num3; string str, another; system.out.println ("*** fighter game ***"); { system.out.println("create fighter (type 3 integers + name): "); num1 = console.nextint(); num2 = console.nextint(); num3 = console.nextint(); str = console.next(); if (num1 + num2 + num3 == 10) { myfighter = new fighter (num1, num2, num3, str); enemyfighter = new fighter( ); enemyfighter.setname ("enemy"); system.out.print( myfighter.getname()+" ["+myfighter.getpower()+","+myfighter.getspeed()+","+myfighter.getheal()+"] ");

sql - If statement to determine which SELECT to return in Table-Valued Function -

due recent change in business rules, set of data used stored in 1 database , stored in different database on same server. things set up, if user wants query data range of dates overlaps time when business rules changed, they're forced use if statement in code. i create table-valued function abstract change in business rules users making such query. i'm trying execute code similar this: create function dbo.somefunction (date datetime) returns table return if (date <= business_rules_change_date) begin select (a select statement) (old database) (criteria) end else select (a similar select statement) (new database) join (a join statement) (criteria) go and i'm being told there syntax error around if statement. there solution problem? or yuriy has suggested can make use of multi-statement-table valued functions this... create function dbo.somefunction (date datetime) returns @table table ( -- define structure of table here ) begin if (date <= b

c++ - vector does not name a type -

i have error in title: here class declaration of variables , prototypes of function #ifndef rozkladliczby_h #define rozkladliczby_h class rozkladliczby{ public: rozkladliczby(int); //konstruktor vector<int> czynnikipierwsze(int); //metoda ~rozkladliczby(); }; #endif and class body: #include "rozkladliczby.h" using namespace std; #include <iostream> #include <vector> rozkladliczby::~rozkladliczby() //destruktor {} rozkladliczby::rozkladliczby(int n){ int* tab = new int[n+1]; int i,j; for( i=0;i<=n;i++) tab[i]=0; //zerujemy tablice for( i=2;i<=n;i+=2) tab[i]=2; //zajmujemy sie liczbami parzystymi for(i=3; i<=n;i+=2) for(j=i;j<=n;j+=i) //sito erastotesa if(tab[j]==0) tab[j]=i; } vector<int> rozkladliczby::czynnikipierwsze(int m){ vector<int> tablica; while(m!=1){ tablica.push_back(tab[m]);

css - Floating menu jquery hover -

i got following floating menu on site: $(function() { var nav = $('nav'); var nava = $('nav a'); /* var navaonhover = $('nav a:hover'); */ var navhomey = nav.offset().top; var isfixed = false; var $w = $(window); nav.css({ background: '#222' }); $w.scroll(function() { var scrolltop = $w.scrolltop(); var shouldbefixed = scrolltop > navhomey; if (shouldbefixed && !isfixed) { nav.css({ transition: 'all 0.30s ease-in-out', position: 'fixed', top: 0, left: nav.offset().left, width: nav.width(), height: 59, background: '#315d90' }); nava.css({ color:'#fff' }); /* navaonhover.css({ color:'#000' }); */ isfixed = true; }

java - Need help sending HTTP post to login on twitter -

i desperately trying send http post authenticate twitter via java keep getting http 400 response code. this html code form want use: sign in remember me · forgot password? new twitter? i using jsoup try access class "signin" form @ top. want because want use code: element loginform = doc.getelementbyclass("signin"); elements inputelements = loginform.getelementsbytag("input"); list<namevaluepair> paramlist = new arraylist<namevaluepair>(); (element inputelement : inputelements) { string key = inputelement.attr("name"); string value = inputelement.attr("value"); if (key.equals("session[username_or_email]")) value = username; else if (key.equals("session[password]")) value = password; paramlist.add(new basicnamevaluepair(key, value)); } this code not work because "loginform" class must "getelemenbyid" instea

java - Client/Server chat, sending online user list, only received by the most recently connect client? -

static arraylist<client> clients = new arraylist<client>(); while (true) { socket s = server.accept(); system.out.println("client connected " + s.getlocaladdress().gethostname()); thread t = new thread(new client(s)); t.start(); } simply premise, inside client class got made adding static arraylist of 'client' located in main server class (above) i.e. clients.add(client.this); i every 10 seconds, sending online users object clients in arraylist (global message in effect) for(int =0; < clients.size(); i++) { system.out.print("sending list"); clients.get(i).sendlist(); } now, correctly add right number of clients etc.. , list gathered correctly, client happily recieves list every 10 seconds

python - Using twisted on OS X Mavericks -

i trying use twisted on os x mavericks, error message when try import it. christohersmbp2:~ christopherspears$ python python 2.7.6 (default, mar 8 2014, 09:29:01) [gcc 4.2.1 compatible apple llvm 5.0 (clang-500.2.79)] on darwin type "help", "copyright", "credits" or "license" more information. >>> import twisted traceback (most recent call last): file "<stdin>", line 1, in <module> importerror: no module named twisted my guess receiving error because not using default python. using python installed brew. ideally, want install twisted virtual environment play with, docs lacking in details. apparently, dmg exists mac os x 10.5, not helpful me. can install tarball virtual environment, not sure how this. hints? if you're using virtualenv , doesn't matter whether using system python or not. simply pip install twisted in virtualenv, like: $ workon mytwiste

php - Linux make file -

i'm trying have php write file using ssh2 connection. i'm trying write file contains this: generator-settings= op-permission-level=4 allow-nether=true level-name=world enable-query=false allow-flight=false announce-player-achievements=true server-port=25565 level-type=default enable-rcon=false force-gamemode=false level-seed= server-ip= max-build-height=256 spawn-npcs=true white-list=false spawn-animals=true snooper-enabled=true hardcore=false online-mode=true resource-pack= pvp=true difficulty=1 enable-command-block=false player-idle-timeout=0 gamemode=0 max-players=40 spawn-monsters=true view-distance=5 generate-structures=true spawn-protection=16 motd=a minecraft server i'm trying use echo -n '.$serverp.' > server.properties $serverp getting data base large chunk of text. if :)

android - Eclipse ADT produces infinite error messages in logcat when running on device -

i received following message when tried debug on android device after failed run. got message in console saying apk invalid, , check logcat more information. below logcat output , kept going. noticed android version on device , version on project different. right-clicked android file(the project set libgdx), properties -> android -> checked box same android version device. fixed problem. i'm new android , know message means , why doesn't stop. 03-22 23:30:01.510: e/mtpservice(6009): in mtpapp onreceive:android.intent.action.battery_changed 03-22 23:30:01.510: e/mtpservice(6009): battplugged type : 2 03-22 23:30:11.570: e/mtpservice(6009): in mtpapp onreceive:android.intent.action.battery_changed 03-22 23:30:11.570: e/mtpservice(6009): battplugged type : 2 03-22 23:30:19.908: e/watchdog(2024): !@sync 108 03-22 23:30:21.600: e/mtpservice(6009): in mtpapp onreceive:android.intent.action.battery_changed 03-22 23:30:21.600: e/mtpservice(6009)

Error with facebook loginexample for android -

i don't example facebook work. implemented code https://developers.facebook.com/docs/android/login-with-facebook till step 3. code gives no errors in logcat, thing when click confirmation want login facebook, logcat tells me "logged out..." message. that tells me piece of code giving problems private void onsessionstatechange(session session, sessionstate state, exception exception) { if (state.isopened()) { log.i(tag, "logged in...."); } else if (state.isclosed()) { log.i(tag, "logged out...."); } } i thonk got steps (keyhash e.d.) done. somebody got , idea? thx

inheritance - C++ Interface issues with creating an instance of it -

so have assignment in c++ class asking me create abstract base class called project, , interface called task. gave driver code main, , within it's asking create instance of interface "task", , keep getting error saying " cant create instance of abstract base class" here's "task" interface header file , main.. hope it's enough. #pragma once #ifndef task_h #define task_h class task { public: task(); virtual ~task(); virtual void addprereq(task *pt) = 0; virtual bool ready() = 0; virtual bool done() = 0; virtual void doit() =0; }; #endif and main: #include "stdafx.h" #include "compositeproject.h" #include "minorproject.h" #include "simpleproject.h" #include "task.h" int _tmain(int argc, _tchar* argv[]) { // create tasks task* tasks[7]; (int = 0; != 7; ++i) tasks[i] = new task();//this error coming // set prerequisites tasks[1]->addprereq(tasks[0]); tasks[2

caching - Using ElastiCache through C# -

i trying setup elastic cache (memcached engine) & use in .net application through memcache c# client api "enyim". i'm new aws , facing problems. have few questions :- question 1 : can access cache cluster nodes local machine ? question 2 : process of setting complete aws elastic cache instance. correct me if i'm wrong :- setup vpc (by default) setup security group in ec2 (by default) setup cache cluster same vpc. how can use same cache cluster ? i have setup memcache engine on local & same code through enyim running not able run same (get/set) code elasticache node instances. as far question #1, when using redis flavor of elastic cache cannot (according aws never able) access cache anywhere except within aws. for debugging purposes nice able to, in production mode, accessing cache outside aws introduce sufficient latency defeat benefit might using cache in first place.

video streaming - Forward packets from one port to another in same program -

i writing program receive video stream vlc , forward it. using java. created port (1234) , receiving packets in port vlc using udp. want forward packets port can re-route it. unfortunately cant forward .receiving part working fine. how can resolve it. code given below datagramsocket clientsocket = new datagramsocket(1234); datagramsocket sendsocket = new datagramsocket(9999); inetaddress ipaddress = inetaddress.getbyname("localhost"); system.out.println("connected server !"); thread.sleep(100); int i=0; byte[] recievedata = new byte[8196]; byte[] senddata= new byte[8196]; datagrampacket dp=new datagrampacket(recievedata,recievedata.length, ipaddress, 1234); while(true) { clientsocket.receive(dp); recievedata=dp.getdata(); senddata=dp.getdata(); system.out.println(recievedata.tostring()); s

java - How to spy an EJB with mockito? -

if normal classes it's @spy classtobespied class = new classtobespied(); ejb? possible doing without having use embedded web server? in advance. you can spy ejb classes, way won't have standard ejb features, transactions. behave "normal" java object, created outside ejb context.

Gracenote API: Search and fetch contents in specific language -

i'm wondering if there way data in specific language when using gracenote series_search or series_fetch methods. it turns out using ger field useless... still data in english ... if resolving this, great! =) gracenote uses 3-letter iso 639-2 codes specify languages. format described @ http://en.wikipedia.org/wiki/list_of_iso_639-2_codes - gracenote supports major languages. thanks suggestion, we've added documentation our page at: https://developer.gracenote.com/eyeq

Generate RDF graph from CSV triplets -

i need convert csv file (tab delimited triplets) [subject predicate object] rdf graph. csv file looks this: <http://gadm.geovocab.org/id/1_3214_geometry_1km.rdf> <http://code.google.com/p/ldspider/ns#headerinfo> _:header14010232801335542310249 _:header14010232801335542310249 <http://www.w3.org/2006/http#responsecode> 200^^<http://www.w3.org/2001/xmlschema#integer> _:header14010232801335542310249 <http://www.w3.org/2006/http#date> fri, 27 apr 2012 15:58:31 gmt _:header14010232801335542310249 <http://www.w3.org/2006/http#server> apache/2.2.16 (debian) _:header14010232801335542310249 <http://www.w3.org/2006/http#expires> sat, 28 apr 2012 15:58:31 gmt _:header14010232801335542310249 <http://www.w3.org/2006/http#content-length> 4173 my knowledge of rdf/rdf query language limited. appreciate pointers. it looks format almost legal rdf (in n-triples syntax), might easiest fix few minor things , use rdf parser support n-triple

javascript - Defer execution for ES6 Template Literals -

i playing new es6 template literals feature , first thing came head string.format javascript went implementing prototype: string.prototype.format = function() { var self = this; arguments.foreach(function(val,idx) { self["p"+idx] = val; }); return this.tostring(); }; console.log(`hello, ${p0}. ${p1}`.format("world", "test")); es6fiddle however, template literal evaluated before it's passed prototype method. there way can write above code defer result until after have dynamically created elements? i can see 3 ways around this: use template strings designed used, without format function: console.log(`hello, ${"world"}. ${"test"}`); // might make more sense variables: var p0 = "world", p1 = "test"; console.log(`hello, ${p0}. ${p1}`); // or function parameters actual deferral of evaluation: const welcome = (p0, p1) => `hello, ${p0}. ${p1}`; console.log(welcome("world&qu

utf 8 - Capitalize UTF-8 text -

i need capitalize text (i.e. put first letter in uppercase) in ocaml. unfortunately text in utf-8 , standard library support ascii. i have found uppercase function in batteries seems available in old versions. , camomile (which looks best option processing utf-8) seems dead , has little documentation. camomile solution here. documentation on sourceforge : http://camomile.sourceforge.net/dochtml/index.html heavily functorized , may intimidating @ first sight, take time master it, job. uppercase : # open camomilelibrarydefault;; # module cm = camomile.casemap.make(camomile.utf8);; # print_endline (cm.titlecase "привет");; Привет

php - Laravel save nested model -

i using laravel 4 , got stuck problem. i have 3 models: user, project, task. relationships: user belongstomany('project') project belongstomany('user') project belongstomany('task') task belongsto('project') i want store task no luck. following code maybe tells in more detail want accomplish: auth::user()->projects($projectid)->tasks()->save($task); with code get: call undefined method illuminate\database\query\builder::tasks() save task first. then can try... auth::user()->projects()->find($projectid)->tasks()->associate($task); you may need modify project/task relationship. inverse of belongstomany belongstomany . thinking need hasmany , belongsto instead. edit: sorry think lead in wrong direction, got working. $task = new task; $task->name = 'some super ultra task'; auth::user()->projects()->where('projects.id', $projectid)->first()->tasks()->save(

sql - Multiple conditions for CONTAINS statement on a full-text indexed result set -

we have stored procedure takes in few parameters, 1 of these parameters has value , used filter result set. select statement contains multiple joins , long. to avoid copy-pasting query multiple times, want able use if or case statement in where clause. problem is, using full-text index , contains statement, , i'm not quite sure how inject if or case statement inside/outside contains clause, this: select * [query] where( if @filter1 not null begin contains(somecolumn, @filter1) end else if @filter2 not null begin contains(anothercolumn, @filter2) end) which doesn't work. can't put select query in view or function either because result set doesn't specify unique index key, i.e. cannot full-text indexed (right tables full-text indexed individually address issue). so there way achieve this? potentially copy-pase long select query inside different if statement each filter, gets ugly. appreciated. maybe i'm over

Laravel 4 foreach loop - wanting to display the last element -

i trying set edit page order form populated using json_decode decode json information saved when form created. because form's size can change have create correct number of inputs json data have place displayed. fortunately inputs numbered should not hard do. unfortunately not sure how pick last element of json information has been decoded. using: public function getedit($id){ $order = order::where('id', '=', $id); if($order->count()) { $order = $order->first(); $order->order_serialized = json_decode($order->order_serialized); foreach($order->order_serialized $key => $value){ $order->$key = $value; } return view::make('orders.edit') ->with('order', $order); } else { return app::abort(404); } } to decode information , working splendidly need able pick

android - Save Canvas to Device in Phonegap -

i've done lot of research , testing on this, getting compatibility/clarity issues right , left. hoping had clear solution this. my phonegap build (3.1) application pulls images s3, adds overlay text them via html canvas, , needs saved user's phone on click action. here relevant details: preferably saved location detectable gallery (android) or photos app (ios). i need work in android 2.3 , ios 6-7. i have composited version of image overlay text located on aws. happy downloading image device either composited image's url or canvas directly. here of barriers: i keep getting "tainted canvas" security errors when trying "canvas.todataurl()", though set wildcard on s3's cors permissions used bucket. the "download" attribute seems unsupported in mobile browsers . i happy use phonegap's "filetransfer.download()" method , haven't been able figure out adequately acquire right file path on each device use in ga

Breeze: how to tell if the query returned is from local cache or remote server? -

i know can call function query locally, if possible, or remotely. there way tell if result local or remote? remember read it, couldn't find anymore. manager.fetchentitybykey('employee', employeeid, true) .then(function(data) { employee(data.entity); }); use 'fromcache' boolean property on promise result. manager.fetchentitybykey('employee', employeeid, true).then(function(data) { var employee = data.entity var wasfoundincache = data.fromcache; }); see: http://www.breezejs.com/sites/all/apidocs/classes/entitymanager.html#method_fetchentitybykey

build automation - How to verify if the product code and product version have been updated using MSBuild support for Installshield -

i'm trying build installshield project msbuild , tfs 2013. followed steps required override product code indicated here . first, created .isproj file , managed generate installer successfully. however, product code seems not changed. check file setup.ini , noticed product guid still same value of product code in .ism file. there way verify product code , product version have been changed? @update it worked finally, able verify newly generated product code using orca . chris's script works well! this how it: in ism release view (build tab) set release location \installer instead of in path variables declare isbuilddir path variable , give default value of isprojectdatafolder <project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" toolsversion="4.0" defaulttargets="build"> <propertygroup> <msiproductversion>$([system.text.regularexpressions.regex]::match($(tf_build_buildnumber), "

php - How to compare or check and matched ids are removed. return remaining values in an array how? -

function removelightok($onlist) { $remainingvalues= array(); $remainingvalues= explode('' , $onlist); foreach ($remainingvalues $key){ $query = mysql_query("select * table id = '".$key."'"); $rs= mysql_fetch_assoc($query); $id = $rs["id"]; // how compare or check , matched ids removed. return remaining values in array how? } return $remainingvalues; } here $onlist means 1 array. ids array. using php only. you can use ; function removelightok($onlist) { $remainingvalues= array(); foreach ($onlist $k => $v){ $query = mysql_query("select * table id = '".$v."'"); $rs= mysql_fetch_assoc($query); if (!empty($rs["id"]) { $remainingvalues[] = $v; } } return $remainingvalues; } warning: suggest not use mysql_query . php doc page; this extension deprecat

javascript - How to fill a select box, when select name and id include ":" -

Image
i have html code below select names : (i have need fill more select included form mainform): <select id="mainform:projectselectonemenu" name="mainform:projectselectonemenu" class="selectone" size="1" onchange="a4j.ajax.submit('mainform',event,{'similaritygroupingid':'mainform:j_id416','parameters':{'mainform:j_id416':'mainform:j_id416'} ,'containerid':'mainform:trainperiodcriteriaregion'} )"> <option value="">--- ---</option> i'm using code: this.fillselectors('form#mainform', { 'select[name="mainform:projectselectonemenu"]' : "3" }, false); this.wait(6000,function(){ this.echo("i saw new value"); }); i have error: caspererror: errors encountered while filling form: no field matching css selector "select[name="mainform:projectselectonemenu"]&q

ruby - How to test whether two time ranges overlap? -

i need implement booking functionality , ensure bookings don't overlap in rails app. the cover? , between? methods aren't quite need. have ensure uniqueness of time range when compared other potential ranges on same model, , efficiently. i think can done using overlaps? . problem returns true this: (1..5).overlaps?(5..9) => true if compared booking ended right when started ( 3:30 - 4:00 versus 4:00 - 4:30 ), overlap, technically don't. problem right? validatesoverlap seems handle issue, including edge overlap. any suggestions? def overlap?(x,y) (x.first - y.end) * (y.first - x.end) > 0 end will work. problem interval uses >= , can see in " test if 2 date ranges overlap in ruby or rails ".

javascript - AngularJS : promises, can you pass a promise back after using .then()? -

i'm still new angular , promises hope have correct idea here. i have data layer service uses restangular data, returns promise, this... datastore.getusers = function (params) { return users.getlist(params); }; then, controller has called function receives promise back, this... $datastore.getusers(params).then(function (response) { $scope.users = response; }, function(response) { $log.error("get users returned error: ", response); }); this working well, i'd use promise inside of datastore before passing back. i'd use .then() method check if failed , logging, then, sucess function , failure function i'd return original promise controller. my controller able use .then() method is, in fact, don't want controller code change @ all, datastore code. here's semi-pseudo code show i'd datastore function do... datastore.getusers = function (params) { users.getlist(params).then(function (response) { $log("serve

wpf - Hierarchy of applying multiple DataTemplates to a single DataType -

i've seen allusions question around so, haven't found specific answer yet. say have models, objecta , objectb, inherit baseobject , have corresponding viewmodels, objectaviewmodel , objectbviewmodel. each datatype of datatemplate stored in resourcedictionary represents how typically displayed in view. however, in circumstances, based on view's design, want use different datatemplate objecta stored in resourcedictionary, still use same datatemplate objectb. situation order of resource dictionaries matters? i in process of refactoring old project wpf, , day or 2 away structuring part of program. so, i'll come answer on own in couple days, in case catches sooner, figured wasn't 1 wondering this. follows structure have in head how work. class baseobject { } class objecta : baseobject { } class objectb : baseobject { } class baseobjectcollection : icollection<baseobject> { objecta; objectb; } class objectaviewmodel { } class objectbviewmodel { }

c++ - What box to use when cropping a rotated image in opencv -

Image
i have rotated image , want crop borders cut out , full cropped image viewable. tried method found on net didn't work , honest don't understand trying do. understand rotating part. points pushing points? 4 corners of image? method of pushing points not work me. used 4 corners of image instead worked rotating when try run getrectsubpix exception occurs because box wrong i'm not sure getrectsubpix needs then? here output after running code. output iverted (why important?) , crop doesn't work. cv::bitwise_not(img, img); std::vector<cv::point> points; cv::mat_<uchar>::iterator = img.begin<uchar>(); cv::mat_<uchar>::iterator end = img.end<uchar>(); (; != end; ++it) if (*it) points.push_back(it.pos()); cv::rotatedrect box = cv::minarearect(cv::mat(points)); cv::mat rot_mat = cv::getrotationmatrix2d(box.center, angle, 1); cv::mat rotated; cv::warpaffine(img, rotated, rot_mat, img.size(), cv::inter_cubic); cv::size box_size = box.size

SQL Server 2012 unable to turn off Snapshot Isolation -

using code below unable turn off snapshot isolation. i'm using sql server 2012 box. can create brand new empty db, turn snapshot isolation on, can't turn off. the "allow_snapshot_isolation off" line spins it's wheels. alter database snap set single_user rollback immediate alter database snap set allow_snapshot_isolation off alter database snap set read_committed_snapshot off alter database snap set multi_user are sure no other transactions ran on database? remeber implicit transactions used eg. jdbc drivers (when setautocommit false). snapshot isolation cannot turn off if of previous transactions pending. is, because has sure other transaction not try use previous row versions. however, possible make queries spanning through more 1 database setting snapshot isolation not taking care of transaction on 1 database. you can check if case using sp_who2 , select * sys.sysprocesses and searching altering process. sp_who2 showing process suspended

gruntjs - ace editor (static) to highlight code (grunt task) -

i trying use "ace-editor" highlight code documentation. want in grunt task. has done before or knows if possible? i using "highlight.js" works well, not support syntax-highlighting "less.js" tested: (does not highlight want) hljs.highlightauto(grunt.file.read('myfile.less')).value best result: (setting "java" lang) hljs.highlight('java',grunt.file.read('myfile.less')).value it looks (which ok not perfect) http://more-or-less.org/ also appreciated: any other highlighters work (needs work .less code) more info the documentation less.js mixin library i generating documentation actual library using git submodule reading files , injecting them template (jade) generator can found here https://github.com/pixelass/more-or-less-docs you can find ace demo using highlighter @ https://github.com/ajaxorg/ace/blob/master/demo/static-highlighter/server.js need create wrapper that, provides

android - how to get the bitmap from cusom imageview class? -

i want whole bimap map of custom class... getting null...i try every way don't getting write answer.. bitmap b = mboardtile.getdrawing(); used null value.. i m used view cache like.. bitmap b = null; try { mboardtile.setdrawingcacheenabled(true); mboardtile.measure(measurespec.makemeasurespec(0, measurespec.unspecified), measurespec.makemeasurespec(0, measurespec.unspecified)); mboardtile.layout(0, 0, mboardtile.getmeasuredwidth(), mboardtile.getmeasuredheight()); mboardtile.builddrawingcache(true); b = mboardtile.getdrawingcache(); } catch (exception e) { e.printstacktrace(); }` but again null value.. the custom class below.. public class boardtile extends imageview { context mcontext; int posx, posy; arraylist<datavo> marraylistdta; float width, height, newx, newy; arraylist<datavo> marraylistnew; public boardtile(context context) { super(context); this.mcontext = context;