Posts

Showing posts from August, 2010

django - How to release log from celery task -

i have celery task calling django management command using call_command , management command uses python logging framework create timedrotatingfilehandler . on windows test station, getting following stack trace seems show celery tasks still holding log file handle open after have completed: traceback (most recent call last): file "c:\python27\lib\logging\handlers.py", line 77, in emit self.dorollover() file "c:\python27\lib\logging\handlers.py", line 350, in dorollover os.rename(self.basefilename, dfn) windowserror: [error 32] process cannot access file because being used process logged file mycommand.py, line xx is known issue , if there method getting around it? (i have tried googling not find relevant).

android - supplicant connection change doesn't trigger -

i want when wifi connection established. have broadcastreceiver works prefectly receiving network_state_changed_action , scan_results_available_action, not supplicant_connection_change_action. 1 harder test: turn off/on router that. protected void oncreate(bundle savedinstancestate) { receiverwifi = new wifireceiver(); intentfilter intentfilter = new intentfilter(); intentfilter.addaction(wifimanager.supplicant_connection_change_action); intentfilter.addaction(wifimanager.network_state_changed_action); intentfilter.addaction(wifimanager.scan_results_available_action); registerreceiver(receiverwifi, intentfilter); //... } class wifireceiver extends broadcastreceiver { public void onreceive(context c, intent intent) { final string action = intent.getaction(); log.d("mhp","*broadcastreceiver: " + action")} and manifiest.xml &l

Add nodes to a fixed backbone when drawing a networkx graph with graphviz, some of the larger nodes are ending up crammed together -

Image
i have created graph using networkx. drawing graph using graphviz, these lines of code: pos = nx.graphviz_layout(g2, prog='neato', args='-goverlap=prism') plt.figure(figsize=(10, 14)) nx.draw(g2, pos, node_size=sizes, alpha=1, nodelist=nodes, node_color=colors, with_labels=true, labels=labeldict, font_size=8) the graph consists of "backbone" of few larger nodes, attached few hundred smaller nodes. i have used args='-goverlap=prism' (in first line of code above) space out graph, has created problem. matters more larger nodes spaced out, but, because of how many small nodes there are, of larger nodes ending crammed together. my thoughts on solution generate graph larger nodes ensure spaced, add smaller nodes graph without changing layout of original nodes. have done research, , seems tricky add new nodes without changing old ones in graphviz. possible "pin" nodes, unsure of how within networkx. this graph looks like:

Best practice MVVM navigation using Master Detail page? -

i want follow mvvm pattern as possible , don't know if doing navigation quite well. note using masterdetail page , want maintain master page, changing detail side when navigate. here way navigate viewmodel . in example, viewmodelone viewmodeltwo : public class viewmodelone : viewmodelbase { private void gotoviewtwo() { var viewtwo = new viewtwo(new viewmodeltwo()); ((masterview)application.current.mainpage).navigatetopage(viewtwo); } } masterview implementation: public class masterview : masterdetailpage { public void navigatetopage(page page) { detail = new navigationpage(page); ispresented = false; } } viewtwo implementation: public partial class viewtwo : pagebase { public menuview(viewmodeltwo vm) : base(vm) { initializecomponent(); } } pagebase implementation: public class pagebase : contentpage { public pagebase(viewmodelbase vmb) { this.bindingcontext

android - Tabhost/spec vs. viewpage vs tabbed actionbar ..which one? -

Image
i have been familiar tabhost/tabspec create application tabs. noticed there more 1 option create tabs: 1- tabs in action bar 2- viewpager (i guess google calls horizontal pager) 3- , offcourse tabhost/tabspec approach. i tried read google docs everywhere got further confused. when use or there 1 norm? thanks you should use toolbar viewpager simulate tabs (all wrapped in appbarlayout). result this: you can read more type of design on material design spec: https://www.google.com/design/spec/components/tabs.html#tabs-usage also, here tutorial on how implement tabs within viewpager: http://blog.grafixartist.com/material-design-tabs-with-android-design-support-library/

java - Unable to expand a ExpandableListView in Android -

[edit]- changing question framing: how use android expandablelistview inside scrollview? i implementing expandablelistview in android. whenever click on arrow expand i.e calling setongroupexpandlistener. list expands inside group itself. want below it. attaching code . drawable_list_group.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="8dp" android:background="@color/grey_transparent"> <textview android:id="@+id/lbllistheader" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="?android:attr/expandablelistpreferreditempaddingleft" android:textsize=&quo

php - htaccess mod_rewrite rules combination issue -

Image
i'm newbie in apache, it's basic question couldn't solve using questions or links. tried change url using .htaccess , had 2 purposes; hide .php extension change querystring somefile.php?id=bar somefile/id/bar bar number or mixed string t51-3 . querystring http://localhost/payment/theme/ticket?id=770314 want change http://localhost/payment/theme/ticket/id/770314 or http://localhost/payment/theme/ticket/770314 i found code: options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / # externally redirect /dir/foo.php /dir/foo rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r,l,nc] ## internally redirect /dir/foo /dir/foo.php rewritecond %{request_filename}.php -f [nc] rewriterule ^ %{request_uri}.php [l] in stackoverflow.com/this_question this working nice didn't solve second issue. so, searched while in site , others , did find sample codes 1 : rewriterule ^([a-za-z0-9_-]+)-([0-9

android - onClick method not working properly after NestedScrollView scrolled -

i used nestedscrollview coordinatorlayout enable scroll animation toolbar (by app:layout_scrollflags="scroll|enteralways"). nestedscrollview contain linearlayout root child, put 2 textviews linearlayout enable expand/collapse animation. 1 set visible , other 1 set gone. , switching visibility onclick event of linearlayout normally, work expected when scrolled nestedscrollview onclick event not working properly. need double click after scroll expand/collapse animation does have same problem me ? please me <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.widget.nestedscrollview android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/

node.js - Batch file for running NPM if its not on your PATH -

i have requirement cannot add npm path variable. have bash script #!/bin/bash shopt -s expand_aliases alias npm-exec='path=$(npm bin):$path' npm-exec npm install npm-exec gulp which runs tasks , work. need know how accomplish same goal in batch file well. appreciated i've accomplished doing following inside batch file: set path=%appdata%\npm;%path% call npm install the first line prepends current user's roaming profile path path. the second line requires call since npm .cmd , , without batch file exit prematurely right after call npm.

uiview - Objective C - How to create a set of sub views to update -

perhaps thinking incorrectly, please point me in right direction.. i want make many uiviews property can update them different methods. this: @property uiview *view1 @property uiview *view2 ... @property uiview *view200 -(void)updateviews{ (i=0; <200; i++){ //update view here } so questions are: how can make multiple views? how can pass message each individual view? so many great responses, think need add little more info. have tried putting uiviews array index them struggle access them update positions within uiviewcontroller. thought making them property correct way since need update them device heading. looks using tag might best. can further comment on approach: for (i = 0 ; < 144; i++) { uiview *sunview =[[uiimageview alloc] initwithimage:[uiimage imagenamed:@"sun.png"]]; sunview.tag = i; } //then later, in separate method following: (i = 0 ; < 144; i++) { cgfloat cgx = self.acceleration.x; cgfloat cgy = self.acceleration.y [su

github - GIT checkout to master from branch itself updated my local repository -

i created new branch , removed 1 file local repository. checkedin master merge branch. during checkout repository updated , when try merge branch says 'already up-to-date' c:\git\junit [cleanup +0 ~0 -1]> git rm '*.md' rm 'readme.md' c:\git\junit [cleanup +0 ~0 -2]> git checkout master d readme.md d target/surefire-reports/com.tester.webdriver.myfristtest.txt switched branch 'master' **your branch up-to-date 'origin/master'.** c:\git\junit [master +0 ~0 -2]> git merge cleanup up-to-date. the problem forgot git commit changes before switching master branch. git doesn't know changes belong, assumes changes branch in.if specify branch these changes should documented, merge possible.

jquery - Couldn't call server side method using Ajax -

i using 3-tier architecture demo application. i trying call business logic layer method presentation layer using ajax. showing error. think there mistake in passing url. here ajax call index.aspx page in presentation layer: $.ajax({ type: "get", url: "demoapplication.bll/bll/showdetail", contenttype: "application/json; charset=utf-8", datatype: "json", data: { }, success: function (msg) { alert("data received"); }, error: function () { alert("couldn't proceed"); } }); here method in business logic layer: namespace demoapplication.bll { public class bll { public static list<user> showdetail() { dal.dal dal = new dal.dal(); return dal.showdetail(); } } } i think little bit confused, if trying call middle-tier method browser, there wrong. think of implications if supported. in business l

How can i let sql server 2008 accept the date 2003/2/29 -

i have date 29/2/2003 when export table in database system convert null how can let sql server 2008 accept date 2003/2/29 ? if insert date format not valid : 2003/2/29 ,you error : string not recognised valid datetime in order save ,change datatype nvarchar

In Meteor, a MongoDB update is not seen in the Mongo shell -

this odd problem. i running cursor.observe() in tracker.autorun() , changes occurring when refresh page. here imporant code: client side tracker.autorun(function (){ var initializing = true; links.find().observe({ added: function(doc){ var parents = links.find({stacks: {$exists: true, $not: {$size: 0}}}); //find parent of item stack array if(!initializing){ _.each(parents.fetch(), function(parentdoc){ _.each(parentdoc.stacks, function (stackid){ //the troublesome server call meteor.call("addlinksfromdirtostack", stackid, parentdoc.shared[0].id, parentdoc._id); }); }); } initializing = false; } }); }); server side meteor.methods({ addlinksfromdirtostack: function(stackid, userid, dirid){ var stack = stacks.findone(stackid); if (stack){ var webarray = stack.we

Change the unit value of the distance and time getting from map API in android? -

i building android application using google map api distance , time between 2 lat,lng. problem sometime getting value in km , time in meter. is there way fix unit of distance , time value returning google api. here code. public class directionsjsonparser { /** receives jsonobject , returns list of lists containing latitude , longitude */ public list<list<hashmap<string,string>>> parse(jsonobject jobject){ list<list<hashmap<string, string>>> routes = new arraylist<list<hashmap<string,string>>>() ; jsonarray jroutes = null; jsonarray jlegs = null; jsonarray jsteps = null; jsonobject jdistance = null; jsonobject jduration = null; try { jroutes = jobject.getjsonarray("routes"); /** traversing routes */ for(int i=0;i<jroutes.length();i++){ jlegs = ( (jsonobject)jroutes.get(i)).getjsonarray("le

c# - INSERT INTO table with foreign key contraints -

i have read couple things on , came following code. using access database , coding in c# through visual studio. i getting syntax error in this. have tried create query in access test difficult create in that. can me figure out why isnt working? using(oledbconnection conn1 = new oledbconnection(global::insulationprojecttracker.properties.settings.default.insulationdb)) { using(oledbcommand command1 = conn1.createcommand()) { conn.open(); command.commandtext = "insert jobsites (customerid, jobsitename) values ((select customers.customerid customers customers.customername = @cname1 , customers.branchnumber = @bnumber1), @jname1)"; command.parameters.add(new oledbparameter("@cname1", cbocustomername.text)); command.parameters.add(new oledbparameter("@bnumber1", cbobranch.text)); command.parameters.add(new oledbparameter("@jname1", txtjobsitename.text)); command.executenonquery();

java - Multithread programming and incrementing a static variable -

i have read posts related problem not solve problem. code question in big java - object of cay horstmann. question asks counting word of several files using multithread programming , store combined words counting problem. in order combined counter used static variable incremented on each of iteration of counting words in threads. used reentrantlock() make incrementing available 1 thread @ time. works fine except incrementing. seems static variable not incremented. tested number of lock() , unlock() each thread , match expected result static variable not work properly. is there explanation it? thank time , help. my task class : import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; import java.util.concurrent.locks.lock; import java.util.concurrent.locks.reentrantlock; public class wordcount implements runnable { private string filename; scanner inputfile; private long counter; public volatile static long combinedcou

Oracle tablespace can I drop all files -

i trying drop temp tables space has 3 files /tmp/temprm/create/temprm/datafile/o1_mf_temprm_t_bw3t4zkp_.tmp +tempdata/rm/datafile/temprm_tempfile_1.dbf +tempdata/rm/datafile/temprm_tempfile_2.dbf before dropping table space want delete file, able remove first 2 files last 1 gives error. sql> sql> alter tablespace temprm_temp drop tempfile '+tempdata/rm/datafile/temprm_tempfile_2.dbf' * error @ line 1: ora-03261: tablespace temprm_temp has 1 file if not allowed delete files in table space, how clean table space? you cannot make tablespace file-less. can drop tablespace , it's datafiles in 1 statement: drop tablespace temp_tablespace including contents , datafiles; make sure have new temporary tablespace , make default before drop old one. follow below link example: http://dbatricksworld.com/how-to-create-temporary-tablespace-and-drop-existing-temprary-tablespace-in-oracle-11g/

r - Granger causality ordering variable -

i trying compute granger causality var using vars package. know order of variable important in var compute irf, here have different result granger causality. here reproducible example: test <- structure(c(324l, 444l, 456l, 451l, 484l, 535l, 625l, 622l, 532l, 623l, 619l, 642l, 550l, 643l, 629l, 709l, 781l, 792l, 858l, 979l, 974l, 1039l, 1062l, 1167l, 1345l, 1600l, 1789l, 1912l, 1965l, 2086l, 2350l, 2507l, 2186l, 2224l, 2235l, 2435l, 1923l, 2035l, 2253l, 2365l, 2214l, 2554l, 2714l, 2773l, 2777l, 2897l, 3060l, 3053l, 2426l, 2714l, 2953l, 2925l, 3233l, 3494l, 3724l, 4137l, 4147l, 4275l, 4726l, 4910l, 114l, 131l, 137l, 136l, 157l, 174l, 207l, 165l, 168l, 189l, 176l, 187l, 138l, 153l, 176l, 183l, 196l, 229l, 263l, 281l, 263l, 310l, 310l, 313l, 283l, 291l, 324l, 367l, 410l, 423l, 470l, 452l, 465l, 529l, 559l, 602l, 657l, 729l, 721l, 747l, 781l, 815l, 861l, 863l, 817l, 839l, 875l, 855l, 825l, 947l, 1038l, 1086l, 1190l, 1235l, 1347l, 1435l, 1495l, 1482l, 1645l, 1769l, 61l,

How to record Audio on android(2.3) from pc? -

i have single board computer android 2.3 (max version board). , audio input/output(3.5mm) interfaces. need stream audio pc in real time via audio interface (not usb, or wi-fi). first of all, it`s possible? i have simple app, using audiorecorder , audiotrack classes. , app car record data, data different. also, got data, when cable disconnected. main part of app: int samplerate = 8000; int channelconfig = audioformat.channel_in_mono; int audioformat = audioformat.encoding_pcm_16bit; int mininternalbuffersize = audiorecord.getminbuffersize(samplerate, channelconfig, audioformat); int internalbuffersize = mininternalbuffersize * 4; log.d(tag, "mininternalbuffersize = " + mininternalbuffersize + ", internalbuffersize = " + internalbuffersize + ", mybuffersize = " + mybuffersize); audiorecord = new audiorecord(mediarecorder.audiosource.default, samplerate, channelconfig, audi

database - Synchronizing multiple servers and local machines with the same data / source code -

background: building web app team of 2 developers. restful backend via flask. using linux, apache, redis, , postgres. 3 servers: 1 production 1 development 1 uat 4 databases: 1 prod/uat server 1 dev server 1 developer on local machine 1 developer b on local machine 2 local machines / developers in addition 4 databases, developers each have 1 additional database serves testing. testing database needs exact same @ times between 2 developers. developer b has own fork of data, sending pull requests master repo, worked on developer a. problem: we have no real protocols transfer data between each of databases. example, developers test databases different, causes chaos. moving data dev uat/prod done manually. developers work in different environments , on different forks. use pull requests in github transfer code developer a's main repo. question what recommend solution our database woes? there better way share data? there better way develope

php - Is it posible to create a urlManager Rule which preloads an object based on ID? -

working yii 2.0.4, i'm trying use urlmanager rule preload object based on given id in url. config/web.php 'components' => [ 'urlmanager' => [ [ 'pattern' => 'view/<id:\d+>', 'route' => 'site/view', 'defaults' => ['client' => client::findone($id)], ], [ 'pattern' => 'update/<id:\d+>', 'route' => 'site/update', 'defaults' => ['client' => client::findone($id)], ], ] ] if works, not necessary manually find , object each time, crud actions: class sitecontroller extends controller { public function actionview() { // using $client urlmanager rule // instead of using $client = client::findone($id); return $this->render('view', ['client' => $client]); }

vector - Shifting a 2d array in Verilog (Xilinx) -

ref : shifting 2d array verilog my problem similar. have vector array consisting of 8 elements, each of 7 bits. have declared wire [6 : 0][0 : 7] out_wire; reg [6 : 0] [0 : 7] disp_data ; reg [6 : 0] out_disp; // output register now want shift each vector , disp_data = { out_wire[1 : 6], out_wire[0] } ; and assign , in case, out_disp this out_disp = disp_data[0] ; or disp_data[1] etc i using xilinx ise 14.7. everytime try synthesize, gives foll error : expecting 'identifier', found '[' unexpected token: '[' i think have followed steps in reference link above. consulted reference manual. no use. i'm using verilog 2001. apologies if missed pretty basic. relevant code here : always @ (posedge tick_stable, posedge tick_shift) begin if (tick_shift) begin disp_data = { out_reg[1 : 6], out_reg[0] } ; end else begin case (sel_reg) 0 : begin out_disp = disp_data[0] ; enable_reg = en_z ; end

compilation - Visual Stodio - compiling project for 32-bit or 64-bit system -

Image
when compile kind of project in visual studio 2015, compile 32-bit or 64-bit systems? there way find out? how control version compiles between two? from menu bar, can see current platform project compiled. if press little arrow, can open configuration manager , create new target platforms. the configuration manager available under build ---> configuration manager.

angularjs - Binding to a scroll event inside nested views -

i need track if top 300 pixels subview have scrolled out of visible area, cannot bind scroll event of view (but can bind 'resize'!) location: index.html -> global layout -> content area -> subview (this one) .state('my', { url: '/my', views: { '': { templateurl: 'app/views/layout.html' }, 'content': { templateurl: 'app/views/content.html' <-- inside view have ng-view, subtemplate loaded it. } }, important: not windowed / limited height view. has header, no footer, i.e. can length depending on contents length. please help! d. update i've found following workaround. please let me know how ugly angularjs point of view? var el = angular.element(document.getelementbyid('top')); $scope.$watch(function () { $timeout(function () { var top = el[0].

haskell - compare contents of Either type -

is there way use pattern wildcards type constructors make ugly code shorter: eithercompare (left a) (left b) = compare b eithercompare (left a) (right b) = compare b eithercompare (right a) (left b) = compare b eithercompare (right a) (right b) = compare b something (which won't compile) eithercompare :: ord => either a -> either a -> ordering eithercompare (_ a) (_ b) = compare b or other method? you can't pattern matching, can still simplify code using helper function: eithercompare x y = compare (fromeither x) (fromeither y) fromeither (left a) = fromeither (right a) =

unity3d - My Prefab disappears from script when I run the game? -

Image
i have script attached on player, script has public gameobject variable.when attach prefab , run game disappears script ? i add prefab script when run game disappears !!?? the bomb prefab attach must in under asset folder , not in scene , mean when click on bomb assigned must open project tab , shows if exist in scene , disappeared

How do i make the border of android.text.DynamicLayout dynamic change? -

i has android project requirements that: here string of characters show in override view method ondraw(canvas). this string of characters limited fixed rectangle.i know use android.text.dynamic-layout can solved problem. but now: has question: user can change fixed rectangle size real time drag. user can reset string show. need go new dynamic-layout object again real time?

java - FileUtils.readFileToString IOException -

i'm new android app development. currently, i'm trying android download folder path , log it. this, use commons io library. i've got code: file folder = environment.getexternalstoragepublicdirectory(environment.directory_downloads); log.e("files", folder.listfiles().length + " items"); try { string dfolder = fileutils.readfiletostring(folder); log.i(tag2, dfolder); }catch (ioexception e){ toast.maketext(getapplicationcontext(), r.string.fail, toast.length_short).show(); } for reason i'm getting ioexception every time, i'm receiving amount of files in folder 2nd line. i've got permissions in manifest <uses-permission android:name="android.permission.read_external_storage" /> <uses-permission android:name="android.permission.write_external_storage" /> fileutils.readfiletostring reads contents of file string. environment.getexternalstoragepublicdirectory(environ

ruby on rails - how to allow all of the attributes of a model when -

i migrating rails 3.2 app strong_parameters , don't have experience. i have model called item has_many attributes. in our item#update i'd able following: # model class item < activerecord::base include activemodel::forbiddenattributesprotection has_many :assets, :as => :assetable, :dependent => :destroy ... #in items_controller.rb def update @item=item.find(params[:id]) if @item.update_attributes(params[:item]) ... private def item_params params.require(:item).permit(:assets_attributes).permit! end how specify item_params allow asset created through update statement? edit 1 so if pull list of attributes via: a=asset.first a.attributes i get: {"id"=>4424, "name"=>nil, "created_at"=>fri, 24 jan 2014 15:49:17 pst -08:00, "updated_at"=>fri, 24 jan 2014 15:49:17 pst -08:00, "asset_file_name"=>"br-3.jpg", "asset_content_type"=>"image/jpeg",

Django Rest Framework + AngularJS not logging user in or throwing errors -

this urls.py: from django.conf.urls import url django.conf.urls import include cmsapp import views urlpatterns = [ url(r'^$', views.homepageview.as_view()), url(r'^users$', views.user_list.as_view()), url(r'^users/(?p<pk>[0-9]+)$', views.user_detail.as_view()), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), ] so login, use url /api-auth/login. when go /api-auth/login, see drf login screen. if type in incorrect username , password, says: please enter correct username , password. note both fields may case-sensitive. and if type in correct username , password, redirects page login_redirect_url in settings.py, part works. however, want able log in without accessing drf login page. when user visits 127.0.0.1/ this view gets called: class homepageview(templateview): template_name = "home.html" def get_context_data(se

Mikrotik - How to set routes -

i using mikrotik dns server , main router. have 2 dns records, x.x.x.1 , x.x.x.2 mail server mail.example.com , trying find solution when first server down , mikrotik can automatically route second server. me that. you can use netwatch function: watch x.x.x.1, , when it's down, modify dns static record x.x.x.2. use small ttl values, 1 minute. /tool netwatch add host=8.8.8.8 down-script="/ip dns static set [ find name=mail.xx.com ] address=x.x.x.2 ttl=30s " up-script="/ip dns static set [ find name=mail.xx.com ] address=x.x.x.1 ttl=30s "

Backspace key not working in Android Studio -

i trying set custom auto import shortcut in android studio. added backspace + enter shortcut. since backspace key has stopped working. please suggest how can resolve problem. don't want change ide settings default. you not need reset whole settings. go keymap settings again, highlight entry del + enter , press right mouse button, choose "remove del + enter" , remove assignment.

mule - Where can I download previous version of Anypoint Studio? -

my current version 5.2 , doesn't let me install 3.6.0 ee i'm trying previous version of studio. have link? you can view previous releases in s3 here: https://mule-studio.s3.amazonaws.com/ just use object key , append url version want. example: https://mule-studio.s3.amazonaws.com/4.1.1-oct14-u1/anypointstudio-for-macosx-32bit-4.1.1-201411041003.zip

Stop Go server when browser is closed -

i'm running simple go server on osx machine. when run command run go program starts server , open browser window. i know if there's way when close browser window (by window, not program) close server , quit terminal. thank in advance. you let browser emit message before dying, or use web socket, simple, reliable , usual way kind of stuff set javascript timer have browser send heart-beat message server every , (depending on how want server stop after browser's closing ; every second, every 15s, every minute... ?). when server figures due message has not arrived, can exit.

arrays - PHP variable Interpolation, why it works -

given setup $names = array('smith', 'jones', 'jackson'); i understand works: echo "citation: {$names[1]}[1987]".php_eol; //citation: jones[1987] php through complex syntax curly braces, pulling value of second element on array , [1987] text... but in next code: echo "citation: $names[1][1987]".php_eol; i'd expect error, i'd expect php interprets 2 dimensional array , thrown error, instead gave me same output code above "citation: jones[1987]" why that? php goes here first occurrence of ] , since have array, can see in manual : similarly, array index or object property can parsed . array indices, closing square bracket (]) marks end of index . same rules apply object properties simple variables. this means end first index, e.g. echo "citation: $ names[1 ] [1987]".php_eol; //^ start ^ end so means "second dimension" parsed normal string. more complex st

android - How to handle drawing multiple of the same shape in OpenGL ES -

i've been programming couple years now, , know syntax of different languages pretty well, i've spent of time making programs in basic lua. have played around game developing java , c#, directx , opengl, times don't know terms others may know such 'shaders' , 'vbos'. i've heard of them, don't know mean, please explain me i'm five if have answer. i'm trying make simple android game using open gl es 2.0, and, i've seen many tutorials explaining how draw 1 triangle, , not many. case, have world full of triangles, array of true , false's, if there true triangle drawn in position, if false triangle won't drawn. i've made draw triangle's until off screen, realized 1 problem still, , rendering still super slow, takes 2 seconds render 1 frame. at moment, 1 triangle class, , when checks if triangle supposed belong is, create vertex points triangle , pass them triangle class, creating new triangle object updated vertices. ca

c++ - QApplication::processEvents not working in Windows -

i working on project presents live data acquired in real-time using qcustomplot plug-in qt. display has black background color, , multiple channels of data colored differently. when taking screenshot, make printer-friendly, background white , data black. thinking of solution this: change colors way want manipulating pointers graphical objects grab screenshot using qwidget::grab() qpixmap change colors normal this did not work @ first, because system not change colors in time screenshot taken. used qapplication::processevents(), , worked on mac. however, not work on windows 7 (which required). ideas do? code: qsting filelocation = "..."; togglecolors(false); //function toggle colors qapplication::processevents(); qpixmap shot = grab(); togglecolors(true); shot.save(filelocation, "png"); again. works on mac, not windows. update 1. content of togglecolors include: if(enable) ui->plot->setbackground(qbrush(qt::black)); else ui-

c# - Return typed object from method -

Image
is there way make function return type of object pass in? call 1 method below return type pass in. possible? should trying this? there better way...short of having 2 different methods? currently, tried first 2 calls , (with first call) looks dictionary system.object[] in value part of dictionary. screen shot below might show better explanation. ask might have more types need deserialize , don't want have different method each. var firsttry = this.deserialize(path, typeof(observablecollection<listitempair>(); var secondtry = this.deserialize(path, typeof(listitempair)); var thirdtry = this.deserialize(path, typeof(someotherobject)); public static object deserialize(string jsonfile, object type) { var myobject = new object(); try { using (streamreader r = new streamreader(jsonfile)) { var serializer = new javascriptserializer(); string json = r.readtoend(); myobject = serializer.deserialize<object&

sqliteopenhelper - Variable Passing in Android? -

i have variable currentdb in mainactivity.java . initiating variable different values depending upon user choosing different tabs. corresponding code : @override public void tab_selector(view v) { switch (v.getid()) { case r.id.veg_tab: setcontentview(r.layout.vegetable); currentlistview = (listview) findviewbyid(r.id.veg_list); currentdb = "veg"; break; case r.id.meat_tab : setcontentview(r.layout.meat_drawer); currentlistview = (listview) findviewbyid(r.id.meat_list); currentdb = "meat"; break; default: break; } currentlist = mydb.getallitems(currentdb); // definition below, works perfect itemadder2.updatedata(currentlist); currentlistview.setadapter(itemadder2); } i have method in dbhelper.java ideally takes table name , item id input , deletes corresponding row specified table. public integer dele