Posts

Showing posts from March, 2014

python - Stopping ipcluster engines (IPython Parallel) -

how stop engines have been started with: ipcluster engines --n=8 --daemonize the running processes like: /usr/bin/python /usr/local/bin/ipcluster engines --n=8 --daemonize /usr/bin/python -m ipython.parallel.engine --profile-dir /home/ubuntu/.ipython/profile_default --cluster-id --log-to-file --log-level=20 i not want run killall python . from client, can call shutdown : import ipython.parallel ipp rc = ipp.client() # shutdown specific engines rc.shutdown([1, 5]) # shutdown engines: rc.shutdown() # shutdown everything, including hub rc.shutdown(hub=true)

model view controller - Trying to Delete Message from List with Rails -

so have simple list of messages users can submit. i'm trying put delete button (that works) each message. can see here error entirely different action if click button. i'm not totally sure went wrong. guess i'm out of depth in controller area. here applicable files. routes.rb: rails.application.routes.draw root 'messages#index', as: :home '/new' => 'messages#new', as: :edit resources :messages post '/new' => 'messages#create', as: :create delete 'messages/:id' => 'messages#destroy', as: :delete the relevant controller: class messagescontroller < applicationcontroller def index @messages=message.all end def new @messages=message.new end def destroy @messages=message.find(params[:id]) @messages.destroy end def create @messages = message.new(message_params) if @messages.save redirect_to '/'

Azure Mobile Service requires authentication for SignalR HTML/Javascript Client -

i have fresh azure mobile service running locally @ localhost:52253. installed latest signalr nuget package: azure mobile services .net backend signalr extension 1.0.450 i have test html/javascript client served localhost:54697/ after working out cors issues, still cannot connect signalr hubs because negotiation requests signalr javascript client mobile service @ localhost:52232/signalr/negotiate result in http/1.1 401 unauthorized. i have not enabled authentication on server, default. confirmed webapi controller works without authentication. i've tried decorating hub , hub methods with: [authorizelevel(authorizationlevel.anonymous)] public class chathub : hub { public apiservices services { get; set; } [authorizelevel(authorizationlevel.anonymous)] public string send(string message) { return "hello signalr chat hub!"; } } the exact request via fiddler is: http://localhost:52253/signalr/negotiate?clientprotocol=1.4&connect

php - Zend Framework 2 Application inside Zend Framework 1 Application and Session Sharing -

before explaining situation, here small briefing of system running , overall experience web programming: development environment: ubuntu server 4.14 64-bit, apache 2, php , mysql database. experience: not have experience php, main language using current project (it has been 3 years since last worked web programming; these last few years focus on development of desktop apps). i developing new website company , of application code ready. application developed in zend framework 2 (php) + doctrine 2. few aspects missing, are: 1 - client has website works educational social network focused on providing platform students , teachers interact , share knowledge , ideas. work related development of new interface defined 'relational-modular interface' consisting in new way of displaying information users of platform. website client has developed in zend framework 1, , need new application coexist old application in same domain. far good. the question is: these frameworks have

javascript - unable to print parameters from url -

i'm trying read 4 parameters js request django app. how i'm doing js request: site = "http://127.0.0.1:8000/products/loginfo/" + account + "?userid=" + userid + "&sessionid=" + sessionid + "&url=" + url; httpget(site); this url in urls.py: url(r'^loginfo/(?p<siteid>[0-9])/(?p<userdid>)/(?p<sessionid>)/(?p<url>)/$', 'log_info', name='log_info'), and view in views.py: def log_info(request,siteid,userdid,sessionid,url): print 'siteid' + str(siteid) print 'userid ' + str(userid) print 'sessionid ' + str(sessionid) print 'url ' + str(url) return render_to_response("products/all.html", locals(), context_instance=requestcontext(request)) but, i'm nothing being printed on terminal, what's wrong? the problem url pattern in url.py doesn't match url entered. you can use request.get dictionary directly read que

haskell - How to parse a tree-like structure using PArrows? -

i'm trying learn arrows, how parrows can replace parsec, there nonexistent number of tutorials. believe benefit lot simple examples, so, given binary tree: data tree = node tree tree | | b deriving show how can parrow used parse string similar to: "((a b) (a (b a)))" so becomes: node (node b) (node (node b a)) this not cleanest answer, managed with: import text.parsercombinators.parrow import control.arrow data tree = node tree tree | | b deriving show text = "((b a) (a b))" fromtoken :: char -> tree fromtoken 'a' = fromtoken 'b' = b token = anyof "ab" >>> arr fromtoken node = arr (uncurry node) <<< ((char '(' >>> token <+> node) -- left side >>! white -- whitespace &&& ((token <+> node) >>! char ')')) -- right side main = print $ runparser node text mind i'm still working on ar

Storing a lambda function in the Google App Engine Datastore (python 2.7) -

i creating bunch of foo objects in gae. i want each foo have function called fooify(). calling fooify(object) should return object, transformed in way. for example, fooify([2,3]) might return: [1,2] (fooify = lambda x: [n-1 n in x]) [2,3] (fooify = lambda x: x) [2,4] (fooify = lambda x: [x[0],x[1]+1]) i want able define fooify when create objects, preferably like: foo1=foo() foo1.fooify=lambda x: [n^2 n in x] foo1.put() the foo class looks like: from google.appengine.ext import ndb class foo(ndb.model): name=ndb.stringproperty(default="generic foo", indexed=true) fooify=ndb.somethingproperty(indexed=false) # contains function i know isn't datastore made for, still it. option can see following: class foo(ndb.model): name=ndb.stringproperty(default="generic foo", indexed=true) fooify_str=ndb.stringproperty(indexed=false) # contains "lambda x: [n+3 n in x]" def fooify(self,obj): func = eval(self

mysql - PHP script cannot access database in sql -

i trying connect mysql database through php script. gives me error mysql_error() : access denied user '@localhost' database 'userinfo' userinfo database. my script this <?php $servername = "localhost"; $username = "root"; $password = "'mm'"; $database = "userinfo"; $conn = mysqli_connect($servername, $username, $password); if (!$conn) { die("connection failed: " . mysqli_connect_error()); } echo "connected successfully<br>"; mysql_select_db($database) or die(mysql_error()); echo "connected db:" . $database . "<br>"; ?> you connecting using mysqli_ function , selecting data with mysql_ avoid using both @ same time. since they're incompatible. use mysqli_ alternative instead mysqli_select_db($conn, $database); and mysqli_error($conn)

css - How to a make a Bootstrap button full width? -

this have right now. can't become full width almost full width this html. i've tried adding .btn-block class same results if used width: 100%; in css. maybe problem parent element? <article class="col-xs-12 col-md-4"> <div class="label label-success price"><span class="glyphicon glyphicon-tag"></span>$39</div> <div class="price-title"> <h3>lorem</h3> <small>lorem ipsum</small> </div> <div class="price-content "> <ul> <li><h4>item or service # 1</h4></li> <li><h4>item or service # 2</h4></li> <li><h4>item or service # 3</h4></li> <li><h4>item or service # 4</h4></li>

In Lisp is the function `1+` just syntactic sugar? -

i started learning lisp. 1 of first concepts grasp seems prefix notation (i.e. instead of writing "1 + 2", write "+ 1 2"). trying work out why 1+ function exists. what reason prefer (+ 1 2) or (1+ 2) ? is syntactic sugar? code optimisation? readability? perhaps there more complex function call examples show why 1+ function exists. insight appreciated. do remember part of common lisp standardizing many implementations had. so, if many implementations had 1+ function, have been enough include it. rainer's answer quotes cltl2 on which implementations had (maclisp , lisp machine lisp). why implementations have had in first place? it's useful in loops, e.g., (do ((x 0 (1+ x))) ((= x 10)) ; ... ) that's place (+ x 1) have been fine, too. there lots of cases it's handy call kind of function indirectly, , it's easier (mapcar '1+ …) (mapcar (lambda (x) (+ 1 x)) …) . but that's it. adding 1 (or subtra

node.js addon - how to pass a string parameter to (nan) C++ -

my node.js code : var mymq = require( './build/release/mqconn' ) ; var myqmgrname = 'qm_cnt' ; // req.params.qmgrname ; mymq.connect ( myqmgrname, function ( err, result ) { and c++ code (uning nan) wants receive first string parameter : nan_method( mq_connect ) { nanscope(); local<value> szqmn( args[ 0 ] ); printf( "(cc)>>>> qmn [%s].\n", szqmn ) ; ... garbage. any clue on doing wrong ? sebastian. first should validate arguments. can string calling tostring() on argument. example: nan_method(mq_connect) { nanscope(); if (args.length() > 0) { if (args[0]->isstring()) { string::utf8value str(args[0]->tostring()); printf("(cc)>>>> qmn [%s].\n", (const char*)(*str)); } }

python - Losing float precision in for loop -

this question has answer here: what best way compare floats almost-equality in python? 11 answers i have list of floats taken sqlite3 db. want find first 2 numbers greater number, 18 in case, , enumerate position in db. the db list: pr = [(20.49999999999983,), (16.29999999999967,), (13.799999999999102,), (18.600000000000705,), (9.600000000000364,), (11.599999999999966,), (25.30000000000001,)...] hence try following: fnd =([i[0] in pr if i[0] > 18]) >>> [20.49999999999983, 18.600000000000705, 25.30000000000001] j in fnd: print ([i i,k in enumerate(pr) if k == j]) for 3 empty lists. assuming problem comes fact float being rounded when use loop. for j in fnd: print j >>>20.5, 18.6, 25.3 can offer workaround? k takes values of elements of pr , 1-tuples containing numbers. j takes values of elements of fnd , const

android - Passing dynamic string resource to "Toast" -

i trying pass dynamic string "toast" . i made customized function : private void maketoast(string message) { toast.maketext(this, message, toast.length_long).show(); } and able use function pass toast messages : maketoast("you must enter pin code authentication."); what trying achieve pass dynamic string . declared in strings.xml : <string name="must_pin">you must enter pin code authentication</string> and tried pass : maketoast(r.string.must_pin); but not accept , says cannot accept "int" .... how can pass maketoast . right format ? the way have it, passing reference id. need use getstring() maketoast(getstring(r.string.must_pin));

cocoa - How do I run a function with a parameter every 5 seconds in Swift? -

i want execute following function every 5 seconds. have seen other answers related questions use nstimer.scheduledtimerwithtimeinterval works functions without arguments. the function: func sayhello(name: string) { println("hey \(name)!") } this code tried: var timer = nstimer.scheduledtimerwithtimeinterval(5.0, target: self, selector: selector("sayhello(\(name))"), userinfo: nil, repeats: true) but crashes app error: terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[jake.swiftapp sayhello(jake)]: unrecognized selector sent instance 0x7fcd515640a0' how run function 1 input parameter? the problem is, when set selector nstimer fire, have pass name of method. right now, you're dynamically building string , trying point method called: "sayhello(jake)" which doesn't exist. in fact, in can't exist. doesn't make sense. the sayhello() fun if you're addin

Correct way to use git push -f -

$ git branch master *branch1 $ git push -f and on wrote origin/master local stale master. correct way use git push -f ? git push -f origin branch1 this force push branch1 , not master.

amazon web services - AWS RDS on Eclipse -

i know question seems repeat, it's not , have tried solutions find problem: i running aws rds instance database. works fine when connect using aws ec2 instance(uses linux) when try laptop, doesn't work. want work on eclipse( code on laptop , test on ec2 instance, annoying , very inconvenient). here error. com.mysql.jdbc.communicationsexception: communications link failure due underlying exception: ** begin nested exception ** java.net.connectexception message: connection timed out: connect stacktrace: java.net.connectexception: connection timed out: connect @ java.net.dualstackplainsocketimpl.connect0(native method) @ java.net.dualstackplainsocketimpl.socketconnect(unknown source) @ java.net.abstractplainsocketimpl.doconnect(unknown source) @ java.net.abstractplainsocketimpl.connecttoaddress(unknown source) @ java.net.abstractplainsocketimpl.connect(unknown source) @ java.net.plainsocketimpl.connect(unknown source) @ java.net.sock

How to make PyCharm's Project Files window display class/method names -

today company's department installed bunch of system updates on windows computer, , in process blew away pycharm ide's memory of projects , related them. (this pycharm ce v4.5.1.) i've rebuilt project i'm working on now, , (so far) couple of run configurations. however, pycharm's project files window no longer displays classes , methods defined in each file. relied heavily on feature navigation, , can't find procedure recovering it. suggestions? i found can make project window display classes , methods (and functions outside classes) this: select project (not project files) option in leftmost dropdown. select "show members" in "tools" (gear icon) dropdown. the "show members" name threw me off because i'm not accustomed thinking of files having "members." job, though.

ios - Dismissing multiple view controllers showing wrong view during transition -

i have total of 4 uiviewcontrollers. each of views has button when pressed presents next viewcontroller. when button on last uiviewcontroller pressed calls dismissviewcontrolleranimated(true, , completion: nil) on rootviewcontroller. when called shows view #2, instead of staying view #4, transitions view #1. in documentation says when top-most view view animated during dismissing, that's not case me? happens if used segues. class viewcontroller1: uiviewcontroller { @ibaction func btndidtouch(sender: anyobject) { var viewcontroller = self.storyboard!.instantiateviewcontrollerwithidentifier("viewcontroller2") as! uiviewcontroller self.presentviewcontroller(viewcontroller, animated: true, completion: nil) } } class viewcontroller2: uiviewcontroller { @ibaction func btndidtouch(sender: anyobject) { var viewcontroller = self.storyboard!.instantiateviewcontrollerwithidentifier("viewcontroller3") as! uiviewcontroller se

python - How to merge two DataFrames of unequal size based on row value -

i have 2 pandas dataframes of type dataframe 1 index name property1 property2 0 ("a","b") 1 2 1 ("c","d") 3 4 2 ("e","f") 5 6 and second 1 , has common values , not @ same index ( dont care about). dataframe 2 index name property3 property4 0 ("g","h") 7 8 1 ("i","j") 9 10 2 ("k","l") 11 12 3 ("a","b") 13 14 4 ("c","d") 15 16 5 ("e","f") 17 18 is there way these combined such resultant dataframe common rows name shared between tables? i.e result of pandas operation should be result frame index name property1 property2 property3 property4 0 ("a","b") 1 2 13 14 1 ("c","d") 3

Can iOS protocols enforce notifications to be implemented? -

in protocol definition, ios dev page ( https://developer.apple.com/library/ios/documentation/mediaplayer/reference/mpmediaplayback_protocol/ ) lists mpmediaplaybackispreparedtoplaydidchangenotification notification. my understanding class adhering protocol should implement properties , methods. notification? optional? the apple page on protocols ( https://developer.apple.com/library/ios/documentation/cocoa/conceptual/programmingwithobjectivec/workingwithprotocols/workingwithprotocols.html#//apple_ref/doc/uid/tp40011210-ch11-sw1 ) doesn't talk notifications.

python - Getting a pdf from scipy.stats in a generic way -

i running goodness of fit tests using scipy.stats in python 2.7.10. for distrname in distrnamelist: distr = getattr(distributions, distrname) param = distr.fit(sample) pdf = distr.pdf(???) what pass distr.pdf() values of best-fit pdf on list of sample points of interest, called abscissas ? to evaluate pdf @ abscissas , pass abcissas first argument pdf . specify parameters, use * operator unpack param tuple , pass values distr.pdf : pdf = distr.pdf(abscissas, *param) for example, import numpy np import scipy.stats stats distrnamelist = ['beta', 'expon', 'gamma'] sample = stats.norm(0, 1).rvs(1000) abscissas = np.linspace(0,1, 10) distrname in distrnamelist: distr = getattr(stats.distributions, distrname) param = distr.fit(sample) pdf = distr.pdf(abscissas, *param) print(pdf)

angularjs - how to test inner controller which loads data for select control in angular-formly -

i have ui-select field { key: 'data_id', type: 'ui-select', templateoptions: { required: true, label: 'select label', options: [], valueprop: 'id', labelprop: 'name' }, controller: function($scope, dataservice) { dataservice.getselectdata().then(function(response) { $scope.to.options = response.data; }); } } how can access inner controller in unit tests , check data loading select field works ? update: example of test such: var initializepagecontroller = function() { return $controller('pagectrl', { '$state': $state, '$stateparams': $stateparams }); }; var initializeselectcontroller = function(selectelement) { return $controller(selectelement.controller, { '$scope': $scope }); }; then test case looks like: it('should able list of data....', function() { $scope.to = {}; var vm = initializepagecontroller(); $httpback

image - Does imshow have side effects in Matlab? And how can I resolve them? -

i have 2 axes let's a1 , a2 , , on a2 have image displays imshow , on a1 display entirely different imagesc , , produces different result color-wise when a2 used. here example code, shortest example: a = zeros(1); [b,bmap] = imread('f.bmp'); c = figure(); d = axes('parent',c,'position',[0,0,.5,1]); e = axes('parent',c,'position',[.5,0,.5,1]); axes(d); imagesc(a); pause(); axes(e); imshow(b,bmap); pause(); cla(d); axes(d); imagesc(a); figure(); axes(); imagesc(a); the image displays differently after b shown, when displayed in different figure displays normally. how can fix this? after digging in think because providing map, bmap imshow causes figure.colormap value change, can fixed typing colormap default after imshow command.

login - Google SignIn State -

i'm trying build google signin button website. i'm trying avoid using built-in button. code below works sign in user, can't figure out how make webpage remember they're signed in when user refreshes page, or leaves site , comes back. using chrome's developer tools, can see there's entry https://accounts.google.com under both local storage , session storage . seem more or less contain same information, including user's validated token. what don't understand how gapi.auth2.init() function recognize , use token. documentation doesn't seem cover it. <html> <head> <title>login test</title> <script src="http://code.jquery.com/jquery-2.1.4.js"></script> <script src="https://apis.google.com/js/platform.js?onload=renderbutton" async defer></script> </head> <script> var googleuser = {}; function renderbutton() {

Laravel, why do I have so many queries? -

controller $attendees = attendee::with('user')->get(); return view::make('admin.attendees.index', compact('attendees')); attendee model public function user() | if( !( $user->hasrole('admin') || $user->hasrole('programmer') )) { | return redirect::to('/'); return $this->belongsto('user');

html - Understanding the CSS child selector > -

in tests, styles div > ul rule applied div ul li ul elements. why > child selector not enforced? i have solution this, want understand why need use solution. in css, understand a b select every element matches b descendant of element matches a . a element can appear anywhere in hierarchy above b element. i thought understood a > b select elements match b if immediate child of element matches a . a element must direct parent of b element. however, in test below, style font-weight: bold; applied ul items, not immediate children of div element. prevent style being applied, need first set conflicting style, color property. what logic in css makes work way does? div ul { color: black; } div > ul { font-weight: bold; color: red } <div> <ul> <li>red , bold 1</li> <li>red , bold 2</li> <li>red , bold 3 <ul> <li>black , bold 1</li> &

javascript - Load local files using iframe -

i tried load files using iframe , didn't work. i want load file from: c:/users/tom/desktop/courses/c2.pdf , tried: <iframe src="file:///c:/users/tom/desktop/courses/c2.pdf"></iframe> but nothing appears. how can load local files using iframe or else? thanks. this because of same origin policy: in case iframe not allowed load resource if not served localhost. see https://developer.mozilla.org/en-us/docs/web/security/same-origin_policy more info

ios - How to proportinally size the image based on the iphone is using -

let have large image (400wx700h) pixels. want image centered on iphone , take 1/4 of display area. doesn't matter if iphone 4 or iphone 6+, still want image centered , take 1/4 of display area. also, want design in storyboard , using constraints, no coding. know how center image, not sure 1/4 portion. can please guide me? thanks borna create constraints equal width , height super view, , set multiplier in each constraint 0.25

qt - Deploying to Android results in file not found after adding QtQuick Controls -

after importing qtquick.controls 1.2 , using stackedwidget component, error when deploying android seen below. missing file animationdrawable.qml not missing android build directory not understand why not packaged apk. it deploys fine when remove imported qtquick.controls , replace stackview else. my qt version 5.4.2. i tried deploying qt 5.3.2 , works expected. e/qt (12767): can't create main activity e/qt (12767): java.io.filenotfoundexception: --added-by-androiddeployqt--/qml/qtquick/controls/styles/android/drawables/animationdrawable.qml e/qt (12767): at android.content.res.assetmanager.openasset(native method) e/qt (12767): at android.content.res.assetmanager.open(assetmanager.java:313) e/qt (12767): at android.content.res.assetmanager.open(assetmanager.java:287) e/qt (12767): at org.qtproject.qt5.android.bindings.qtactivity.copyasset(qtactivity.java:394) e/qt (12767): at org.qtproject.qt5.android.bindings.qtac

php - Updating different forms at the same time -

Image
current situation so, follow question previous question ( submit button affect multiple files ) the approach in terms of how "click" multiple buttons using "super-button" (patent pending) @omikey. supposed do, clicking buttons. the mark up following: title.php <form role="form" method="post"> <div class="edit_title"> <input type="hidden" value="<?php echo $post_id; ?>"> <?php post_input_box( $post_id, 'post_title', array( 'placeholder' => 'article title..', 'value' => $post->post_title ) ); ?> <div class="update-button-wrap"> <input id="save_button" type="submit" name="update_product" value="<?php esc_attr_e( 'update', 'site' ); ?>"/> </div>

python - ValueError: invalid literal for float(): when inserted substring from "2015-05-21T18:11:55" into dataframe -

i have key value pair in json-derived dictionary looks this: u'local_start_time': u'2015-05-21t18:11:55.000z' when try insert portion of string dataframe error: file "fix_runs_prepare.py", line 63, in <module> df.set_value(i, name, str(g[name])[0:19]) file "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 1679, in set_value engine.set_value(series.values, index, value) file "pandas/index.pyx", line 118, in pandas.index.indexengine.set_value (pandas/index.c:3382) file "pandas/index.pyx", line 132, in pandas.index.indexengine.set_value (pandas/index.c:3264) file "pandas/src/util.pxd", line 60, in util.set_value_at (pandas/index.c:15472) valueerror: invalid literal float(): 2015-05-21t18:11:55 this when inserting using call: run_info = df['run_info'] in range(len(df['run_info'])): g = run_info[i] name in name_list: if g.get(name):

vb.net - Declaring multidimensional array -

i want loop array , fill data. have not been able find out, how declare multidimensional array when don't know width in advance. here's have right now. dim items()() string y integer = 0 object.count - 1 items(y)(0) = "something" items(y)(1) = "something" items(y)(2) = "something" items(y)(3) = "something" items(y)(4) = "something" items(y)(5) = "something" items(y)(6) = "something" next i've been suggested (x, x) i'm not sure how declare without width. how should this? looks want 2-dimensional array keep track of multiple arrays of strings. if know total count of arrays have, this: dim items(object.count - 1, 6) string y integer = 0 object.count - 1 items(y, 0) = "something" items(y, 1) = "something" items(y, 2) = "something" items(y, 3) = &qu

java - Weird behaviour of ListView -

when add item below "add item below" comment shown below, onitemlongclick , listitemclick cannot work. once i've removed items below "add item below", work. what's wrong? <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/caldroid_transparent" android:orientation="vertical"> <linearlayout android:id="@+id/event_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="@dimen/event_list_margin" android:layout_marginbottom="@dimen/event_list_margin" android:orientation="horizontal"

javascript - Calling socket.disconnect in a forEach loop doesn't actually call disconnect on all sockets -

i new javascript world. working on chat application in nodejs. have method called gracefulshutdown follows. var gracefulshutdown = function() { logger.info("received kill signal, shutting down gracefully."); server.close(); logger.info('disconnecting socket.io clients'); if (object.keys(io.sockets.sockets).length == 0) process.exit(); var _map = io.sockets.sockets, _socket; (var _k in _map) { if (_map.hasownproperty(_k)) { _socket = _map[_k]; _socket.disconnect(true); } } ...code here... settimeout(function() { logger.error("could not close connections in time, shutting down"); process.exit(); }, 10 * 1000); } here happening in disconnect listener.the removedisconnectedclient method updates entry in db indicate removed client. socket.on('disconnect', function() { removedisconnectedclient(socket); }); so in case disconnect event wasn

Writing floats to a binary file in C++ | Equivalent of Java's DataOutputStream.writeFloat() -

i'm porting code java c++ , need write floats binary file. in java use dataoutputstream.writefloat() . how do in c++? i tried method doesn't work: std::ofstream out; out.open(somepath, std::ios::out | std::ios::binary); float f = 0.5; out.write(reinterpret_cast<const char*>(&f), sizeof(float)); java's default behaviour write files (and other data streamed io) in big endian . c++ writes files in native format. on standard x86-derived pc native little endian, 0.5 get: 0x00 00 00 3f in c++ and 0x3f 00 00 00 in java. in order write files can read both, have establish endian output files use , 1 of programs have reverse endian.

sharding - how to clear out garbage tables from broken mongodb shard -

i trying remove remains of data shard proved slow useful. programming error produced bunch of databases have bogus names: mongos> db.runcommand( { removeshard: "shard0002" }); { "msg" : "draining ongoing", "state" : "ongoing", "remaining" : { "chunks" : numberlong(0), "dbs" : numberlong(30) }, "note" : "you need drop or moveprimary these databases", "dbstomove" : [ "*�\u000f", "m�\u0006", "ed_tione_tr�\u0002", "sns�\u0002", "sns�\u0002", "sns�\u0002", "sns�\u0002", "sns�\u0002", "sns�\u0002", "sn�\u0002", "sn�\u0002", "sn�\u0002", "sn�\u0002&q

html5 - Pass image between canvas with Webrtc -

i have found similar question doesn't seem answer question. have html5 canvas , use pubnub webrtc. want pass image between canvas data here passed http://pubnub.github.io/codoodler/history.html . ideas? (please add example answer if possible) ! function() { function a(a) { q.publish({ channel: 'mychannel12', message: }) } function b(a, b) { h.strokestyle = a, h.beginpath(), h.moveto(b[0].x, b[0].y); (var c = 1; c < b.length; c++) h.lineto(b[c].x, b[c].y); h.stroke() } function c(a) { !a || a.plots.length < 1 || b(a.color, a.plots) } function d(a) { if (a.preventdefault(), r) { var c = j ? a.targettouches[0].pagex - g.offsetleft : a.offsetx || a.layerx - g.offsetleft, d = j ? a.targettouches[0].pagey - g.offsettop : a.offsety || a.layery - g.offsettop; s.push({ x: c << 0, y: d

angularjs - Convert .ajax to $http - Method not Allowed (405) -

i attempting convert .ajax $http use in angular app, throwing "method not allowed" error. believe missing obvious, can't figure out failing. here .ajax version: function uploadfilesync(spweburl , library, filename, file) { var reader = new filereader(); reader.onloadend = function(evt) { if (evt.target.readystate == filereader.done) { var buffer = evt.target.result; var completeurl = spweburl + "/_api/web/lists/getbytitle('"+ library +"')" + "/rootfolder/files/add(url='"+ filename +"',overwrite='true')?" + "@targetlibrary='"+library+"'&@targetfilename='"+ filename +"'"; $.ajax({ url: completeurl, type:

How do i add a marker on maps in android programming -

Image
so reason when try adding marker geopoint, marker fails show @ given location. tried researching problem reason code seems follow researched on. can guide me in right direction? import android.content.context; import android.location.criteria; import android.location.geocoder; import android.location.location; import android.location.locationmanager; import android.support.v4.app.fragmentactivity; import android.os.bundle; import android.util.log; import android.widget.toast; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.supportmapfragment; import com.google.android.gms.maps.model.cameraposition; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.markeroptions; import java.text.decimalformat; public class mapsactivity extends fragmentactivity { private googlemap mmap; // might null if google play services apk not available. @override protected void

Using Javascript function parameters with onClick in photoshop dialog not working -

i've got script here (it's alot, sorry): var dlg = new window('dialog', 'templates',[1100,540,1465,720]); dlg.btnpnl = dlg.add('panel', [20,15,345,155], 'please select template:'); dlg.btnpnl.shoes = dlg.btnpnl.add('button', [20,55,300,45], 'shoes, hats , belts', {name:'ok'}); dlg.btnpnl.bags = dlg.btnpnl.add('button', [20,85,300,45], 'bags , pouches', {name:'ok'}); dlg.btnpnl.shoes.onclick = extendcanvas(0.035, 1.035) dlg.btnpnl.bags.onclick = extendcanvas(0.221, 1.221) dlg.show(); function extendcanvas(negative, positive) { #target photoshop var doc = activedocument; var docwidth = activedocument.width; var docheight = activedocument.height; var docname = activedocument.name; var guides = activedocument.guides; // if width longer height, extend height if(docheight/ docwidth < 1.044) { app.preferences.rulerunits = units.pixels app.preferences.