Posts

Showing posts from June, 2015

Add date to MySQL using PHP -

i trying add current date mysql table using php. have following code: $date = date('y-m-d'); mysql_query("insert book_order values($date)") or die (mysql_error()); mysql returns error: incorrect date value: '1996' column 'date_order' @ row 1 date_order attribute type date . i've tried echo $date value , prints out 2013-05-12 why can't add date table , strange 1996 ? if can send local date use: mysql_query("insert book_order values(now())"); the problem because sql have typo - $date variable must quoted: mysql_query("insert book_order values('$date')") or die (mysql_error()); in addition, if not work edit question , paste result sql explain book_order

cq5 dialog is not changing its width after increasing the size -

i have dialog in cq5 using xtype tabpanel, planning change default dimensions of dialog using these instructions still see default size of dialog though increased width of xtype panel. i got working after change xtype dialog this known issue, , has been present since @ least cq 5.3. workaround i'm aware of said, change xtype dialog, set height , width properties on dialog node, , add tabpanel node child node of dialog.

MongoDB java update a doument by a function with fields -

i using mongodb, java, have following document structure : { _id : ... total_items : 34 avarage_cost : 54 } now have item cost, , want update collection total increase 1 , avarage cost right, best way so? i thought doing : int cost = ... ; basicdbobject updatequery = new basicdbobject(); updatequery.put("$inc", basicdbobjectbuilder.start().add("total_items ", 1).get()); updatequery.put("$function", "function(){this.avarage_cost = ((this.total_items-1)*this.avarage_cost + "+cost+"/) / this.total_items;}"); is good/working solution ? best way ? for cannot run javascript code on update queries. there open issue on jira. check issue here . you can solve problem follows : get current object. if null calculate average_cost & total_items , insert db. if not null, current total_items & average_cost field. calculate new total_items & average_cost values. update fields using $set

ios - CALayer with transparent hole in it -

Image
i have simple view (left side of picture) , need create kind of overlay (right side of picture) view. overlay should have opacity, view bellow still partly visible. importantly overlay should have circular hole in middle of doesn't overlay center of view (see picture bellow). i can create circle : int radius = 20; //whatever cashapelayer *circle = [cashapelayer layer]; circle.path = [uibezierpath bezierpathwithroundedrect:cgrectmake(0, 0,radius,radius) cornerradius:radius].cgpath; circle.position = cgpointmake(cgrectgetmidx(view.frame)-radius, cgrectgetmidy(view.frame)-radius); circle.fillcolor = [uicolor clearcolor].cgcolor; and "full" rectangular overlay : cashapelayer *shadow = [cashapelayer layer]; shadow.path = [uibezierpath bezierpathwithroundedrect:cgrectmake(0, 0, view.bounds.size.width, view.bounds.size.height) cornerradius:0].cgpath; shadow.position = cgpointmake(0, 0); shadow.fillcolor = [uicolor graycolor].cgcolor; sh

sql server - fully update a temporary table sql -

i have problem: trying update temporary table (in stored procedure) in sql server 2012, updates first entry matches description. here code: create table #t (store_name varchar(30), product_name varchar(30), price int, valab_since date, valab_until date, best_offer varchar(3)) --some code populates table update #t set best_offer = 'yes' price = (select min(price) cataloage c inner join produse p on c.codp = p.codp p.denumire = #t.store_name) update #t set best_offer = 'no' price > (select min(price) cataloage c inner join produse p on c.codp = p.codp p.denumire = #t.product_name) select * #t cataloage , produse tables use to cover records, first set them "no", run separate query update ones min price store. update #t set best_offer = 'no'; ;wit

301 redirect phpbb forum and all subpages -

hello redirect website/forum/ , subpages (e.g.: /forum/viewtopic.php?f=2&t=453) index page. i have tried few different methods not work. i tried redirectmatch 301 ^/forum/.*$ http://myhomepage.com leaves part of forum page in url. i tried: rewriteengine on rewritebase / rewriterule ^/forum/.*$ http://myhomepage.com [l,r=301] but did nothing. any appreciated. for apache's httpd.conf , try using rewriterule ^/forum/(.*)$ http://myhomepage.com/ [r,nc] the (.*) should catch comes after /forum/ . r means redirect, , nc means case insensitive.

unix - How to use fgets() instead of fscanf() on stdin in C? -

i want use fgets instead of fscanf stdin , send child process via pipe. code below works sorting lines in file replacing fscanf(stdin, "%s", word) with fgets(word, 5000, stdin) gives me warning warning: comparison between pointer , integer [enabled default] otherwise program seems work. ideas why getting warning? int main(int argc, char *argv[]) { pid_t sortpid; int status; file *writetochild; char word[5000]; int count = 1; int sortfds[2]; pipe(sortfds); switch (sortpid = fork()) { case 0: //this child process close(sortfds[1]); //close write end of pipe dup(sortfds[0]); close(sortfds[0]); execl("/usr/bin/sort", "sort", (char *) 0); perror("execl of sort failed"); exit(exit_failure); case -1: //failure fork case perror("could not create child"); exit(exit_failure); default: //this parent process close(sortfds[0]); //close read end of

sql - mysql order by, skip non-alphanumerics -

in doing mysql sort by title, following results: #314: basket case $1.2 billion scam: ft. frauderdale (dis)members - m - ...and makes 3 3:10 yuma (2007) how ignore special characters, results sorted follows: $1.2 billion scam: ft. frauderdale 3:10 yuma (2007) #314: basket case ...and makes 3 (dis)members - m - nested replaces achieve column without special char, ugly like select replace(replace(field, '.', ''), '#', '') fld table order fld

c++ - template method specialization for ptr to struct and vector of ptr to struct? -

if have variant contain 2 types- pointer struct, , vector of pointer struct. how specialize 2 template methods in boost::static_visitor handle 2 cases? boost::variant<a*,b*,c*,vector<a*>*, vector<b*>*, vector<c*>*> have visitor functor inherit static_visitor<void> , or typedef void result_type . have override of each type in variant -- can via templates, or explicit overrides. struct my_visitor: static_visitor<void> { void operator()( a* ) const { std::cout << "i see a*\n"; } void operator()( b* ) const { std::cout << "i see b*\n"; } void operator()( c* ) const { std::cout << "i see c*\n"; } void operator()( std::vector<c*>* ) const { std::cout << "i see std::vector<c*>*\n"; } void operator()( std::vector<b*>* ) const { std::cout << "i see std::vector<b*>*\n"; } void operator()( std::

xml - Android - Simplest approach for a basic app? Details included -

i need build simple android app. app lists clients , within each client page, lists monthly progress reports. client information includes name, email, etc (strings) , progress report items includes few more strings. question is, easiest approach building - task performs adding new clients , adding progress items each client. the 3 ways aware of are: - sqlite seems pretty advanced - xml - or sharedpreferences definitely not shared preferences. xml ok, such application data, android seems prefer use sqlite. it's built-in, there tutorials, , works enough. that's easiest solution.

php - How can I add these arrays? -

how can addition of total_qty_ordered of arrays? this can number of arrays array ( [0] => array ( [total_qty_ordered] => 1.0000 [1] => ) [1] => array ( [total_qty_ordered] => 1.0000 [1] => ) [2] => array ( [total_qty_ordered] => 1.0000 [1] => ) [3] => array ( [total_qty_ordered] => 1.0000 [1] => ) [4] => array ( [total_qty_ordered] => 1.0000 [1] => ) [5] => array ( [total_qty_ordered] => 1.0000 [1] => ) [6] => array ( [total_qty_ordered] => 1.0000 [1] => ) [7] => array ( [total_qty_ordered] => 1.0000 [1] => ) [8] => array ( [total_qty_ordered] => 1.0000 [1] => ) [9] => array ( [total_qty_ordered] => 2.0000 [1] => ) [10] => array ( [total_qty_ordered] => 1.0000 [1] => ) [11] => array ( [total_qty_ordered] => 1.0000 [1] => ) ) $sum = array_sum(array_map(function($item){ return $item['total_qty_ordered']; }, $array

php - Database Communication in Java -

i trying store, modify, , variables mysql database have set up. have figured out how using sql java library. loading java program using external client not allow external libraries. have been doing research , need sort of communication between php , java. let's have int in java program: int x = 0; i want to store variable in mysql database. if please me or give me example gets variable java , stores in database using php, great. thanks! you can use web-services (soap ..) or rest method... although gonna have research because can't putt of code here plus depend on jws , php files..

taglib - How to check whether an error happened on a specific property with spring mvc -

i'm using form tag. <form:form commandname="foo"> <div class="myclass "> <label>foo</label> <form:input path="fooname"/> </div> <div class="controls"> <input type="submit" class="btn" value="submit"/> </div> </form:form> question is there way find out if error happened on specific field? i aware of <form:erros path="fooname"/> print out error message. after returns true or false based on if error happened on fooname property. need because if error happened can insert css class error next my class yes, possible: <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <form:form command

osx - Applescript to click Done when dictating (Mac) -

i have script opens "dictation & speech", activates (turns dictation: on) , runs shortcut start dictating (system events keystrokes command d). works fine, want click done (or return key) after speech not heard. tried someone's answer stackoverflow. here link: applescript automatically close dialog box after input? but when it's done editing , return key pressed, there no text entered. maybe return key not pressed, , quits dictation? edit: after research, found out dictation window (or tiny microphone popup) close if clicked anywhere except done. guessing when keystroke return happens, on different window, wondering how current window/pop-up click done key in it? the done button button 1 of process "dictationim" : tell application "system events" tell process "dictationim" click button 1 end tell

android - How to instantiate custom view when other arguments are added? -

i know simple answer, i'm little stumped here. i'm creating custom view, panel , following constructor: public panel(context context, attributeset attrs, int barlength){ super(context, attrs); //paint object drawing in ondraw barpaint = new paint(); bar = new rect(3, 13, barlength, 3); // rect object //...other stuff, etc etc } in activity view used, created 5 different times within different cells of table layout. panel simple rect length vary based on argument barlength . so, in activity panel views created, they're called so: private panel tagbar; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tagbar = (panel) findviewbyid(r.id.custview); } as can tell, doesn't use constructor outlined above. how instantiate new panel , including passing right context , attributeset ? seems when constructed (without int barlength argument)

asp.net - JQGrid filterToolbar is not working -

this first time i'm working jqgrid. i've loaded data grid filtertoolbar not working. here view <asp:content id="content1" contentplaceholderid="titlecontent" runat="server"> index </asp:content> <asp:content id="content2" contentplaceholderid="maincontent" runat="server"> <title>jqgrid asp.net mvc - demo</title> <!-- jquery ui theme used grid --> <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.0/themes/redmond/jquery-ui.css" /> <!-- css ui theme extension of jqgrid --> <link rel="stylesheet" type="text/css" href="../../content/themes/ui.jqgrid.css" /> <!-- jquery library prerequisite jqgrid --> <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.0.min.js" type="te

Error in Java program missing packages -

i tried run java program missing packages. import org.activiti.engine.*; public class rawdriver { public static void main(string[] args) { processengine processengine = processengineconfiguration.createstandaloneinmemprocessengineconfiguration().setdatabaseschemaupdate(processengineconfiguration.db_schema_update_false).setjdbcurl("jdbc:h2:mem:my-own-db;db_close_delay=1000").setjobexecutoractivate(true).buildprocessengine(); system.out.println("processengine = " + processengine); } } how can import external packages , run program? the external packages need in classpath. can set environment variable or on command line. need have libraries associated need shipped jar files. more classpaths here: http://docs.oracle.com/javase/tutorial/essential/environment/paths.html

entity framework - Select last inserted ten rows -

i using entity framework. want inserted (means last ten) ten rows. table user has 2 columns: userid password datetime how can recent ten rows? if have datetime (or date ) column can use this: using(yourdbcontext ctx = new yourdbcontext()) { var lasttenrows = ctx.users.orderbydescending(u => u.datetimecolumn).take(10).tolist(); }

php - Will these functions protect me from XSS and SQL injections? -

i'm having query; $sql = "insert statusups (pid, text) values ('{$_session['sess_id']}', '{$_post['appendedinputbutton']}')"; and i'm processing variable $_post['appendedinputbutton'] this; $_post['appendedinputbutton'] = $purifier->purify($_post['appendedinputbutton']); $_post['appendedinputbutton'] = strip_tags($_post['appendedinputbutton']); $_post['appendedinputbutton'] = trim($_post['appendedinputbutton']); does protect me xss , sql injections? i've looked mysqli , prepared statements , looks takes code simple thing. if protects me sql injections , xss love keep method or should upgrade mysqli? the function $purifier->purify comes plugin htmlpurifier a cross site scripting attack allows attacker execute code hosted on server on webpage. stripping tags , running through purifier start long aren't whitelisting way attacker can't li

graphics - Change "fill style" or "line style" in Gnuplot automatically -

Image
i need plot grid. each segment of grid can have different color /style. style correspond value specified in file. thought boxxyerrorbars style can relevant. created file has 7 columns: #x y xlow xhi ylow yhi style 1 1 0.9 1.1 0.5 1.5 0.2 2 1 1.9 2.1 0.5 1.5 0.4 3 1 2.9 3.1 0.5 1.5 0.6 i make plot using boxxyerrorbars style , first 6 columns data: plot[0:4][0:2] 'aa1.dat' w boxxy fs solid 0.6 nobo the plot (just 3 segments of grid) looks as... (don't have enough reputations submit image). all segments drawn style solid 0.6 . changing number, 1 can change fill style density. need each segment has own style, example, specified in 7th column of data. maybe, there other ways. need segments drawn style /color, specified file (not inserted hand script). add palette option plot the palette option automatically assign color value current palette according value of last column of datafile (in case 7th column, in ord

visual c++ - Use assignment operator instead of calling a function in C++ -

i'm new c++, it's messing googlefu. i'm not sure ask guess. i'm wondering if possible make can use assignment operator pass values objects. the closest thing can think of i'm talking how python works when use @public , @myvar.setter. can say: class myclass(object): @public def myvar(self): return self._myvar @myvar.setter def myvar(self, value): self._myvar = value; myclass.myvar = 12 print myclass.myvar this print 12, never have call myvar method function called, "myvarset(12)" , "myvarget()". the reason ask, because understand "string" not true data type, array of char. mean when include string, somehow has ability interesting assignment operator. instead of having assign variable following: char word[5] = { "h","e","l","l","o" }; you can say: string word = "hello"; what if 1 wanted able other types of arrays? let

ios - How to get text string dimensions if I have CTFontRef? -

i know can use: cgsize r = [mystring sizewithfont:uifont]; problem not have uifont, use core text. have ctfontref. way string size givet ctfontref? have font size in double . thank you you can create ctframesetter use ctframesettersuggestframesizewithconstraints measure dimensions of string when rendered text -- using additional context provide. of course, create function reduces variables font+size there.

math - How to store three small numbers into one double? -

i have int a, b, c . , a in range 0-9999 , b 0-99 , c 0-99 . because function must return 1 double , think of putting them 1 number. otherwise need call function 3 times. cannot write efficient code this. called millions times, should quite effective, no asm. i need function double pack3int_to_double(int a, int b, int c) {} couldn't store + 1000b + 100000c? for example, if wanted store = 1234, b = 6, , c = 89, you'd store 89061234 ccbaaaa you can extract numbers casting double int , using standard integer division , modulus tricks recover individual values. hope helps!

loops - Batch Programming Looping? -

i'm not expert in batch programming, skill in c\c++. i'm not sure how go really. i've got bunch of videos video1.mp4, video2.mp4 (that's not actual names, have numbers indicating beginning , end) basically have ffmpeg command can use convert of these aspect ratio of 16:10 looks this: "ffmpeg -i "section 1 video 1.mp4" -aspect 16:10 outsection 1 video 1.mp4" "ffmpeg -i "section 1 video 2.mp4" -aspect 16:10 outsection 1 video 2.mp4" "ffmpeg -i "section 2 video 1.mp4" -aspect 16:10 outsection 2 video 1.mp4" now instead of writing command on , on again, there anyway me substitute numbers actual variables? know section 1 ends @ video 27 , section 2 ends @ video 26 , on. need loop run 165 times don't need write command 165 times. or beyond scope of capability of mere batch program? well, of course batch can it, real question can handle framing question correctly? here's 3 ways - ffmp

c++ - Cross compiler error: reference 'm_memoryManager' cannot be decalred 'mutable' [-fpermissive] -

i compiling arm11 , use xalanc. bunch of these: in file included /xx/include/xalanc/domsupport/domservices.hpp:39:0, /xx/include/xalanc/xpath/xobject.hpp:39:43, xy/myxpath.cpp:7: /...xx/include/xalanc/platformsupport/xslexception.hpp:199:29: error : reference 'm_memorymanager' cannot decalred 'mutable' [-fpermissive] make: *** [mypath/myxpath.arm-bcm2708hardfp-linux-gnueabi-gcc.release.32.0] error 1 any idea? edit_ using gcc 4.7 this seems a bug/configuration issue . need modify xerces_autoconf_config.hpp workaround it.

java - Jsoup is not finding my element -

perhaps i'm doing wrong, i'm trying parse page using jsoup, reason doesn't find me div i'm looking for doc = jsoup.connect(params[0]).get(); content = doc.select("div.itemcontent").first().text(); where going wrong here? thanks the problem: different website using jsoup using browser. set useragent in jsoup, no luck. possible content changed through javascript?! however, can change selector according webseite get. it's idea take document it's parsed - simple system.out.println(doc) enough. here steps can try: print document doc (eg. using system.out ) search required value(s) in there select tags instead i played around bit, maybe can use snipped: content = doc.select("description").first().text(); it seems me, <description>...</description> you're looking for.

sql - How to Merge 2 Queries in 1 -

i have these 2 sql queries need join. query1 (shows list of entiries): select e.entityid ,e.entityno , e.name , e.shortname [xx].[xx].[entities] e e.type = 'a' , e.yearendmonth = 6 query2 (shows list of contacts): select p.firstname,p.lastname, p.email [xxx].[xx].[people] p p.peopleid= ( select top 1 a.peopleid [xxx].[xx].[entityattentions] a.entityid = ? order a.entityattentiontypeid asc ) my objective have combined list of entities , contact people. i tried have error (only 1 expression can specified in select list when subquery not introduced exists) select e.entityid ,e.entityno , e.name , e.shortname , (select p.firstname,p.lastname, p.email [xxx].[xx].[people] p p.peopleid= ( select top 1 a.peopleid [xxx].[xx].[entityattentions] a.entityid = e.entityid order a.entityattentiontypeid asc ) ) [xxx].[xx].[entities] e e.type = 'a' , e.yearendmonth = 6; i guess must use ki

Passenger reading .htaccess from outside rails documentroot -

i have rail3 application running on apache2+phusion_passenger. working pretty smoothly till couple of days when started getting following error: [mon may 13 11:43:16 2013] [error] [client 54.228.16.0] request exceeded limit of 10 internal redirects due probable configuration error. use 'limitinternalrecursion' increase limit if necessary. use 'loglevel debug' backtrace. [mon may 13 11:43:16 2013] [debug] core.c(3063): [client 54.228.16.0] r->uri = /blog/index.php [mon may 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected r->uri = /blog/index.php [mon may 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected r->uri = /blog/index.php [mon may 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected r->uri = /blog/index.php [mon may 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] redirected r->uri = /blog/index.php [mon may 13 11:43:16 2013] [debug] core.c(3069): [client 54.228.16.0] r

JSON Parsing issue in Rails -

i seeing strange issue in rails. request body (request.body): renewals[][driver_1][dl_number]=123& renewals[][driver_1][expiration_date]=20130513& renewals[][driver_1][last_name]=123& renewals[][driver_1][state]=al& renewals[][driver_1][verified]=1& renewals[][driver_2][verified]=0& renewals[][id]=6415& renewals[][insurance][expiration_date]=20130513& renewals[][insurance][naic]=123& renewals[][insurance][policy_number]=123& renewals[][insurance][verified]=1& renewals[][mailing_address][address_has_changed]=0& renewals[][mailing_address][city]=gulf%20shores& renewals[][mailing_address][state]=al& renewals[][mailing_address][street_address]=8094%20beach%20lane& renewals[][mailing_address][zip]=35023& renewals[][driver_1][dl_number]=123& renewals[][driver_1][last_name]=123& renewals[][driver_1][state]=al& renewals[][driver_1][verified]=1& renewals[][driver_2][verified]=0& renewals[][id]=6412&

ios - AFImageRequestOperation in order not asynchronous -

i implementing code downloads images , saves them in database of app, i have array of objects, each object contains image url , other information. download images i'm using class library afimagerequestoperation.h afnetworking. my code downloads , saves data in database, need notify user image downloaded, eg: if have array containing 5 objects (quoted above each object), have downloading same order in array, afimagerequestoperation makes downloading asynchronously item 4 can downloaded before first item. in short, want have control , release next download when previous 1 completed. i have runs through array of objects , calls function each position, function has following code: nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:[arrimagem valueforkey:@"urlimagem"]]]; afimagerequestoperation *operation = [afimagerequestoperation imagerequestoperationwithrequest:request imageprocessingblock:nil success:^(nsurlrequest *request, nshttpu

inno setup - How can I extract an embedded archive to disk during the installation process -

i have embedded 7zip archive in setup script. there "native" way of extracting contents target folder? if not hints on how achieved? updated implementation. hint tlama [files] source: "documentation.7zip"; destdir: "{tmp}" source: "7za.exe"; destdir: "{tmp}" [run] filename: "{tmp}\7za.exe"; parameters: "x -o""{app}"" ""{tmp}\documentation.7zip"""; flags: runhidden; description: "{cm:installingdocumentation}"; statusmsg: "{cm:installingdocumentationstatus}" [custommessages] en.installingdocumentation=documentation files en.installingdocumentationstatus=installing documentation files. may take several minutes... no, there no native way extract 7zip files innosetup installer. however, can copy of 7zip library, which redistributable , call innosetup script's code section.

c# - Is it safe to use GetHashCode to compare identical Anonymous types? -

given 2 identical anonymous type objects: {msg:"hello"} //anontype1 {msg:"hello"} //anontype2 and assume haven't resolved same type (e.g. might defined in different assemblies) anontype1.equals(anontype2); //false furthermore, assume @ compile time, can't structure of 1 (say anontype1 ) because api exposes object so, compare them, thought of following techniques: use reflection msg property on anontype1 comparison. cast anontype1 dynamic type , reference .msg on dynamic member comparison compare result of .gethashcode() on each object. my question is: safe use option 3? i.e. sensible assume .gethashcode() implementation return same value indentically-structured, different anonymous types in current , future versions of .net framework? interesting question. specification defines equals , gethashcode (note typo in specification!) methods behave instances of same type, implementation not defined. happens, current ms c# co

mechanicalturk - Mturk Worker ID, completion code and approval -

i trying solve following questions in mturk: worker id: know can ask worker id. practice or can/should extract worker id referral url in other way ? the standard example external survey includes textbox worker should input completion code. understand random generated code i have choose/generate. or there mturk completion code system ? if worker enters code in textbox (input form). stored in mturk ? in other words, create textbox named , amazon takes care of storing in csv ? or missing here ? know how can create textbox , download .csv assignment id, worker id , random generated code ? how can make sure worker can enter completion code once ? can standard html templates ? thanks (1) @ question: how specify requester's workerid in mechanical turk hit? (2) have generate codes. mturk provides no system generating these. (3) code stored in hit results, see here: https://requester.mturk.com/manage or via api. if use requester user interface create hit (perhaps

Changing every route from /product to /eshop in Rails Route 3 -

in routes.rb have foll entries:- resources :products 'get_products', :on => :collection 'show_product_details',:on=>:member 'buy_this',:on=>:collection 'search_product',:on=>:collection end i want change every /products /eshop in url. not sure can use :path=>:eshop .will applicable sub routes such eshop/get_products,eshop/buy_this ...etc. you can modify routes , run rake routes in terminal check paths. resources :products, :path => 'eshop', :as => 'eshop' 'get_products', :on => :collection 'show_product_details',:on=>:member 'buy_this',:on=>:collection 'search_product',:on=>:collection end will produce these get_products_eshop_index /eshop/get_products(.:format) products#get_products show_product_details_eshop /eshop/:id/show_product_details(.:format) produ

WebRTC on a standalone mobile app -

i know webrtc designed browsers, possible use webrtc libraries on mobile applications directly? thanks! as of may 14 here android project using webrtc works nicely. i translated entire android project objective-c ios , got webrtc working in ios i'm having trouble on iphone 4 , 4s. works in iphone 5 , 5s. i think problem performance. when make videocall webrtc libraries takes 140% of cpu on iphone 5, guess that's lot of resources , iphone 4s can't handle it. edited after struggling video connection (always disconnected after 10 seconds) got webrtc working on iphone 4s, have set right constraints when creating local videosource capturing object: nsstring *_width = @"320"; nsstring *_height = @"180"; nsstring *_maxframerate = @"10"; rtcmediaconstraints *videoconstraints = [[rtcmediaconstraints alloc] initwithmandatoryconstraints:@[[[rtcpair alloc] initwithkey:@"maxheight" value:_height], [[rtcpair alloc

c - SDL event sequences on wheel movement -

i new sdl , maintaining sdl application. want know (and how) events delivered when user play wheel. in app user modify size of little square on screen using mouse wheel. found out app slow when user turning wheel. basically there 1 big loop sdl_event event; for(;;){ // sdl_waitevent(&event); sdl_lockmutex(mymutex); switch(event.type){ case sdl_customevent: //handle 2 or 3 customs events break; case sdl_keydown: //handle keydown break; case sdl_videoexpose: //handle keydown break; case sdl_mousebuttondown: switch(event.button.button){ case sdl_button_right: break; case sdl_button_right: break; case sdl_button_wheelup: <---------------------- /** recompute size of box. also, not believe, update whole screen redrawing images each time. **/ break;

php - How to make the content appear in an object element? -

am using firefox 20.0.1 <object type="text/html" data="nature.php" style=" margin:1%;overflow:hidden; width: 100%; height: 100%"></object> the content page (nature.php) appears clipped on screen. the object element not including complete pages another. including java applets or flash programs.

html - Check Id element javascript -

var jewels = new array() var index var rand var scard = [a1, a2, a3, b1, b2, b3, c1, c2, c3] function generateboard() { (var = 0; <= 8; i++) { jewels[i] = new array(); var index = math.floor(math.random() * scard.length) jewels[i] = scard[index] console.log("i:" + + jewels[i]) var yy = scard.indexof(scard[index]); scard.splice(yy, 1); } } function drawboard() { generateboard() var html = '<div class=game_background>' (var = 0; < 9; i++) { rand = math.floor(math.random() * jewels.length) html += '<div class="' + jewels[rand] + '" id="ship' + + '" style="top:' + ((i * 12) + 135) + 'px; left:245px;" ></div>' jewels.splice(rand, 1); } var newarray = [a1, a2, a3, b1, b2, b3, c1, c2, c3] } here a1,a

symfony - best practice how to schedule symfony2 action -

my application based on symfony2 has standalone jobs @ differents moments , differents frequencies. exemple, sending newsletter, editing report ... i want able add/edit each task application task close cron jobs , consist call specific url. from point of view : i think creating cron job launch script every half hour, or ten minutes. script curl command witch docronjob action. docronjobaction inside symfony , responsible task , launch 1 has to. my questions : is there cleaner way achive ? inside docronaction how launch others action ? how manage set time limit 0 entire controller ? does bundle doing allready exist ? it sounds storing schedule of tasks in database. no problem. every different type of task (eg. sending newsletter, save reports) create service, task. add services tag (like twig.extension, but own ), have taskchain, knows tasks. for executing create console command , retrieves schedule database, loads taskchain, , executes tasks. console comman

html - Is it possible to escape &amp; &apos; present in database? -

the data retrieved database has &amp; or &apos; . how escape , show & or ' without using gsub method? if can't stop data being inserted that, there code here create function in mysql can use in query in order return decoded data. or within ruby, not using replace strategy, take @ how-do-i-encode-decode-html-entities-in-ruby .

java - Are methods overridden when methods have the same name but different signatures? -

public class superclass { void method(object a){ } } public class subclass extends superclass { void method(string a){ } } in class above, method in superclass has parameter of type object while subclass has parameter of type string. string subclass of object. question is, method overriden in case? the famous example of confusion caused issue raise involves equals : public class banana { private final double weight; public boolean equals(banana that) { return this.weight == that.weight; } } many people think valid override of equals , it's method unrelated object#equals(object) , not involved in equals comparison. this 1 of known pitfalls of java's type system take care right. to confuse matters further, are allowed specialize return type (the return type covariant ): public abstract class fruittree { public abstract object getfruit(); } public class bananatree { ... @override public banana getfruit() { return this.bananas.

Android RecognizerIntent simple destroy -

i use intent voice recognition, here code : /** * fire intent start voice recognition activity. */ private void startvoicerecognitionactivity() { intent intent = new intent(recognizerintent.action_recognize_speech); intent.putextra(recognizerintent.extra_language_model, recognizerintent.language_model_free_form); intent.putextra(recognizerintent.extra_prompt, "voice recognition demo..."); startactivityforresult(intent, request_code); } everything works fine. want stop voice recognition after 5 seconds example. can't figure how kill voice recongnition activity. to kill voice recongnition activity call finishactivity(request_code) . need set countdown timer duration of 5 second, in onfinish call finishactivity(request_code) . start timer after call startactivityforresult

c++ - Should I use a singleton for hardware management ? -

so i'm rather new @ oo design, , i'm wondering use of singleton design pattern. i've read articles why singletons bad still can't figure out if need 1 or not. i'd avoid as possible. in case, work oceanoptics spectrometers, can controlled , consulted through api, in c++. i've put code manages spectrometers (discovering them, setting or getting parameters, retrieving data) in single class spectrometerproxy . and know if class should singleton or not. feel there might few reasons justify it: it manages hardware whatever number of spectrometers, they're controlled , consulted through class there's specific procedure must done in precise order, , once (opening spectrometers, checking variables, , closing spectrometers when program stops) then, don't know if there better ways of implementing class making singleton. other solution thought of keeping normal class prevent copying (by declaring copy constructor , assignment operator private)

java - Hex values instead of line numbers in the stack trace -

i trying debug java program loaded embedded system reading output via serial port. when exception raised cannot see line numbers in stack trace. instead there hexadecimal values. suspect maybe stand memory addresses, not sure @ all. here portion of stack trace give idea: exception in thread "main" com.is2t.web.rs.restexception @ java.lang.system.@m:0x8009e7c:0x8009e86@ @ java.lang.throwable.@m:0x8009f88:0x8009f9e@ @ java.lang.throwable.@m:0x8008cec:0x8008cfe@ is there way view line numbers? if not, best technique debug without knowing them? edit: embedded system stm32 microcontroller , don't believe have documentation explaining particular situation.

javascript - Hammer.js Carousel Start Pane -

heyho, i´am working on project in university , i´d use "hammer.js". i´ve downloaded carousel-example , works me. but start middle pane of code , it´s not simple think. it´s this: http://img203.imageshack.us/img203/6326/schemeas.jpg so hammer.js starts green screen. start yellow one. i´ve added 1 swipe right init function looks horrible when page loading , not goal ^^ i hope of have idea how solve problem. try calling carousel.showpane(1); that display second pane instantly. want put near bottom, right after says. carousel.init(); if you're feeling adventurous try , make automatically start pane there's variable inside carousel function called current_pane set default of 0 (the first pane). altering may work might require more code somewhere else. experiment! edit null right, animate it. here's more in depth method set without animation: i found method responsible changing pane showing setcontaineroffset mthod passed variable

Can I create osX java application bundle that open multiple instances of program? -

i wonder if possible specify osx application bundle .plist key allows opening new instances of program when click "open with" in finder? have created simple text editor in java , want open multiple instances when clicking on different text files. current behaviour open instance of program destroyed , new opened. there way handle in mac osx applicationlistener interface? in windows "open with" opens new instance of program. /andreas

java - Very Strange error found during unit testing of my web server project using junit -

i working on 1 project namely http threadpool web server . writing unit tests of same using junit in maven . in mean while found 1 weird error , didn't understand why happening. unable trace reason of error. asking same in question. i wrote test cases methods server provides, i.e., options, get, put, post, head . tested test files separately 1 one, , runs fine. but when put test files together, namely, getmethodtest, putmethodtest, headmethodtest, postmethodtest, optionsmethodtest , stucks. i put webserverstarter module, under @before , , module makes threadpool, open server socket, , starts listening on 1 port client request. when saw logs, shows in starting tries close socket, didn't understand, why happening. i spent lot of time on this, can't find reason why happening. please me in removing weird behavior of junit . i think there threading issue. edit no 1 logs mon may 13 21:50:10 ist 2013 root directory not valid 1 mon may 13 21:50:10 ist 2

import - Transfer Scrumwise to GreenHopper -

scrumwise can export whole data xml. contains lots of data including projects, backlog, sprints, tasks, team members, etc. can export tasks csv. greenhopper can import projects in various formats (but not xml). i'd transfer as possible between scrumwise , greenhopper. i'm thinking of extracting projects node xml, converting json, , importing that. right greenhopper rejects data right start. is there reference data schema used in greenhopper? i'd transfer more project, associated data. select backlog tasks , export. scrumwise uses semicolon delimiter. convert search , replace , jira @ least try import. import new empty project, expect take several attempts right. you'll need add columns time remaining in seconds. getting statuses , resolution hardest part. jira gives status options fail during import! check jira workflow valid states. also, empty resolution means "unresolved", unrecognized resolution defaults "resolved". tasks, need

Annotating bars using Google Chart API -

Image
i'm trying add annotations horizontal bars similar annotations in attached chart image. [eg: annotation bar '1' "7.4% (+2.4/ -.19)", bar '3' "11.7% (+2.9/ -2.4)" , average vertical line representation in image]. i have used bar chart , configured it's options render bars , interval. but, google charts api documentation, bar chart won't support annotation/ annotationtext in role. which chart have choose google chart api? options have configure mark annotation? there example explains problem using google chart api? the image excerpt google consumer survey page ( http://www.google.com/insights/consumersurveys/view?survey=xirgjukonszvg&question=9&subpop&subpop ). thanks ! there no way create chart displayed in google visualization. can create error bars using datatable roles , barchart not support annotations (meaning can't have text on chart in example posted). you can fiddle combochart , can support

ios - How to make irregular shaped UIScrollView? -

i want make irregular shaped uiscrollview(using cgpath or uibezierpath). the contents scrollable , zoomable. , scroll actions accepted in these areas, not rectangular area. ideas? your use cashapedlayer path create clipping path , apply scrollview's layer's mask. use same path in view's hittest:withevent: decide, if uiview should response touch or not.

c++ - LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup error when using WinMain -

i've been following tutorial learn directx programming: http://www.rastertek.com/dx11tut02.html i'd gotten end, tried build , threw error when compiled: msvcrtd.lib(crtexe.obj) : error lnk2019: unresolved external symbol _main referenced in function ___tmaincrtstartup so, googled extensively try find solution, things i've tried included: -setting entry points winmaincrtstartup , wwinmaincrtstartup , maincrtstartup (probably others too) -making sure subsystem set windows rather console, tried setting 'console' , 'not set' in case. -add existing item file containing main method. -downloaded provided code in tutorial make sure wasn't coding error on part, still didn't work. now interesting bit: i tried downloading tutorial code desktop (which don't have access to, being away) has copy of visual c++ express 2010 (my laptop running visual studio 2010 professional). worked absolutely fine on desktop, first time, didn't have

How use a parameter as datasource in Jasper list element? -

i have report template parameter defined as: <parameter name="phonenumbers" class="java.util.list"/> those phonenumbers objects of type: se.primenta.data.entity.phonenumber and these objects have 2 methods need present in report: string getmaskednumber(); long getnumber; i can't understand how these 2 fields subdataset can visualized in list element. how write dataset , list definitition in jrxml template? what having datasource list : <datasourceexpression> <![cdata[new net.sf.jasperreports.engine.data.jrbeancollectiondatasource($p{phonenumbers})]]> </datasourceexpression> and using $f{maskednumber} , $f{number} inside list ?