Posts

Showing posts from February, 2012

android - How to use Context to access/manipulate another class/activity -

i want create generic asyncetask class activities use/share downloading content url. reason, don't want onpostexecute other send content method in activity invoked asynctask class. i know need create constructor sets context of activity invoked asynctask , what, how use context send the activity corresponding context. i've seen no tutorials show how use context in manner. lets have: public class loginactivity { public int activitymember; public void handlebuttonclick(void){ downloadfromurl task = new downloadfromurl(this); task.execute(url); } public void handleloginresult(int x){ activitymember = x; } } now in separate java file have: private class downloadfromurl extends asynctask<list<namevaluepair>, long, jsonobject> { context context; public void downloadfromurl (context context){ this.context = context; } @override protected void onpostexecute(jsonobject json) {

c - OpenGL sprite mapping doesn't work -

Image
i'am working on own graphics engine using opengl , glut (under linux, c). problem sprite loader.basicaly, have structure holds data rendering part of texture, this: struct sprite { vertex start,end,size; int textureid; } and have function renders screen. textureid represent id of texture. vertices start , end represent uv coordinates(between 0 , 1), specify top left(start) , bottom right(end) of sprite want render. vertex size specifies actual size of sprite in screen space. part of function splits big texture in smaller sprites. math part of , made c app test , does`nt work how want. s.u , s.v start uv coordinate(top left of sprite), x(s.u) , y(s.v) . e.u , e.v end coordinate(bottom right of sprite). nx , ny number of splits on texture( in image bellow there 2 horrizontal splits , 2 vertical splits. id represents sprite want. s.u=(1.0f/nx)*(id%nx-1); s.v=(1.0f/ny)*(ny-id/nx); e.u=s.u+(1.0f/nx); e.v=s.v-(1.0f/nx); for example if give fu

plsqldeveloper - How can implement a procedure in ESQL (an internal procedure) from Oracle database -

i create store procedure in oracle db insert customer table this code : create or replace procedure thp.insert_customer( p_custname in varchar2, p_custlast in varchar2, p_custfather in varchar2, p_nationno in number, p_birthday in varchar2, p_birhtplace in varchar2, p_email in varchar2, p_custename in varchar2, p_custelast in varchar2, p_ownid in number, p_custtypeid in number, p_genderid in number, p_billstid in number, p_billspid in number, p_idno in varchar2, result out integer) cnt number; begin result := 1; cnt := 0; select count(1) cnt thp.tbcustomer nationno=p_nationno ; if cnt=1 commit; result := 1; --if record exis

in asp.net can we give same name to session variable and cache variable -

in asp.net can give same name session variable , cache variable session["lookup"] = "a"; cache["lookup"] = "a123"; ? will not clashed @ access point in page ? do mean cache collection ? if so, not same collection session. session application wide user specific collection cache application wide not user specific. not same object. from msdn: one instance of class created per application domain, , remains valid long application domain remains active. i should warn cache collection global object users, , therefore think user specific information should avoided. best practices , use: http://msdn.microsoft.com/en-us/library/aa478965.aspx

Pixel by pixel data in Python -

i want following: load png image python code get pixel pixel rgb data in 3 arrays, 1 each r, g , b. mean r[i,j] should give me value of r @ i,j th pixel of image. once have arrays can edit data. plot edited data using 3 array r,g , b , save png image how in python? use pil load image: from pil import image img = image.open('yourimage.png') i'm going suggest method messes directly image data, without accessing individual pixels coordinates. you can image data in 1 big byte string: data = img.tostring() you should check img.mode pixel format. assuming it's 'rgba', following code give separate channels: r = data[::4] g = data[1::4] b = data[2::4] = data[3::4] if want access pixels coordinate like: width = img.size[0] pixel = (r[x+y*width],g[x+y*width],b[x+y*width],a[x+y*width]) now put together, there's better way, can use zip : new_data = zip(r,g,b,a) and reuce: new_data = ''.join(reduce(lambda x,y: x+y, z

c# - How to use public property in actioninvoke in asp.net mvc? -

i have code public actionresult index() { if (currentuser != null) { usermanager.user usr = (user.user)currentuser; } } i have done admincontroller : testcontroller now way access currentuser in actioninvoke use check user admin or not public class adminauthorize : actionfilterattribute { public override void onresultexecuting(resultexecutingcontext filtercontext) { base.onresultexecuting(filtercontext); } } is anyway use currentuser variable in invoker. you should able access current controller instance controller property of filtercontext. public class adminauthorize : actionfilterattribute { public override void onresultexecuting(resultexecutingcontext filtercontext) { base.onresultexecuting(filtercontext); var currentuser = ((admincontroller)filtercontext.controller).currentuser; // need currentuser } }

text files - How do I load data into Win Bugs from Excel or from Notepad (doc ending with .txt)? -

i need load data winbugs excel , reason, winbugs doesn't recognize it. there many things have tried (all of listed below) , none of these work. i tried copy excel , 'paste special' 'plain text' winbugs. added [] after every variable , 'end' @ end. error message came follows: sorry went wrong in procedure loadnumeric data in module bugrectdata i copied , pasted notepad, added [] after every variable , 'end' @ end again , removed space between lines, , 1 space between each data. when dragged winbugs, dispersed double space between lines , large gaps between data , error message came (when trying load data): sorry went wrong in procedure loadnumeric data in module bugrectdata the last thing did open .txt file winbugs , became jumbled , when tried load data, instead highlighted data such na2.0 should have been na 2.0 , said "expected number or na or end". after correcting these mistakes, data seemed fine until end s

Execute Javascript Command in Selenium to get data from a webpage -

<h4>lotus</h4> what want grab lotus value h4 tag , in post got answer using javascript command follow: document.getelementbyid('17285').getelementsbytagname('h4')[0].innerhtml; and worked fine. what want use javascript in selenium. i tried following code : msgbox driver.executescript("javascript:document.getelementbyid('17285').getelementsbytagname('h4')[0].innerhtml;") but empty messagebox, know why. thank ! your id in html(17171) dosen't match id in code(17285). try this: msgbox driver.executescript("javascript:document.getelementbyid('17171').getelementsbytagname('h4')[0].innerhtml;")

jsf 2 - Multiple actionlisteners in JSF -

i want use multiple action listener set state of 2 backing beans before further processing 1st way: <p:commandbutton process="@this" > <f:attribute name="key" value="#{node.getidtestgroup()}" /> <f:actionlistener binding="#{testcontroller.nodelistener}" /> <f:actionlistener binding="#{testdevicegroupcontroller.preparecreate}" /> </p:commandbutton> it give exception: warning: /testgroup/list.xhtml @26,88 binding="#{testcontroller.nodelistener()}": method nodelistener not found javax.el.elexception: /testgroup/list.xhtml @26,88 binding="#{testcontroller.nodelistener()}": method nodelistener not found 2nd way: <p:commandbutton process="@this" > <f:attribute name="key" value="#{node.getidtestgroup()}" /> <f:actionlistener binding="#{testcontroller.nodelistener(event)}" /> <f:actionlistener binding=

python - How to arrange numbers in Label into grid in Tkinter? -

i create sudoku solver , want show candidates each cell. sudoku grid list of label widgets , have problem arranging these candidates grid. goal this (without colors). have them in grid, number "0" still visible. , i´m asking how hide these zeros. tried substitute "0" space (" "), brackets displayed instead. my code: from tkinter import * root = tk() text_good = [1,2,3,4,5,6,7,8,9] text_wrong1 = [1,2,3,4,0,0,0,8,9] text_wrong2 = [1,2,3,4," "," "," ",8,9] l1 = label(root,bg="red",text=text_good,wraplength=30) l1.place(x=0,y=0,width=50,height=50) l2 = label(root,bg="red",text=text_wrong1,wraplength=30) l2.place(x=50,y=0,width=50,height=50) l3 = label(root,bg="red",text=text_wrong2,wraplength=30) l3.place(x=100,y=0,width=50,height=50) root.mainloop() i hope described problem well. appreciate answer. thank you use text_wrong2 = ' '.join(map(str,[1,2,3,4," "

php - Linking URL in middle of string -

wondering how detect url in string , return link. example $text = 'go www.example.com example.com example.net http://example.com '; echo $text; would return go www.example.com example.com etc. you use regex, or explode $text string on spaces , check substring each exploded word if begin http://, https:// or end in .com, .net, .org , wrap string in link

.net - Embedded Font Causes a Crash -

i have winform app. using custom font in embedded resources. works @ first, causes program crash after while. using following code example, if keep resizing form, forcing redraw itself, crash within few seconds. message ' error in 'form1_paint()'. object in use elsewhere. '. doing wrong? how can avoid this? got font here. thanks. imports system.drawing.text imports system.runtime.interopservices public class form1 friend harabara font private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load loadfonts() end sub private sub form1_paint(byval sender object, byval e system.windows.forms.painteventargs) handles me.paint try e.graphics.drawstring("this drawn using custom font 'harabara'", harabara, brushes.lime, 10.0f, 10.0f) catch ex exception msgbox("error in form1_paint()'" & vbcrlf & ex.message) end try e

eclipse - Compiling LESS CSS with Maven and m2e-wtp -

i'm trying compile less css files lesscss-maven-plugin , both in pure maven (with command line) , within eclipse (juno). in lesscss-maven-plugin, need define output directory, noticed in eclipse wtp copies files target/m2e-wtp in server (jboss), directory ignored war plugin of maven. i succeeded reach goal maven profiles : in eclipse use m2e profile configured in project settings, can define 2 different destination folders depending on build in eclipse or not. here pom.xml : <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.dgadev.motd</groupid> <artifactid>motd</artifactid> <version>0.0.1-snapshot</version> <packaging>war</packaging> <properti

java - Add markers to google maps refresh -

i load markers google maps via asynctask. however, when markers loading finish, need click on zoom button inorder map show markers ( guess needed refreshing map) is there method refreshing google maps?or solution? i use variable private static googlemap map; thanks i think map.invalidate() refresh because cause redraw. see.. redraw/refresh itemizedoverlay? (android/google maps api) how refresh google map.

java - How to get fully qualified class name from IResource object? -

i have iresource object of java class. need qualified class name object. my iresource.getfullpath().tostring() gives me /myproject/src/abc/def/myclass.java . want abc.def.myclass it. how can qualified class name? not sure if want qualified class name or qualified location in file system. i'll mention both: class name: ((itype) javacore.create(ifile)).getfullyqualifiedname() also, make sure check nulls , instanceof. resource location: ifile.getlocation()

symfony - Symfony2 plugin for links CSRF protection -

is there plugin works way? i've found knpradbundle, got working project , adjusting new framework long , unnessesary. knows such plugin? in knpradbundle it's function: https://github.com/knplabs/knpradbundle/wiki/csrf-protected-links ps. i'm using symfony 2.2 i had exact same problem , found this pull request solves it. using csrf_token('your_intention') function can generate csrf token in twig template. later can check token using form.csrf_provider service described in pull request.

Windows Phone variable class type -

i want create a user class type object, , maybe later change class type. eg. there 2 custom class: class a{} class b{} then later want declare object changes it's type accordingly; var obj; if(x=0) obj=new a(); else obj=new b(); is possible in windows phone visual studio environment? note: want obj global variable, can use anywhere. it possible, not great design. should have more typesafe, either having base class , b , variable object base type or have classes interfaced. example: class baseclass { } class a: baseclass{} class b: baseclass{} baseclass obj; or interface iclass{} class : iclass{} class b: iclass{} iclass obj;

Javascript replace between string tag <strong> -

i don't how replace this: aaadddłłłłłaaałłłłĄąąąą<strong> to aaadddłłłłłaaałłłłĄąąąą <strong> must add 1 space between string pseudo kod: replace('string<strong> ','string <strong>'); just this: var p = your_string.indexof('<strong>'); if (p > 0 && p.charat(p-1) != ' ') { replaced = your_string.replace('<strong>',' <strong>'); }

Spring - HTTP Status 404 - The requested resource is not available -

i have 404 error when requesting page. have users page list of objects user can click on carry out number of transactions, add, edit etc. the controller it @requestmapping(value="/main/user/setter/addpage/", method = requestmethod.get) public string getaddpage(@requestparam("userid") integer userid, modelmap model) { module module = new module(); model.addattribute("userid", userid); model.addattribute("module", module); return "/main/user/setter/addpage"; } the page want get <c:url var="processurl" value="/main/user/setter/addpage/?id=${userid}" /> <form:form modelattribute="module" method="post" action="${processurl}" name="module" enctype="multipart/form-data"> </form:form> the page i'm requesting from: <c:foreach items="${users}" var="setter" > <c:url var=&

c# - How to ensure that a static constructors is called without calling any member -

i have class static constructor. i want static constructor called without calling or using of members, if constructor has not been called already. i tried using reflection. reflection can invoke static constructor (many times), cannot find out if has been called before. how do this? edit not 1 class talking about, more. lets say, classes marked special attribute. you can use runtimehelpers.runclassconstructor method (assuming correctly understood trying do...) runtimehelpers.runclassconstructor(typeof(yourtype).typehandle);

java - Listen to messages from various texting applications -

is there way android listen facebook or twitter messages (maybe whatsapp or viber or skype messages ). know when message application arrives. possible? there's no common mechanism these apps have use work on android, answer in general "no" being notified may either individual thing ("per app"), or not not possible (if possible)

php - How to mask a URL -

i'm not try hide url. need appear nice client. url i'm trying mask is: mysite.com/group/2 . nice if mysite.com/client . so, whenever client hit url mysite.com/client code behind url mysite.com/group/2 group module(folder/sources) , 2 primary id. i've tried using rewrite mod/apache(.htaccess), didn't succeed. how can done? other way? thanks here .htaccess <ifmodule mod_rewrite.c> options +followsymlinks rewriteengine on # rewrite rule rewriterule ^client$ group/2 # rid of index.php rewritecond %{request_uri} /index\.php rewriterule (.*) index.php?rewrite=2 [l,qsa] # rewrite directory-looking urls rewritecond %{request_uri} /$ rewriterule (.*) index.php?rewrite=1 [l,qsa] # try route missing files rewritecond %{request_filename} !-f rewritecond %{request_filename} public\/ [or] rewritecond %{request_filename} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$ rewriterule . - [l] # if file doesn't exist, rewrite index rewritecond %{request_filename} !-

python - Tkinter menu command action carried out before calling, Why? -

the following producing tkinter menu 1 label "do something". running script produces "done" output immediately, means before clicking on "do something" menu label. why that? doing wrong @staticmethod? in anticipation. import tkinter class appmenu(object): def __init__(self, master): self.master = master self.file_content = "initialised" self.menu_bar(self.file_content) def menu_bar(self, file_content): menu_bar = tkinter.menu(self.master) self.menu_bar = tkinter.menu(self.master) self.master.config(menu=self.menu_bar) self.task_menu = tkinter.menu(self.menu_bar, tearoff = false) self.task_menu.add_command(label = "do something", command = convert.do(self.file_content)) self.menu_bar.add_cascade(label = "task", menu = self.task_menu) class convert(object): @staticmethod def do(text): print "done" root = tkinter.tk() menu = appmenu(root) root.mainloop()

html - Why is transition started up with autofocus? -

i created contact form uses autofocus="autofocus" . have noticed weird thing, when form has autofocus transition on nav fired up. have noticed in firefox. there did wrong or how firefox behaves(bug)? with autofocus (refresh page) without autofocus form: <form method="post" action="" id="contactform"> <textarea id="contactf" name="message" tabindex="1" placeholder="type message here" required="required"></textarea> <input type="submit" id="contacts" name="submit" value="send" tabindex="3" /> name: <input type="text" id="contactn" name="name" tabindex="2" placeholder="type name" required="required" /> </form> css nav: #menu ul li { width: 251px; text-align:center; display: inline-block; background: #ddd; hei

ruby on rails - Fix inconsistency with polymorphic association -

i have polymorphic association in model , experienced intermittent bug (in production) when created. fixed it, need repair entries created under bug. my models: class user < activerecord::base belongs_to :userable, :polymorphic => true attr_protected :userable end class usertype1 < activerecord::base has_one :user, :as => :userable, :dependent => :destroy end class usertype2 < activerecord::base has_one :user, :as => :userable, :dependent => :destroy end so, problem have entries on user table without relation polymorphic table. record example (users table): id userable_id userable_type 999 null usertype1 and usertype1 hasn't entry related. so made query detect entry errors: select users.* users coalesce(userable_id, 0) = 0' but don't know how repair cleanly. my idea create script this: user.find_by_sql('select users.* users coalesce(userable_id, 0) = 0').each |user| userable = user.userable_type.c

android - Adding a horizontalScrollView to bottom navigation bar -

i have activity contains table layout , below have buttons, implemented sort of navigation bar using radio group , radio buttons. want add horizontal scroll view radio group, when try add navigation bar changes position top of activity collapse table layout , need navigation bar stick bottom of activity. appreciated. in advance. here's xml code: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bckgroundchinese" android:id="@+id/bottom_layout" > <scrollview android:id="@+id/scrollview1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbaralwaysdrawverticaltrack="true" android:scrollbarfadedurat

multidimensional array - Creating data structures in PHP -

i have problem have convert 2d array data structure that's efficient printing out table scheduler. link problem http://goo.gl/rrusj [opens in google docs]. first of all, clarify understanding, supposed write code generate table itself? or write code create structure? secondly, since i'm new php, ideas on how go doing this? at first: need datababase. have learn how make database: 1:uml(class) diagram 2:relations(1 1, n 1, n m, ...) 3:datatypes 4:make database in open office then have learn how make database in php.( arrays tables, ... ) hope you!

Ruby grocery list program -

i learning ruby , i'm trying write simple ruby grocery_list method. here instructions: we want write program keep track of grocery list. takes grocery item (like "eggs") argument, , returns grocery list (that is, item names quantities of each item). if pass same argument twice, should increment quantity. def grocery_list(item) array = [] quantity = 1 array.each {|x| quantity += x } array << "#{quantity}" + " #{item}" end puts grocery_list("eggs", "eggs") so i'm trying figure out here how return "2 eggs" passing eggs twice to count different items can use hash. hash similar array, strings instead of integers als index: a = array.new a[0] = "this" a[1] = "that" h = hash.new h["sonja"] = "asecret" h["brad"] = "beer" in example hash might used storing passwords users. example need hash counting. calling grocery_list(&quo

database - One to One relationship modeling -

Image
i using access 2010 this. i have created 2 tables , 1 one , don't seem in 1 one relationship. create table person( id varchar(1) unique, name varchar(30), primary key (id) ); create table passport( id varchar(1) unique, country varchar(30), primary key (id), foreign key (id) references person(id) ); from little knowledge have, should 1 one relationship 1 many. how 1 one via access? i have tried things can find in books no success. please help. you may misled way relationships displayed in relationships window. ran exact ddl , when view relationship in relationships window looks one-to-many... ...but when right-click on line joining 2 tables , choose "edit relationship..." dialog shows one-to-one:

text - How to Change Background Color on Processing? -

i'm still extremely new processing , i'm playing around right now. hoping find out how change background color between 2 colors, particularly between white , black, when click mouse. found code online has background color change between several different colors can't seem figure out how bg color can changed between 2 colors. particularly 'col+=' , 'col%=' represent because can't seem find in processing tutorial. please me! thank you! below code found. void setup() { size(600,400); smooth(); colormode(hsb); } int col = 0; void draw() { background(col,255,255); } void mousepressed(){ col+=20; col%=255; println(col); } "x += y" shorthand "x = x + y" and, likewise, "x %=y" shorthand "x = x % y" (where % modulo operator). i'm going assume wanted ask "how change background 1 colour another, , again"; there's 2 based ways this. 1: set 2 (or more) reference colours, "curr

arrays - Will not display in list box VB -

so, i'm trying display statistics soccer teams points scored. @ time being executed, arrays have been filled , not. when form opens, i'd display maximum, minimum, , average scores.... want players name , score max , min. example: maximum: john scored 9 minimum: joe scored 2 like, i'd getting value @ strplayers(i) name , intscores(i) score. i'm pretty sure had functions correct, but, whatever reason, can not display in list box upon loading form! public class frmdisplaystatistics function findmaximum() string dim max integer dim integer = 0 redim intscores(intnumberofplayers) max = cint(intscores(0)) = 0 intnumberofplayers if max < intscores(i) max = cint(intscores(i)) end if next max = strplayers(i) & " scored maximum points of " & intscores(i) return max end function function findminimum() integer dim min integer dim integer = 0 redim intscores(int

python - Using Python3 with Pymongo in Eclipse Pydev on Ubuntu -

i trying run pydev pymongo on python3.3 interpreter. problem is, not able working :-/ first of installed eclipse pydev. afterwards tried installing pip download pymongo-module. problem is: installs pip default 2.7 version. read shouldn't change default system interpreter (running on lubuntu 13.04 32-bit) tried install second python3.3 , run in virtual environement, can't find detailed information on how use on specific problem. maybe there out there, uses similar configuration , can me out running (in simple way) ? thanks in advance, eric you can install packages specific version of python, need specify version of python want use command-line; e.g. python2.7 or python3 . examples python3 pip your_package python3 easy_install your_package .

ffmpeg - How to convert audio/music to video with static image (commandline) -

i have audio file convert video. if possible, use static image appearing @ video. have investigated couple possible solutions, non of them functional. this solution in previous thread ffmpeg -loop_input -shortest -y -i image8.jpg -i sound11.mp3 -acodec copy -vcodec mjpeg result.avi does not work more, not extend video duration of audio file. additionally, ffmpeg complains deprecated , suggests use avconv instead. avconv -i sound11.mp3 -strict experimental -i 341410.jpg -map 0:a out.mp4 but image not appear finally have tried gstreamer gst-launch filesrc location=deltio.mp3 ! mp3parse ! mp4mux name=mux filesink location=output.mp4 filesrc location=341410.jpg ! jpegdec ! x264enc ! mux. but error error: element /gstpipeline:pipeline0/gstx264enc:x264enc0: can not initialize x264 encoder. additional debug info: gstx264enc.c(1269): gst_x264_enc_init_encoder (): /gstpipeline:pipeline0/gstx264enc:x264enc0 error: pipeline doesn't want preroll. since want include

python - Calculate size of textstring in pygtk pango for text fill -

i'm searching method pre calculate width of text string variable length python gtk/pango. want use adjusting text size automatically fill given space, gui can displayed different resolutions , text of labels or buttons or whatever should adjust given resolution use maximum possible font size without braking boundaries. i have workaround now, slow method , think there must better: def buttonschriftanpassen(self, aktiverbutton, inbox): '''function set fint size of directory/category buttons use max. amount of available space''' if inbox == true: aktiverbutton.show() gewolltebreite = aktiverbutton.get_parent().get_allocation()[2] gewolltehoehe = aktiverbutton.size_request()[1] maximalebreite = gewolltebreite elif aktiverbutton.get_label() == "home" or aktiverbutton.get_label() == "hauptmenue": #print aktiverbutton.get_label() gewolltebreite = aktiverbutton.size_request()[

OpenCL Copy-Once Share a lot -

i implementing solution using opencl , want following thing, example have large array of data want copy in gpu once , have many kernels process batches of , store results in specific output buffers. the actual question here way faster? en-queue each kernel portion of array needs have or pass out whole array before hand let each kernel (in same context) process required batch, since have same address space , each map array concurrently. of course said array read-only not constant changes every time execute kernel(s)... (so cache using global memory buffer). also if second way faster point me direction on how implemented, haven't found concrete yet (although still searching :)). cheers. i use second memory normally. sharing memory easy. pass same buffer each kernel. in real-time ray-tracer. render 1 kernel , post-process (image process) another. using c++ bindings looks this cl_input_mem = cl::buffer(context, cl_mem_write_only, sizeof(cl_uchar4)*npixels, nu

Change of Behavior of jQuery Starting with 1.9.0 -

the following code displays alert boxes containing "radio1 selected", "radio2 selected" or "radio3 selected" in response click events on radio buttons when version 1.8.3 of jquery used. versions after displays "none selected". ideas why? thanks <html> <head> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script> function radioclicked(){ if ($('#radio1').attr('checked') == 'checked') alert('radio 1 selected'); else if ($('#radio2').attr('checked') == 'checked') alert('radio 2 selected'); else if ($('#radio3').attr('checked') == 'checked') alert('radio 3 selected'); else alert('none selected'); } </script> </head> <body> <label for="radio1">radio 1</label><input type="r

spring - Persist OneToOne relation with SpringData JPA -

i have next 2 entities onetoone relation between them: @entity @table(name = "tasks") public class task { @onetoone(mappedby = "task", cascade = cascadetype.persist) private tracker tracker; /* more code */ } @entity @table(name = "trackers") public class tracker { @onetoone @joincolumn(name = "trk_task", unique = true) private task task; /* more code */ } i'm trying run code: task task = taskservice.finddispatchabletask(); if (task != null) { tracker tracker = trackerservice.findidletracker(); if (tracker != null) { task.settracker(tracker); task.setstatus(taskstatus.dispatched); taskservice.save(task); } } but error: error org.hibernate.assertionfailure - assertion failure occured (this may indicate bug in hibernate, more due unsafe use of session) org.hibernate.assertionfailure: non-transient entity has null id i can "solve" changing code to: t

mysql - SELECT query cutting off field? -

my query is: select close stocks the_date = '2013-04-10' , ticker = 'jcp'; i empty set. have since realized problem lies ticker field, because using date fine. so did select * stocks; +----------+------------+--------+--------+--------+--------+-----------+-----------+--------+ | stock_id | the_date | open | high | low | close | volume | adj_close | ticker | +----------+------------+--------+--------+--------+--------+-----------+-----------+--------+ | 1 | 2013-04-26 | 409.81 | 418.77 | 408.25 | 417.20 | 27289200 | 417.20 | aapl | 2 | 2013-04-25 | 411.23 | 413.94 | 407.00 | 408.38 | 13713700 | 408.38 | aapl | 3 | 2013-04-24 | 393.54 | 415.25 | 392.50 | 405.46 | 34630400 | 405.46 | aapl | 4 | 2013-04-23 | 403.99 | 408.38 | 398.81 | 406.13 | 23294100 | 406.13 | aapl | 5 | 2013-04-22 | 392.64 | 402.20 | 391.27 | 398.67 | 15340900 | 398.67 | aapl | 6 | 2013-04-19 | 387.97 | 399.60 | 385.10 | 390.53 | 21749700 | 390.53 | aapl | 7 | 2013-04-18 | 404.99 | 405.79 |

How to set arrays so php write xml file correctly -

i’m stuck, trying figure out code put .php question should arrays xml file “href links” $xml = new domdocument ("1.0","utf-8"); $playlists = $xml -> createelement("playlists"); $playlists = $xml -> appendchild($playlists); $playlist = $xml -> createelement ("playlist"); $playlist = $playlists -> appendchild ($playlist); $track = $xml -> createelement ("track"); $track = $playlist -> appendchild ($track); $meta = $xml -> createelement ("meta"); $meta = $track -> appendchild ($meta); $xml->formatoutput = true; $string_value = $xml->savexml(); $xml->save("preview.xml"); xml-code: <playlists> <playlist id="pl1"> <track href="music/adg3com_bustedchump.mp3" title="artist 1 - track 1" target="http://google.de" rel="

Make music streaming app using Ruby on Rails and WebSockets -

i make ruby on rails app streams music using websockets. know of tutorial or guide on how started? need make app in ruby on rails have beginner's level of knowledge in language. have, however, programmed in javascript , .net many years, understand number of intermediate advanced programming concepts. rails getting started: http://guides.rubyonrails.org/getting_started.html websocket rails gem: https://github.com/danknox/websocket-rails more websocket , rails http://www.slideshare.net/jeroen_rosenberg/websocket-on-rails and more information: http://www.google.com ;)

sbt - akka.dispatch.Future not found -

i trying import akka.dispatch.future in class compiler unable find particular package. 1 it's able find akka.dispatch.futures . can point out might doing wrong? build.sbt follows: name := "someapp" version := "0.1" scalaversion := "2.10.1" librarydependencies ++= seq("com.typesafe.akka" %% "akka-actor" % "2.1.2") it's in docs: http://doc.akka.io/docs/akka/2.1.2/project/migration-guide-2.0.x-2.1.x.html see "pieces moved scala standard library" section.

php - session files not found in session save path -

i trying use following php script specify session save path: <?php echo session_save_path('/temp'); echo session_save_path(); ?> line 2 set save path directory called ‘/temp’. line 3 print out current save path. expected, did print out ‘/temp’. went temp directory session files there none. restarting apache server didn’t help. when call phpinfo(), can see session.save_path has no value. can kindly , patiently tell me how correctly set session_save_path , find session files please?

java - Why am i getting this error '.class' expected? -

im trying create program im getting errors cant eliminate. can give me hand please? import java.util.scanner; class juliandate { long year; long month; long day; long epochyear; juliandate() { } long returnjulianepochdays(long year, long month, long day){ long yearcounter = epochyear; long total = 0; while (yearcounter < year){ total += returndaysinyear(yearcounter); yearcounter += 1; } total += returnjuliandate(long year, long month, long day); return total; } } public class juliandatenew { } errors: these errors when compile program: /users/netbeansprojects/javaapplication1/src/juliandatenew.java:25: '.class' expected total += returnjuliandate(long year, long month, long day); /users/netbeansprojects/javaapplication1/src/juliandatenew.java:25: ';' expected total += returnjuliandate(long year, long month, long day); /users/vlopezlama/netbeansprojects/javaapplication1/src/juliandatenew.ja

javascript - My extension of jQuery's next is acting unexpectedly -

i extending jquery method find given selector using given function way traverse through this's siblings. the reason i'm doing because jquery's next() doesn't keep traversing object's siblings, need. (function ($) { $.fn.extend({ findsibling: function (selector, fn) { var $this = $(this), $sibling = fn($this); if ($sibling.length === 0){ console.log("no " + selector + " found."); } else if($sibling.is(selector)) { console.log(selector + " has been found!"); return $sibling; } else { $sibling.findsibling(selector, fn); } } }); }(jquery)); $next = $this.findsibling('.line', function (object) { return object.next(); }); even when function finds i'm looking for, $next remains undefined. thanks help. $sibling.findsibling(selector, fn); should be return $sibling.findsibling(selector, fn);

ruby on rails - How to run two Zeus servers -

i have several projects in different folders, can run several zeus instances, different port each one? i have gotten till https://github.com/burke/zeus/blob/master/docs/ruby/modifying.md . have no clue if can done. added rails tag people using rails know one. yes can - don't need anything, because zeus using unix domain sockets rather tcp (unlike spork example) say you're working on 2 apps. when in root folder of first app , run zeus start , zeus creates socket called zeus.sock in folder. when run various zeus commands in folder, finds socket , uses talk zeus server. meanwhile second app have own zeus.sock file, in folder. commands run in folder find socket rather first.

c++ breaking out of loop by key press at any time -

what have here loop supposed read output on piece of equipment every 500 milliseconds. part works fine. however, when try introduce cin.get pick key "n" being pressed stop loop, many outputs number of key presses point. if press keys (apart 'n') several times followed enter, few more outputs. need loop keep looping without interaction until want stop. here's code: for(;;) { count1++; sleep(500); analoginput = readanalogchannel(1) / 51.0; cout << count1*0.5 << " " << analoginput << endl; outputfile << count1*0.5 << ", " << analoginput << endl; if (cin.get() == 'n') //problem starts introduced break; }; my output follows (there 2 key presses stage in program) unless press few more keys followed enter: 0.5 0 // expected 1 2 // expected should more values until stopped i have no particular preference in type of loop use, long works. t

java - Creating Multiple Objects in a Loop Issue -

i need create multiple objects in loop. read elsewhere adding them list accomplish task, below code gives me set of copies of same object, i.e. same values. idea how can create multiple objects, rather copies of same one? thank you. (the code below simplified version of i'm working on) system.out.println("creating swarm of size "+swarmsize); list<dog> mydogs = new arraylist<dog>(); for(int = 0; < dogamount; i++) { system.out.println("new dog # "+i); mydogs.add(new dog(i)); } dog first = mydogs.get(0); dog other = mydogs.get(3); system.out.println(first.getid()+" "+other.getid()); //prints out number of dogs should have created -1 both times my dog class import java.util.*; public class dog{ public static int dogid; public dog(int id) { dogid = id; } public int getid() { return dogid; } public void setid(int id) { dogid = id;

jsf 2 - JSF 2 template partial update -

this question has answer here: how ajax-refresh dynamic include content navigation menu? (jsf spa) 3 answers i have following jsf 2 template page primefaces menu, want partially update cenral centent of page onclick of links left menu, don't want update entire page.i have gone throu posts in stackoverflow, suggetign should have form name in central_body_div, don't want sepcify form in central_body_div, dynamically loaded page have form it's own name, should able submit form in page appearing dynamically in central_body_div div. first of layout page not loading , giving below exception. cannot find component identifier "central_body_div" referenced "leftmenuformid:menuitem1". experts can give solution problem. apprecite replies. <?xml version='1.0' encoding='utf-8' ?> <!doctype html public "-//w3c/

magento - how implement setPagesize for pagination, right now returning all products -

all trying setpagesize() on collection can use pagination. i getting products returned no matter integer put setpagesize. code: <?php class rik_featured_block_featured extends mage_core_block_template { private $_itemperpage = 2; public $_category_id = '' ; private $_currentpage = ''; public function __construct() { $custom_var_code = mage::getmodel('core/variable')->loadbycode('homepage_firstrow_prod'); if(isset($custom_var_code)) echo $this->_category_id = $custom_var_code->getvalue('text') ; echo $page_var = $this->getrequest()->getparam('p'); if(isset($page_var)&&$page_var!=0){ $this->_currentpage = $page_var; } if(isset($page_var)&&$page_var == '0'){ $this->_currentpage = '1'; } } /****************** here setcurpage , setpagesize*****