Posts

Showing posts from July, 2012

Matlab Huffman Encoding in matrix -

i trying encode matrix have (after calculating frame differences) huffman code having difficulties completing it the matrix wish encode huffman called "amp" something found this: function y = mat2huff(x) %mat2huff huffman encodes matrix. % y = mat2huff(x) huffman encodes matrix x using symbol % probabilities in unit-width histogram bins between x's minimum % , maximum values. encoded data returned structure % y: % y.code huffman-encoded values of x, stored in % uint16 vector. other fields of y contain % additional decoding information, including: % y.min minimum value of x plus 32768 % y.size size of x % y.hist histogram of x % % if x logical, uint8, uint16, uint32, int8, int16, or double, % integer values, can input directly mat2huff. % minimum value of x must representable int16. % % if x double non-integer values---for example, image % values between 0 , 1---first scale x appropria...

jQuery's each function and array inside of it -

having trouble each function... try explain example... in code, there div id "media-type-container-1", content changes "live", in runtime: <div id="media-type-container-1"> <div><input type="checkbox">media 11<span id="media-stations-id-11" class="media-stations-id">11</span></div> <div><input type="checkbox">media 12<span id="media-stations-id-12" class="media-stations-id">12</span></div> </div> if changes, can chnanged ie: <div id="media-type-container-1"> <div><input type="checkbox">media 13<span id="media-stations-id-13" class="media-stations-id">13</span></div> <div><input type="checkbox">media 14<span id="media-stations-id-14" class="media-stations-id">14</span><...

sql server - Equivalent of GETDATE() BETWEEN Two DateTime Fields where Both can be NULL -

is select [id] ,[dateonline] --nullable ,[dateoffline] --nullable ,[pageid] ,[downloadid] ,[weight] [downloadpage] getdate() between [dateonline] , [dateoffline] equivalent to: select [id] ,[dateonline] --nullable ,[dateoffline] --nullable ,[pageid] ,[downloadid] ,[weight] [downloadpage] ([dateonline] null or [dateonline] <= getdate()) , ([dateoffline] null or [dateoffline] > getdate()) but catering nulls? or there more elegant way of doing it? where parentheses needed here? thanks. edit: both [dateonline] , [dateoffline] of type datetime if [dateonline] null logic "online now" if [dateoffline] null logic "never go offline (once online)" sorry, should have included in question begin with. the author's second query net better performance if there no indexes on columns. if there indexes, that's no brainer... using coalesce disable index , table sc...

.net - The method HtmlDecode has invalid arguments? -

hi using richeditor . editor saves span , style in table . so, using following method avoid this: htmldecode(databinder.eval(container.dataitem, "imagedesc")) but giving error like: htmlcode has invalid arguments how can solve .the c# code is: public string htmldecode(string strvalue) { string functionreturnvalue = null; try { functionreturnvalue = server.htmldecode(strvalue); } catch (exception exc) { // processmoduleloadexception(this, exc); } return functionreturnvalue; } could strvalue null? try adding null test. if it's null, replace empty string.

jquery - Close colorbox (iframe) after submitting form and load new url in parent page -

i'm loading page in iframe colorbox. on page there's form can submitted. close colorbox automatically , load new url in parent page after submitting form. how can realize this? now use onclick function after submitting form, want done automatically: <a onclick="parent.$.fn.colorbox.close();" target="_parent" href="http://www.test.com">test</a> it's not clear issue is. generally speaking, you'll want use submit action on iframed form trigger behavior desire. example, can trap event , following: process form submission close colorbox load new uri parent's location you've figured out how close colorbox, study on parent.window.location , you're off races. personally, in javascript rather trying work out using default browser behavior. all best.

Change the color of a view with a button click in android? -

this create greeting card application , here have change background color of view( background of card) when button clicked. when click button labeled red view should change it's color red. , on. can me this? public void myclickhandler(view view) { switch (view.getid()) { case r.id.btn1: layout= (framelayout) findviewbyid(r.id.laidout); layout.setbackgroundcolor(color.red); break; } you should write code in onclick(view view) method instead of myclickhandler().and id "btn1" should id name declared in xml file.

android - GridView with dynamic number of columns in each row -

Image
how can recreate following view of gridview . the number of items in list dynamic. i guess not single gridview combination of multiple layouts. make linearlayout , decide according content, layout want have in row.

namespaces - Perl: Setup multiple package names for variable/functions? -

first, i'd isn't question of design, question of compliance. i'm aware there issues current setup. in module, there packages named after servers, has many of same variables/functions pertain server. looks set do: production_server_name::printer() or test_server_name::printer() perhaps better design might have been like: central_package_name::printer('production') or central_package_name::printer('test') anyhow, seems server names have changed, instead of using actual servernames, i'd rename packages production or test , without changing other code still refering production_server_name . something like: package production, production_server_name; # pseudo code i'm guessing sort of glob/import might work, wondering if there something similar. realize it's not practice saturate namespaces. i not providing comments on design or might involve changing client code. functions in mytest.pm can accessed using ei...

regex - Javascript: Replace one or more identical characters with the same number of another character? -

i need escape special characters js string, can replace 1 or more occurrences single character. for example, want replace & &amp; when escape string: &&& &amp;&& . i've been using input = input.replace(/&/g,"&amp;"); i know solution problem has using anonymous function, need escape 10 other characters. can't see way pass replacement variable function. mean i'll have write 11 separate functions? your code okay, seems have tested without /g . you can use: replace(/(&)/g,"$1amp;"); see , test code here .

mysql - SQL query in Doctrine2 -

i need here, know how transform sql query doctrine2 query using createquerybuilder? select a.resposta, ( select count(r.id) car_resultado r2 left join car_resultado_inquerito ri2 on r2.id_resultado_inquerito = ri2.id ri2.id_inquerito = 20 , r2.id_resposta = a.id group r2.id_pergunta, r2.id_resposta ) total car_resposta a left join car_resultado r on ( r.id_resposta = a.id ) group a.id, r.id_resposta i have no idea how it, because nested select normally have create entities , repositories data database. in doctrine2 uncool way. can execute native sql. doctrine2 native sql if possible shouldn't , work classes if have complicated existing queries can it.

windows phone 7 - Error in http request -

i'm making http request google.com. way i'm doing it: httptestwebrequest = (httpwebrequest)system.net.webrequest.create("http://www.google.com/"); httptestwebrequest.method = "get"; httptestwebrequest.begingetresponse(gethttptestresponse, httptestwebrequest); ... private void gethttptestresponse(iasyncresult asynchronousresult) { var webrequest = (httpwebrequest)asynchronousresult.asyncstate; webresponse response =((httpwebrequest)asynchronousresult.asyncstate).endgetresponse(asynchronousresult); ... } with fiddler gives me http 302 moved status code, in app throws me exception , don't redirects new location of website. any ideas why happening? update 1 im getting nullreferenceexception . the stack trace is: at system.net.browser.httpwebrequesthelper.removehttponlycookies(uri requesturi, string setcookieheadervalue) @ system.net.browser.httpwebrequesthelper.parseheaders(uri requesturi, securitycriticald...

c# - Static Constructor in derived class getting invoked first then the base class -

i wondering, in c#, constructor concept is, base class cons should execute first, why seeing derived class static constructor getting called , base class cons. please explain ? :( static constructors initialize class itself , must called before other static members accessed, , before creation of instances of class. as ordering of calls static constructors within class hierarchy, should consider undefined. msdn page on static constructors : the user has no control on when static constructor executed in program.

extjs - ext js accordion -

http://www.myethiopia.org/quicklinks/accordion.html please check link in ie. did not have time figure out why not working in firefox. trying click on link on left column , have page open in center. if click on weather station , oromiya station, title opens fine link not open. line no.325 under var menu1, @ first item code. doing wrong? second question. want round bulltein or outline type of thing (not sure call it) left of oromiya station. how can that? checkbox not looking for. if want update centerpanel html can use update() function. in small example i've added 'id' center panel , in handler function menu item used code show update. var centerregion = ext.getcmp('centerpanel'); centerregion.update('<iframe src="http://www.myethiopia.org/quicklinks/weather/ethiopiaweatherstations/amharastations.html" style="width:100%;height:100%"></iframe>'); i'm not sure trying...

php - DOMDocument: how to append after <title> tag -

i have following code , works far. however, try attach <link href=".." ../> tag below <title> tag or, better yet, below last <meta> tag. is there way accomplish domdocument? $dom = new domdocument(); $dom->loadhtml($html_data); $element = $dom->createelement( 'link'); $element->setattribute( 'rel', 'stylesheet' ); $element->setattribute( 'type', 'text/css' ); $element->setattribute( 'href', $url ); $element->setattribute( 'media', isset($media) ? $media : 'screen' ); $head = $dom->getelementsbytagname('head')->item(0); $head->appendchild($element); echo $dom->savehtml();

android - How Remove This Exception And What's meaning of this Exception? -

in applicatin occure exception please suggest me how can rectify exception:- have been tried change in imageloader code not success. //decode image size bitmapfactory.options o = new bitmapfactory.options(); o.injustdecodebounds = true; bitmapfactory.decodestream(new fileinputstream(f),null,o); /* * options.injustdecodebounds = true; bitmapfactory.decoderesource(res, resid, options); // calculate insamplesize options.insamplesize = calculateinsamplesize(options, reqwidth, reqheight); // decode bitmap insamplesize set options.injustdecodebounds = false; return bitmapfactory.decoderesource(res, resid, options); * * * * */ // calculate insamplesize o.insamplesize = calculateinsamplesize(o,100,100); o.injustdecodebounds = false; //find correct scale value. should power of 2. // final int required_size=70; //int width_tmp=o.outwidth, height_tmp=o.outheight; ...

php - Combine an Image File with an Audio File -

i have requirement in php site join image(jpg or png) audio(wav) , output should video (like mpeg ,mp4 or wav itself). is there tool available this? ffmpeg quite easily. can create video set of images (in case, one) , attach audio it. have @ documentation.

dynamic - Is calling doLayout() method a must after adding child to a parent? -

in our application, there tabpanel in adding/removing panel dynamically. the panels added @ click of menu item following code in menu handler: ext.getcmp('maintabpanelid').add(getpanel()); here getpanel() method returns panel after creating it. assuming id of main tab panel maintabpanelid , of child panel panelid, in context, guide @ following: is necessary call dolayout() on maintabpanel after add method? should dolayout() called on maintabpane l or on newly added child panel, is, ext.getcmp('maintabid').dolayout() or ext.getcmp('panelid').dolayout() ? will call dolayout() take care of issues related rendering, scrollbars esp.? the method getpanel() should return created panel (using ext.create ) or should return config object (having xtype:'panel' )? 1 should preferred better performance keeping time in mind? abstractcontainer::add() <...> if container configured size-managing layout manager, container rec...

android - How to shift parent layout to right without changing inner components layout? -

Image
in application want have sliding menu on left side facebook. in previous question had raised concern regarding same , this answer found way slide layout right using this library . but, found that, library not slides layout, instead takes screenshot , slides image towards right components on layout not clickable. , need components clickable. so, tried new way of achieving putting slideout menu on left keeping default visibility view.gone , make visible on click on left top corner "show/hide menu" button shown in figure below. layout before: now when click "show/hide menu" button, layout like- layout after: as can see, layout on right shrinks , button "some other view" changes width if i've set android:minwidth attribute 2 buttons on right parent relativelayout . so question is, is there way shift layout towards right without inner components changing width/layout ? in whatever area available view, filled whatever portion of con...

rest - when jersey cannot map a query parameter, fails with 404, why so? -

i'm not jersey guru read jersey cannot resolve java methods based on query params, looks does, here example. this server code: @get @path("/services") public string getall( @queryparam("limit") integer limit, @queryparam("offset") integer offset){ return "1 2 3"; } and client code: clientresponse response = webresource .path("services") .queryparam("limit", "ab") .get(clientresponse.class); logger.info(response.tostring()); assertequals(response.getstatus(), 200); it looks jersey doesn't "ab" , isn't able map query param returns 404, if limit = "1", can hit right method. is jersey right return 404 in case?, know broad interface using string rather integer override treatment feasible sintax error., can configure jersey on behalf? i'm using server: grizzly/1.9.18, jersey 1.11 thanks! currently not possible i...

android - Web Console: What is Omniture? -

i came across interesting logcat entry: 06-28 08:43:25.616 web console 5075 omniture: s.t, instance: 1 @ :1158337217 06-28 08:43:25.624 web console 5075 [object object] @ :1158337217 what omniture (in context) , can learn more these web console messages? omniture analytics tool , in sense it's comparable google analytics. you're seeing logging of omniture javascript code on website you're viewing. edit: to elaborate. comes in web console logs calls console.log() in webpage you're viewing.

javascript - Make a child div visible on click -

edit code make work please. edited latest version. here have: <body> <!-- visibility toggle --> <script type="text/javascript"> <!-- function toggle_visibility() { if(document.getelementbyid(window.event.srcelement.id+'menu').style.display=='block'){ document.getelementbyid(window.event.srcelement.id+'menu').style.display='none'; } else{ document.getelementbyid(window.event.srcelement.id+'menu').style.display='block'; } }; //--> </script> here divs (edited show have) <ul class="lyrics"><h3>all lyrics</h3> <?php while ( have_posts() ) : the_post(); ?> <li ><a id="links" href="#" onclick="toggle_visibility();"><?php the_title(); ?></a> <div id="linksmenu"><?php the_content();?></div> ...

How to use forms in jQuery Mobile? -

i'm new jquery mobile, i'm stumbling on couple things. app (prior getting jquery mobile involved) made heavy use of html forms submitted data via url parameters next page. no server involved in this; it's client side. since jqm uses whole ajax page loading system, had data-ajax="false" in order make them still work. on ios, fine. perfect working app. but android has bug passing parameters url not allowed. how else can purpose achieved?

sql - Hibernate Annotations Id for table with no primary key -

i have table has no primary key, , 1 cannot created either. can construct unique key using 3 columns of table. hibernate demands id every annotated class, how satisfy id unique id can create. if entity type should use composite key. can done moving primary key fields separate class , mapping in entity class @id annotation. see mapping composite primary keys , foreign keys composite primary keys if not entity value type should map accordingly. see https://stackoverflow.com/a/1696146/324900 , entity , value types in hibernate

Need to convert a subquery that selects multiple values to an nhibernate query (criteria or hql) -

i have following query need convert nhibernate: select o.* orders o inner join ( -- recent orders based on end_date (this implies same order can exist in orders table more once) select o2.order_id, max(o2.end_date) max_end_date orders o2 group o2.order_id ) most_recent_orders on o.order_id=most_recent_orders.order_id , o.end_date=most_recent_orders.max_end_date -- of recent orders, ones complete o.is_complete=1 i know hql doesn't support joining subqueries why doesn't work. can't use "in" statement because subquery selecting 2 values. tried using suggestion hibernate documentation: http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-tuple from cat cat not ( cat.name, cat.color ) in ( select cat.name, cat.color domesticcat cat ) but threw error because sql server doesn't multiple values in "in" statement. any appreci...

node.js - NodeJS SAML Lib -

are there saml libraries nodejs? there seems ton of code available node no saml libraries. if not, there reason why not? i did not tried yet, seems looking : https://npmjs.org/package/passport-saml it kind of new (it came out after last answer posted).

php - $_GET does not work in some areas of the page -

so page has lot of include calls on different parts of page. of these includes have kind of function grabs $_get variables. of them work fine, except navigation file doesn't return when try grab variables. nav.php <? require_once("config.php"); require_once("functions.php"); ?> <div id="nav"> <ul> <? initializemainnav( $_get['page'] ); ?> </ul> </div> inside function.php function initializemainnav( $curpage ) { // array ( slug, name ) of navigation items $nav = array( array( "", "home" ), array( "case_studies", "investment case studies" ), array( "current_inv", "current investments" ), array( "about", "about mdig" ), array( "management", "management" ), array( "news", "news" ), array( "s...

ios - Stretching a UIToolbar background image when rotating to landscape -

i adding image uitoolbar's background in app delegate using code: [[uitoolbar appearance] setbackgroundimage: [uiimage imagenamed:@"toolbarbackground.png"] fortoolbarposition:0 barmetrics:uibarmetricsdefault]; the image 768 pixels in width (the size of ipad screen width in portrait orientation). when rotate landscape image not stretch fill new screen width (1024 pixels). how can use custom background image on uitoolbar stretches fit screen when rotating? does toolbar autoresize? if not , set it's autoresizing mask: [mytoolbar setautoresizingmask: uiviewautoresizingflexiblewidth | uiviewautoresizingflexiblerightmargin] if toolbar autoresize , image still doesn't , set contentmode of image view uiviewcontentmodescaletofill .

Spring MVC 3: same @RequestMapping in different controllers, with centralised XML URL mapping (hybrid xml/annotations approach) -

i keep mapping in same place, use xml config: <bean class="org.springframework.web.servlet.handler.simpleurlhandlermapping"> <property name="mappings"> <value> /video/**=videocontrollerr /blog/**=blogcontroller </value> </property> <property name="alwaysusefullpath"> <value>true</value> </property> </bean> if create second request mapping same name in different controller, @controller public class blogcontroller { @requestmapping(value = "/info", method = requestmethod.get) public string info(@requestparam("t") string type) { // stuff } } @controller public class videocontroller { @requestmapping(value = "/info", method = requestmethod.get) public string info() { // stuff } } i exception: caused by: java.lang.illegalstateexception: cannot map handler...

html - Footer not sticking to end of the page -

i have page header,content , footer. issue i'm facing page after footer there grey background being seen , footer not sticking end of page. i have uploaded html here... http://cruzer.net76.net/temp.html any appreciated! in stylesheet , set magin-top: 0 in line 300 (part of .wstoryfootertxt's style);

c - PCM-downsampling: input-frames/output-frames vs. buffer-size -

i have program reads 4096 frames (16384 bytes) 16bit le 48000 hz pcm into 16384 bytes large buffer per "read" kernel module (= read alsa's ring-buffer). after each "read" have downsample 48 khz 44.1 khz , output must smaller/equal 4096 frames (streaming apple's airport express). it works, output sounds "too fast" , "flickering" (i think due lost frames in "read", described below), stops (i think "too fast" causes "wait data"). for resampling use src_process libsamplerate (aka secret rabbit code): int src_process (src_state *state, src_data *data) ; with following parameters: data_in : pointer input data samples. input_frames : 4096 data_out : pointer output data samples. output_frames : 4096 src_ratio : 44100 / 48000 -> 0,91875 my kernel module tells me when missed frames in alsa's ring-buffer inside , happens. i'am missing 100 frames / "read...

ios5 - Filter Live camera feed -

so i've been using uiimagepickercontroller access camera photo , video capture, wanted apply filters on 2 sources, succeeded filtering token photos i'am having trouble finding solution rest, need access raw image data : live image feed camera showing , apply filter , show filtered ones instead. or advice appreciated. uiimagepickercontroller doesn't give low level access camera buffer. you should setup avcapturesession , use delegate process cmsamplebufferref take @ avcam & squarecam demos apple, give introduction video capture. http://developer.apple.com/library/ios/#samplecode/avcam/introduction/intro.html http://developer.apple.com/library/ios/#samplecode/squarecam/introduction/intro.html an easier solution use https://github.com/bradlarson/gpuimage thanks adam

php - wordpress frontend posts to automatically post on user's facebook timeline -

can please give me hand on how should setup flow on website: user connected site facebook connect these permissions: email, read_friendlists, publish_stream, publish_actions. , works fine. user submits article frontend in wordpress successfully. what want when add_post() action triggered (using custom theme) , submits article in wp, post same article user's fb timeline. believe me i've read darn documentation in fb dev no straightforward example on how that. they mention using curl graph api , how use it? php or javascript? maybe have working example cod have look?

android - onCancelled() is called, but isCancelled() is never called -

i making http request using asynctask , want when logout, asynctask should stop. calling cancel(true) in onstop() . when call cancel(true) , requests not started yet, cancelled, problem iscancelled() never called checks if executing task cancelled or not. checking iscancelled() in doinbackgroud() method of asynctask there way stop executing asynctask. following scenario. class asyncclass extends asynctask<>{ @override protected string doinbackground(void... params) { if(iscancelled()) { log.d("iscancelled", iscancelled()); } //call webservice } } now there other class i'm calling if(asynctaskobject!=null){ asynctaskobject.cancel(true); asynctaskobject=null; } but log statement inside iscancelled() never called. why expect iscancelled() should executed android itself. getter method allows code query status of task.

python - How can I render a list of checkboxes with checkboxes with django? -

i want create form django; [ ] parent_checkbox1 [ ] sub_cb1_pcb1 [ ] sub_cb2_pcb1 ... [ ] parent_checkbox10 [ ] sub_cb1_pcb10 [ ] sub_cb2_pcb10 i can render parent checkboxes with: parent = forms.multiplechoicefield(label="parent", widget=forms.checkboxselectmultiple) self.fields['parent'].choices = 'list of choices' but how can add sub_checkboxes parent? try using jquery dynatree plugin instead. thought of writing custom widget, found 1 easier install , maintain. for that, you'll need output recursive html: <div id="tree"> <ul> <li id="1">element 1</li> <li id="2">element 2 <ul> ... </ul> </li> </ul> </div> install js file , call jquery method: $('#tree').dynatree(parameters);

security - Using Android 4.1 Keychain -

i using android 4.1 keychain , following code worked fine under 4.0 gives me nullpointer exception (cipher can't read internal attribute) privatekey = keychain.getprivatekey(context,malias); byte[] data = // biary data cipher rsasinger = javax.crypto.cipher.getinstance("rsa/ecb/pkcs1padding"); rsasinger.init(cipher.encrypt_mode, privkey); byte[] signed_bytes = rsasinger.dofinal(data); i handling private key keychain opaque , use java security api. need need use keychain api in different way? after further debugging , contacted google engenier (thanks!) turned out android registers differents java crypto providers , openssl provider able use privatekeys keystore. but hacks , using /system/lib/ssl/engines/libkeystore.so should possible work around problem. see http://code.google.com/p/ics-openvpn/source/browse/jni/jbcrypto.cpp , proccesssignjellybean in http://code.google.com/p/ics-openvpn/source/browse/src/de/blinkt/openvpn/openvpnmanagementthread.j...

adsi - retrieving group members/membership from active directory when members attrib doesn't work -

i trying group members "domain users". when using ad users mmc tab, lot of results. when using adsi - not. following doesn't work expected: looking @ members attribute of group entry via ldap/adsi. returns 56 members when there considerably more. searching memberof (returns few entries) searching primarygroup (it not primary group) searching tokengrops (it constructed attribute) any ideas appreciated. (i read more , saw mentioend it's not primary group...but i'm suspicious answer anyway :)) there mechanism user can member of group, , it's controlled primarygroupid attribute of user in group. if primarygroupid of user set rid of group, user functionally in group, though don't show in member attribute of group. tools aduc wise enough this. when step bit lower in stack , hit directory on ldap, smart enough go hunting it. you can either searches or use constructed attributes in directory take in account.

xcode - How to return the App Temp directory -

i trying determine place script file in location can read/write while being sandboxed. while reading apple documentation, seen below: some path-finding apis (above posix layer) refer app-specific locations outside of user’s home directory. in sandboxed app, example, nstemporarydirectory function provides path directory outside of user’s home directory specific app , within sandbox; have unrestricted read/write access current user. behavior of these path-finding apis suitably adjusted app sandbox , no code change needed. so need use nstemporarydirectory function return application temp directory.. can't seem figure out how other documentation nstemporarydirectory: nstemporarydirectory returns path of temporary directory current user. nsstring * nstemporarydirectory (void); return value string containing path of temporary directory current user. if no such directory available, returns nil. can please assist me in figuring out temp directory may located, or how find sort...

ruby - Rails - How does 'will_paginate' plugin work? -

will_paginate plugin allows whatever activerecord paginated. indeed, paginate method available within activerecord. example, if want paginate order , do: order.paginate page:params[:page], order: 'created_at desc' how paginate method created? will_paginate plugin kind of: "taking activerecord definition , injecting paginate method into? furthermore, keep example, if above assumption correct: how avoid conflict plugin if whatever reason, order has defined proper paginate totally different purpose? will_paginate uses extend method add modules activerecord::base class. see https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/active_record.rb#l202 if order has method called paginate override activerecord::base#paginate method.

running php scripts on Apache and Microsoft SQL server on Windows 7 (64 bits) -

i have access web server. need have installed in 64 bit, windows 7 os desktop run php scripts? have ms sql server 2008 installed. why don't use xampp or wamp setup php , apache , mysql on windows , if don't want connect mysql connect mysql via php script.

php - Is it a good idea to create variables using references? -

example: function create_pets(&$cats, &$dogs){ $dogs = get_dogs(); $cats = get_cats(); } so call like: function foo(){ create_pets($cats, $dogs); // here use $cats , $dogs variables } i know assign new varible return value of 1 of getter functions, example. in situation there's more getter... the answer says "it depends". in specific example, "create" function, code less obvious work , maintain, , it's idea avoid pattern. but here's news, there's way of doing trying keeps things simple , compact while using no references: function create_pets(){ return array(get_dogs(), get_cats()); } function foo(){ list($dogs, $cats) = create_pets(); //here use $cats , $dogs variables } as can see can return array , use the list language construct individual variables in single line. it's easier tell what's going on here, create_pets() returning new $cats , $dogs; previous method using references didn...

json - Getting the error code message in twitter api request (java) -

i'm trying use twitter api in following way: string urladd = "https://api.twitter.com/1/following/ids.json?user_id=1000123"; url url = new url(urladd); urlconnection urlconnection = url.openconnection(); bufferedreader in = new bufferedreader(new inputstreamreader(urlconnection.getinputstream())); getinputstream input stream throws ioexception, happens because i've reached request limit. want able distinghuish between request limit error , other errors. twitter returns error message in json format, can't read because of thrown exception. any ideas on how can fetch error message? i found way it: string urladd = "https://api.twitter.com/1/following/ids.json?user_id=1000123"; url url = new url(urladd); urlconnection urlconnection = url.openconnection(); httpurlconnection httpconn = (httpurlconnection)urlconnection; inputstream is; if (httpconn.getresponsecode() >= 400) { = httpconn.geterrorstream(); } else { = httpconn.geti...

How to increase heap size of an android application? -

i writing android application uses several 3d models. such model textures can take lot of memory. found out manufacturer sets limit on heap size application can use. example tablet samsung galaxy tab 8.9 p7310 can take 64mb of memory. is there way increase size of memory application can use? you can use android:largeheap="true" request larger heap size, not work on pre honeycomb devices. on pre 2.3 devices, can use vmruntime class, not work on gingerbread , above. the way have large limit possible memory intensive tasks via ndk, ndk not impose memory limits sdk. alternatively, load part of model in view, , load rest need it, while removing unused parts memory. however, may not possible, depending on app.

java - Unable to find Clojure -

edit: there other discussions going on related question on the bukkit forums , on github . so, know 1 or 2 people have attempted no luck.. think i'm there. one problem: don't know java, little alien me. anyway.. so, made simple class in clojure, follows: (ns com.gdude2002.clojureplugin.mainclj (:gen-class :name com.gdude2002.clojureplugin.mainclj :extends org.bukkit.plugin.java.javaplugin) (:import org.bukkit.plugin.java.javaplugin)) (defn -onenable [this] (java.util.logging.logger/getlogger "loaded clojure plugin!")) (defn -ondisable [this] (java.util.logging.logger/getlogger "unloaded clojure plugin!")) i use clojure's compile function compile java class, follows.. (set! *compile-path* ".") (compile 'com.gdude2002.clojureplugin.mainclj) i put in jar manually, under com/gdude2002/clojureplugin/mainclj.class (as putting plugin.yml in root). so far good. method isn't making bukkit bitch code (specifically...

android - Converting string to uri to bitmap to display in an ImageView -

i have looked on solution problem , can't seem figure out. i'm sure 1 or 2 simple lines , can steer me in right direction. in app, user can click button open gallery. once select image, display image in imageview within app. part working fine. originally, had return uri gallery , directly display this: imageview1.setimageuri(myuri); well, running dreaded "out of memory" error if user reloads page several times in row i'm having clean code scale down image. have done implementing bitmap class turns image bitmap , scales down me. now, imageview display code looks this: imageview1.setimagebitmap(bitmap1); that part working fine well. here problem: i convert uri path string , save in sharedpreference. when user exits application , comes later, image set automatically displays. convert uri this: ... selectedimageuri = data.getdata(); string selectedimagepath; selectedimagepath = getpath(selectedimageuri); ... the old method retrieve sharedp...

iphone - storyboard: add a new scene after embedding other scene in navigation controller -

Image
i have scenes set , embedded them in navigation stack (see pic). if duplicate lower right segue, doesn't have navigation bar (see pic below). can set top bar "inferred" "navigation bar", won't put on existing navigation stack (e.g. no button etc.). how can new viewcontroller existing navigation stack? lots of in advance. i don't know order did in, find if duplicate view controller, , add new segue have login table view controller duplicated view controller, duplicated view controller pick navigation bar , part of set of viewcontrollers .

seo - Doesn’t Google support Schema.org’s AggregateRating at the moment? -

a rich snippet example schema.org http://schema.org/aggregaterating : <html> <div itemscope itemtype="http://schema.org/product"> <img itemprop="image" src="dell-30in-lcd.jpg" /> <span itemprop="name">dell ultrasharp 30" lcd monitor</span> <div itemprop="aggregaterating" itemscope itemtype="http://schema.org/aggregaterating"> <span itemprop="ratingvalue">87</span> out of <span itemprop="bestrating">100</span> based on <span itemprop="ratingcount">24</span> user ratings </div> </div> </html> but http://www.google.com/webmasters/tools/richsnippets won't show preview. so, following words http://support.google.com/webmasters/bin/answer.py?hl=en&answer=146645 lies? new! schema.org lets mark wider range of item types on pages, using vocabulary google, micros...

Using image resources which don't comply to Android's naming scheme -

i need use image resources ios application i'm porting android. unfortunately have dashes in file name, causes errors. i can't rename resources because they're shared ios codebase, , having duplicate resources no-go. is there way can around naming requirement? there's no way around naming requirement, use symlinks. (i'm bit confused, though, , kind of assume must either copying files or using symlinks. how else build both android , ios apps, given different directory structures required each?)

jquery - Referencing a linkbutton within a gridview thats inside a AJAX tab -

on home page have 10 grids sit inside ajax tabs etc one grid in particular has link button called "archive" when user clicks need show seperate div textbox user has enter reason in why wont archieve selected information, problem how can name , email of row needs archieved using jquery, want information store in hidden fields , reference hidden fields code behind etc. i tried use asp:modalpopup extender grid placed inside ajax tab modal pop extender complains can see control link button iv decided user jquery the 2 fields name , number can me achieve this? below 1 grid need name , email address when link button pressed <asp:hiddenfield id="hdnuserfullname" runat="server"/> <asp:hiddenfield id="hdnuseremail" runat="server" /> <div id="maincontent_tabcontrol_body" class="ajax__tab_body" style="height: 100%; display: block;"> ...

Wordpress Pagination for single.php -

Image
i've implemented category-based numeric pagination in wordpress theme: what i've done far create custom page template list of paginated excerpts. once user clicks on excerpt view full article i'd paginate list of returned articles displayed. it's understanding achieved in theme's 'single.php', though may wrong. the pagination works custom template, when try implementing custom query within single.php think pagination attempts find next page within article itself, not i'm trying achieve (because doesn't exist). i'd paginate though returned articles user may navigate next , previous 1 article in category next. i've read bit next/previous links, i'd rather use blog post boutros abichedid - stole idea custom page template, , it's awesome! i've made derivative of class in theme's 'template.php' pagination custom theme , works great, i'm missing when comes getting work through returned single posts. sh...

c# - How to configure the factory to generate the object? -

Image
maybe title not clear. let me clarify i'm trying accomplish. i have base classes: baseproperties baseproblem baseproperties contains data generation of math problems. example, in image above, basicadditionproperties contains addend1 , addend2, 2 objects know range of generated value represent basicadditionproblem. so, idea.. guess supposed pass abstract class factory, , 1 should generate problem (in case basicadditionproblem). i have read, it's recomended pass these values base class. , main doubt is, when pass object baseproperties factory, time have cast object? or ideas can implement model scenario? or have have static factory maintain , used mapping concrete factories? in advance. define abstract createproblem() in baseproperties class. method can used generically allow each concrete properties subclass provide own factory method. this similar using instance of webrequest subclass , calling getresponse() on , returns coresponding subcla...

entity framework - Why can't I have a referential constraint with a one to zero-to-one association? -

i'm using entity framework 4.3 model first , can't figure out why i'm not allowed have 1 zero-to-one association along referential constraint. i have 2 main problems. can't force referential integrity (without manual intervention) , lazy loading doesn't seem work... 1 many associations fine. i have 2 tables, loans , contracts. contracts table has scalar field loanid. until loan submitted , not have contract data , chose not place in same table due size of contract data. ie. don't want contract data retrieved database unless required. i've searched around , can't seem find model first information answers questions. information may me understand , clarify problem appreciated. regards craig i guess loanid field not primary key in contracts table. in such case cannot have such one-to-one relation because ef doesn't support it. when create loanid field in contracts table way force one-to-one relation add unique constraint on ...

Where does mongodb stand in the CAP theorem? -

everywhere look, see mongodb cp. when dig in see consistent. cp when use safe=true? if so, mean when write safe=true, replicas updated before getting result? mongodb consistent default - if write , read, assuming write successful able read result of write read. because mongodb single-master system , reads go primary default. if optionally enable reading secondaries mongodb becomes consistent it's possible read out-of-date results. mongodb gets high-availability through automatic failover in replica sets: http://www.mongodb.org/display/docs/replica+sets

objective c - maintaining wikitext and richtext editing modes in iPad app -

i designing ipad app in have textview apart other things. in textview rendering wikitext. have implemented basic functionalities bold, italic etc. in editor using accessory view. now, want provide user mode edit in rich text well. rich text editing done in web view (not implemented yet). problem facing don't know way keep text in both modes in sync when user jumps 1 able see changes made in other mode instantly. can suggest clue regarding this? thanks. it's no problem sync uitextview uiwebview using uitextviewdelegate fire events user types textview. bigger problem uiwebview you'd need check source-code check changes , sync them uitextview . the next best possibility wait on ios 6 provides styled text, ios 6 still under nda, nobody provide help.

php - What performance improvements can I make to Symfony + Doctrine? -

i've built reasonably complex database application university handling 200 tables. tables can (e.g. publications) hold 30 or more fields , store 10 one-to-one fk relations , 2 or 3 many-to-many fk relations (using crossreference-ref tables). use integer ids throughout , normalisation has been key every step of way. ajax minimal , pages standard crud forms/processes. i used symfony 1.4, , doctrine orm 1.2, mysql, php. while benefits development time , ease of maintenance have been enormous (in using mvc , orm), we've been having problems speed. is, when have more few users logged in , active @ 1 time application slows considerbly (up 20 seconds save or edit record). we're engaged in discussions our sysadmin should have more enough power. 6 or more users engaged in activity, end queuing 4 cpus in virtual server environment while memory usage low (no bleeds). of course, we're considering multi-threading our mysql application (if help), refining our code (though...

java - Including a directory inside web-inf/lib in tomcat classpath -

in webapp; web-inf/lib added in classpath default fine. now, want add spring jar files in tomcat's classpath. if put jar files inside web-inf/lib; works fine. if want add directory web-inf/lib/spring , put jar files inside spring directory ; doesnt work. how can include web-inf/lib/spring in classpath. i prefer make changes in web.xml localised webapp. surely not want make changes in catalina.properties because there jar files loaded in jvm ( not added in classpath ) you shouldn't care how jar files segregated war file: it's used container. segregating jar files useful in source project. need have build process (using ant, gradle, whatever) copies jar files subdirectories web-inf/lib . using ant: <copy todir="web/web-inf/lib" flatten="true"> <fileset dir="lib"> <include name="**/*.jar"/> </fileset> </copy>

c# - Avoid version specific information in configSection in app.config -

i have made small gui administration of settings in app.config file. gui released part of product, making possible change values in app.config file, without opening in text editor. the properties implemented in custom configsection, making typed in code. problem is, when app.config file updated (when save gui), qualified name of assembly written in configsection this: <section name="configurationsettings" type="performancedude.msbuildshellextension.common.configurationsettings, common, version=2.2.1.0, culture=neutral, publickeytoken=1ab1b15115e63xxx" /> when upgrade assembly new version number, gui code assembly version not longer matches assembly references in app.config. this how load settings: var config = configurationmanager.openmappedexeconfiguration(new execonfigurationfilemap() { execonfigfilename = configfilepath }, configurationuserlevel.none); var settings = config.getsection("configurationsettings") configurationsettings; ...

Is there a way to turn off animations in github while viewing navigating through code? -

is there way turn off animations in github while viewing navigating through code? example, if click on directory there javascript animation changes present list of new directory's contents. drives me nuts, i'd turn off. can't find in github settings. when on github page, type url bar: javascript:(function(){jquery.fx.off=true;})(); you can create bookmarklet avoid pasting time.