Posts

Showing posts from August, 2012

c++ - Null vs ZeroMemory -

what difference between setting object null , using zeromemory? i hear practice in winapi (which c) person should use zeromemory on c objects. come background of c# , seems c++ guy should know. i found directx api, whether zeromemory objects or not, application still works, samples use zeromemory , don't. can clarify these things? zeromemory fills block of memory zeros. setting pointer null make pointer points nothing, , is different filling memory pointer pointing zeros (you still able access memory via pointer, example). before can useful object, need replace these zeros more meaningful - why both programs use zeromemory or not works. reason zeromemory in context find operations on objects not initialized @ point of access (for example, visual studio filling uninitialized memory 0x0c0c0c0c /* or similar */, when encounter pattern during debugging, know object has not been initialized yet).

json - php script to push data 2d array -

i there add data file.but trying ti figure out exact syntax..any highly appreciated.. my php script $inp = file_get_contents('jsontrail.json'); $temparray = json_decode($inp, true); //adding matchid index of matches array $matchid=3; $arrne['games']['matches'][$matchid]['winner'] ="winner"; $arrne['games']['matches'][$matchid]['player1id'] ="player1id"; $arrne['games']['matches'][$matchid]['player2id'] ="player2id"; array_push($temparray,$arrne ); $jsondata = json_encode($temparray); file_put_contents('jsontrail.json', $jsondata); print_r( $inp); my valid json file { "players": [ { "name": "moldova", "image": "/images/moldova.jpg", "roll_over_image": "tank.jpg" }, /* repeat */ ], "games": [ { "matches": [ {

c# - How do i get dynamic properties using EPIServer webservice -

i'm trying dynamic property using episerver webservice. thing see can create new properties using pagestoreservice.rawproperty dynproperty = new pagestoreservice.rawproperty(); dynproperty.isdynamicproperty = true; but have no clue how property. question this. proper way dynamicproperty dynproperty = dynamicproperty.load(therootnode, "mydynamicprop"); using episerver webservice? in advance! very similar this question. roll own service obtain information [webservice(namespace=http://yournamespace/")] public class pagereferenceservice : system.web.services.webservice { [webmethod()] public pagereference getdynamicproperty(pagereference rootnode, string propertyname) { return dynamicproperty.load(rootnode, propertyname); } } (untested)

c# - Attribute to generate compilerwarning for a method in class -

i have class, use singleton-pattern. class looks like public class messageaccess { private static messageaccess instance; public static messageaccess instance { { return instance ?? (instance = new messageaccess()); } } private messageaccess() { } public void initialize(string data) { //... isinitialized = true; } private bool isinitialized; public void readdata1() { // method can called } public void readdata2() { // method can called, if initialize called. otherwise exception thrown } } is possible generate compiler-warning if method initialize never called while understand point of view, don't think such warning handy think. i'm afraid .net framework doesn't cater type of warnings couple of defined reasons (please refer link: http://blogs.msdn.com/b/csharpfaq/archive/2004/03/19/why-doesn-t-c-warn-about-unused-methods.aspx ). one mig

How-to generate a JKS keystore Report? -

i have been looking generating report keystore of type jks. looking see following details in report: alias name issued validity validity i know, possible using keystore manager tool manually. there way of extracting such information programatically? [or automated process] thank you. i have got following method: create batch file followed: @echo off :top keytool -list -v -keystore -storepass :enter

ios - GMSGroundOverlay animating - should I be using a CATiledLayer? -

i experimenting google maps ios sdk latest version 1.2.1.2944 animate gmsgroundoverlay . user has control on image sequence, using animated uiimage isn't possibility sadly, i'm loading in uiimage on fly. gmsgroundoverlay.icon set uiimage being updated. aside high memory usage, seem have struck limitation in whenever try overlay uiimage using gmsgroundoverlay.icon more 1000px x 1000px, crashes. referencing uiimage of 1000px x 1000px gets around crash. it strikes me though maybe should utilise catiledlayer handling image load memory , subsequently icon property of gmsgroundoverlay , has had experience of using catiledlayer google maps ios sdk , sequencing images animated gmsgroundoverlay ? i got answer pressinganswer.com, think may helps you. as cannot use "position" keypath animating, ended animating using "latitude" , "longitude" keypaths separately. first calculate points , add them 2 separate arrays, 1 latitude value

In DB2 Database, How to find out the actual storage size of data in varchar column? -

i new db2, , looking function memory_size(column_name) return number of bytes occupied column of particular row. example: having column named 'address' of varchar(50) datatype & data stored 'fountain street, zip-12345' , function should return memory occupied these 26 characters, not total column size nor length of data. thank you! you can find precision of column, via catalog (length query database catalog). however, real storage size vary. you cannot infer like cardinality * (leght(column1) + lenght(column2) + ...) = occupied storage there many other facts affect storage. also, title of question storage size (it seems tablespace -> container), in body talking memory (bufferpool) , things different in databases. what mean "memory occupied"? column precision or storage usage?

jquery - Bootstrap chevron icon doesn't change onclick, why? -

i have section: <div id="weather"> <h4><i class="icon-chevron-down"></i> weather</h4> and code this: $('#weather h4').click(function (){ $('#weather .entries').toggle(); $('#weather .icon-chevron-down').toggleclass('icon-chevron-right'); }); jsbin1 and doesn't work, if change places icon-chevron, works: jsbin2 is bug or doing wrong?? this 1 working: http://jsbin.com/omerep/1/edit $('#weather h4').click(function (){ $('#weather .entries').toggle(); $(this).find('i').toggleclass('icon-chevron-right icon-chevron-down', 200); });

Start Activity clearing top in Android -

i have following activities in stack: a , b , c, d i want relaunch b in order stack: a , b' where b' new b instance (not old receiving onnewintent callback, how can it? by way i'm using intent.setflags(intent.flag_activity_clear_top); when launching b activity way onnewintent called instead of start new instance use android:nohistory=true in manifest file particular activity clear.hope might solve issue.

Android: Showing cards like layout as in Google Keep -

Image
i wondering how show snapshot of notes, checklists, images in grid view. have no trouble creating grid view creating preview of challenge i'm facing right need add different type of views(text, checklist, imageview) grid according time of creation. works fine single type of view image or text only. or in other words. how add different views dynamically gridview adapter? all or appreciated. thanks. they surely not use gridview google keep - adapter nonetheless. to use different views adapter can use different view types: override getviewtypecount() return number of view types support. return appropriate type in getitemviewtype(int position) specific item. create correct view in getview(int position, view convertview, viewgroup parent) . keep in mind rules recycling, viewholder , on still apply. multiple types recycling happens correct type. marcus körner shared gist jake wharton on g+ recently might useful.

reading public data insights from page fan about facebook -

i have noticed obtaining insight information, facebook provides particular graph api unfortunately can access @ page_fans_country , page_storytellers data. however i've seen if go in general fan page, there "likes" section (in "about" page) created graph trend of "talking_about_this" number , trend of "like" number. this 2 graph "canvas" object , if move mouse on them, displayed information impossible obtain graph api. i've tried find method take information analysing javascript code. once thing i'v understood there "mouseover" event active code @ 118 line javascript page , code show div element in html page classname "graphtooltip". dont able text information in div element. know how obtain text?

return object from dictionary of nested lists when a condition (python) -

i have dictionary looks like: myd={'key_0':[[['descrp_0_0'],obj_0_0],.....,[['descrp_0_n'],obj_0_n]] ,....., 'key_n':[[['descrp_n_0'],obj_n_0],.....,[['descrp_n_n'],obj_n_n]]} all objs ndarrays of same shape , have function f() returns x float i.e.: obj_0_0.f() --> x_0_0 i want extract dictionary descrp , obj , respective key obj.f() (i.e. x) minimum values in each key (at myd scope of n keys give n items in shape of [descrp,obj]): the result must like: resd = {'key_0':[[descrp_0_min],obj_0_min], ....., 'key_n':[[descrp_n_min],obj_0_min]} something like: minxs = [min([item[-1].f() item in v]) k,v in myd.iteritems()] minobjs = [item k,v in myd.iteritems() item in v if item[-1].get_potential_energy() == minxs[myd.keys().index(k)]] resultlist = zip(myd.keys(),minobjs) resultdict = dict() in resultlist: resultdict[i[0]]=i[1] although works rather cumbersome , think there must easie

objective c - Can not call class method -

i'm building tag-based application , want call same function each tab ( viewcontroller ). i'm trying in following way: #import "optionsmenu.h" - (ibaction) optionsbutton:(id)sender{ uiview *optionsview = [options showoptions:4]; nslog(@"options view tag %d", optionsview.tag); } optionsmenu.h file: #import <uikit/uikit.h> @interface optionsmenu : uiview - (uiview*) showoptions: (nsinteger) tabnumber; @end optionsmenu.m file: @import "optionsmenu.h" @implementation optionsmenu - (uiview*) showoptions:(nsinteger) tabnumber{ nslog(@"show options called"); uiview* optionsview = [[uiview alloc] initwithframe:[[uiscreen mainscreen] bounds]]; optionsview.opaque = no; optionsview.backgroundcolor = [[uicolor blackcolor] colorwithalphacomponent:0.5f]; //creating several buttons on optionsview optionsview.tag = 100; return optionsview; } @end the result never "show options called" d

ios - UIScrollView clipped during animation -

i want move contentoffset of uiscrollview. i'm using different methods, cabasicanimation or uiview animatewithduration problem that, during animation, uiscrollview clipped right , left sides. when animation finished, size of uiscrollview seems right. - (void)animatescrolltothebottom { self.scroll.scrollenabled = no; cgfloat scrollheight = self.scroll.contentsize.width; [uiview animatewithduration:10 delay:0 options:uiviewanimationcurveeaseinout | uiviewanimationoptionbeginfromcurrentstate animations:^{ self.scroll.contentoffset = cgpointmake(0, scrollheight); } completion:^(bool finished) { self.scroll.scrollenabled = yes; }]; } any suggestions? thanks! [uiview animatewithduration:5.0f animations:^ { [scrollview setcontentoffset:destination animated:no]; }]; worked me

javascript - HTML5 Game jump() function not working properly -

i'm new canvas. i'm student developing runner game in canvas. have function jump() , called when mousedown() event occurs; function jump(){ img= new image(); //is_jump=1; h.clearrect(20,430,170,250); img.onload= function(){ //h.drawimage(img,mx,my,190,280,120,410,190,350); h.drawimage(img,mx,my,190,350); //mx--; //my--; } img.src= "mario-copy.png"; h.clearrect(mx,my,190,350); //for(i=mx;i<130;i+=7) //{ if(mx<110&&my<480){ mx=(mx+5); my=(my-15); //settimeout(h.drawimage(img,mx,my,190,350),100000/5); h.drawimage(img,mx,my,190,350); }else{ mx=60; my=410; } } the problem jumping character not working properly, jumps , not clear previous jumping state image while moving on. so me out animation works , smoothly. the goal make character jump click. i think problem you're clearing , redrawing in same functio

Delphi XE4 immutable strings -

with delphi xe4 ios platform new string type introduced: immutable 0 based strings. far delphi had copy on write mutable strings. question is, mean future programming? there advantages of 1 string type on other? pitfalls need take care of when switching new string type (other obvious 0 vs 1 base)? according marco cantù's whitepaper , string data type in xe4 ios target not in fact immutable, although seems contradict himself. he says: in new delphi llvm-based compiler, there 1 string type, representing unicode strings (utf16), , mapped current string type in delphi xe3 (an alias unicodestring type on windows compiler). however, new string type uses different memory management model. string type still reference counted, immutable, means cannot modify string contents once constructed. but goes on say: in other words strings unicode-based, soon-to-become immutable, , reference-counted . and also: where things start change, however, when modify exist

c# - Getting Rectangles stacked vertically to horizontally but keeping shape -

Image
i have input done correctly rectangles stacked vertically , have different colors each time new rectangle drawn, struggling output bottom pic. please can put me on right path. //list strore randomly generated rectangles list<rectangle> rectanglecollection = new list<rectangle>(); //counts amount of time rectangle needs drawn int count = 0; public static random ran = new random(); void createrectangle() { int tallestrectangle = 0; ; int prevrecy = 0; graphics graphic = picturebox1.creategraphics(); solidbrush brush; foreach (rectangle rect in rectanglecollection) { if (rect.height > tallestrectangle) tallestrectangle = rect.height; } foreach (rectangle rect in rectanglecollection) { graphic.fillrectangle(brush = new solidbrush(color.fromargb(ran.next(1, 255), ran.next(1, 255), ran.next(1, 255))), new rec

indexing - in git, can i restore previous uncommitted index state? -

i had modified files , staged them (they added index). mistakenly called git reset --hard . possible restore state of index before reset? in other words, i'm looking reflog index, allow me browse previous states of index, uncommitted ones. i've found this , partially answers question, , helps recovering lost files: can use git fsck --lost-found , save unreferenced objects <path repo>/.git/lost-found/ , , staged-but-uncommitted changes there. i'm not sure if doesn't qualify question marked duplicate, though.

javascript - How can I display the file name with file upload -

i want show file name while uploading file.for used hidden field. code is <label>file</lable> <input type="image" src="http://upload.wikimedia.org/wikipedia/commons/c/ca/button-lightblue.svg" width="30px"/> <input type="file" id="my_file" style="display: none;" /> javascript is $("input[type='image']").click(function() { $("input[id='my_file']").click(); }); how can this? you can this: $("input[type='image']").click(function () { $("input[id='my_file']").click(); }); $("input[id='my_file']").change(function (e) { var $this = $(this); $this.next().html($this.val().split('\\').pop()); }); fiddle

How to declare & call NetShareEnum of svrapi.dll from c# -

i need call netshareenum of svrapi.dll (not netapi32.dll) c#. should method signature. helpful if can me example on how call(parameters passed) , process result. thanks nishitha i believe netshareenum located in netapi32.dll?

inter process communicat - Communication between two python scripts -

a methodology question: i have "main" python script runs on infinite loop on system, , want send information (a json data string example) other python scripts started later myself or program , end after sending string. i can't use subprocess here because main script doesn't know when other run , code execute. i'm thinking of making main script listen on local port , making other scripts send strings on port, there better way ? zeromq: http://www.zeromq.org/ - best solution interprocess communications imho , have excelent binding python: http://www.zeromq.org/bindings:python

c# - WPF New Window with content -

i want create new window beside existing main windwoe scrollable textbox. i'm pressing in main window on button "open new window" , should open new window scrollable textbox. inside form2 in wpf can drag drop elements in main window cant new window. thought possible when create new window in mainwindow.xaml.cs i able create new window trough: private void btnconnect_click(object sender, routedeventargs { form form2 = new form(); //do intergreate textbox scrollbar in form2 form2.show(); } and want textbox but how can in c# or wpf? thx well... can create new window , load windows.content usercontrol wich createt in new xaml. example: newxamlusercontrol ui = new newxamlusercontrol(); mainwindow newwindow = new mainwindow(); newwindow.content = ui; newwindow.show(); the xaml <usercontrol x:class="projekt" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="ht

symfony - Symfony2 - Give a default filter in a list of elements of Sonata Admin -

i have list of elements of type vehicle , show these elements sonata admin. allow filter these elements "status" field, want that, when list showed, active vehicles showed, , if wants see inactive vehicles, uses filter , select inactive status. know if knows way apply filters default list of elements using sonata admin. here code: public function configurelistfields(listmapper $listmapper) { $listmapper ->addidentifier('name') ->add('status') ; } protected function configuredatagridfilters(datagridmapper $mapper) { $mapper ->add('name') ->add('status') ; } is there option can added status field in configuredatagridfilters() achieve goal? other options? thanks in advance. you have override $datagridvalues property following (for status > 0 if it's integer) : /** * default datagrid values * * @var array */ protected $datagridvalu

html - Windows 7 High contrast theme overrides website colors in Firefox -

i have website used control custom device. in table click on cell , color send device using javascript. <table style="width:100%;" id="colortable"> <tr> <td style="background-color:#ff8080;"><br/><br/></td> <td style="background-color:#ffff80;"><br/><br/></td> <td style="background-color:#808000;"><br/><br/></td> etc. unfortunately, on windows 7 computer controls device high contrast theme #1 active (sigh), because customer wants way. windows xp used ignore websites when changing theme, windows 7 appears override stylesheet information of websites in firefox. when loading website cells appear black , upon clicking send #000000 device. google chrome displays colors unchanged. internet explorer not. is there way .. ..tell firefox/websites ignore windows 7 themes? .. tell windows 7 themes leave websites alone? changing co

javascript - Redirect the user to the top of the screen (smartphones) -

i know if there jquery/javascript events allow redirect users top of smartphone screen. display top safari bar. what want use anchor. put @ top of page: <a name="top"></a> add want link top of page be: <a href="#top">go top</a> here link more info: http://www.w3schools.com/tags/tag_a.asp

apache - WSO2 example error - Must Understand Check Failed -

i'm setting test lab learn bit more wso2 apps. i'm trying re-create scenario described here: http://wso2.org/library/tutorials/2012/12/providing-xacml-fine-grained-authorization-webapps i'm using single windows 2008 server , have wso apps listening on different ports. tryit feature of wsois shows policy being correctly evaluated. however, when attempting use web service receive must understand check failed 500 error. the full text of error below i've re-created setup , same error. suggestions? tid[-1234] [as] [2013-04-25 21:36:37,740] error {org.apache.axis2.engine.axisengine} - must understand check failed header http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd : security org.apache.axis2.engine.axisengine.checkmustunderstand(axisengine.java:104) org.apache.axis2.engine.axisengine.receive(axisengine.java:170) org.apache.axis2.description.outinaxisoperationclient.handleresponse(outinaxisoperation.java:356) org.apache.axis2.d

Any idea on visualization of multiple correlation matrix? -

i compare correlation structure in group of variables in 3 different cases, i'd produce graph this: sample graph it's combination of 3 correlation matrices. hope more creative others ... p.s. it's one: data-visualization something similar r-blogger ; might find helpful, http://www.r-bloggers.com/visualizing-the-correlations-of-a-matrix/

android - Make javascript injection compatible for api 16 -

i building android app have compatible api 14 , newer. have 1 method inside javascript interface. from api 17 have add annotation method, @javascriptinterface , annotation not supported backwards api, since app target api 14 got error. if dont add annotation, javascript not trigged in mobile android 4.2. is possible make kind of ifdef if deviceos newer 4.2? set build target api level 17. set android:minsdkversion old of android want support. code compile and have @javascriptinterface annotation. lint point out places in code use classes, methods, etc. newer android:minsdkversion , can make sure doing correctly. or, set android:targetsdkversion 16 or lower, in case @javascriptinterface not required. see http://developer.android.com/guide/webapps/webview.html#bindingjavascript .

Matlab - Graphical user interface (GUI), plot with arduino data -

i have matlab program done real time plot acquire data ldr sensor arduino. want implement program in gui , i'm facing problems ploting. here part of program dont know how plot in gui mode. (...) while(1) state = a.analogread(0); (...) axis tight drawnow; x = [x, state]; plot(x,'-*b'); grid on; end the code must in openingfcn? should copy paste there? have change in ploting code? thank much! a neverending while loop in openingfcn indefinitely lock gui. you're better off creating timer object , running 'continually' plotting code code in callback; example: function myui_openingfcn(hobject, eventdata, handles, varargin) % create timer delay of 0.1 seconds handles.tmrplot = timer( ... 'executionmode', 'fixedrate', ... 'period', 0.1, ... 'timerfcn', @myplottingfunction); % store in ui data guidata(hobject, handles); % start it! start(handles.t

css - How to align text vertically within bootstrap progress bar -

i modified height of bootstrap progress bar can see in following link: http://jsfiddle.net/8xf2j/31/ what i'm trying make text centered vertically. tried add property: vertical-align:middle but not works... want increase font size of text containing progress bar adding: font-size:30px; as you'll see in de fiddle doesn't works too. idea or advice appreciated. one way achieve vertical alignment of single line of text make line-height match desired height. example: http://jsfiddle.net/vqs2k/ .progress { height: 40px; font-size: 30px; } .bar { font-size: 30px; line-height: 40px; } plain version (no bootstrap): http://jsfiddle.net/vqs2k/1/

jsf 2 - Why I receive this strange 'ExceptionHandlerFactory' issue on jboss-7? -

i want migrate existing icefaces application jboss server 7 receive exception: 15:01:27,399 severe [javax.enterprise.resource.webcontainer.jsf.config] (msc ser vice thread 1-2) critical error during deployment: : com.sun.faces.config.config urationexception: factory 'javax.faces.context.exceptionhandlerfactory' not configured properly. @ com.sun.faces.config.processor.factoryconfigprocessor.verifyfactories exist(factoryconfigprocessor.java:305) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.config.processor.factoryconfigprocessor.process(factory configprocessor.java:219) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.config.configmanager.initialize(configmanager.java:361) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.config.configurelistener.contextinitialized(configureli stener.java:225) [jsf-impl-2.1.7-jbossorg-2.jar:] @ org.apache.catalina.core.standardcontext.contextlistenerstart(standar dcontext.java:3392) [jbossweb-

java - Create a war file including external jars using command prompt -

i have 2 projects - project1 , project2. project1 contains java classes. , project2 contains jar files required in project1. means, project1 depends on project1 (for jars). i using glassfish server. while creating war file of project1, included jar files project2. example: project2 conatins 2 packages - poi , web-services. poi package contains: poi-examples-3.6-20091214.jar, poi-contrib-3.6-20091214.jar, poi-ooxml-3.6-20091214.jar, poi-ooxml-schemas-3.6-20091214.jar, poi-scratchpad-3.6-20091214.jar. web-services package contains: javax.servlet-3.0.jar, javax.servlet-api.jar, jersey-bundle-1.10.jar, jersey-client-1.12.jar, jersey-core-1.12.jar, jersey-multipart-1.4.jar. now creating war file project1 command prompt, used following command: jar cvf project1.war d:\javaproject\project2\lib\external\poi\poi-examples-3.6-20091214.jar d:\javaproject\project2\lib\external\poi\poi-contrib-3.6-20091214.jar d:\javaproject\project2\lib\external\poi\poi-ooxml-3.6-20091214.jar

list - NullPointerException on a listener pattern in scala -

i'm trying create listener design pattern that: abstract class listener(g: engine) { g.addlistener(this) } class listener1(g: engine) extends listener(g) class listener2(g: engine) extends listener(g) class engine { val listener1 = new listener1(this) val listener2 = new listener2(this) var listeners: list[listener] = nil def addlistener(g: listener) = { listeners = g::listeners } } but if fails nullpointerexception , because listeners equal null when listener1 , listener2 created. how overcome problem? edit: tried following: def addlistener(g: listener) = { if(listeners == null) { listeners = list(g) } else { listeners = g::listeners } } but problem after class initialized, listeners = nil. need better design pattern achieve goal. solution: without using lazy val or mutable collections: var listeners: list[listener] = _ def addlistener(g: listener) = { if(listeners == null) listeners = list(g) else

C++ string function return statement -

i'm trying add int string in return statement so: string birthday::asstring() { return -> day + "/" + -> month + "/" + -> year; } and getting following error: error: expression must have integral or unscoped enum type i'm kind of new c++. easiest way trying use ostringstream(found in header <sstream> ): string birthday::asstring() { std::ostringstream out; out << -> day << "/" << -> month << "/" << -> year; return out.str(); } you getting error show because c++ not know how add integer string. edit: suggest in m m.'s answer since c++11 there option, namely use function std::to_string.

java - transferhandler ignores drag event -

i set transfer handler on jtable (embedded in jpanel + jscrollpane). dragging elements table somewhere else (create transferable ...) works. drop elements table doesn't work,any drag event ignored. problem might event consumer (consuming drag event), that's idea have. final jtable tbl = new myjtable(); tbl.setdragenabled(true); tbl.settransferhandler(new transferhandler() { @override protected transferable createtransferable(jcomponent comp) { // .... works } @override public boolean canimport(transfersupport support) { // ... never called } @override public boolean importdata(transfersupport support) { // ... never called } i remember having same problem working jtree , solution implementing getsourceactions in transferhandler , define transfer action inside it. example: @override public int getsourceactions(jcomponent comp) { return move; }

javascript - how to pass a variable to a regex -

i have find statement this collsession.find({"venue.type": /.*mt.*/}).toarray(function (err, _clssession) { console.log(_clssession); }); it giving answer.but need value of variable instead of harcoded value mt. how achieve ? thanks. update tried "/. "+searchterm+". /" not working. instead of using inline syntax create regular expression, can use regexp object create 1 based on string var searchphrase = "mt"; var regularexpression = new regexp(".*" + searchphrase + ".*"); collsession.find({"venue.type": regularexpression}) [...]

Does caja.appspot.com cache cajoled objects -

i'm developing site use google caja sandbox javascript. i'm using server @ caja.appspot.com cajole html,js , css. seem cache cajoled object time quite anoying when developing. me seems take 5 minutes before updated content cajoled. if case , if can turned off? i asked same question on caja discussion group @ google , got answer there. caja.appspot.com cache url:s. max-age changed 10s makes developing more pleasant. workaround append unique string url cajoling ?id=345. https://groups.google.com/forum/?fromgroups=#!topic/google-caja-discuss/fzxjdq5hl58

Nginx with default_server and multiple domains on one ipaddress -

i have freshly installed nginx , created new configuration test.example.com. works. but example.org points server. if go example.org nginx redirects me test.example.com. i've read need create default server entry , e.g. return 444; did. configuration site: server { listen ip:80; server_name test.example.com; server_tokens off; root /nowhere; rewrite ^ https://test.example.com$request_uri permanent; } server { listen ip:443; server_name test.example.com; server_tokens off; root [...]; [...] } the default server entry added in nginx.conf before (also tried after) "include /etc/nginx/sites-enabled/*;" server { # use default instead nginx 0.7.x, default_server 0.8.x+ listen ip:80 default_server; server_name _; return 444; } for me looks correct. still redirected example.org test.example.com. you shouldn't have server_name set @ in default one. need before actual server block in ngi

php - How to custom filter bugs in MantisBT -

i want filter bugs in mantisbt 1.2.14 only defined custom filter. can load filter database using $t_filter = filter_ensure_valid_filter( filter_get_row($t_filter_id) ); then try rows filter with: $t_rows = filter_get_bug_rows( $f_page_number, $t_per_page, $t_page_count,$t_bug_count, $t_filter ); with paramaters $t_filter equals null . here turns out, bugs loaded. i tried $t_rows = filter_get_bug_rows( $f_page_number, $t_per_page, $t_page_count, $t_bug_count, $t_filter, $t_filter['project_id'] ); which should set project filter on, no success. i tried done in view_all_bug_page.php of mantis: $t_rows = filter_get_bug_rows( $f_page_number, $t_per_page, $t_page_count, $t_bug_count, null, null, null, true ); but here (i guess) additionally using current project cache filtering. is possible use only advanced custom filters on bugs in mantisbt, , how?

c - Different array sizes -

this question has answer here: why isn't size of array parameter same within main? 13 answers when run following program, different array sizes. tired different ways result same, io doing wrong ? #include<stdio.h> void array_size(char *a[]) { printf("func array size: %d\n", sizeof(a)); } int main() { char *str_array[]={"one", "two", "three"}; printf("array size: %d\n", (int)sizeof(str_array)); array_size(str_array); return 0; } in function main str_array array 3 char * . the parameter a of function array_size pointer. compiler not dynamically pass array length information when calling array_size. the size of 1 pointer not equal size of 3 char * pointers.

JQuery - dynamically modify CSS in CKEDITOR -

i dynamically modify css in ckeditor. read possible via jquery. dont know how tell jquery, want modify elements inside ckeditor, not in whole document. i tried this, not working: function ok() { $('textarea#editor1').css({ "color": "blue", "background-color": "orange" }); any ideas? thanks! you can use looking this var iframecontent = document.getelementsbyclassname('cke_wysiwyg_frame')[0].contentdocument // whatever want if main "document" element iframecontent.getelementbyid("..."); iframecontent.getelementsbyclassname("..."); or using jquery, interested in solution : how body's content of iframe in javascript? side note, don't think can access content of iframe remote / different domain, check if ckeditor isn't on domain.

What should I include using the mergExt mergSettings in my Livecode app -

i downloaded mergsettings , inappsettingskit. noticed in standalone application settings demo app in mergsettings there many .nib files listed can not find equivalent in either mergsettings download or inappsettingskit. is there tutorial on how include mergsettings in livecode app? if not, files should included , where? see youtube video how set inclusions in copy files pane http://www.youtube.com/watch?v=zftsvu7_qoi however appears required nib files missing in 1.0.3 i'll them there asap

c++ - How do I create a pointer to an array of object pointers -

i have two-dimensional array of pointers block objects block* grid[grid_columns][grid_rows]; (int i=0; i>grid_columns; i++) { (int k=0; k>grid_rows; k++) { grid[i][k] = null; } } how create pointer grid? ??? // create pointer grid here myblock.shiftdown(???); // pass pointer grid function the function definition of myblock.shiftdown. should put in place of ??? make work? void block::shiftdown(???) { if (row == grid_rows) ???grid[column][row] = this; else row++; } edit: i'm trying here letting block::shiftdown manipulate grid. if there's easier way hear it. what problem with: void block::shiftdown(block* g[grid_columns][grid_rows]) { if (row == grid_rows) g[column][row] = this; else row++; } and call it: myblock.shiftdown(grid);

Different Left Sliding Panel in Android -

Image
i trying create own sliding panel menu code have seen on internet. want following concept provided here . i've tried looking @ different libraries implement sliding panel menu. don't see way add panel screen, wether overlay or panel shifts entire screen. i think know how make type of menu, don't know how add activity. i saw post explaining aimed functionality: here post: navigation drawer it's in spanish, won't have problems code. i'm going try solution create navigation view application. and here google tutorial

c# - Why does the Name Property of FileInfo object start with "~$"? -

so i'm writing code going through directory of .xlsx files , picking file created last. it's simple task, there bit strange happening name property of particular fileinfo object , potentially there more cases of occurring. here code: directoryinfo di = new directoryinfo(folderpath); fileinfo[] filearray = di.getfiles("*.xlsx", searchoption.alldirectories); if (filearray.count() != 0) { datetime latestdate = datetime.minvalue; string filename = string.empty; foreach (fileinfo file in filearray) { if (file.creationtime > latestdate) { latestdate = file.creationtime; filename = file.fullname; } } } the filename important because use query latest file information , display it. however, name property of particular .xlsx file (potentially more) appearing ~$file.xlsx w

java - Value not initialized in if statement -

the below code has compiler error: speedmsg might not been initialized how can fix that? string speedmsg; // determine grade if (speed >= 150) speedmsg = "stop! stop! please let me out!"; else if (speed <= 150) speedmsg = "whew i'll walk here thanks."; change to: // determine grade if (speed >= 150) speedmsg = "stop! stop! please let me out!"; else speedmsg = "whew i'll walk here thanks."; that should enough let compiler sure variable initialized.

in app purchase - With new in-app billing, com.android.vending.billing.PURCHASE_STATE_CHANGED intent is no longer being sent -

my android app makes in-app purchase using old (v2) version of android's in app billing architecture . not able update clients v3 yet. however, on phones, new "checkout experience" being shown during purchase -- google-provided dialog purchasing item has changed more modern look. fine, except along change, key part of in-app purchase flow has stopped working, namely sending of com.android.vending.billing.purchase_state_changed intent, vitally important. thinking must doing wrong, hunted down , found old sample app (dungeons) illustrates use of old v2 in-app purchase api. sure enough, sample fails complete purchase, because android (with new fancier in-app purchase dialog) no longer sending intent. has else seen old v2 in-app purchase flow break, , found way work around it? i love attach images of way in-app-purchase dialog looks on old phone (where dungeons sample succeeds make purchase) , new phone (where dungeons fails due lack of purchase_state_changed i

c# - How to create Expression<Func<TModel, TProperty>>; -

is possible create expression<func<tmodel, bool>>() can used in different htmlhelpers (for instance in checkboxfor() ), if have model object this htmlhelper<tmodel> htmlhelper and name of property (through reflection). sure: static expression<func<tmodel,tproperty>> createexpression<tmodel,tproperty>( string propertyname) { var param = expression.parameter(typeof(tmodel), "x"); return expression.lambda<func<tmodel, tproperty>>( expression.propertyorfield(param, propertyname), param); } then: var lambda = createexpression<somemodel, bool>("isalive");

objective c - Parse.com get the username if its facebook or a parse user -

to current username use: nsstring *username = [[pfuser currentuser] username]; problem if user logged fb string 'u55yceub4z2yzrezbdfpyx3bl' , not real username. i know can with: fbrequest *request = [fbrequest requestforme]; [request startwithcompletionhandler:^(fbrequestconnection *connection, id result, nserror *error) { if (!error) { nsdictionary *userdata = (nsdictionary *)result; nsstring *username = userdata[@"name"]; }}]; but question is, there way username forgetting user logged parse or facebook? if negative, how can know user logged via facebook proper username ? use pffacebookutils - islinkedwithuser:

c# - DLL being overwritten by older version in Visual Studio project -

i'm working on web application in visual studio 2012 using htmlagilitypack. project references 1.4.0.0 version of dll in application's bin folder. used 1.3.0.0 the application works, once day dll in bin folder overwritten replacing version 1.4.0.0 1.3.0.0. i've checked gac , deleted asp.net temp folders first time happened. know what's going on here? you need delete 1.3.0.0 dll solution's reference list solution explorer.

php json data return jquery -

looking best solution: $.getjson("insertdata.php", {fullname:val1, course_id:course_id, occupation:val2}, function(data) { $.each(data, function(i, user) { //alert(user.arya.status); if(user.arya.status == 'true'){ currentposition = 2; checkdata(); nextslide(); }else{ nextslide(); } }); }) here php code: mysql_select_db("db", $con); $query="select * table fullname='".$fullname."' , course_id='".$cid."'"; $result = mysql_query($query); $totalrecords = mysql_num_rows($result); if($totalrecords) { while ($row = mysql_fetch_array($result)) { $returndata[]=array( //for json data array 'username' => $row['fullname'], 'arya' => array( 'status' => $row[

Determining the value of local variables using gdb in a function in shared library built with -g (gdb says no line number information) -

list items 1- 4 steps did. list item 5 describes problem list item 6 provides additional information i have compiled c source code c1.c -g flag. i have dynamic shared library liba1.so built -g source files has. i built executable exe1 linking c1.o (c1.c object code) liba1.so . i gdb exe1. , able step through sources of c1.c. when c1 calls shared library, able put breakpoint on function in shared library . however, when try step through function, says "single stepping until exit function foo1 ,which has no line number information" should ordinarily show value of parameters passed function foo1 not that. happens functions in shared library including big ones values cannot optimized out i did objdump -t on shared library , executable - shows symbol table (the fact can set breakpoint on function supports this). also, can see values of variables used in file c1.c should in order ensure can see values of local variables inside shared library. here other arguments being

java - How can an Integer be added to a String ArrayList? -

list list = new arraylist<string>() ; list.add(1) ; integer hello = (integer) list.get(0) ; system.out.println(hello); the above code has reference of type list referring instance of arraylist of type string . when line list.add(1) executed, isn't 1 added arraylist (of type string) ? if yes, why allowed? you have used type erasure, means have ignored set generic checks. can away this generics compile time feature isn't checked @ runtime. what have same as list list = new arraylist() ; list.add(1) ; integer hello = (integer) list.get(0) ; system.out.println(hello); or list<integer> list = new arraylist<integer>() ; list.add(1) ; integer hello = list.get(0); // generics add implicit cast here system.out.println(hello); if @ byte code generated compiler, there no way tell difference. interestingly, can this list<string> strings = new arraylist<string>(); @suppresswarnings("unchecked"); list<integer> int

How to create JSON object from php string? -

i have large php string consists of json style data , need somehow convert json object. string looks below: (it 1 big string). syntax string isn't attached below it's example. how convert string lik $string below json object? thanx. $string = " { \"name\": \"flare\", \"children\": [ { \"name\": \"analytics\", \"children\": [ { \"name\": \"cluster\", \"children\": [ {\"name\": \"agglomerativecluster\", \"size\": 3938}, {\"name\": \"communitystructure\", \"size\": 3812}, {\"name\": \"hierarchicalcluster\", \"size\": 6714}, {\"name\": \"mergeedge\", \"size\": 743} ] } ] } ] } "; use json_decode() this: $obj = json_decode($string); var_dump($obj); output: class stdclass#1 (2) {

c# - Can I use the same Entity Model for 2 databases in one application -

i have create application copy common configuration settings 1 database database (same schema). i'm wondering if can use 1 entity model access both databases. stores , products need copied. can use same model store servera.databasea , insert server.databaseb? you can have 2 similar dbset s in 2 different dbcontext classes. mentioned in comments, real problem deal identity columns , imo context attachments. think best way handle identity columns manually , fetch data db in detached state.

c# - Passing a "reference" to Dictionary element? -

so have: concurrentdictionary<string, int> dict; i want pass reference 1 of elements, suppose dict["x"] method, , allow method change/set element. possible that, or have pass dictionary itself? also, possible if element not exist key in dictionary? or has valid key contained in dictionary? yes, using delegate. delegate can called within changing function. delegate change or set key/value inside dictionary. void dochangemyelement<t>(action<t> changeit) { changeit(123); } you can call method with: concurrentdictionary<string, int> dict = new ...; dochangemyelement(value => dict["x"] = value);

java - Do I need an interface that has only one implementation? -

i have interface, has 1 implementation. following pair represents simple java object. want remove interface , use object directly. want understand when it's needed , why designed in way. done not ease unit test coverage. so, why there interface 1 implementation in project? thanks. an interface useful when might extend/change project. instance, if start project storing data in text file, , decide change doing database. if both of these implementations of same interface, swapping first out second simple. case of swapping concrete implementation in class uses it. instance, changing istorage storage = new filestorage(); to istorage storage = new dbstorage(); whilst may seem pointless have interface single implementation, may save lot of refactoring effort later.

Tracking game progress with Google Analytics -

we in process of creating android game in want use google analytics track users progress , engagement. i have read through custom dimensions/metrics docs , got insights on how analytics can used games. not sure though how model our usecase though. the game board game have 3 different modes in can play game. in addition have 10 different difficulty levels can applied on mode. mode 1 progresses linear though difficulty mode 2 lets user choose difficulty mode 3 has no difficulty. local player vs player. the questions want ask are: how users play particular mode? which mode popular? what difficulty level play in particular mode? what finishing rate difficulty level in mode? i guess clever combination of custom dimensions , metrics answer questions. if willing hint me in right direction thankful.

javascript - jQuery function as a property value of an object -

i have object within object contains property value jquery function: var fields = { id: {}, timestarted: {}, duration: {}, status: {}, name: { field: $("#companyname"), changeevent: $("#companyname").on("click", function(){ alert("bazinga!"); }) } }; i have function goes through values found within fields , tries register change events: function registerchangeevents(){ $.each(fields, function(field, v){ $.each(v, function(prop, vv){ // check property loop on: if changeevent if (prop == "changeevent"){ vv(); } }); }); } when run registerchangeevents() however, console returns uncaught typeerror: object not function . can wrap value of changeevent function(){...} , make function run fine. reason doesn't seem right approach, though. please let me know if have ideas. thanks.

Maximize memory for file cache or memory-based file system on Windows? -

i have application needs create many small files in maximum performance (less 1% of them may read later), , want avoid using asynchronous file api keep simplicity of code. size of total files written cannot pre-determined, figured achieve maximum performance, need: 1.windows utilize unused ram cache (especially file writes), no regard of relibility or other issues. if have more 1gb of unused ram , create 1 million of 1kb files, expect windows report "done" immediately, if has written nothing disk yet. or 2.a memory-based file system backed real on-disk file system. whenever write files, should first write in memory only, , update on-disk file system in background. no delay in synchronous calls unless there isn't enough free memory. note it's different tmpfs or ram disk implementations on windows, since require fixed amount of memory , utilize page file when there isn't enough ram. for option 1, have tested vhd files - while offer high 50% increase of t

c# - Validating exact length of value -

i using microsoft visual developer c#. trying validate textbox book code (int) entered 4 characters long. used range validator control so. maximumvalue , minimumvalue properties of range validator made them both equal 4. doesnt seem work. doing wrong? this simple, should thinking more problem before posting. however, empathize beginner , give couple of solutions. option 1 - convert string , check it's length; string myvar = bookcode.tostring() if (myvar.length < 5) // it's good! else // error option 2 - largest value less ten thousand 9999, 4 digit value. if (bookcode < 10000) // it's else // it's bad

magento - Add terms and condition to the new account registration -

how can add checkbox , content of terms , condition when user create new account. the file talking register.phtml <li class="control"> <div class="input-box"> <input type="checkbox" id="privacy_policy" name="privacy_policy" value="1" title="<?php echo $this->__('accept privacy policy') ?>" class="checkbox required-entry"> </div> <label for="is_subscribed"><?php echo $this->__('accept privacy policy') ?> (<a href="<?php echo mage::helper('cms/page')->getpageurl( 6 ) ?>"><?php echo $this->__('privacy policy'); ?></a>)</label> </li> this works great, thanks!

innerhtml - best way to reset a form using jquery -

i have following javascript , html form: <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> <!--<script src="./_js/jquery-1.7.2.min.js"></script>--> <script> // wait dom loaded $(document).ready(function() { $("#clear_form").click(function(){ var resetforms = function () { $('form').each(function() { this.reset(); }); // end earch }; // end var resetforms resetforms(); // ************edit based on questions responses ************* var x = document.getelementbyid("all_clear"); x.innerhtml = ''