Posts

Showing posts from May, 2011

javascript - Show image before actually uploading it -

i'm using filefield upload image server on form , works fine. but can somehow after user uses browse button load image image field (kind of preview) ? since have no access real full path, didn't find way that... edit: shayan managed proper code this: (in fileupload componentes change event): var file = uploader.fileinputel.dom.files[0]; var reader = new filereader(); reader.addeventlistener('load', function(evt) { form.down('#imglogo').setsrc(evt.target.result); }); reader.readasdataurl(file); you should use filereader api , it... <script> var file=new filereader(); file.readasdataurl(fileinput.files[0]); file.onload=function(evt){ var img=document.getelementbyid("myimage"); img.src=evt.target.result; } </script>

Exposing a property in delphi to C++ from the VCL -

enumallwindowsonactivatehint property tapplication, , according help, should exposed in c++ builder - codegear 2007. not. my difficulty need expose c++ or otherwise set true application. so there different avenues accomplish this, , things i've tried , did wrong: exposed enumallwindowsonactivatehint in forms.pas. however, having difficulty getting change included application/vcl. i've tried i've read on recompiling vcl. nothing has worked. call delphi code can access property c++. something else? i cannot upgrade newer version of codegear, break rtti behavior application relies on. suggestions? solutions? tapplication::enumallwindowsonactivatehint not introduced real c++-accessible property until c++builder 2009. in c++builder 2007, implemented property of class helper instead: tapplicationhelper = class helper tapplication private procedure setenumallwindowsonactivatehint(flag: boolean); function getenumallwindowsonactivatehint: boolean;...

java - How to create sequential number but not ROWID in Android SQLite database? -

i working on app contains android sqlite database. add , delete rows in database. when delete row, based on rowid. found out, despite delete row, rowid remains. example if have 3 rows in database , delete 2nd row, third row not change 2 remains 3. if add row, 4. so question is, how when delete row, , add new 1 number of added row equal deleted row. example if delete first row, database show me next other rows 1,2,3... , not 2,3,4... sorry, maybe little bit complicated, hope makes sense. here code: public hotornot open() throws sqlexception{ ourhelper = new dbhelper(ourcontext); ourdatabase = ourhelper.getwritabledatabase(); return this; } public void close(){ ourhelper.close(); } public long createentry(string name, string hotness) { // todo auto-generated method stub contentvalues cv = new contentvalues(); cv.put(key_name, name); cv.put(key_hotness, hotness); return ourdatabase.insert(database_table, null, cv); } public string getdata() { // todo auto-generated method st...

ios - Will Apple Reject my App on code sign identity selection? -

Image
i have developed ios app now, have submitted app app store approval, in xcode - organizer archive vaidation , distribution done successfully. but in xcode project - target - code signing identity section have selected iphone developer... , selected same option debug , release under code signing identity (see snapshot more details..) is necessary select iphone distribution:compnyname... in project - target - code signing identity section ?? will apple reject app ?? : i surprised if apple doesnt reject it, in fact systems should have rejected , not allowed upload developer profile. distribution profile required app store distribtution. should contact them details.

asp.net - JQuery Edit in Place, No Plugins -

i'm trying use jquery (with no plugins) enable edit in place control. functionality this. on click of paragraph, paragraph converted editable text area. once user clicks out paragraph (loses focus) text saved. i have following code below , part 1 working, when click in editable area textarea rows="10" cols="160 gets generated , can't type. here have $("#para1").click(function () { var textarea = '<div><textarea rows="10" cols="160">' + $(this).html() + '</textarea>'; $(this).html(textarea); $("textarea.textarea").focus(); $("textarea.textarea").blur(function () { var value = $(this).val(); $("#para1").text(value); }); i have tried base code per link below, haven't had success. http://www.unleashed-technologies.com/blog/2010/01/13/jquery-javascrip...

file io - Issue when trying to use getResourceAsStream in java -

Image
so have 2 lines in code follows: inputstream = this.getclass().getclassloader().getresourceasstream("resources/config"); bufferedreader bufferedreader = new bufferedreader(new inputstreamreader(is)); and file structure in eclipse follows (image posted): when try run code, nullpointerexceptions when reaches second line (bufferedreader line). can't life of me figure out why inputstream "is" becoming null. ideas? when using classloader load stream, path using absolute path (so should not use leading / in case) , should start root package. in case under src . so since resource under package qbooksprintfix/resources should access like: getresourceasstream("qbooksprintfix/resources/config")

rounding - PHP round different results -

this question has answer here: php rounding numbers 4 answers hi got problem rounding. ex.: $x = 100; $y = 4.2030; $result = round($x / $y, 2); $result 23.79 but $result2 = round(23.79 * 4.2030, 2); $result2 99.99 , it's incorrect. should 100 ($result2 equal $x) how slove ? your round precision 2 decimal places. if trying whole numbers need omit precision argument: $result2 = round(23.79 * 4.2030); note: lower precision argument, more inaccurate result actual results. you can use ceil() , floor() if looking round in specific direction ( ceil() round up, floor() round down).

java - Bytecode changes over time in undocumented manner -

today exploring classes of huge applications (like jboss server apps) javaagent , instrumentation on openjdk 7. called retransform on classes every 10 seconds, bytecode got in classfiletransformer implementation. my implementation keeps track of how bytecode of classes changes on time. first of all, surprised, order of fields , methods, method access modifiers, contents of constant pool , other such things vary 1 check other. but, still, documented . what not documented - items may created in class'es constant pool , injected methods. noticed happen numeric values (longs, doubles, floats , such). this how looks in javap; before: pool: ... #17 float nanf method: #1 fload #17 //nanf ... after changed class during runtime: pool: ... #17 float nanf #18 float nanf method: #1 fload #18 //nanf <- look, loads #18 i double checked, no other transformers or agents attached. why can't jvm leave bytecode same? can read such optimisations/transformations (or else it)?...

AngularJS ng-class not applying css styles -

i have company site developing angularjs , having troubles ng-class here html: <a href="timeentry.php" ng-class="{{(userrole.admin) ? '' : 'inactive'}}"> link </a> css: .inactive { pointer-events : none; cursor : default; } chrome inspect element: <a href="timeentry.php" ng-class="inactive"> link </a> obviously have tested class="inactive" , working should, chrome's view source appears showing me should working not being applied. assuming userrole.admin boolean, should work <a href="timeentry.php" ng-class="{ inactive: !userrole.admin }"> link </a>

html - IE10 Border Issue w/ Rowspan while printing -

can explain why when printing ie10, borders in following html table not displayed on print-out? even if don't have answer, has else noticed behavior? i've been printing microsoft xps viewer, not display when printing printer. here's similar ie10 print issue, it's not quite problem i'm experiencing: ie 10 missing border segments while printing table elements <!doctype html> <html> <head> <title>broken ie10 print page</title> <style> table { border: 3px solid black; font-size: 8pt; font-family: arial, helvetica, sans-serif; border-collapse: collapse; } th { padding: 2px; border: 1px solid black; } td { padding: 2px; border: 1px solid black; } </style> </head> <body> <table style="width: 975px;"> <thead> <tr> <th>test1</...

javascript - Date.getTime() v.s. Date.now() -

i noticed now() can called date object. gettime() can called instance of date. var dd1 = new date(); //console.log(dd1.now()); //throws error -> typeerror: object mon aug 19 2013 16:28:03 gmt-0400 (eastern daylight time) has no method 'now' console.log(dd1.gettime()); console.log(date.now()); //console.log(date.gettime()); //throws error ->typeerror: object function date() { [native code] } has no method 'gettime' is there formal name difference? difference between "static" , "non-static." when create new instance of date, shouldn't methods inherited? it's difference between properties of constructor object , properties of constructor object's prototype. "now" property property of date constructor itself, , not property of date.prototype . it's opposite situation "gettime". semantically makes sense: concept of "now" independent of particular date instance. "gettime" m...

php - Cakephp paginate based on model method -

in order model have following method sum total price of order's orderitems public function gettotalprice($id = null) { if (!$this->exists($id)) { throw new notfoundexception(__('invalid order')); } $total = $this->orderitem->find('first', array( 'conditions' => 'orderitem.order_id = '.$id, 'fields' => 'sum('.$this->orderitem->virtualfields['total_price'].') total', 'group' => 'orderitem.order_id' )); return $total[0]['total']; } in ordercontroller's view action calling method , setting value send view. in order's index view see paginator links baked fields. <th><?php echo $this->paginator->sort('user_id'); ?></th> but understand it, parameter sort needs actual field on model. there way use paginator helper paginate custom method? or there way make method used virtual...

android - Can you show a public leaderboard without calling to GamesClient.connect()? -

is possible show leaderboard game if user not logged in google plus? i'm using gamesclient, , seems need call connect() first , have them log in: http://developer.android.com/reference/com/google/android/gms/games/gamesclient.html#connect() before can use: http://developer.android.com/reference/com/google/android/gms/games/gamesclient.html#getallleaderboardsintent() but i've noticed vast majority of users don't choose connect. i'm thinking it'd nice show public leaderboard if user not connected. them interested in connecting gplus , competing. thanks this not possible. you can show leader-borads in 2 ways: pre-build intent provided sdk, need call intent , magic arises. , calling gamesclient.loadleaderboardmetadata(...) method returns json leader-boards (then you'll have call gamesclient.loadtopscores() or 1 of variants scores). the problem both methods info public charts , social ones, before getting info, service needs know play...

php - Update query with PDO and MySQL -

im trying write update query pdo cant code execute? try { $conn = new pdo("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb); $conn->exec("set character set utf8"); // sets encoding utf-8 $conn->setattribute(pdo::attr_errmode, pdo::errmode_exception); $sql = "update `access_users` (`contact_first_name`,`contact_surname`,`contact_email`,`telephone`) values (:firstname, :surname, :telephone, :email); "; $statement = $conn->prepare($sql); $statement->bindvalue(":firstname", $firstname); $statement->bindvalue(":surname", $surname); $statement->bindvalue(":telephone", $telephone); $statement->bindvalue(":email", $email); $count = $statement->execute(); $conn = null; // disconnect } catch(pdoexception $e) { echo $e->getmessage(); } your update syntax wrong you meant update row not of them have use where clause target speci...

javascript - D3.js enter() broken for svg shape animation but updates and removes them fine -

building off of malcom mclean's "d3 tips , tricks" update data dynamically , scatterplot tutorials, i'm trying take 2 different csv's of data, , through animation, plot points each when selected (using 2 html buttons). when user hits either button, changetask function moves line, axises, , points accordingly, removes points not in new dataset. however, new points not added (e.g. when new data should have more points current one). wrong .enter() in changetask function. if try code , data, you'll notice points on left missing when hitting reset. full code: <!doctype html> <meta charset="utf-8"> <style> body { font: 12px arial;} path { stroke: red; stroke-width: 2; fill: none; } .axis path, .axis line { fill: none; stroke: grey; stroke-width: 1; shape-rendering: crispedges; } .grid .tick { stroke: lightgrey; opacity: 0.7; } .grid path { stroke-width: 0; } .area { fill: light...

Extract a column from text file - Python -

i'm beginner py. i need extract contents of column 12 huge flat text file every time word found within text file (similar awk '{print $12}' in bash) in python script. so far have (example, not real code): word = a_word a_word in data: column12 = data.split() print(column12[11]) i assumed should start counting 0 opposed 1, though may incorrect. also, for loop correct type of code? thanks! loop on open file object: with open('somefile') infile: line in infile: print(line.split()[11]) so, yes, use for loop , use 0-based indexing.

html5 - Positioning an image in the centre? -

i struggling position image using background auto. have article tag not centre. how fix issue following code? body { background:url('index1.jpg')no-repeat; width:auto; } try this: body { background: url('index1.jpg') no-repeat center center; background-size: cover; } this should center background image , resize accordingly. hope helps. edit (pertaining comment): first off, in order obtain border on element use border , not border-radius . border-radius round edges of element rather add border itself. in order center objects need use margin: auto; . place content in center of parent container. here fiddle of working code: js fiddle in future please attempt little research , figure things out on own. of these solutions found on existing questions on so.

android - Synchronize timestamps across multiple devices -

i'm trying synchronize timestamps between multiple android devices can kick off task @ same time. figure can use timer , set date based on system.currenttimemillis(), problem seems timestamps of multiple devices far enough apart each other i'm not getting precision want. i'm looking @ somewhere in range of 50-100 ms, if possible. 1 idea had use android beam send 1 device's timestamp other device , calculate delta, turns out have timestamp before message sent , received (i.e., longer user waits send, bigger delta be), makes scheme fall apart. how can sync 2 or more devices internal clocks no more 100 ms apart each other? possible without using external server keeps time? any other suggestions techniques across multiple devices close simultaneously possible welcome. why not use gps time? time tags gps pretty accurate. you agree on devices on time , start when gps tells to.

c++ - getting a sub string of a std::wstring -

how can substring of std::wstring includes non-ascii characters? the following code not output anything: (the text arabic word contains 4 characters each character has 2 bytes, plus word "hello") #include <iostream> #include <string> using namespace std; int main() { wstring s = l"سلام hello"; wcout << s.substr(0,3) << endl; wcout << s.substr(4,5) << endl; return 0; } this should work: live on coliru #include <iostream> #include <string> #include <boost/regex/pending/unicode_iterator.hpp> using namespace std; template <typename c> std::string to_utf8(c const& in) { std::string result; auto out = std::back_inserter(result); auto utf8out = boost::utf8_output_iterator<decltype(out)>(out); std::copy(begin(in), end(in), utf8out); return result; } int main() { wstring s = l"سلام hello"; auto first = s.substr(0,3); au...

android - Can not set OnListItemClick on Tab Activity -

i want activity tab bar, , have 5 tab menus. mainactivity includes tabhost that; public class mainactivity extends tabactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.activity_main); string tab_title[] = { "tab 1", "tab 2", "tab 3", "tab 4", "tab 5" }; int tab_drawables[] = { r.drawable.menu_bookmark, r.drawable.menu_filemanager, r.drawable.menu_download, r.drawable.menu_sharepage, r.drawable.menu_about }; object tab_act[] = { tab1.class, tab2.class, tab3.class, tab4.class, tab5.class }; final tabhost tabhost = (tabhost) findviewbyid(android.r.id.tabhost); tabhost.setup(); tabspec tab_spec; (int = 0; < tab_act.length; i++) { tab_spec = tabhost.newtabspec(tab_title[i]); tab_spec.setindicator(tab_title[i], ...

objective c - my own subclass's delegate methods wrapping around UITextField's delegate methods is crashing my app -

i creating own subclass subclass of uiview uilabel , uitextfield in it. so still want delegate methods of uitextfield function, created own protocol called mylabeledinputviewdelegate wraps around uitextfield 's delegate methods in way: -(bool)textfieldshouldreturn:(uitextfield *)textfield { return [self.delegate inputviewshouldreturn:self]; } and since textfield property of instance of own class, of course set it's delegate this: if (self.delegate) self.textfield.delegate = self; but however, seems if init mylabeledinputview delegate set nil , crashes reason. am setting correctly or there missing? thank much! my designated initializer this: - (id)initwithframe:(cgrect)frame titlerelativelength:(float)length titletext:(nsstring *)text titlebackgroundcolor:(uicolor *)color titletextcolor:(uicolor *)textcolor textfieldbgcolor:(uicolor *)textfieldbgcolor textfieldtextcolor:(uicolor *)textfieldtextcolor delegate...

web services - PHP Curl http code 100 and failing -

i'm trying use web service php curl i'm getting http code "100" , "recv failure: connection reset" error.. tested web service google chrome's extension "postman -rest client" , works perfectly. searched http code , looks server expecting body request data don't know it's expecting me send since i'm not posting data, headers. my code looks this: error_reporting(-1); $header = array('content-length: 1831', 'content-type: application/json', 'authorization: '. $authorization, 'authorization-admin: '. $authorization_admin); $url = 'http://api.bookingreports.com/public/1/analytics/reports/departures'; $ch = curl_init($url); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_httpheader, $header); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlinfo_header_out, true); $result = curl_exec($ch); $errorcode = curl_getin...

c - How to detect signedness with a macro? -

i trying detect if value of integer type family ( char , unsigned char , short , unsigned short , int , ...) negative number in c. if possible macro can compiled compliant c compiler (so, no gcc -tricks allowed) , with no warning ! after time came following: #define isneg(x) ((x) && (x-1) && ((x <= 0) && (~x >= 0))) i tried following examples: void display_result(int arg, int result) { printf("isneg(%d) %stive\n", arg, (result ? "nega" : "posi")); } void display_uresult(unsigned int arg, int result) { printf("isneg(%u) %stive\n", arg, (result ? "nega" : "posi")); } int main () { short shrt = 5; short nshrt = -5; unsigned short ushrt = 5; display_result(shrt, isneg(shrt)); display_result(nshrt, isneg(nshrt)); display_uresult(ushrt, isneg(ushrt)); int ni = -5; int = 5; int 0 = 0; display_result(ni, isneg(ni)); display_result(i, isneg(i)); display_result...

Node.js / Express routing -

i'm new express. way i'm doing routing kicking error. here relevant code: app.js var express = require('express') , routes = require('./routes') , http = require('http') , path = require('path') , firebase = require('firebase'); ... // routing app.get('/', routes.index); app.get('/play', routes.play); index.js , play.js exports.index = function(req, res){ res.sendfile('views/index.html'); }; exports.play = function(req, res){ res.sendfile('views/play.html'); }; this error: error: .get() requires callback functions got [object undefined] it references line in app.js app.get('/play', routes.play); i'm lost why doesnt work because code structure identical routing index page , index page loads perfectly. any ideas? thanks the issue routes.play undefined when function expected. console.log(typeof routes.play); // ... if routes split multip...

vb.net - Subclassing DatagridView, onPaint event -

i subclassing datagridview extend , bind common functionailty. here overrides few (about 10) events , work ok except onpaint event. code: imports system.componentmodel public class xdatagridview inherits datagridview private _selected_row integer protected overrides sub onpaint(byval e system.windows.forms.painteventargs) sel_row = me.currentrow.index + 1 mybase.onpaint(e) end sub <browsable(true)> _ public property sel_row() integer return _selected_row end set(byval value integer) _selected_row = value end set end property end class in main form contains class under _paint event handler selected row common property: mysel_row = mydgv.sel_row when try open designer main form in vbide on place of dgv big red 'x' red border. system.nullreferenceexception: object reference not set instance of object. but if start program works normally. other events class work , doesn't report that. what may cause of erro...

shell - Rename File Based on Portion of Directory Name using zsh -

i rename file in directory based upon portion of directory name. have following structure: sample_1234/all_r2.gz sample_2345/all_r2.gz sample_3456/all_r2.gz in each directory create new file concatenation of multiple other files. name new concated file using number portion of directory name. example, sample_1234/1234_r2.gz sample_2345/2345_r2.gz sample_3456/3456_r2.gz i can return portion of directory name want with: pwd | grep -o '[0-9][0-9][0-9][0-9]' but unable new file name using zmv. suggestions in zsh shell? thanks, don't use find , use zmv . use ( ) pairs grab bits of filename want, , ${1} , ${2} etc reference them. here's folder structure: $ ls **/* sample_1234/all_r2.gz sample_4567/all_r2.gz sample_2345/all_r2.gz sample_6890/all_r2.gz sample_1234: all_r2.gz sample_2345: all_r2.gz sample_4567: all_r2.gz sample_6890: all_r2.gz and here's zmv , assuming you've got loaded : $ zmv -n 'sample_(*)/all_r2.gz' '...

java - Strange error since upgrading to Android 4.2.2 - Activity has leaked IntentReceiver -

i upgraded samsung galaxy tab 2 android 4.2.2 last night, , have since spotted strange errors in logcat didn't appear before 'upgraded'. i hoping highlighting hidden bug or memory leak in application, can't find anything. it seems occur if activity i'm on has spinner , , spinner expanded. the error below. activity uk.co.xxxx.xxxx has leaked intentreceiver com.immersion.android.haptics.hapticfeedbackmanager$hapticfeedbackbroadcastreceiver@41e4bac0 registered here. missing call unregisterreceiver()? has else seen this? think it's safe ignore it's occurring on 1 of devices? --- edit --- and, incidentally, i'm not registering receivers anywhere, there's nothing unregister. i have similar problem , i've asked question on haptic developer's forum , received following reply: the exception see harmless warning , os take care of freeing resources mentioned in exception. in other words, no need worry or it. if n...

Screenshot of entire webpage (localhost) -

i'm having html file on localhost , want screenshot of entire page. know software screenshots entire page (localhost)? found plugins don't support localhost files. press “prtsc” on windows or “command+shift+3/4” on mac take screenshots of visible parts on screen. take screenshot of entire page, can make use of screenshot extensions. safari, awesome screenshot choice. chrome, there multiple snapshot extensions , such nimbus, webpage screenshot, diigo , on. hope helps.

javascript - How do you get webdriverjs working? -

anyone here have experience using selenium , webdriverjs? i'm coming non-java background deal of experience node.js , javascript in general. according selenium docs, have set-up stand-alone selenium server use node web driver. fortunately, seem bundled together. npm install webdriverjs gets jar file standalone selenium server inside node_modules/webdriverjs/bin directory. example tests inside node node_modules/webdriverjs/examples directory tests in them fail when run them either webdriverjs or examples directories. what's missing piece here? what's quickest way , running? i have read docs. note: stack overflow wouldn't let me use tag webdriverjs, webdriverjs, not using selenium java or other languages. update: problem built-in example tests broken! here's did webdriverjs working: step 1: start selenium standalone in laptop running command java -jar selenium-server-standalone-2.33.0.jar . listen http://localhost:4444/ , can acces...

jquery - get text from SPAN element always returns null -

below html structure: <span id="id1" class="classname1" xmlns="http://www.w3.org/1999/xhtml"> <span class="class_2">user created successfully: laksh venkat</span> when try text "user created successfully: laksh venkat" above html have return null or empty using xpath. so have tried using jquery , below code have used: string script = "return document.getelementbyid('id1').text"; but again i'm returned null, tried using .textcontent, .innerhtml. nothing working. suggestion pls??. please tell me how text above html. highly helpful. thanks in advance, regards

How to print the value of a single cell using MySQL and PHP? -

this returns blank page: <?php $con=mysqli_connect("xxx.x.xx.x","user","password","db"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select column table id=1"); print $result; mysqli_close($con); ?> and returns data: <?php $con=mysqli_connect("xxx.x.xx.x","user","password","db"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * table"); while($row = mysqli_fetch_array($result)) { echo $row['column_1'] . " " . $row['column_2']; echo "<br>"; } mysqli_close($con); ?> what wrong first block of code prevents returning data? http://php.net/manual/en/mysqli.query.php tells me mysqli_...

com.android.ddmlib.SyncException: Local path doesn't exist - While compiling app with eclipse -

i following error during compling , running application using eclipse. failed install abc.apk on device '4df11bd574734fd9': local path doesn't exist. [2013-08-20 09:28:04 - abc] com.android.ddmlib.syncexception: local path doesn't exist. [2013-08-20 09:28:04 - abc] launch canceled! the pop in eclipse says that, application contains errors, need fix. have updated eclipse , other related things latest. i followed posts whihc talks resolving error, none of them work me. see once error, bin folder kind of locked , cannot delete it. currently, option left me restart laptop , starts work again tedious , time taking. can suggest me should do? well make it. there program/process has blockep miapp.apk file, when tryed clean app doesn't drop file. stop program/process , delete manually apk file. running great.

file - Ubuntu 12.04 redirection command does not work -

i need stuck logs ffmpeg. so command below. ffmpeg -f rtsp -rtsp_transport tcp -ss 600 -i rtsp://aaa.bbb -vframes 1 out.jpg>aaa_log.list i confirm command makes fine outputs, except ">aaa_log.list" part. it makes file name "aaa_log.list", not write anything. my os ubuntu 12.04 64bit , ffmpeg version 1.2.0. thnaks. try 2> instead of >. ffmpeg writing stderr instead of stdout

c++ - Hexadecimal doubts and C + + -

my question is: why there "--p", understand "++p"function serves climb number of imaginary array pointer, "--p" that? realized without code letters not shown did not understand how works. , more code : #include <stdio.h> using namespace std; int main() { char* p = new char [12]; *p=0x48; ++p; *p=0x65; ++p; *p=0x6c; ++p; *p=0x6c; ++p; *p=0x6f; ++p; *p=0x20; ++p; *p=0x57; ++p; *p=0x6f; ++p; *p=0x72; ++p; *p=0x6c; ++p; *p=0x64; ++p; *p=0x0; ++p; --p; --p; --p; --p; --p; --p; --p; --p; --p; --p; --p; --p; printf(p); delete p; return 0 ; } char *p = _ _ _ _ _ _ _ _ _ _ _ _ /\ initially p points beginning of array shown p++ == ++p == (p = p+1) so moves pointer forward 1 place right . p-- == --p == (p = p-1) so moves pointer back 1 place left .

matlab - Is it possible to have different contour ranges for contourf? -

i have bathymetry data values ranging -7000 0. possible contour different value ranges in single image? example: range -100 10, -1000 -100, -5000 -1000 , -7000 -5000 in single contourf plot. sure – specify vector in second argument, e.g.: z = peaks; contourf(z,[-10 -5 -1 0 1 5 10]); you can use inf , -inf @ extremes make sure capture extrema (or min(z(:)) , max(z(:)) ). in case, use [-7000 -5000 -1000 -100 10] second vector ranges want. not sure why want go +10 when said range of data goes 0 ...

c - Is this a proper for-loop optimization -

for homework assignment need optimize loop run in under 7.5 seconds. think may have done because code runs in 4 seconds. however, worried not doing correctly because instructor told far under 7.5 seconds wrong. worried might not doing things correctly. here original code: #include <stdio.h> #include <stdlib.h> #define n_times 600000 #define array_size 10000 int main (void) { double *array = calloc(array_size, sizeof(double)); double sum = 0; int i; (i = 0; < n_times; i++) { int j; (j = 0; j < array_size; j++) { sum += array[j]; } } return 0; } here optimization: (i = 0; < n_times; i++) { int j; (j = 0; j < array_size/2; j += 20) { sum += array[j] + array[j+1] + array[j+2] + array[j+3] + array[j+4] + array[j+5] + array[j+6] + array[j+7] + array[j+8] + array[j+9]; sum1 += array[j+10] + array[j+11] + array[j+12] + arra...

java - Setting context for development server [playframework 2.1.3] -

i using java / play framework 2.1.3. in production, build war using plugin, serve in tomcat, , tell apache redirect /myapp tomcat app. in development, start server with: play debug run and root dev instance "/". now specify context development instance. example, i'd route /myapp in routes file i'd root still "/", etc. how do this? in play 2.1.x can specify context in application.conf file. application.context="/myapp" ...or can , run local apache instance , same thing in prod :)

ruby - Error with Devise - Cannot run rails s or any devise commands -

i've added gem 'devise' of sudden can no longer run rails s or devise commands without seeing error message: `c:3:in rescue in execute_if_updated': rails::application::routesreloader#execute_if_updated delegated updater.execute_if_updated, updater nil: #<rai s::application::routesreloader:0x276cf60 @paths=["c:/sites/code/omrails/config/routes.rb"], @route_sets=[#<actiondispatch::routing::routeset:0x2ab40c0>]> (runt meerror) c:65535:in `execute_if_updated' c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0.rc2/lib/rails/application/finisher.rb:69:in `block in <module:finisher>' c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0.rc2/lib/rails/initializable.rb:30:in `instance_exec' c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0.rc2/lib/rails/initializable.rb:30:in `run' c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/railtie...