Posts

Showing posts from June, 2011

php - how to use # in reqular expression in pup htaccess file -

i need use # in regular expression make commented characters after ( #) rewriterule ^([a-za-z0-9_-]+)?/?([a-za-z0-9@#$&%_"'\{\}:\,\-]+) can 1 me how can use # not comments...i used # doesn't work help. it looks might over-escaping inside second character class. check out accepted answer question: htaccess regexp underline , space doesn't work not knowing goal of rewriterule makes difficult offer further help. recommend looking rewriterule flags see if there useful can leverage there, such noescape flag [ne]: http://httpd.apache.org/docs/current/rewrite/flags.html

javascript - How to run the same specs several times for each startup config -

jasmine favorite testing javascript framework. far i've wrote specs without problems. but 1 day i've decided extend application (it's simple mind-map tool) several graph types instead of single one. it's supporting "wbs" , "orgchart" data models. don't want duplicate current specs previous data model newly created one. may in case enough fix 1 global beforeeach function? looks like var graph; beforeeach(function () { graph = new graph({ template: templates.orgchart }); }); so question how make same spec run each type of data models. or if there way pass arguments jasmine.getenv().execute() ? appreciated, thanks. you run tests in loop: ['wbs', 'orgchart'].foreach(function(datamodel){ var graph; beforeeach(function () { graph = new graph({ template: templates[datamodel] }); }); describe('with ' + datamodel, function(){ //your tests }) })

actionscript - VerifyError: Error #1014: Class spark.components::HGroup could not be found -

i created simple flex application contains following line of codes <?xml version="1.0" encoding="utf-8"?> <s:hgroup xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minwidth="955" minheight="600"> <fx:declarations&gt <!-- place non-visual elements (e.g., services, value objects) here --> </fx:declarations&gt </s:hgroup> when run application in flex got following error on browser verifyerror: error #1014: class spark.components::hgroup not found. also there warning on flash builder console follows `this compilation unit did not have factoryclass specified in frame metadata load configured runtime shared libraries. compile without runtime shared libraries either set -static-link-runtime-shared-libraries option true or remove -runtime-sha

windows - Command runs fine on command line but not from Task Scheduler -

powershell 2.0 on windows 7 64-bit when tested out in shell, following works fine: powershell -command { sleep 5 } but when have in scheduled task, powershell in program box , -command { sleep 5 } in argument box, task scheduler reports "the operation completed successfully. (0x0)" nothing run. i had record screen video camera , played in slow motion find out going on. after powershell profile script runs, sleep 5 shows on screen no error , powershell closes immediately. (both x86 , x64 versions have executionpolicy set remotesigned.) what have make -command work in task scheduler? . try powershell -command "sleep 5" instead.

404 error in php eclipse -

i trying run webpage using php eclipse , 404 error ("the webpage cannot found"). the page trying run simple "hello world" variation in html. web-server set localhost (in window > preferences > php servers). localhost server running, using iis server in windows 7. when go http://localhost on browser "it works!" message. i've tried access http://localhost/tryout1/index.php through browser , "the requested url /tryout1/index.php not found on server". i've tried with\without backslash , without tryout1 library , same message. way project on eclipse trying run tryout1, , page index.php. what need in order run page in php eclipse? you need install php in iis, use web platfrom install it, here link : http://www.microsoft.com/web/downloads/platform.aspx

java - Hibernate Criteria issues a deprecation warnings -

i'm getting warning: positional parameter considered deprecated; use named parameters or jpa-style positional parameters instead. with criteria object ( restrictions class). how add parameter criteria when criteria object doesnt seem have criteria::setstring . here criteria: criteria.add(restrictions.eq("userid", 1); you're right deleted line , warning still here. caused use of posistionnal parameter ? in @namedquery (inside @entity ) seems deprecated in hibernate 4.

php - sed regex with replace -

given file: <? $dbo = mysql_fetch_assoc(); $dbo->employee_id; $dbo->employee_name; $dbo->dirt; $dbo->dirt23; $dbo->dirt_2_3; ?> and using sed find , replace: sed -e "s|$dbo->([\w\_]*)|$dbo['\1']|g" test.php it returns error. i've tried using apostrophes container , escaping , using forward slash command delimiter, no avail. result should be: <? $dbo = mysql_fetch_assoc(); $dbo['employee_id']; $dbo['employee_name']; $dbo['dirt']; $dbo['dirt23']; $dbo['dirt_2_3']; ?> help, please. few mistakes: \w includes underscore $ needs excaped square brackets need excaped you're using $ inside double quotes while expanded shell use following sed: sed -r 's/(\$dbo->)([[:alnum:]_]+)(.*)$/\1["\2"]\3/g' or on osx: sed -e 's/(\$dbo->)([[:alnum:]_]+)(.*)$/\1["\2"]\3/g' for using single quotes: sed -r "

Issue while reading an excel file in android -

i trying read excel file. file kept in work space in folder called rocom_db , file name rocom.xlsx . i trying read file using following code : public string readcomplexexcelfile(context context){ try{ // creating input stream file file = new file(environment.getexternalstoragedirectory() + "/android/data/" + getapplicationcontext().getpackagename() + "/rocom_db/", "rocom.xlsx"); fileinputstream myinput = new fileinputstream(file); // create poifsfilesystem object poifsfilesystem myfilesystem = new poifsfilesystem(myinput); // create workbook using file system hssfworkbook myworkbook = new hssfworkbook(myfilesystem); // first sheet workbook hssfsheet mysheet = myworkbook.getsheetat(0); /** need iterate through cells.**/ iterator<row> rowiter = mysheet.rowiterator();

visual studio 2010 - which plugin i want to dowlod for develop Android and Windows Phone apps -

i have vs2010 , vs2012 professional in pc i'm using os window 7 , both vs installed here want develop android , windows phone apps want know pluging have instal start learning develop android , windows phone apps on system. please let me know how can start working on to learn development of android , windows phone apps. for develop in android can use eclipse ide , install plugin. see this: http://developer.android.com/sdk/installing/installing-adt.html for windows phone can continue using visual studio. download windows phone 8 sdk here: http://dev.windowsphone.com/en-us/downloadsdk

Multiple Migrations whit same Version Number on Deployng Rails to Heroku -

im have problem many times, search , not found solution solve, problem this: after run git push heroku push master when run heroku run rake db:migrate i error: multiple migrations have version number 20130615132808 im search problem , found this: rails database migration - multiple migrations have version number x but when execute git rm appear options dont understand git need solve problem, in localhost im delete archives problem persists, help. just rename files duplicate timestamps (add 1 last digit) , add, commit , push files. when run heroku run rake db:migrate again dandy. and future remember not copy , rename migrations hand (so don't repeated version numbers)

Varargs with different type parameters in scala -

i'm new scala... anyway, want like: val bar = new foo("a" -> list[int](1), "b" -> list[string]("2"), ...) bar("a") // gives list[int] containing 1 bar("b") // gives list[string] containing "2" the problem when do: class foo(pairs: (string, list[_])*) { def apply(name: string): list[_] = pairs.tomap(name) } pairs gonna array[(string, list[any]) (or that) , apply() wrong anyway since list[_] 1 type instead of "different types". if varargs * returned tuple i'm still not sure how i'd go getting bar("a") return list[originaltypepassedin] . there way of doing this? scala seems pretty flexible feels there should advanced way of doing this. this can't done. consider this: val key = readstringfromuser(); val value = bar(key); what type of value ? depend on user has input. types static, they're determined , used @ compile time. so you'll either have use

actionscript 3 - Adobe Flash Builder Mobile - Check Internet connection and choose view -

is possible check internet connection, choose view according connection/no connection? thanks maybe following code useful: <?xml version="1.0" encoding="utf-8"?> <s:viewnavigatorapplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" firstview="views.testconnectionhomeview" applicationdpi="160" creationcomplete="init()"> <fx:script> <![cdata[ import air.net.urlmonitor; private var monitor:urlmonitor; public function init():void{ monitor = new urlmonitor(new urlrequest('http://www.adobe.com')); monitor.addeventlistener(statusevent.status, announcestatus); monitor.start(); } public function announcestatus(e:statusevent):void { trace("status change. current status: " + monitor.available); }

c# - "NullReferenceException was unhandled by user code" when trying to retrive a navigation property using entry.GetDatabaseValues().ToObject() -

i have folloiwng action methods:- [httppost] [validateantiforgerytoken] public actionresult edit(rack rack) { try { if (modelstate.isvalid) { repository.insertorupdaterack(rack); repository.save(); return redirecttoaction("index"); } } catch (dbupdateconcurrencyexception ex) { var entry = ex.entries.single(); var databasevalues = (rack)entry.getdatabasevalues().toobject(); var clientvalues = (rack)entry.entity; if (databasevalues.ru != clientvalues.ru) modelstate.addmodelerror("ru", "current value: " + databasevalues.ru); if (databasevalues.datacenterid != clientvalues.datacenterid) modelstate.addmodelerror("dat

php - Safari: Forms not submitting, works in other browsers -

i'm trying figure out what's wrong forms. on 1 page, dont know if issue. i dont know if it's safari or what. anyways heres html: <!-- table show/hide change form --> <form method="get" action="check.php" onsubmit="settimeout('location.reload()');"> <div id="arrange-form" class="modal hide fade"> <div class="modal-header"> <a class="close" data-dismiss="modal">&times;</a> <h4><?php _e('customise table layout'); ?></h4> </div> <div class="modal-body"> <div id="message"></div> <div class="control"> <div id="show-form"> </div>

dns - Return IPv6 address Python from domain name -

so searched little on internet , found socket class can return ipv4 address domain name in python. ip address of domain on shared host says how it. can same thing return ipv6 address? looks support ipv6 in python bit limited , found no resources searching on internet. take here , think looking for. socket.getaddrinfo("example.com", none, socket.af_inet6)

winforms - How to call the mainwindow object from a second object created from main window in c# .net -

being first user in windows form development want ask simple question ... i created form(mainwindow.cs) within solution opens @ time of running solution. latter created second form(secondwindow.cs) , created event can called first window clicking button.when second window loded first window(mainwindow.cs) disabled. now want enable mainwindow.cs when second window closed. how that... a simple solution have hide mainwindow.cs , latter on closing second window make new object of first window , show it.but not way think because there object created .net framework first window automatically, why should create new object of mainwindow.cs . code of first window ( mainwindow.cs ) : private void pricecontrolltoolstripmenuitem_click(object sender, eventargs e) { secondwindow price = new secondwindow(); this.enabled = false; price.show(); } code of second window ( on closing secondwindow.cs ) private void price_controll_formclosed(object sender

.htaccess - htaccess not working due to lack of knowledge -

so want send 3 variables (separated slashes) index.php can't working, i'm leek htaccess. my base url localhost:8888/smbo/ and have code not work: <ifmodule mod_rewrite.c> rewriteengine on rewritebase /smbo/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([a-za-z0-9_-]+)/([a-za-z0-9_-]+)/([a-za-z0-9_-]+)$ index.php?id=$1&idtwo=$2&idthree=$3 </ifmodule> who can me? try code : rewriteengine on rewritebase /smbo/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/([^/]+)$ /index.php?id=$1&idtwo=$2&idthree=$3

http - Is If-Modified-Since strong or weak validation? -

http 1.1 states there can either strong , weak etag / if-none-match validation. questions is, last-modified / if-modified-since validation strong or weak? this has implications whether sub-range requests can made or not. from http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p5-range-23.html#rfc.section.4.3 : "a response might transfer subrange of representation if connection closed prematurely or if request used 1 or more range specifications. after several such transfers, client might have received several ranges of same representation. these ranges can safely combined if have in common same strong validator, "strong validator" defined either entity-tag not marked weak (section 2.3 of [part4]) or, if no entity-tag provided, last-modified value strong in sense defined section 2.2.2 of [part4]."

actionscript 3 - as3 .text not working -

so heres code im using: endscreen.scoreprint.text = string(score); endscreen.distanceprint.text = string(distance); and doesent show anything, while same code in other places in app works, tried embed fonts , stuff still blank space. doing wrong? edit: endscreen movieclip without linkage, manipulated .visible , scoreprint , distanceprint part of movieclip. scoreprint , distanceprint identical in names , following: classic text -> dynamic text try endscreen.scoreprint.text = "" + score; if not, does trace("" + score); show anything?

iphone - adjustsFontSizeToFitWidth doesn't properly work -

i'm developing app ios > 5.0 , using xcode 4.6.2 explain problem, i've uiscrollview contains bunch of uilabel . text i'm going display in these uilabel s dynamic but, uilabel 's frame constant, if current text doesn't fit in frame width, need scale font size down. so, i've found adjustsfontsizetofitwidth property of uilabel . here explanation took directly uilabel class reference. a boolean value indicating whether font size should reduced in order fit title string label’s bounding rectangle. yeap, thought that's looking since text i'm going display in uilabel 1 line. so i'm aware of property should used numberoflines property set 1. here code make happen. for (nsstring *currentimage in self.imagesnames) { uilabel *lbl = [[uilabel alloc]initwithframe:cgrectmake(imagenumber*resulttypeimagewidth, 10, 75, 35)]; [lbl setfont:[uifont fontwithname:@"gothamrounded-bold" size:25]]; [lbl setnumberoflines:1];

sharepoint 2010 - How to show Document ID in an excel file cell? -

Image
in sharepoint 2010 have document library. when create new document in library, document gets automatic document id. show document id in cel in excel file. these document id available property in excel file. i have try macros below, didnt work document id property. other properties working fine . there solution? i have tried these macros scripts: public function getmycustomdocumentproperties(prop string) string getmycustomdocumentproperties = thisworkbook.customdocumentproperties(prop) end function public function getmybuiltindocumentproperties(prop string) string getmybuiltindocumentproperties = thisworkbook.builtindocumentproperties(prop) end function error got in cell: #value! this value of cel a4: =getmycustomdocumentproperties("document id value") this value of cel a5: =getmybuiltindocumentproperties("document id value") i found solution. was: public function getmycontenttypeproperties(prop string) string getmycont

css - Center a menu with left align items -

i need design menu, in menu centered, variable number of items, browser resolutions, , items aligned left (menu centered in page, items aligned left). http://i39.tinypic.com/2vx0ha9.jpg (as can see not centered @ all). this code: <html> <head> <style type="text/css"> .extpanel{ background-color:#555; padding: 0px 20% 0px 20%; display: table; } .split{ clear: both; } .menuelement{ float:left; background-color:#aaa; margin: 0px 20px 20px 0px; width: 200px; height: 200px; text-align: center; } </style> </head> <body> <div class="extpanel"> <div class="menuelement">item1</div> <div class="menuelement">item2</div> <div class="menuelement">item3</div> <div class="menuelement">item4</div> <div class="split"></div> external panel. 20% left , right padding. </div>

javascript - Understanding Nodejs documentation -

i on thinking, having trouble digesting nodejs documentation. new javascript , come java background. my question not specific nodejs function overall understanding. below give example of trying understand... when working statically typed language java clear types needed method calls. trivial example, if want sort array of int's can @ arrays.sort , see takes int[] (same other types well). can see returns void. public static void sort(int[] a) however javascript dynamic language there no types api calls. take example in crypto module crypto.pbkdf2(password, salt, iterations, keylen, callback) asynchronous pbkdf2 applies pseudorandom function hmac-sha1 derive key of given length given password, salt , iterations. callback gets 2 arguments (err, derivedkey). so without going out , finding example code, or looking @ nodejs source how know argument types of function? realized possible derive types looking @ name (ie callback function type) there other way? for e

python - weight issues in scikit-learn's adaboost -

i'm trying use adaboostclassifier decision tree stump base classifier. noticed weight adjustment done adaboostclassifier has been giving me errors both samme.r , samme options. here's brief overview of i'm doing def train_adaboost(features, labels): uniqlabels = np.unique(labels) alllearners = [] targetlab in uniqlabels: runs=[] rrr in xrange(10): feats,labs = get_binary_sets(features, labels, targetlab) baseclf = decisiontreeclassifier(max_depth=1, min_samples_leaf=1) baseclf.fit(feats, labs) ada_real = adaboostclassifier( base_estimator=baseclf, learning_rate=1, n_estimators=20, algorithm="samme") runs.append(ada_real.fit(feats, labs)) alllearners.append(runs) return alllearners i looked @ fit every single decision tree cl

ruby on rails 3 - Railcasts: #241 Simple Omniauth, routing error for "/auth/twitter" -

hi following railcasts: #241 simple omniauth tutorial can let users log in sample application using omniauth-twitter gem, getting routing error when entering /auth/twitter stage of tutorial. what have added after few online searches :strategy_class => omniauth::strategies::twitter omniauth.rb file. same problem, when run rake route following routes: /auth/:provider/callback(.:format) sessions#create auth_failure /auth/failure(.:format) :controller#:action which guess mean contacting omniauth-twitter gem still can't /auth/twitter work. what think need do: think need following show in rake routes. omniauth_authorize get|post /auth/:provider(.:format) /omniauth_callbacks any appreciated. thank in advance mark. for has similar problem, had addition space @ end of omniauth.rb file ( i.e. omniauth.rb(space) ) rails didn't recognise it. difficult see works now.

swing - Java - TrayIcon messages not displaying on Windows XP, Vista -

Image
i'm writing application utilizes java's trayicon class, can't seem display messages on windows xp/vista. known issue or there i'm missing? (messages appear should on windows 7) code: public class systray { public static void main(string[] args) throws exception { trayicon icon = new trayicon(getimage()); icon.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "good"); } }); systemtray.getsystemtray().add(icon); icon.displaymessage("attention", "please click here", trayicon.messagetype.warning); } private static image getimage() throws headlessexception { icon defaulticon = metaliconfactory.gettreeharddriveicon(); image img = new bufferedimage(defaulticon.geticonwidth(), defaulticon.geticonheight(), bufferedimage.type_4byte_abgr

php - uploading the name of the images -

i'm uploading name of images database! the problem name in database blank space before name! where problem? $original_name = strtolower(trim($arquivo['name'])); $caracteres = array("ç","~","^","]","[","{","}",";",":","´",",",">", "<","-","/","|","@","$","%","ã","â","á","à","é", "è","ó","§","ò","+","=","*","&","(",")","!","#","?", "`","ã"," ","©","£"); $original_name = str_replace(' ', '', $original_name); $final_name = str_replace($caracteres,"",$original_name);

android - get nullpointer using getLocalActivityManager().getActivity(tag) -

i'm using tabactivity implement tabs in project , want communicate activities of tabs , invoke methods tabactivity , use method below: coachactivity activity=(coachactivity) getlocalactivitymanager().getactivity(mtabhost.getcurrenttabtag()); but activity null. coachactivity tab1 activity. my code bit long don't post here. double checked , i'm sure problem isn't setup of tabs. set current tab , checked coachactivity created.

Replace Values in R - Error Received -

i have dataframe, titled gen , data frame made of a's, c's, g's, t's, , 0's. replace 1, c 2, g 3, , t 4. when try using code gen1[gen1 == "a"] = 1 , error message: warning messages: 1: in `[<-.factor`(`*tmp*`, thisvar, value = "1") : invalid factor level, nas generated the resulting data frame has of a's replaced, there na's instead of 1's. does know how correctly? thanks solution: you can use coerce column factors integer using as.integer : using sapply : sapply(gen1,as.integer) and colwise plyr : library(plyr) colwise(as.integer)(gen1) for example, generate first data.frame of a,b,c , d: set.seed(1) gen1 <- as.data.frame(matrix(sample(letters[1:4], 4 * 5, rep = true), ncol = 4)) ## v1 v2 v3 v4 ## 1 b d b ## 2 b d c ## 3 c c c d ## 4 d c b b ## 5 d d library(plyr) colwise(as.integer)(gen1) ## v1 v2 v3 v4 ## 1 2 3 1 1 ## 2 2 3 1 2 ## 3 3 2 3 3 ## 4 4 2

ios - Map out longitude and latitude -

i have "map" shows poi's defined longitude , latitude. can somehow figure out these 2 values put dot representing poi relative user's position ? have thought this: let's user's position longitude = 12.3456789 , latitude = 98.7654321 , shop longitude = 12.2345678 , latitude = 98.6543210. (imaginary values) possible map these shops onto rectangular area (just google maps) ? i using ios, if have references helpful if c oriented, java , obj-c should ok too. use page learn lat long calculations. apple things, if use cllocation can use distancefromlocation method. once have distances , angles want normalise distances unit circle easier map coordinate system of view. add subviews represent each location , set positions based on normalised distance , angle center (which represents user), or implement drawrect , draw lines / circles show positions.

cocoa - iOS design pattern to upload items to web while showing progress in a TableView -

i trying remove ui code dependency upload methods better understanding of mvc paradigms. i want design way visualize upload progress inside uitableview, individual cells being designated show corresponding nsoperation subclasses. nsoperation subclass has been hacked support delegate callback pattern (ie non-concurrent/mainthread only). nsoperation looks this: @class myuploadop; @protocol myuploaddelegate; -(void)uploadop:(myuploadop *)uploadop madeprogress:(cgfloat)progress; -(void)uploadop:(myuploadop *)uploadop diduploadlocalfile:(localfileobject *)localfile; @end @interface myuploadop : nsoperation <dbrestclientdelegate> @property (nonatomic,strong) localfileobject *mylocalfile; -(id)initwithlocalfile:(localfileobject *)localfile; @end as can see, using dropbox sdk ios. nsoperation subclass uploads local file dropbox. receive necessary dropbox delegate methods inside nsoperation class , forward them onward class responsible setting , keeping track of upload. what

Entity Framework model updates, but model's list of other items not updating -

here's issue. revived old text based game of mine used flat files saving , loading. have been porting old c++ code c# using mvc 4 entity framework 5 , sql server 2012. rendering pages razor views straightforward. problem comes when building wizard creating/editing rooms. a room contains collection of exit objects. works fine when first create room , assign exits. not work when edit room , change exits. putting breakpoint in edit code shows exit value has changed, no problem setting room state modified, , room appears save fine i.e. changes name , description updated. however, exit info not. i tried loop through list of exits, mark each exit modified, throws sorts of errors during save. question this. correct way update list of exits on room model? i've tried other solutions here, refresh, copying new values old values before saving, nothing works. how exit objects update database. in advance. public abstract class entity { public virtual int id { get; set; }

Undefined local variables in Rails 3 partials after upgrade to Ruby 1.9.3 -

i know there several posts on issue none of solutions i've read here. i've upgraded ruby 1.8.7 1.9.3p429 , now, undefined local variable in partials. i calling partial (from partial in case that's relevant) thusly: = render :partial => 'user_name', :locals => {:user => item_user, :extra_class => "active"} in partial, access these locals thusly: - if(current_user , user.silhouette_user_id.to_i == current_user.silhouette_user_id) = notranslate(current_user.full_name) - else - if !local_assigns[:extra_class].nil? = notranslate(link_to( h(user.full_name), stream_url(:user_id => user.silhouette_user_id), :class => extra_class )) rescue "anonymous" - else = notranslate(link_to( h(user.full_name), stream_url(:user_id => user.silhouette_user_id) )) rescue "anonymous" = notranslate(link_to "pro", "#", :class => "badge badge-pro", :title => &q

ios - Mp3 without mp3 extension not playing on iphone -

the following fiddle works on pc not on iphone: http://jsfiddle.net/t4j7a/ the player src being set of form: http://apifree.forvo.com/audio/3d3j2o2c311k2k383b332c211m3d271o32273i211b3a252j3e3m2h3c1m3b2c2o372c3o333c311p25331n2l1n3p252o3j1i392i2c3832372o3d1i2e32371o2m2m2j2g3e3o1i2g2o211m281b2g243b3q2826221l2i1k2h1t1t_251o293n2m262p2k3l3g2q3q3i1f32222j3e292i352h1t1t is there limitations iphone can handle causing paths of form not work?

qt - Memory leak in C++ function using std::swap -

i'm using qt creator , i'm having trouble memory leak. i've read posts dynamic memory allocation i've seen, can't understand why function accumulating in memory. i'm sure i've pinpointed function causes problem: void csimwindow::clonenet(int origin, int destination) int newnumsensors = netvector[origin].getnumsensors(); int newnumactuators = netvector[origin].getnumactuators(); int newnumneurons = netvector[origin].getnumneurons(); cnet newnet(newnumneurons, 0); newnet.setnumsensors(newnumsensors); newnet.setnumactuators(newnumactuators); (int = 0; < netvector[origin].getnumneurons(); i++) { ... } std::swap(newnet, netvector[destination]); } i'm quite newbie, understand it, objects created inside function should destroyed when it's finished. if can tell me why function causes memory leak, thank in advance. the way see there 3 possibilities: 1: (the likely) cnet destructor not

mysql - Can I use INSERT INTO ... On DUPLICATE KEY without by using auto_increment value? -

i trying write query check if record exists (based on couple of clause , not unique identifier) if such search return records need update found records if nothing found need insert record. note can't use if exists because trying make query client side script , not server side. came cross idea of insert .... on duplicate key can without knowing row key identifier? if find record accountid = 17 , name = 'mike' update make name 'mike a' if there no record these 2 clause insert record. this attempt giving me syntax error insert test (name, accountid) values ('mike', 17) on duplicate key update test set name='mike a' name ='mike' , accountid = 17 can method handle trying do? if yes can please correct syntax? thank you the way can work if have primary key or unique constraint on fields. documentation: if specify on duplicate key update, , row inserted cause duplicate value in unique index or primary key, update o

c++ - Writing huge txt files without overloading RAM -

i need write results of process in txt file. process long , amount of data written huge (~150gb). program works fine, problem ram gets overloaded and, @ point, stops. the program simple: ostream f; f.open(filepath); for(int k=0; k<ndataset; k++){ //treat element of dataset f << result; } f.close(); is there way of writing file without overloading memory? you should flush output periodically. for example: if (k%10000 == 0) f.flush();

html - Extra Box Appears When Browser Ratio is Different -

i'm trying create clickable box sizes , positions relative how browser sizes, box when decrease width of browser , increase length. i'm not sure going on , how rid of it. here screen captures of going on: - browser @ full size: http://i.imgur.com/mbymoyw.png - browser stretched described above: http://i.imgur.com/kux1tdn.png css: img.banner { width: 100%; z-index: 0 } #banner { width: 100%; margin-top: 0px; margin-bottom: auto; margin-left: 0px; margin-right: auto; position: relative } a.rollover { display: block; position: absolute; top: 15%; left: 15%; width: 17%; height: 8%; background-color: black; } html: <body> <div id="banner"> <img src="image.png" class="banner"/> <a href="banner1.png" class="rollover"> </div> </body> also, other suggestions improve css , html appreciated, since i'm new this. t

python - Un-normalized Gaussian curve on histogram -

Image
i have data of gaussian form when plotted histogram. want plot gaussian curve on top of histogram see how data is. using pyplot matplotlib. not want normalize histogram. can normed fit, looking un-normalized fit. here know how it? thanks! abhinav kumar as example: import pylab py import numpy np scipy import optimize # generate y = np.random.standard_normal(10000) data = py.hist(y, bins = 100) # equation gaussian def f(x, a, b, c): return * py.exp(-(x - b)**2.0 / (2 * c**2)) # generate data bins set of points x = [0.5 * (data[1][i] + data[1][i+1]) in xrange(len(data[1])-1)] y = data[0] popt, pcov = optimize.curve_fit(f, x, y) x_fit = py.linspace(x[0], x[-1], 100) y_fit = f(x_fit, *popt) plot(x_fit, y_fit, lw=4, color="r") this fit gaussian plot distribution, should use pcov give quantitative number how fit is. a better way determine how data gaussian, or distribution pearson chi-squared test . takes practise understand powerful tool.

Excel equivalent Google Docs function to "query()" custom VBA function -

i transitioning google docs excel , running int oproblems equilivent function: google docs: query() from googleing around know there no query in excel , have started make vba function same thing running trouble the original google docs query =query('gp referrals 2012-2013'!a15:z ; "select a, z j = 'wh' order z desc limit 9", 0) a string, z number , j 1 of 3 possible strings. run 3 times different values in j. is there way in excel. have second sheet setup put results of in. i have function started but stuck how next step. appreciated. function gettopgps(clinic string) integer dim activesheet object set activesheet = worksheets(1) dim rawrange object set rawrange = activesheet.range("a15:z65536") // how can go here? end function based on @chuff's approach, give data array labels (i chose a > z a14:z14) , name array (a14:zn) - chose gparry . data > external data - other sources, micro

javascript - file input does not update except in Chrome -

i have local program writes json object file javascript can pick data , process it. file selected using <input> object: <form id = "getfiles"> <input type = "file" multiple id = "files" /> </form> with following js function setinterval repeat every 300ms. however, when file changes, google chrome reloads file , processes new content; have manually reselect file on page in ie 10 , firefox 20. function speaktext() { var thefile = document.getelementbyid('files').files[0]; var lastchanged = thefile.lastmodifieddate; var reader = new filereader(); reader.onload = function(event) { var lcd = document.getelementbyid("last_change_date"); if (!lcd) { var spanlastchanged = document.createelement("span"); spanlastchanged.id = "last_change_date"; spanlastchanged.innertext = lastchanged;

ruby on rails - rake migrate aborted trouble -

i following tutorial, tutorial using rails 2.0. however, using rails 4.0. guess difference makes trouble when doing rake migrate? [photos/db/migrate/20130722034245_create_photos.rb] class createphotos < activerecord::migration def change create_table :photos |t| t.timestamps end end def self.up create_table :photos |photo| photo.column "filename", :string end end def self.down drop_table :photos end end [on terminal] seodongju@seoui-macbook-pro ~/desktop/projects/photos$ rake migrate rake aborted! don't know how build task 'migrate' /usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval' /usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>' (see full trace running task --trace) rake db:migrate not rake migrate.

How does the PHP code execute even without closing the ?> PHP tag? -

following code come notice php file: <?php # should log same directory file $log = klogger::instance(dirname(__file__), klogger::debug); $args1 = array('a' => array('b' => 'c'), 'd'); $args2 = null; $log->loginfo('info test'); $log->lognotice('notice test'); $log->logwarn('warn test'); $log->logerror('error test'); $log->logfatal('fatal test'); $log->logalert('alert test'); $log->logcrit('crit test'); $log->logemerg('emerg test'); $log->loginfo('testing passing array or object', $args1); $log->logwarn('testing passing null value', $args2); you can notice closing php tag( ?> ) not present there still statements within code working perfect. i'm not getting how possible execute code without completion of php tag( ?> ). researched didn't satisfatory explanation. can guide me in regard? in advance. the cl

toad - how to Combine two tables column in oracle? -

table 1: currency code er guarantor id g amount usd 1.2986 117 750 aed 4.76976 117 5750 zar 11.4717 117 234 inr 70.676 117 1243 amd 526.5823 117 500000 eur 1 117 12435 139.63197 117 2000000 eur 1 173 200000 eur 1 217 20000000 inr 70.676 26 100000 aed 4.76976 43 1000000 eur 1 53 10000 table 2: f amount usd 1.2986 117 450 aed 4.76976 117 7900 inr 70.676 117 2237.4 zar 11.4717 117 140.4 amd 526.5823 117 500000 eur 1 117 6961 139.63197 117 2000000 eur 1 173 20000 eur 1 217 14000000 inr 70.676 26 300000 aed 4.76976 43 2000000 eur 1 53 10000 result: currency code er guarantor id g amount f amount usd 1.2986 117 750 450 aed 4

android - Making a middle element to get stuck in the header (ScrollView/ListView) -

i want make element shown in middle of scrollview (or listview ) @ first , gets stuck in header of screen when it’s scrolled. it’s prototype implementation in css+js: http://jsfiddle.net/minhee/apcv4/embedded/result/ . at first glance make scrollview include listview , official docs says: you should never use scrollview listview, because listview takes care of own vertical scrolling. importantly, doing defeats of important optimizations in listview dealing large lists, since forces listview display entire list of items fill infinite container supplied scrollview. so, approaches can try achieve ui? update : tried stickylistheaders , but: “it not possible have interactive elements in header, buttons, switches, etc. work when header not stuck.” plus, find it’s not suitable situation. don’t need multiple headers, 1 middle element stuck in header. i have used(or rather, tried use) stickylistheaders library in past. after having issues it, came following. not d

events - Running a javascript function based on statechange -

following answer in stackoverflow question , trying run following code. myfunction takes 1 google visualization event. following code valid? or how handle multiple statechange google visualization events in single function? var categorypicker1, categorypicker2; function drawvisualization() { // etc. categorypicker1 = // etc... categorypicker2 = // etc... // register hear state changes. google.visualization.events.addlistener(categorypicker1, 'statechange', myfunction); google.visualization.events.addlistener(categorypicker2, 'statechange', myfunction); // etc. } function myfunction() { var whereclauses = []; if (categorypicker1) { whereclauses.push("something1 = '" + document.getelementsbyclassname('goog-inline-block goog-menu-button-caption')[0].innerhtml + "'") } if (categorypicker2) { whereclauses.push("something2 = '" + document.getelementsbyclassname('goog-inline-block goog-menu

c# - Set contents of page according to browser resolution -

Image
here default browser size.and qr code @ right place. when re-size browser .i got one.but here qr code disappearing if reduce more. i want qr code under captcha . have searched ,got answers not working in case.please help. here code.thanks in advance. <div style="border: 1px solid lightgrey; border-radius: 10px 10px 10px 10 </table>px; width: 75%"> <table width= "75%" style="margin-left:1%"> <tr> <td> @html.captcha("refresh", "enter captcha", 5, "is required field.", true)<div style="color: red;">@tempdata["errormessage"]</div> </td> <td> <div id="qrcode" style="width: 200px; display: none"> <img src="@url.action("qrcode", "qr

pyglet - Python install of setup.py files not running 2to3 -

recently, when trying install pyglet module opengl in python, have run problem. appears when running setup.py file, not converted 2to3. due issue, unable use pyglet in python 3 due errors python 2 code contained in pyglet. appreciated thanks. use 1.2alpha1 release, has python 3 support.

c# - MVC model binding - abstract collection properties -

not duplicate, see appended clarification i bind model setup following public class shop{ public string name {get;set;} public icollection<product> products {get;set;} //product abstract } public abstract class product{ public string name {get;set;} } public class producta : product{ public string foo {get;set;} } public class productb :product{ public string bar {get;set;} } and controller so public actionresult(){ shop model = shopfactory.getshop(); return view(model); } [httppost] public actionresult(shop model){ //.... } i'm using begincollectionitem bind collection, problem arrises when posting form cannot create abstract class - namely objects inside shop.products i've looked @ subclassing defaultmodelbinder override createmodel createmodel never called argument modeltype = product , modeltype = shop how create modelbinder bind object has abstract collection property? clarification question not duplicate be

Event display in php with date difference -

i want display event using date difference.. example i'm having 3 fields in table ie. start_date , end_date, publish_date. event should publish publish_date end _date.. how query , result. 1 pls use between keyword: "select * table_name date between '" . $publish_date . "' , '" . $end_date . "' also if want give format below select * table_name date str_to_date(date, '%m/%d/%y') between str_to_date(publish_date, '%m/%d/%y') , str_to_date(end_date, '%m/%d/%y') hope sure you

ios - Check how many users launch my apple application on their devices? -

this question exact duplicate of: customer reviews , app analytics on apple store ? [closed] 2 answers i have published application on apple store, , hope know how many users launch application on devices. but how can know it? need implement sort of code in application? if yes, implement next version, because first version on apple store? need help, thank you! you can use google analytics counting active users using below code id<gaitracker> tracker = [[gai sharedinstance] trackerwithtrackingid:google_tracking_id]; if want check unique users can use flurry or can web service.

android - Close all activities and come to mobile's home screen -

when press log out button , come start(main) screen , when press button main screen comes 2nd screen. but, want close application on click of button main screen , close activities before that. while doing research found, intent intent = new intent(this, home.class); intent.setflags(intent.flag_activity_clear_top); finish(); but not satisfying requirement. you can use code referred here how exit application , show home screen? : intent intent = new intent(intent.action_main); intent.addcategory(intent.category_home); intent.setflags(intent.flag_activity_new_task); startactivity(intent); although android's design not favor exiting application choice. related links: how close android application? android exit application

C Strings Comparison with Equal Sign -

i have code: char *name = "george" if(name == "george") printf("it's george") i thought c strings not compared == sign , have use strcmp . unknown reason when compile gcc (version 4.7.3) code works. though wrong because comparing pointers searched in google , many people it's wrong , comparing == can't done. why comparing method works ? i thought c strings not compared == sign , have use strcmp right. i though wrong because comparing pointers searched in google , many people it's wrong , comparing == can't done that's right too. so why comparing method works ? it doesn't "work". appears working. the reason why happens compiler optimization: 2 string literals identical, compiler generates 1 instance of them, , uses same pointer/array whenever string literal referenced.

how to convert string into it's "html" ascii code using Java? -

e.g. &#66; uppercase b. if have string "boy". want converted &#66;&#79;&#89; i'm hoping there's library can use. i've searched net didn't see it. thanks you try writing own utility: string input = "boy"; char[] chars = input.tochararray(); stringbuilder output = new stringbuilder(); (char c : chars) { output.append("&#").append((int) c).append(";"); } output content after execution: &#66;&#79;&#89;

jquery ui - using JQueryUI DateTimePicker with Knockout -

in continuation of knockout js bind datetimepicker gives exception able use datetimepicker knockout unable use time picker option of same tool code have tried embedded following jsfiddle throwing error <code> http://jsfiddle.net/saqibshakil/scdet/ </code> check console after edit looks calling getdate on timepicker not return actual date . it appears can call using datetimepicker successfully. so, binding like: ko.bindinghandlers.timepicker = { init: function (element, valueaccessor, allbindingsaccessor) { //initialize timepicker optional options var options = allbindingsaccessor().timepickeroptions || {}; $(element).timepicker(options); //handle field changing ko.utils.registereventhandler(element, "change", function () { var observable = valueaccessor(); observable($(element).datetimepicker("getdate")); }); //handle disposal (if ko removes t

javascript - how can put a variable ID into asp.net code inside java script? -

i'm trying turn textbox enable , disable depends on checked checkbox java script, there anyway this? here code <script type="text/javascript"> function ed1(benable, textboxid, textboxid2) { document.getelementbyid("<%= textboxid.clientid %>").disabled = !benable document.getelementbyid("<%= textboxid2.clientid %>").disabled = !benable } </script> here checkbox , text box <asp:checkbox id="ch0" runat="server" font-names="tahoma" onclick="ed1(this.checked, 'tb1', 'tb2');" font-size="x-small" style="font-size: 12px; right: 20px; color: #006699; font-family: tahoma; position: absolute; top: 25px; width: 80px;" /> <asp:textbox id="tb0" runat="server" enableviewstate="false" height="12px" maxlength="2" style="font

ios - Proper way of preventing GPU access with Core Image when app is in background -

i'm experiencing crashes customers, following backtrace: 0 libgpusupportmercury.dylib 0x3542ae2e gpus_returnnotpermittedkillclient + 10 1 imgsgx543rc2gldriver 0x30bbf5e5 submitpacketsifany + 245 2 glengine 0x32f827db glfinish_exec + 167 3 coreimage 0x31fb85b7 ci::glescontext::recursive_render(ci::node const*, cgrect, bool) + 219 4 coreimage 0x31fbb351 ci::glescontext::render(ci::node*, cgrect) + 41 5 coreimage 0x31fc2901 ci::image_get_cgimage(ci::context*, ci::image*, cgrect, cgcolorspace*, ci::pixelformat) + 1313 6 coreimage 0x31fa8427 -[cicontext createcgimage:fromrect:format:colorspace:] + 487 7 coreimage 0x31fa81e9 -[cicontext createcgimage:fromrect:] + 89 8 app 0x0013c9db -[pztiledimagelayer drawincontext:] (pztiledimagelayer.m:129) which