Posts

Showing posts from August, 2010

javascript - Userscript not running on ajax loaded content. (waitForKeyElements not working) -

i have script scans page phone numbers , adds link place call via voip api. it's pretty simple, , works on every page. however doesn't work on 1 page really want run on (unfortunately, page behind paywall, link useless). my script (essentially copy of linkify ( http://userscripts-mirror.org/scripts/review/6111 ) updated fit needs): // ==userscript== // @include * // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js // @require https://gist.github.com/raw/2625891/waitforkeyelements.js // @grant gm_addstyle // ==/userscript== const defaultprefix= '+1'; // begin modify area const rcusername = ""; // account info temp removed const rcpassword = ""; const rcextension = ""; const rcringout = ""; const rccallerid = ""; const rcprompt = "0"; // end modify //close new window after starting call if (location.pathname == "/ringout.asp

html - PNG images not loaded -

i developper of www.zundelcristea.com website. for reason, png images not being loaded , although exist on right path, right permissions (664, other file on server). my .htacess doesn't contain related images, nor folders. have no idea else can check. locally, .png loaded normally. suggestion appreciated [ edit ] nothing in error_log you transferred them in text mode: $ pngcheck -v mobile-menu-icon.png file: mobile-menu-icon.png (425 bytes) file corrupted. seems have suffered dos->unix conversion. errors detected in mobile-menu-icon.png the first 8 bytes of png file contain following values: (decimal) 137 80 78 71 13 10 26 10 (hexadecimal) 89 50 4e 47 0d 0a 1a 0a (ascii c notation) \211 p n g \r \n \032 \n from png specification, "rationale": signature both identifies file png file , provides immediate detection of common file-transfer problems. first 2 bytes distinguish png files on s

python - Sum of all the multiples of 3 or 5 below 1000 -

beginner here- trying make simple python program compute/answer problem: if list natural numbers below 10 multiples of 3 or 5, 3, 5, 6 , 9. sum of these multiples 23. find sum of multiples of 3 or 5 below 1000. currently have: a = 0 b = 0 while < 1000: = + 3 print (a) while b < 1000 b = b + 5 print (b) this print numbers being considered. need add them , that's answer. i 1 of 2 things happen, instead of code have written: i of happen internally, , therefore not have use "print" function. print sum of of multiples. i of stuff print, want able print sum of of them too. there way make computer take value of has printed? actually problem can solved in o(1) instead of o(n) without using loops or lists: required sum sum of multiples of 3 plus sum of multiples of 5 minus sum of multiples of (3*5=15) below given number 1000 (n=999). sums calculated sum of arithmetic series. can calculated in following way: n=999 # upper

iCheck with AngularJS and RequireJS -

i've looked around stackoverflow read this thread still no success. trying use icheck in angularjs web app still seeing regular checkboxes. using require.js. ideas how work? thanks! html: <label ng-disabled="true" style="font-weight:normal"> <input icheck type="checkbox" ng-model="permissions[0]" ng-disabled="true" ng-checked="user.isadmin" />&emsp;option #1<br /> </label> <label ng-disabled="true" style="font-weight:normal"> <input icheck type="checkbox" ng-model="permissions[1]" ng-disabled="true" ng-checked="user.isadmin" />&emsp;option #2<br /> </label> <label ng-disabled="true" style="font

How to build webpack on heroku? -

what best way trigger webpack build after deploying heroku? push bundled version in not beautiful solution. what kind of application this? if using package.json, run webpack in postinstall step using npm scripts.

algorithm - is bellman-ford can be done in a single iteration? -

does every graph have order of edges such after running single iteration of bellman-ford algorithm according order, every vertex labeled it's shortest path source ? i'm quiet sure answer yes, can't think of algorithm able find order of edges, =] sort shortest path tree topologically.

html - Yii2 Where is the CSS file that permits to edit the style of pages -

i'm new yii2, , spent last 2 hours in finding how change black top menu bar color of yii2. in yii1.1 easy, cannot figure out css file. inspecting element in chrome says file in assets dir, edit file , nothing happens. in folder vendor/yiisoft/bower/bootstrap -> editing css files inside wont change thing. so, whats going on yii2 change css appearance of page? many in advance. the css file inherited bootstrap css files. extension navbar.php uses navbar-default style when initiated. including css file custom styling can linked after boostrap vendor css included in config file: 'components' => [ 'assetmanager' => [ 'bundles' => [ 'yii\bootstrap\bootstrapasset' => [ 'sourcepath' => 'your-path', 'css' => ['css/bootstrap.css', 'path/to/custom.css'] ], ], ], ], source: http://www.yiiframework.co

c# - Streaming a list of objects as a single response, with progress reporting -

my application has "export" feature. in terms of functionality, works this: when user presses "export" button (after configuring options etc.), application first runs relatively quick query determines ids of objects need exported. then, each object, executes calculation can relatively long time finish (up 1s per object). while happening, user watching progress bar -- easy render, since know expected number of objects, how many objects have been processed far. i move functionality webservice, usual reasons. however, 1 additional wrinkle in process our users have lot of network latency. thus, can't afford make 1000 requests if have 1000 rows process. what i'd return custom stream service. can write row count first 4 bytes of stream. client read these 4 bytes, initialize progress bar, , proceed read stream , deserialize them on fly, updating progress bar deserializes each one. meanwhile, server write objects stream become available. to make matters

javascript - PEG.JS parsing logical variable names, its operand and value -

getting terrible headache after hours of trying work. using peg.js parsing input query parsed array. right im trying best grammer. operands , connectors static , generated app. start = start:(statement) statement = statement:block_statement* { return statement; } block_statement = openparen block:block+ closeparen connector:connector block2:(block_statement+ / block+) { return [block, block2]; } / openparen block:block+ closeparen connector:connector* !(block_statement / block) { return block; } / block:block block = control:atom operand:operand atom:atom connector:connector* { return { control: control, operand: operand, value: atom, connector: connector[0] || false }; } atom = _ quote "#"*atom:(word)* quote _ { return atom.tostring(); } operand = _ operand:("=" / "in") _ { return operand.tostring(); } connector = _ connector:("or" / "and") _ { return connector.tostring(); } word

c# - Creating repositories for Unit Testing -

i've written web application in c#, mvc, entity-frame, linq etc... , want retroactively create unit tests whole project. i understand in order write effective unit tests, need create repositories models, can mocked, , entity framework hits on database. i have 3 main models; category, password, userpassword. categories contain categories , passwords. , passwords contain userpasswords (which link user accounts). i've created 3 repositories basic methods such as; create, delete, update etc... however, looking @ linq query: var selectedcategoryitem = databasecontext.categories .where(c => c.categoryid == parentcategoryid) .include(c => c.subcategories) .include(c => c.passwords) .include(c => c.passwords.select(p => p.creator)) .tolist() .select(c => new category() { subcategories = c.subcategories

c# - Keyboard Shortcut Not Working with VSIX Installer -

i've created vsix package, , i've added keybindings section in .vsct file. when run experimental instance of visual studio, keyboard shortcut works, when install vsix package on machine, keyboard shortcut doesn't work, despite other aspects of addin working. there else stopping shortcut binding properly? the key bindings <keybindings> <keybinding guid="myaddincmdset" id="cmdidrollback" editor="guidvsstd97" key1="vk_numpad2" mod1="control"/> </keybindings> the command in vspackage commandid commandidrollback = new commandid(guidlist.myaddincmdset, (int)pkgcmdidlist.cmdidrollback); menucommand menuitemrollback = new menucommand(menuitemcallbackrollback, commandidrollback); mcs.addcommand( menuitemrollback);

android - GoogleAuthUtil: get access token that will provide an email address? -

i'm unable access token provide email address. i'm using googleauthutil. (the result says token invalid) i use this: mgoogleapiclient = new googleapiclient.builder (cordova.getactivity().getapplicationcontext()) .addconnectioncallbacks (this) .addonconnectionfailedlistener (this) .addapi (games.api) .addscope (games.scope_games) .addapi(plus.api) .addscope(plus.scope_plus_profile) .addscope(plus.scope_plus_login) .build (); , this: scope = "oauth2:" + scopes.profile + " " + "email"; dropping " email" works give me valid access token -- there's no email address in response. here code. package com.flyingsoftgames.googleplayservices; import com.google.android.gms.common.connectionresult; import com.google.android.gms.common.scopes; import com.google.android.gms.common.api.googleapiclient; import com.google.android.gms.common.api.googleapiclient.connectioncallbacks; import com.google.android

scp - Store a private key outside of ~/.ssh -

i have deal rather annoying situation. must transfer file via shell script using scp 1 server another. problem not have root access on either of them. i'm not allowed install packages like, sshpass, ssh2, expect etc. don't have write permission in home directory of user have use on second server. since can't use sshpass etc. enable script enter login credentials, thought using ssh keypair auth. first thought, since user on second server doesn't have write permissions in home directory in subsequent directory, ssh-keygen fails can't put keys in ~/.ssh. both debian servers btw. is there way generate ssh keypair , use outside of ~/.ssh? any appreciated. on clientside yes. however, on serverside, unless configured differently, sshd expect credentials in directory. if can scp server can't access .ssh 1 can, can use -i option specify keyfile location. do have alternative transport mechanism? can put filn public_html , wget on other side?

javascript - Cannot use global variable in NodeJS MySQL -

i cannot access upcoming_matches array inside mysql query callback, how come? i'm greeted 'typeerror: cannot read property '1' of null' error message on console.log(upcoming_matches[1]); line indicates variable being reset reason (a guess, i'm not experienced javascript)? var regex = regex code.. while ((upcoming_matches = regex.exec(body)) != null) { hltvid = upcoming_matches[1].split("-"); connection.query('select * `csgo_matches` hltvid=' + hltvid[0], function(err, rows, fields) { if (err) throw err; console.log(upcoming_matches[1]); }); } because @ moment callback passed connection.query executed, while loop finished , upcoming_matches null (because that's condition while loop stop). connection.query asynchronous . see why variable unaltered after modify inside of function? - asynchronous code reference

comparison - Python: How to find two equal/closest values between two separate arrays? -

let's have 2 arrays of equal length: arr1 = (21, 2, 3, 5, 13) arr2 = (10, 4.5, 9, 12, 20) which variable arr1 equal / closest variable arr2 ? looking @ these 2 lists can closest numbers 4.5 , 5 . i've tried implement function returns 2 closest values given 2 lists , kinda works examples above, barely solution because not optimal. , can check function fails when change arrays this: arr1 = (21, 2, 3, 5, 13) arr2 = (10, 4.5, 9, 12, 18) the values function returns 13 , 18 here function: def get_nearest(arr1, arr2): lr = [[0, 0, 0]] x1 in arr1: x2 in arr2: r = (x1 / x2 % (x1 + x2)) print x1, x2, r if r <= 1 , r >= lr[0][2]: lr.pop() lr.append([x1, x2, r]) return lr can come better one? is speed issue? care ties? if not, simple like from itertools import product sorted(product(arr1, arr2), key=lambda t: abs(t[0]-t[1]))[0] for both arr1 = (21, 2, 3, 5,

TextBox not firing valueChangedEvent in GWT -

i have code , action never fired textbox textbox = new textbox(); textbox .addvaluechangehandler(new valuechangehandler<string>() { @override public void onvaluechange(valuechangeevent<string> event) { //do action } }); what doing wrong ? one information forgot textbox setenable(true), reason don't use other handler. find solution way fire event when textbox set , use couttotal.settext("sometext") fire event need use couttotal.setvalue("sometext", true) private void computetotal() { double total = 0.0; (int = 0; < discloserpanel.getwidgetcount(); i++) { if (discloserpanel.getwidget(i) instanceof lignecout) { lignecout lignecout = (lignecout) discloserpanel.getwidget(i); total += lignecout.getsoustotal(); } } couttotal.setvalue(formh

replace duplicate values in hashmap java -

i have hashmap contains student id key , string value. map<integer, string> data = new hashmap<integer, string>(); it contains data 1 2 b 3 4 c 5 b 6 i want find duplicate values in map , replace them integer values. i.e. want map like 1 1 2 2 3 1 4 3 5 2 6 1 i.e. map shud pick first value(a), find keys value , replace value of keys 1. pick second value(b) find keys , replace them 2 , on. file reading large cannot replace keys manually specifying each key. so, have tried far is map<integer,integer> finalmap = new hashmap<integer,integer>(); int a=0; list mapkey = new arraylist(data.keyset()); list mapval = new arraylist(data.values()); iterator valit = mapval.iterator(); while(valit.hasnext()){ a=a+1; object valuet = valit.next(); iterator keyit = mapkey.iterator(); while(keyit.hasnext()){ object keyt = keyit.next(); string comp1 = data.get(keyt).tostring();

php - Problems with PDO bindParam/Value -

i trying query database, however, value have bindparam (:name) not being bound, when echo $sql , print_r($stmttwo) where clause states where :name instead of string $wherefinal . the code have is: $sql= "select species.species_id species join ( select species.species_id, count(*) mynum species_opt left join species on (species.species_id = species_opt.so_species_id) :name group so_species_id having mynum = 6 ) mytable on species.species_id = mytable.species_id"; $stmttwo = $pdo->prepare($sql); $stmttwo->bindparam(':name', $wherefinal); $stmttwo->execute(); with $wherefinal being defined before sql statement , being defined as: $where = ""; foreach ($_post $k => $v){ $where .= "(species_opt.so_option_id = $v) or "; }; $wherefinal = substr($where, 0, strrpos($where, " or ")); and when echoed, $wherefinal displays: (species_opt.so_option_id = 4) or

java - Detecting a shake when Android is asleep and locked with service -

i want wake android device locked , asleep state single state. what should use? a wake lock keep service running , listening shake. or possible same thing flags service? will service receive if android device locked , asleep, if don't have wake lock? update: wake lock ideal or unnecessary? you can write service runs on background , listens event(shake) as per flag can lock , unlock screen //get window context windowmanager wm = context.getsystemservice(context.window_service); //unlock //http://developer.android.com/reference/android/app/activity.html#getwindow() window window = getwindow(); window.addflags(wm.layoutparams.flag_dismiss_keyguard); //lock device devicepolicymanager mdpm; mdpm = (devicepolicymanager)getsystemservice(context.device_policy_service);

javascript - AngularJS parent directive scope from inner ng-transclude -

i print index of ng-repeat iterator of parent directive. pseudo code: index.html <div data-repeatable> {{$index}} not display </div> template.html <div ng-repeat="i in gettimes(5) track $index"> {{$index}} displays correctly <div ng-transclude></div> </div> app.js // other code omitted .directive('repeatable', function() { return { scope: {}, transclude: true, templateurl: 'template.html' }; }) i've explored many different approaches/tweaks, nothing has worked far. appreciated! thanks. okay, may hacky, , rely on internal implementation details angularjs might pulled in version, still... here way found work. note appears work in angular 1.3 branch. var app = angular.module('plunker', []); app.directive('repeatable', function($timeout) { return { scope: {}, transclude: true, templateurl: 'templ

asp.net - System.UnauthorizedAccessException: Access to path is denied -

This summary is not available. Please click here to view the post.

ember.js - Ember cli simple auth login with facebook using torii authenticate against server using oauth2 -

how allow user login facebook , take facebook authentication code , pass server using simple auth oauth2? i want validate whether or not user has permissions make request server. i have been looking on , not able find point me in right direction. i see examples tell me this.get('session').authenticate('simple-auth-authenticator:torii', 'facebook-oauth2'); do afterwords? , how use check against own server using oauth2? a full example allowing multiple ways login server authentication returns user info used later on in application(user_id, firstname, lastname, etc...) appreciated!!!

c# - How to catch Exception thrown in a method invoked by using MethodInfo.Invoke? -

Image
i have following codes: using system; using system.reflection; namespace testinvoke { class program { static void main( string[] args ) { method1(); console.writeline(); method2(); } static void method1() { try { myclass m = new myclass(); m.mymethod( -3 ); } catch ( exception e ) { console.writeline( e.message ); } } static void method2() { try { string classname = "testinvoke.myclass"; string methodname = "mymethod"; assembly assembly = assembly.getentryassembly(); object myobject = assembly.createinstance( classname ); methodinfo methodinfo = myobject.gettype().getmethod( methodname ); methodinfo.invoke( myobject, new object[] { -3 } ); } catch ( exception e ) { console.writeline( e.message ); } } } public class myclass { public void my

map - JavaFx: populate TableView with ObservableMap -

i coudn't find in internet right answer, how can populate tableviw observablemap mapproperty. show articles in tableview sorted value. public class article { private mapproperty<string, integer> article = new simplemapproperty<>(); public final observablemap<string, integer> gearticle() { return article.get(); } public final void setarticle(observablemap<string, integer> value) { article.set(value); } public mapproperty<string, integer> articleproperty() { return article; } } public class tablecontroller extends vbox implements initializable{ @fxml private tableview<article> tableview; @fxml private tablecolumn<article, string> article; @fxml private tablecolumn<article, integer> count; ...... @override public void initialize(url location, resourcebundle resources) { article.setcellval

javascript - Why array cannot be accessed like given below? -

below code returns true. if case why 4th line in code error out? var x = ['a', 'e', 'f']; x[2]; alert('2' in x); alert(x.2); the property names can access dot syntax conform javascript's rules identifier names (first character letter, _, or $, , remaining characters letters, numbers, _, or $). what have there syntax error, , that's why errors out. from mdn : dot notation = object.property; object.property = set; property must valid javascript identifier, i.e. sequence of alphanumerical characters, including underscore ("_") , dollar sign ("$"), cannot start number. example, object.$1 valid, while object.1 not. you can use square bracket notation access property name, either of following return item want: x[2]; x["2"];

customization - Is there any application/software/web tool that creates customized search engine -

i wonder if there application/software or tool creates customized search engine , results classified according websites i've defined before. what want combining world wide news websites lets 4 sites , when search global warming results classified according sites specified earlier. cnn.com retrieves 509655 global warming bbc.co.uk retrieves 303255 global warming abc.com retrieves 4588 global warming aljazeera.com retrieves 2699 global warming is possible? there can this give apache solr try. http://lucene.apache.org/solr/ from website: solr popular, blazing-fast, open source enterprise search platform built on apache lucene™

parsing - Is there any benefit to wrapping a bufio.Scanner's reader in a bufio.Reader? -

i'm using bufio.scanner , , i'm not sure if should giving reader wrapped bufio.reader . i.e., f os.file , should i: scanner := bufio.newscanner(f) or scanner := bufio.newscanner(bufio.newreader(f)) from the scan.go source doesn't need pass *bufio.reader : has own buffer, defaulting 4k bufio.reader 's buffers do. // newscanner returns new scanner read r. // split function defaults scanlines. func newscanner(r io.reader) *scanner { return &scanner{ r: r, split: scanlines, maxtokensize: maxscantokensize, buf: make([]byte, 4096), // plausible starting size; needn't large. } }

python - Elif causing a syntax error -

i trying write function (in python 3.4) allow user make choice output shown. first elif line keeps getting flagged invalid syntax. i'm not sure i'm doing wrong. here's code: def questionfunction () : q1=input('would to: \n1. submit input , see costs \n2. view summary data \n3. reset summary data \n4. exit \n input corresponding number choice here: ') if q1 == 1: print ("cost = $" + format(str(costfunction()), '.4')) print ("shipping cost = $" + format(str(shippingfunction()), '.4')) print ("total cost = $" + format(str(totalcostfunction()), '.4') elif q1 == 2: print ("user count = " +str(count)) print ("total revenue = $" + format(str(totalrevenue), '.4')) elif q1 == 3: count = 0 totalrevenue =

Order by in find() cakephp -

table unit(id, unitno, summary). id | unitno 1 | 23 2 | 25 3 | 22 in unitscontroller: public function index() { $this->set('units', $this->unit->find('all'), array( 'order' => array('unit.unitno asc'), 'fields' => array('unit.id', 'unit.unitno')) ); } index.ctp <table> <tr> <th>unit</th> <th>summary</th> </tr> <!-- here loop through our $posts array, printing out post info --> <?php foreach ($units $unit): ?> <tr> <td> <?php echo $this->html->link($unit['unit']['unitno'], array('controller' => 'units', 'action' => 'view', $unit['unit']['id'])); ?> </td> <td><?php echo $unit['unit']['summary'];

html - how to get a td value of a table using javascript -

Image
i have aspx file has html below: i want value 37.23961( seen above). how value ( td iindex 6 of table 'gridview2) using javascript ? myhtml: <table rules="all" id="gridview2" style="width:542px;border-collapse:collapse;" border="1" cellspacing="0"> <tbody> <tr> <th scope="col">hname</th> <th scope="col">haddress</th> <th scope="col">hphone</th> <th scope="col">hhours</th> <th scope="col">hrating</th> <th scope="col">hlat</th> <th scope="col">hlong</th> </tr> <tr> <td>kaiser permanante</td> <td>200 fremont boulevard</td> <td>5105199000</td> <td>mon-fri : 8:00 - 11:00 pm, sat, sun: 10:00 am- 6:00

ios - Update progress view in custom cell in another viewController -

this custom cell code : #import <uikit/uikit.h> @interface sharecell : uitableviewcell @property (strong, nonatomic) iboutlet uilabel *lbltitle; @property (strong, nonatomic) iboutlet uiprogressview *progressview; @property (strong, nonatomic) iboutlet uibutton *btncancel; @end how call update progress view event in custom cell in view controller.thank in advanced i think need following link , , create uiprogressview in cellforrowatindexpath method. https://github.com/lightdesign/ldprogressview

javascript - prevent laravel link_to_action to perform on double click -

in laravel project controller wrote code approve , reject appointments. on rejecting appointment entry deleted database , redirect again listing table. i used code in reject section html_entity_decode(link_to_action('admincontroller@getatoggle', '<img src="'.$icon2.'"alt=asknow width=20 height=20/>',array($data['appointment_id'],2),array('title'=>'click me reject','ondblclick' => "event.preventdefault();"))); but still when double clicks " trying property of non-object " error showing. know occurs because , on first click entry deleted database second click there no entry delete in db. in case user double clicks don't want show them error message or 404 page. so there way prevent double clicks. tried "alert" in "ondblclick" shows both alert , error page. i think problem you're trying use event before it's been initialised. try mov

c# - Delete using navigation properties in EF 6 -

i using ef 6 database modal in application. have table tbl_user has 1:n relationship in other table. 1 of them tbl_user_case primary key of tbl_user act foreign key in tbl_user_case . now deleting user tbl_user . before need delete corresponding entries in tbl_user_case . using following code that private long deleteuser(long userid) { using(verbatrackentities datacontext = new verbatrackentities()) { tbl_user user = datacontext.tbl_user.where(x => x.lng_user_id == userid).singleordefault(); if(user != null) { foreach (var cases in user.tbl_user_case.tolist()) { user.tbl_user_case.remove(cases); } } datacontext.savechanges(); } return 0; } here m getting exception additional information: operation failed: relationship not changed because 1 or more of foreign-key properties no

ios - Retrieving multiple users from Parse via REST API and using only one AFNetworking request -

i need retrieve multiple users parse.com , via rest api , , using afnetworking . need retrieve these users using 1 single api call. the following code able fetch 1 user. notice including 1 objectid because fetching 1 user. need modify code can call multiple objectid's , result, retrieve multiple users: //setup request manager afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; [manager.requestserializer setvalue:applicationid forhttpheaderfield:@"x-parse-application-id"]; [manager.requestserializer setvalue:apikey forhttpheaderfield:@"x-parse-rest-api-key"]; [manager.requestserializer setvalue:@"application/json" forhttpheaderfield:@"content-type"]; nsdictionary *query = @{@"objectid":@"cbfg5dfjy7"}; nserror *error; nsdata *jsondata = [nsjsonserialization datawithjsonobject:query options:0