Posts

Showing posts from August, 2011

Ruby on Rails global categories block -

i new ror , don't understand how can make global template put in other template. example have categories module , create sidebar navigation , put @ homepage template. tried way, categories controller method side_nav never called. practice type of problem or should different way? categories/categories_controller.rb def side_nav @categories = category.all end categories/_side_nav.html.erb <ul class="list-unstyled"> <% categories.each |category| %> <li><%= link_to category.title, category.title.downcase %></li> <% end %> </ul> homepage/index.html.erb <%= render 'categories/side_nav' %> you may @ layout/application file. it's global layout in custom project default. , can provide custom layouts in contollers. http://guides.rubyonrails.org/layouts_and_rendering.html

Can Wireshark display info about the size of the data in a POST request? -

as heading states: can wireshark display info size of data in http post request? it better if see size of specific fields submitted in post data. how/can achieved? can wireshark display info size of data in http post request? if "data" mean posted data, then, if post request has content-length: header, yes, can - header. it better if see size of specific fields submitted in post data. that's not easy, although can individual fields of "xxx=yyy" item "urlencoded-form.key" , "urlencoded-form.value" if content-type application/x-www-form-urlencoded.

android - Make scrollbar visible in ionic content when using native scroll -

i using overflow-scroll = "true" make ionic use native scrolling : <ion-content overflow-scroll = "true"> <ion-list> <ion-item ng-repeat="foo in bar"> {{foo.label}} </ion-item> </ion-list> </ion-content> this works great (performances good). problem (vertical) scrollbar disappeared. as per documentation , tried adding scrollbar-y="true" ion-content , didn't work. i tried adding css : ::-webkit-scrollbar { -webkit-appearance: none; } ::-webkit-scrollbar:vertical { width: 11px; } ::-webkit-scrollbar:horizontal { height: 11px; } ::-webkit-scrollbar-thumb { border-radius: 8px; border: 2px solid white; background-color: rgba(0, 0, 0, .5); } ::-webkit-scrollbar-track { background-color: #fff; border-radius: 8px; } ... didn't work either. this article (look "native scrolling") says problem can solved using css, though. ...

javascript - Dependency Injection and Interfaces in Node -

coming c# background, used interfaces base mock objects off of. created custom mock objects myself , created mock implementation off c# interface. how do in js or node? create interface can "mock" off of , interface serve real class able implement interface? make sense in js or or node world? for example in java, same deal, define interface method stubs , use basis create real class or mock class off of. unfortunately you're not going find standard interface part of javascript. i've never used c#, i've used java, , correct me if i'm wrong, looks you're talking creating interfaces , overriding methods both mock testing purposes, being able implement interfaces in other classes. because isn't standard javascript feature, i think you'll find there going lot of broad answers here . however, idea of how popular libraries implement this, might suggest looking @ how angularjs looks @ mock testing (there many resources online, google ...

java - Memory efficient way to initialize a String to be reused inside a loop -

i'm using couple of strings in code going reused within loop , i'm wondering best way initialize string variables improve memory usage: // sample purposes declare map, same thing // applies arraylist, database set, etc. point. map<string, string> samplemap = getmap(); int mapsize = samplemap.size(); // string initialization string a; string b = new string(); string c = ""; for(int = 0; < mapsize; i++){ = samplemap.get(i); b = somefunc(a); c = anotherfunc(a); // stuff strings } after loop, strings no longer used. you cannot optimize initialization or memory usage of strings in snippet of code, several reasons: java strings immutable - cannot change characters inside string, can point new string. in loop, called function (such afunc() or get() ) 1 responsible allocating string, not loop. for advanced programmers: if want optimize memory usage of strings, need use stringbuffer/stringbuilder or raw character array , pass...

objective c blocks - completionHandler definition inside handleEventsForBackgroundURLSession: -

this not trivial question asked here in stackoverflow before, @ least haven’t found similar, of course googled , read of high ranked results. btw, if folks here don't feel comfortable objective c’ s block syntax, visit page please http://fuckingblocksyntax.com , before throwing block related issues. 1st part of question is: the background of declaration of block-parameter, invoking method has block-parameter ( in many cases, completionblock ) the “ callee-method " in myworker class: … ... @implementation myworker -(void) aworkermethodneedsablockinput: ((void)(^)( nsobject *, double )) blockparam { nsobject *anobj=[[ nsobject alloc] init]; double *adouble; [self retrievetimeconsumingresults: anobj withnumberoftry: adouble ]; blockparam ( anobj, * adouble ); } @end the “ caller-method " in mymanager class: @interface mymanager() @property (nonatomic) myworker * mworker; @property (nonatomic, copy) (void)(^mblockproperty)...

console application - load a web page and click a button using c# -

i have requirement automate procedure on web page. open web page find input click on it close web page i achieve of above using c# in console application . dont want open browser, code automate process. i have url web page , id of input element. what c# code should use achieve this.? i think able serve purpose. selenium 1 (selenium rc) : selenium server launches , kills browsers, interprets , runs selenese commands passed test program , , acts http proxy, intercepting , verifying http messages passed between browser , aut. selenium server receives selenium commands test program, interprets them, , reports program results of running tests. the rc server bundles selenium core , automatically injects browser. occurs when test program opens browser (using client library api function). selenium-core javascript program, set of javascript functions interprets , executes selenese commands using browser’s built-in javascript interpreter. the server receives ...

javascript - Appending to current route in Backbone/Marionette? -

i have part of marionette app opening bootstrap modal. when happens, want register opening "navigate" event, using app.navigate("/modal",false); change url. in modal view listening history event close modal (useful android / mobile), append "/modal" current route, instead of root. how can current route/url append "/modal" , call .navigate() function on? thanks! edit: apparently phrase looking here, in terms of web development, "micro-state", explained @ blog here: http://chrisawren.com/posts/implementing-microstates-in-backbone-js the approach suggested bypass backbone history altogether , directly interface html5 history stack, places need fullscreen modal don't want invoke router handling or change url, still want support button. simply router.navigate(router.fragment + "/modal")

Smoothing 3D surface in Matlab -

Image
i struggling optimization of displayed 3d object. want achieve make 3d spectrogram of audio file. what's more want have black , white , nice looking. nice looking means - this: this sample image - aware spectrogram won't that this code used generating surface reduced number of faces: [y,fs,nbits]=wavread('audio.wav'); [s f t]= spectrogram(y(:,1),256,100,256,fs); clear y [x,y]=meshgrid(t,f); z=log10(abs(s)); rskip = round(linspace(1,size(z,1),80)); cskip = round(linspace(1,size(z,2),64)); surf(x,y,z,'facecolor','white','edgecolor','none'); hold on surf(x(rskip,:),y(rskip,:),z(rskip,:),'facecolor','none','meshstyle','row'); surf(x(:,cskip),y(:,cskip),z(:,cskip),'facecolor','none','meshstyle','column'); hold off view(-65.5, 28); the main problem audio file , reason why using reduced number of faces size of x,y,z arrays - 129 269065. pc has 8gb of ram , around 1gb us...

c# - Route attributes range constraint vs range attribute validation -

with new attribute routing , constraints seems border why should use attributes validate dto`s gets blurry more , more. i can range validation on 2 ways - consider first approach has action complex class + weight property - when should use approach , advantages vs other approach? [range(0,500)] public int weight {get;set;} vs [get("{id:range(0, 500)}")] public machine getmachine(int weight) { } the first approach result in bad request. the second approach result in not found request. your last 2 sentences summarize well. in case of [range] , sets validation of input can tell caller request bad. in second, it's defining rules matching url route, used sending requests different routes, not validating input. second useful, example, if have ids of different formats want handle different methods. in short, ux first "i must sending invalid data" , second "i must have wrong url." update : here's demonstration of meant ho...

apache - PHP File edits not taking affect after uploading to the server -

i have php helper class static methods. when add new method or make changes file , afterwards upload server, server not detect changes. error saying fatal error: call undefined method class::functionname() not exist even though exist. i've tried restarting apache server , clearing browser cache. don't have caching setup on server either. if can, connect server ssh , investigation. example, search php file find, see if lies around multiple times, check last modified dates, , of course contents. maybe modify main file of webpage (for example index.php ), verify looking in right place.

reporting services - Drill thru report multivaled paramter passing -

i have report add action drill through report. in target report, have multivalued parameter need pass 2 values to. them literals set, not user selectable or based off of tablix data, can't seem find way this. know =join(field!col.value, ","), have used great success, need pass set value of 8 , 3 recieved target parameter selection of id 8 (works on it's own) , value of 3, if use =8 , 3 or =8 or 3 or =8,3 pass both value parameter, either mathematically adds 2 (value of 11 passed across) or errors in syntax. there method of passing these 2 static values parameter in target report? was able resolve own problem. incredibly mess, modified dataset include fixed value , referenced in parameter split() function send across multiple values.

jquery - How to manage multiple timers in javascript? -

below coding use 1 count timer: var sec = 0; function pad ( val ) { return val > 9 ? val : "0" + val; } function settime() { document.getelementbyid("seconds0").innerhtml=pad(++sec%60); document.getelementbyid("minutes0").innerhtml=pad(parseint(sec/60,10)); } var timer = setinterval(settime, 1000); if have 2 timers, write this: var sec = 0; var sec1 = 0; function pad ( val ) { return val > 9 ? val : "0" + val; } function settime() { document.getelementbyid("seconds0").innerhtml=pad(++sec%60); document.getelementbyid("minutes0").innerhtml=pad(parseint(sec/60,10)); } function settime1() { document.getelementbyid("seconds1").innerhtml=pad(++sec1%60); document.getelementbyid("minutes1").innerhtml=pad(parseint(sec1/60,10)); } var timer = setinterval(settime, 1000); var timer1 = setinterval(settime1, 1000); actually timer use show waiting time of people. n...

regex - Display all lines matching a pattern in vim -

i search particular string in file in vim, , want lines matching string displayed, perhaps in vim window. currently this: search 'string' /string and move next matching string n or n bur, want lines matching string @ 1 place. for example: 1 here string 2 nothing here 3 here same string i want lines 1 , 3 displayed below, highlighting string 1 here string 3 here same string :g/pattern/#<cr> lists lines matching pattern . can :23<cr> jump line 23. :ilist pattern<cr> is alternative filters out comments , works across includes. the command below: :vimgrep pattern %|cwindow<cr> will use vim's built-in grep-like functionality search pattern in current file ( % ) , display results in quickfix window. :grep pattern %|cwindow<cr> does same uses external program. note :grep , :vimgrep work files , not buffers. reference: :help :g :help include-search :help :vimgrep :help :grep :help :cwindow ...

matrix - Quickest distance computation between two large vectors in R -

i wish calculate distance between each element in 1 vector , each element in vector in quickest possible way in r. small example is: distf<-function(a,b) abs(a-b) x<-c(1,2,3) y<-c(1,1,1) result<-outer(x,y, distf) the issue x , y of length 30,000 each , r crashes while trying computation. , doing once, have repeat process 1000 times in simulation study. there quicker functions able achieve this? i need identify of these distances less fixed number/calliper. studying many such fixed callipers eventually, therefore, need save these distances, if computation demanding. function called caliper in r package optmatch process directly, cannot handle such big computation well. here's rcpp version returns integer matrix of 1s , 0s dependent on whether each pair wide comparison <= threshold. on machine took 22.5 secs 30,000 30,000. output matrix little under 7 gb in ram though. fast_cal.cpp #include <rcpp.h> using namespace rcpp; // [[rcpp::expor...

javascript - Using AngularJS $compile on CKEditor contents -

i trying render angularjs directives within ckeditor instance editor area. right now, able render directives unto separate div block, searching here on stackoverflow. unfortunately, still unable render on preview area itself. this current code looks like: <div class="widget-body" ng-app="myapp"> <div compile="ckvalue"></div> <form> <textarea ck-editor data-ng-model="ckvalue"></textarea> </form> </div> <script type="text/javascript"> angular.module('myapp', [], function($compileprovider) { $compileprovider.directive('compile', function($compile) { return function(scope, element, attrs) { scope.$watch( function(scope) { return scope.$eval(attrs.compile); }, function(value) { element.html(value); $compile(element.contents())(scope); ...

javascript - error in compiled .ts with tsc compiler in visual studio code -

there duplicate identifier error in .js tsc compiled code in vs code here .ts file i'm using vs code 0.5 , typescript 1.5.3,there error in line exports.user = user , complaining duplicate: import store = require("store/mongo") export class user { public connectionid: string; public telegram_user: telegram.user; addtopooldb(next): void { store.addtopooldb(this, function(err) { next(err); }); } } and output : var store = require("store/mongo"); var user = (function () { function user() { } user.prototype.addtopooldb = function (next) { store.addtopooldb(this, function (err) { next(err); }); }; return user; })(); exports.user = user;

algorithm - Adapt existing GOST code in C to hash a file -

i trying hand-code gost hash function using c. came across following code markku-juhani saarinen (from link ). /* * gosthash.c * 21 apr 1998 markku-juhani saarinen <mjos@ssh.fi> * * gost r 34.11-94, russian standard hash function * * copyright (c) 1998 ssh communications security, finland * rights reserved. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "gosthash.h" /* lookup tables : each of these has 2 rotated 4-bit s-boxes */ unsigned long gost_sbox_1[256]; unsigned long gost_sbox_2[256]; unsigned long gost_sbox_3[256]; unsigned long gost_sbox_4[256]; /* initialize lookup tables */ void gosthash_init() { int a, b, i; unsigned long ax, bx, cx, dx; /* 4-bit s-boxes */ unsigned long sbox[8][16] = { { 4, 10, 9, 2, 13, 8, 0, 14, 6, 11, 1, 12, 7, 15, 5, 3 }, { 14, 11, 4, 12, 6, 13, 15, 10, 2, 3, 8, 1, 0, 7, 5, 9 }, { 5, 8, 1, 13, 10, 3, 4, 2, 14, 15, 12...

ruby on rails - How do I send a user a temporary, expiring URL using ActionMailer? -

i have ruby/rails app class, engagements, , actionmailer mailer sends out mail each time engagement created. want include link in email goes page on site creates , displays item user. want link expire after 1 click , want real url (website.com/items/itemid, example) it's going not shown. how can achieve this? thank on this. you add 2 fields model: token , has_expired (default: false) model. actionmailer send link generated token, once user click link , token validated, set has_expired true. if user tries go again, expired true don't show page ... guess same thing happen if user tried go invalid token.

Renaming Windows.old to windows -

in laptop's old hdd. there windows.old , windows folders.windows.old belongs win7, windows belongs win10. however, win10 not start. connnected hdd externally pc. happens if delete windows folder , rename windows.old windows. old operating system(win7) work ? it not. however, can use cmd iso rename user folder , clean install. cd /d c:\ move c:\users c:\u /y move c:\programdata c:\d /y rd c:\windows /s /q rd c:\program files /s /q rd c:\program files (x86) /s /q note: not format

flash - actionscript 2 collision detection -

i can achieve bounding box collision in as2 it's not accurate enough needs. here fla: collisiontest click , drag car; you'll see text box change "true" when collision detected. you'll note can triggered before rotating bar touches badly drawn car. is there way achieve per-pixel collision, or close as2? i'm tied as2 rather as3 because of scaleform implementation of game engine i'm developing for. thanks. use movieclip.hittest movieclip instances have custom hit areas (using vector shapes). use hitarea property define these custom hit areas.

php - Can someone please explain this mysql statement to me -

i trying learn mysql on own debugging php program. stuck. not understand particular statement or does: $statusrequirements = array( array(80*1024*1024*1024, 0.50, 0.40), array(60*1024*1024*1024, 0.50, 0.30), array(50*1024*1024*1024, 0.50, 0.20), array(40*1024*1024*1024, 0.40, 0.10), array(30*1024*1024*1024, 0.30, 0.05), array(20*1024*1024*1024, 0.20, 0.0), array(10*1024*1024*1024, 0.15, 0.0), array(5*1024*1024*1024, 0.10, 0.0) ); $db->query("update users_main set requiredstatus=0.50 access>100*1024*1024*1024"); in simple english understand this: database query update users_main , set required status 0.50 access greater 100 * 1024 * 1024 * 1024. what don't understand significance of numbers 100*1024*1024*1024. could please explain me? if doing code inspection , reading code, 1 way be: "in table users_main , update requiredstatus field 0.50 rows have access field greater 10g."

scripting - Aid with tcsh shell script for protein research -

could please me figure out what's wrong it? thanks! it gives me lots of these errors when try initialize it: startdssp not created due error: empty protein, or no valid complete residues my script: #! /usr/bin/env tcsh set getlocation = "/home/yyyyyy/desktop/dcompartment/xxxxxxxx/perl_scripts" set getname = "get_right_pdb_format.pl" set sslocation = "/home/yyyyyyy/desktop/dcompartment/xxxxxxxx/perl_scripts" set ssname = "get_ss_dssp_itasser.pl" set suffix = ".dssp" foreach file (*.pdb) cp $getlocation/$getname . cp $sslocation/$ssname . sed -i "s/2jix\.pdb/$file/g" $getname perl $getname dssp -i $file-1 -o $file:r sed -i "s/bamboozled/$file:r/g" $ssname sed -i "s/2j1x\.pdb_1/$file:r/g" $ssname perl $ssname end

c# - WPF Mvvm navigation with parameters -

following this tutorial (among others) , reading questions asked here i've constructed navigation mechanism allow me pass parameters between viewmodels : object base - every view model inherits it: public abstract class objectbase : inotifypropertychanged { //inotifypropertychanged members ... //navigation handling public abstract objectbase backlocation { get; } public abstract event action<objectbase> navigateto; public abstract string viewheader { get; } } mainviewmodel - in charge of navigation: public class mainviewmodel : objectbase { private objectbase _selectedview; private commandbase _backcommand; public mainviewmodel() { selectedview = new firstviewmodel(); } public objectbase selectedview { { return _selectedview; } set { setproperty(ref _selectedview, value); //register navigation event of new view selectedview.navigateto += (t...

f# - FsUnit assert exception message -

how assert on exception message in fsunit? nunit: [<test>] let shouldthrowexceptionandlog() = assert.that ((fun () -> calculator.calculate "-1"), throws.exception.with.property("message").equalto("negatives not allowed: -1")) edit: don't care exception itself, i'd test exception message. afaik there no out-of-the-box matcher want, it's easy enough create 1 yourself: open nhamcrest let throwanywithmessage m = custommatcher<obj>(m, fun f -> match f | :? (unit -> unit) testfunc -> try testfunc() false | ex -> ex.message = m | _ -> false ) usage: (fun () -> raise <| exception("foo") |> ignore) |> should throwanywithmessage "foo" // pass (fun () -> raise <| ex...

JDBC java null pointer exception on my resultset while loop -

this question has answer here: what nullpointerexception, , how fix it? 12 answers i getting java.lang.nullpointerexception on while loop on aftermigration method not working properly. , getting warnings on if statement preparedstatements.setstring(..) , setint(..) . please appreciate responses. in jdbc code connecting local db. first selecting records in 1 method updating on next aftermigration method. public static void main (string[] args) throws exception { resultset rs = null; connection bidsconnection = null; mydatabasetest migration = new mydatabasetest(); try { bidsconnection = migration.getoracleconnection(); rs = migration.selectrecordsbids(bidsconnection); migration.aftermigration(bidsconnection, rs); } catch (exception e){ e.printstacktrace(); } { if (migration.scanner != null)...

Lua - Attempt to index local 'item' (a function value) -

i'm getting error, , can't figure out if it's scoping issue, logic issue, or else entirely. objective, in c terms, modify pointer within module change behavior of draw() command. place error coming is: function m.draw() k, item in pairs(m.buttons.current) love.graphics.setcolor(m.buttons.bkg_color) love.graphics.rectangle("fill", item.pos_x, item.pos_y, m.buttons.size_x, m.buttons.size_y) love.graphics.setcolor(m.buttons.txt_color) --todo: center text on button love.graphics.print(item.text, item.pos_x+10, item.pos_y+10) end end this function works in first menu, when click button change menus, error pops in love.graphics.rectangle(...) line. code changes m.buttons.current is: function m.mousereleased(x, y, button) if button == 'l' , m.buttons.buttonpressedflag , m.mousecollide(x,y,m.buttons.buttonpressed) m.buttons.buttonpressed.fun() end m.buttons.buttonpressedflag = false end and button i'm clicking d...

c++ - Qt crashes/doesn't appear when i use Qthread::sleep to update progress bar -

i kinda new qt wondering why invalid: i have progress bar , want update using class inherits qthread . void mt::run(qprogressbar * asd){ for(int = 0;i<100;i++){ asd->setvalue(i); qthread::sleep(100); } } mt class inherits qthread . run overloaded qprogressbar argument. main ui thread send it's progressbar m.run(ui->progressbar); . if remove qthread::sleep(100); work fine won't able see increment because thread done fast. if put little delay, screen won't appear @ all. you can access , update gui elements main thread only. if want prepare data inside custom thread, should use signals/slots mechanism send data widgets. here's basic example: class mythread : public qthread { q_object public: mythread(qobject *parent = 0); signals: void valuechanged(int value); protected: void run(); } void mythread::run() { (int = 0; < 100; i++) { emit valuechanged(i); qthread::sleep(100); } } ...

swift - iOS Parse notification with custom radius geopoint from key -

i have huge problem parse ios , geo-query push notifications. want schematically. class "helplocationlistener" | location | radius | user | | xxx | 2 | usera | | xxy | 5 | userb | | xyy | 2.5 | userc | when user sends "help" geo-located, other users should notified if "help" within area calculated | location | , | radius | if coordinates of "help" contained in area date xxx radius 2, user usera receive push notification. absurdly need this: userquery.wherekey ("location", neargeopoint: "help", withinmiles " radius ") i searched hours not find answer, if not possible application not make sense exist. seems impossible possibility has not been provided. i'm using swift lang. i ask sincere help! (sorry english)

asp.net mvc - Azure VM NGINX Plus + Web App leads to 404 -

i'm working on nginx plus setup reverse proxy traffic management , routing on azure cloud solution. i'm getting started , works independently, when try use proxy_pass route web traffic .net web app rests in cloud, 404 errors. i've tried app i've had deployed while(a .net mvc web app) , node express app nothing more basic offering test: http://rpsexpressnodetest.azurewebsites.net/ each of these runs expected when go directly them, when enable pass thru 404 error. i'm using following config file nginx: user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { upstream web_rps{ server rpsexpressnodetest.azurewebsites.net; } # ssl_certificate /etc/nginx/ssl/server.crt; # ssl_certificate_key /etc/nginx/ssl/server.key; # drop requests no host header # server{ # listen 80 default_server; # server_name ""; #...

Change width to full width in JavaScript -

i have following code in javascript. need increase width full width. in css can writing width:100%. how write in javascript? please guide. thanks. jquery(document ).ready(function( $ ) { jquery('#example3' ).sliderpro({ width:1250, height:400, fade: true, arrows: true, buttons: false, fullscreen: true, shuffle: true, thumbnailarrows: true, autoplay: false }); }); sinse you're using slider pro 100% should possible width: '100%' this says on page: width: sets width of slide. can set fixed value, 900 (indicating 900 pixels), or percentage value, '100%'. it's important note percentage values need specified inside quotes. fixed values, quotes not necessary. also, please note that, in order make slider responsive, it's not necessary use percentage values. default value: 500

PHP explode a string but keep the serialized part intact -

i trying take string, part of insert statement, explode ( separated commas ) , test reform string depending on index of value. have done realize exploding comma while potentially having serialized value whole string own value explode serialized value throws whole thing off. im trying avoid having go , check before creating string, involved might option. wondering if there way take initial string , separate commas without separating actual serialized value within string. example below. null,null,null,null,'hello world','a:3:{s:6:"johnny";a:3:{s:7:"physics";s:9:"great job";s:5:"maths";s:19:"you did a, job";s:9:"chemistry";s:27:"need work on this, johny";}s:5:"brady";a:3:{s:7:"physics";s:9:"great job";s:5:"maths";s:19:"you did a, job";s:9:"chemistry";s:27:"need work on this, brady";}s:5:"keith";a:3:{s:7:"physics"...

r - what is used to write functions within mongoDB/mongolite? -

i'm learning mongolite/mongodb right now, , came across this: https://cran.r-project.org/web/packages/mongolite/vignettes/intro.html inside saw code this: tbl <- m$mapreduce( map = "function(){emit({cut:this.cut, color:this.color}, 1)}", reduce = "function(id, counts){return array.sum(counts)}" ) can tell me these functions written in? don't think r functions. the r language allows create environments put functions referenced $-operator 1 pull items list. m$mapreduce calling r function , sending text database engine: http://docs.mongodb.org/manual/reference/command/mapreduce/ if install package , execute help(pac=mongolite) see package has single exposed function, mongo allows of function calls. can work through examples on page , vignette. (note: error if not first install , set database executable.) if execute mongolite loaded list of objects in environment defined when mongo function created: ls(envir=environment(mon...

c# - Scintilla .NET editor. Position cursor at the first visible line -

Image
i using scintilla .net text editor control (scintillanet.dll) display sql. using following command position caret cursor @ given line number. in example below, positioning caret cursor @ line 102 (0 based. grid displays 1-based line numbers.) scintilla1.goto.line(102); //0 based i'd text in viewport displayed @ top of screen shown below, first visible line can please me identify how this? update: this looked promising.. scintilla1.lines.firstvisible.number = targetlinenumber; but after executing, scintilla1.lines.firstvisible.number wasn't equal targetlinenumber , don't know interferring it.there hundreds of lines following targetlinenumber line.

javascript - How to divide JSON collection result using backbone.js -

current results of json this. <div id="item-list"> <div class="row" id="featured-item"> <div class="col-md-6"><p>content righ here</p></div> <div class="col-md-6"><p>content righ here</p></div> <div class="col-md-6"><p>content righ here</p></div> <div class="col-md-6"><p>content righ here</p></div> <div class="col-md-6"><p>content righ here</p></div> <div class="col-md-6"><p>content righ here</p></div> <div class="col-md-6"><p>content righ here</p></div> <div class="col-md-6"><p>content righ here</p></div> <div class="col-md-6"><p>content righ here</p></div> </div> </div...

linux - SystemTap script to analyze the cache behavior of functions -

i profile cache behavior of kernel module systemtap (#cache references, #cache misses, etc). there example script online shows how systemtap can used read perf events , counters, including cache-related ones: https://sourceware.org/systemtap/examples/profiling/perf.stp this sample script works default process: probe perf.hw.cache_references.process("/usr/bin/find").counter("find_insns") {} i replaced process keyword module , path executable name of kernel module: probe perf.hw.cache_references.module(module_name).counter("find_insns") {} i'm pretty sure module has debug info, running script get: semantic error: while resolving probe point: identifier 'perf' @ perf.stp:14:7 source: probe perf.hw.instructions.module(module_name).counter("find_insns") {} any ideas might wrong? edit: okay, realized perf counters bound processes not modules (explained here: https://sourceware.org/systemtap/man/stapp...

c++ - Branch Prediction and Division By Zero -

i writing code looked following... if(denominator == 0){ return false; } int result = value / denominator; ... when thought branching behavior in cpu. https://stackoverflow.com/a/11227902/620863 answer says cpu try correctly guess way branch go, , head down branch stop if discovers guessed branch incorrectly. but if cpu predicts branch above incorrectly, divide 0 in following instructions. doesn't happen though, , wondering why? cpu execute division 0 , wait see if branch correct before doing anything, or can tell shouldn't continue in these situations? what's going on? the cpu free whatever wants, when speculatively executing branch based on prediction. needs in way that's transparent user. may stage "division zero" fault, should invisible if branch prediction turns out wrong. same logic, may stage writes memory, may not commit them. as cpu designer, wouldn't bother predicting past such fault. that's not worth it. fau...

Single-user PHP OAuth request using PECL -

i'm trying implement api (the noun project), , they've provided example: https://gist.github.com/hirobert/710f2e22ed803dc34cc0 i'd love implement using oauth pecl library i'm unfortunately getting stuck, since doesn't follow conventional oauth flow. i don't need account's authorization. rather, need use key/secret make calls. this i'm getting stuck: $oauth = new oauth( $key, $secret, oauth_sig_method_hmacsha1, oauth_auth_type_uri ); $oauth->enabledebug(); $oauth->fetch( $url, array(), oauth_http_method_get ); am able use oauth pecl library, or should elsewhere? best if knows of examples of kind of flow, using pecl oauth; i'm sure apply approach case

c# - How can I use volumeSlider in NAudio? -

i'm using naudio library audio player project. want make user control volume-slider here is there knows how use volume-slider in naudio? the naudiodemo project included in source code includes example of using slider. handle volumechanged event on volumeslider , , use volume property set volume either on stream (e.g. volume property on samplechannel ), or directly on output device (e.g. waveout )

javascript - DOM not updating until page is refreshed -

Image
i have asynchronous method calls web api retrieve json data. i use json data fill in few `' boxes. however, values not appear in text boxes until refresh page? the html: <form> <h1 id="ordernameheader"></h1> <div class="dataitemdiv"> <p class="dataitemlabel">quantity:</p> <input id="quantitytb" type="text" readonly="readonly" class="dataitemtextbox" /> </div> <div class="dataitemdiv"> <p class="dataitemlabel">delivery date:</p> <input id="deldatetb" type="text" readonly="readonly" class="dataitemtextbox" /> </div> </form> the javascript: function searchorder() { var ordername = document.getelementbyid("searchtextbox").value; var frurl = 'order/getbyname/' + ordername; var ap...

angularjs - Process with an ID #### is not running in vs 2013 -

i using iis express host angularjs website collecting data webapi project within same solution, running under iis express. whenever building project following error: [iis express] process id #### not running any ideas problem might , how resolve it? i have found solution described here . nevertheless, following instructions, great understand happening... you need remove of hidden .vs folders in projects directoy. restart visual studio , startup debugger.