Posts

Showing posts from May, 2010

vb.net - DataTable belongs to another Data set / Saves extra Entries in XML -

i know question has been asked , answered here. ds.tables.add(dt.copy) ds.tables(0).tablename = "items" ds.writexml("inventory.xml") dt.copy resolve "datatable belongs data set" message when save, of course screws xml file , saves entries in file, when data grid loads xml file shows entries weren't there before. here's code. try dt = new datatable() dim ds new dataset 'dtcopy = dt.copy() dt.columns.add(new datacolumn("product_name", type.gettype("system.string"))) dt.columns.add(new datacolumn("product_sku", type.gettype("system.string"))) dt.columns.add(new datacolumn("product_price", type.gettype("system.decimal"))) dt.columns.add(new datacolumn("product_quantity", type.gettype("system.int32"))) dim integer = pinventory.rows.count = - 1 each prow in pinventory.rows if <> 0 or > 0

wcf - Inconsistent behavior when executing New-WebServiceProxy in a loop -

i'm having problem powershell script wrote call method on wcf web service. wcf service has composite datacontract sole request parameter. have modified servicecontract (by adding 2 new methods), new methods not being called powershell script. here original contract: [servicecontract] public interface ifilesystemservice { [operationcontract] hashfileresponse hashfile(hashfilerequest req); [operationcontract] void generatefiles(generatefilesrequest req); } and here new contract: [servicecontract] public interface ifilesystemservice { [operationcontract] hashfileresponse hashfile(hashfilerequest req); [operationcontract] void generatefiles(generatefilesrequest req); [operationcontract] parsefilepathresponse parsefilepath(parsefilepathrequest req); [operationcontract] archiveparsedfileresponse archiveparsedfile(archiveparsedfilerequest req); } the generatefiles method 1 being called powershell script. have not modified gen

php - smtp error on vps hosting when sending email -

i installed smtp module (with phpmailer). can work on gmail , sends mail fine. when try set on hosting company's server error. 2015-06-29 13:41:52 server -> client: 220-server.safensahookup.com esmtp exim 4.85 #2 mon, 29 jun 2015 13:41:52 +0000 220-we not authorize use of system transport unsolicited, 220 and/or bulk e-mail. 2015-06-29 13:41:52 client -> server: ehlo 173.214.189.92 2015-06-29 13:41:52 server -> client: 250-server.safensahookup.com hello server.safensahookup.com [173.214.189.91] 250-size 52428800 250-8bitmime 250-pipelining 250-auth plain login 250-starttls 250 2015-06-29 13:41:52 client -> server: starttls 2015-06-29 13:41:52 server -> client: 220 tls go ahead 2015-06-29 13:41:53 client -> server: ehlo 173.214.189.92 2015-06-29 13:41:53 server -> client: 250-server.safensahookup.com hello server.safensahookup.com [173.214.189.91] 250-size 52428800 250-

vb.net - Githubbing a ClickOnce application -

i want upload application github people start aiding in it's development. what issues should aware of? know theres matter or security...they not able open solution without .pfx file right? i've read if people access certificate sign malware certificate. how should go doing this? you might want delay signing .

class - c# and functional purity -

i've been having use c# lately, don't have experience in. conundrum keep finding myself in is, when building class, having state dependent on state initialized before it class foo{ public bar_ {get;} public dum_ {get;} public foo (){ bar_ = buildbar(); dum_ = builddum(bar_); } } its bit redundant builddum carry parameter if it's going use accessable member. on other hand explicitly pointing out dependencies function relies on i guess asking: best way handle situation? both ways fine. current version of builddum made static , in case it's fine method not access member variables, because cannot anyway: private static dum builddum(bar b) { ... } if make builddum accesses bar_ directly, should make access _dum , i.e. should non-static void : private void builddum() { ... _dum = ... }

python - How do I make this snippet Pythonic? -

i want know how python programmers write following snippet: for in range(10): indexvector[i] = empavg[i] + upperbound(t, pullcount[i]) here t constant. can see, used c/c++ style code want use python right way. if want use list comprehension create indexvector (assuming not have other value outside 10 indexes entered in snippet) , can use - indexvector = [empavg[i] + upperbound(t, pullcount[i]) in range(10)]

ios - Basic auth header from username and password is not working In AFNetworking 2.0 -

i invoking api required authorisation header. this api need on given url username : testingyouonit@gmail.com password : testingyouonit2 to create authorisation header step 1 - base64 encoding of given password. step 2 - sha256 hash on password obtained in step 1 step 3 - use password obtained in step 2 , given username create authorization header now passing request using afnetworking nsstring *email=@"testingyouonit@gmail.com"; nsstring *password=[self encodestringto64:@"testingyouonit2"]; here encoded password - (nsstring*)encodestringto64:(nsstring*)fromstring { nsdata *plaindata = [fromstring datausingencoding:nsutf8stringencoding]; nsstring *base64string; if ([plaindata respondstoselector:@selector(base64encodedstringwithoptions:)]) { base64string = [plaindata base64encodedstringwithoptions:kniloptions]; } else { base64string = [plaindata base64encoding]; } return base64string; } now passin

memory management - Is there a way to lower Java heap when not in use? -

Image
i'm working on java application @ moment , working optimize memory usage. i'm following guidelines proper garbage collection far aware. however, seems heap seems sit @ maximum size, though not needed. my program runs resource intensive task once hour, when computer not in use person. task uses decent chunk of memory, frees after task completes. netbeans profiler reveals memory usage looks this: i'd give of heap space os when not in use. there no reason me hog while program won't doing @ least hour. is possible? thanks. you perhaps play around -xx:maxheapfreeratio - maximum percentage (default 70) of heap free before gc shrinks it. perhaps setting bit lower (40 or 50?) , using system.gc() might go lengths desired behaviour? there's no way force happen however, can try , encourage jvm can't yank memory away , when want to. , while above may shrink heap, memory won't handed straight os (though in recent implementations of jvm does.)

python - ValueError when trying to convert Dataframe Column into float -

i trying convert data under column yield_pct of dataframe df below float types, facing issues doing this. error valueerror: not convert string float: ' na' , hence added line if row1['yield_pct'] != 'na': code below, yet same error after adding line. date maturity yield_pct currency 0 1986-01-01 0.25 na cad 1 1986-01-02 0.25 0.0948511020 cad 2 1986-01-03 0.25 0.0972953210 cad 3 1986-01-06 0.25 0.0965403640 cad 4 1986-01-07 0.25 0.0953292440 cad (i1, row1) in (df.iterrows()): if row1['yield_pct'] != 'na': row1['yield_pct'] = float(row1['yield_pct']) if isinstance(row1['yield_pct'], float)==1: print('success') else: print('failure') thank you edit : lower part of dataframe df : 920538 2015-01-19 e

javafx - Can't clear all items (elements) in an ObservableList -

i've couple of copied elements in observablelist use copy/paste operations in tableview. name of table cptable ( c opy , p aste t able) storing copied elements , paste elements stored in table. after each paste operation want clear contents of cptable before copy other selected items ctrl+c. error: javafx application thread" java.lang.unsupportedoperationexception: not supported. @ com.sun.javafx.scene.control.readonlyunbackedobservablelist.remove(readonlyunbackedobservablelist.java:246) here pseudocode: if (cptable !=null) { //first, copied items removing elements observablelist<string> copieditems = cptable.getitems(); int size = copieditems.size(); // remove elements for(int i=0;i<size;i++) { copieditems.remove(i); } cptable.setitems(copieditems); //clear cptable setting empty list } this method copies contents of selected items , puts in cptable public tableview<stri

java - Resource management on spark standalone -

i'm running on spark 1.4.0, , have cluster of 10 executors, 4 cores each (40 cores in total) i have 5 applications (and more in future)i want run, submit them using scheduler (each application runs every 2-5 hours) - 2 applications more important, , want them have 50% of resources 2 application want run 25% of resources 1 application want run 10% of resources the number of total cores 40, might change time time if add more slaves, , don't want change submit script every time add slave i'm not sure how configure spark-submit call, won't give me message: org.apache.spark.scheduler.taskschedulerimpl- initial job has not accepted resources; check cluster ui ensure workers registered , have sufficient resources any ideas anyone? from current (1.4.0) spark documentation: the standalone cluster mode supports simple fifo scheduler across applications. however, allow multiple concurrent users, can control maximum number of resources each application

javascript - Find() function retunrs undefined - Mongoose and Node.js -

i trying simple function node.js , mongoose returns true if model empty. the mongoose configuration fine: var mongoose = require('mongoose'); var db = mongoose.createconnection( 'mongodb://localhost:27017/prueba' ); var userschema = mongoose.schema({ phonenumber: number, name: string }); var user = db.model('user', userschema, 'user''); then tried this: user.find(function(err, data) { if (err) {console.log(err)}; console.log(data.length == 0 ); }); and works fine, logs true, or false. then tried do: var isusersempty = function () { user.find(function(err, data) { if (err) {console.log(err)}; console.log(data.length == 0); }); } isusersempty(); and again works fine, logs true or false, buy if do: var isusersempty2 = function () { user.find(function(err, data) { if (err) {console.log(err)}; return data.length == 1; }); } console.log(isusersempty2()); then log prin

ruby - Rails cannot find templates in test environment -

i've strange problem. have working rails application , on 1 machine tests don't work. problem when running tests rails cannot find application templates layout file. i've tried debug , ended in actionview::pathresolver class , particular piece of code below: def find_template_paths(query) dir[query].reject { |filename| file.directory?(filename) || # deals case-insensitive file systems. !file.fnmatch(query, filename, file::fnm_extglob) } end it looks file.fnmatch methods returns different results in test environment. i've render same action in development , test environment , compare results fnmatch method. in test in cannot match filename query. i have no idea why that. happens on 1 machine. osx yosemite 10.10.2 (14c2055), rvm 1.26.11 , ruby 2.2.2p95.

linux - How to connect and run commands in a ubuntu and windows machines? -

i want run few scripts (jmeter scripts) in few aws ubuntu machines , windows7 machines. use winscp (transfer files), putty (run commands) linux , remote desktop connection windows machines, work manually. now want automate these processes , know how achieve that. intention write code to, connect these machines, copy scripts, run scripts, fetch log files , close machine i want schedule them. best way of doing this? prefer code write can hosted somewhere (so rest api can exposed) or called direct library (api) in java server. i know chef scripts can written, want know other alternatives. https://www.chef.io/chef/ thanks ton in advance .

node.js - ExpressJS AngularJS POST -

i'm learning angularjs , want know how correctly wire node expressjs. this controller: app.controller('view1ctrl', function($scope, $http) { $scope.sub = function(desc) { console.log(desc); $http.post('/view1', desc). then(function(response) { console.log("posted successfully"); }).catch(function(response) { console.error("error in posting"); }) } }); and server.js: app.post('/view1', function(req, res) { console.log(res.desc); res.end(); }); i have not used body-parser. don't how body-parser used form values html when using function in controller. values got html on clicking submit when using body-parser or values got function on passing form values arguments. please tell me how done . edit: html: <form> <input type="text" ng-model="desc" placeholder="enter desc" /> <button class

How to get started with ESAPI out of a servlet container -

could give considerations started using esapi on no-web context? came little test validates string defaultvalidator.isvalidcreditcard, got web-container dependency errors. the following method consumed junit test: @override public validationerrorlist creditcard(string value) { this.value = value; validationerrorlist errorlist = new validationerrorlist(); try { isvalid = validator.isvalidcreditcard(null, value, false, errorlist); }catch(exception ie){ system.out.println(">>> ccvalidator: [ " + value + "] " + ie.getmessage()); messages = (arraylist) errorlist.errors(); } return messages; } this error (relevant part) of course i'm not running in container: attempting load esapi.properties via file i/o. attempting load esapi.properties resource file via file i/o. found in 'org.owasp.esapi.resources' directory: c:\foundation\validation\providers\esapi\esapi.properties loaded 'esapi.p

c# - ASP.NET WebForms - How to Authorise access to a page -

in latest asp.net webforms application no longer user rolemanager etc (as far can tell) how authorize access webpage particular role? in mvc use authorize attribute doesn't exist in webforms @ loss - ideas? try code on login pass role formsauthenticationticket formsauthenticationticket ticket = new formsauthenticationticket(1, username.text, datetime.now, datetime.now.addminutes(2880), false, role, formsauthentication.formscookiepath); string hash = formsauthentication.encrypt(ticket); httpcookie cookie = new httpcookie(formsauthentication.formscookiename, hash); if (ticket.ispersistent) { cookie.expires = ticket.expiration; } response.cookies.add(cookie); response.redirect(formsauthentication.getredirecturl(username.text, false)); on particular webform on page_load event retrieve role protected void page_load(object sender, eventargs e) { form

regex - PHP Match String Pattern and Get Variable -

i looked reference this question , this question not figure out need do. what trying is: say, have 2 strings: $str1 = "link/usa"; $str2 = "link/{country}"; now want check if pattern matches. if match, want value of country set usa. $country = "usa"; i want work in cases like: $str1 = "link/usa/texas"; $str2 = "link/{country}/{place}"; maybe integers well. match every braces , provide variable value. (and, yes better performance if possible) i cannot work around since new regular expresssions. in advance. it give results expected $str1 = "link/usa"; $str2 = "link/{country}"; if(preg_match('~link/([a-z]+)~i', $str1, $matches1) && preg_match('~link/{([a-z]+)}~i', $str2, $matches2)){ $$matches2[1] = $matches1[1]; echo $country; } note: above code parse alphabets, can extend characters in range per need. update: you can using explode , see example

Ckeditor - how to indent multiple times -

Image
i have client wants able indent multiple times. sort of things works in word use to. specifically, want able indent bullets more once. from can tell ckeditor doesn't allow this... i'm assuming because using ul , li tags doesn't have easy way this. does know if ckeditor can this? i'm looking give output this: <ul> <li>test</li> <ul> <ul> <li>sdfdsf</li> </ul> </ul> </ul> not this <ul> <li>test</li> <ul> <li>sdfdsf</li> </ul> </ul> yes ckeditor can addon ( http://ckeditor.com/addon/indent ) via buttons, or when manually edit source this: <ul> <li>1. level</li> <ul> <li>2. level</li> <ul> <li>3. level</li> </ul> </ul> </ul> and on...

ios - Detect when second tableview cell comes into view - then perform an action -

i've got uitableview in uiviewcontroller , filter button. hide filter button when user starts scroll down list. want show filter button when second cell ( index 1 ) visible. however, can't desired effect, can appear when reaches top. here code when reaches top (i show filter button again). //determines when tableview scrolled -(void) scrollviewdidscroll:(uiscrollview *)scrollview { cgpoint currentoffset = scrollview.contentoffset; //tableview scrolled down if (currentoffset.y > self.lastcontentoffset.y) { //if showfilter button visible i.e alpha greater 0 if (self.showfilter.alpha==1.0) { [uiview animatewithduration:1 animations:^{ //hide show filter button self.showfilter.alpha=0.0; //i adjust frames of tableview here }]; } } //determines if scrolled top if (self.showfilter.alpha==0.0 && currentoffset.y==0) { [uiview anim

Side by side code comparison with either jQuery or PHP -

i'm looking library allow me compare 2 code snippets. said snippets in lua. i want show differences between them la github. think split screen showing what's been added, what's been deleted, usual. i've searched around , nothing seems satisfying, answers i've come across mention libraries 3-4 years old. i'm stuck either using jquery or php comparison. basically, has "look pretty" , accurate. any suggestions more welcome.

password hash - what is best way of using password_hash and password_verify -

using md5 (old way): $sql = "select * 'table' `username`='bob' , `password`='123456'"; ** check password before getting data out of database. using password_hash , password_verify (new way): $sql = "select `password` 'table' `username`='bob'"; $bool = password_verify('password_from_post_method', 'password_from_database'); if($bool) {echo "your password right";} ** data got database first, , check password out of database. *** think old way better. data out of database when confirm password right. maybe, use password_hash , password_verify in wrong way. please give suggestion if have idea. thanks. you persist [hashed(password) + randomsalt] in password column of database. can write sql have mentioned in approach 1, during verification ? can not, because random generated salt persisted along password. why 'new way' way go.

python - I really need help, this is my code below and i want to give a random comment for each correct answer -

import random score = int(0) q1 = ("work out answer. 45 + 46 = ") q2 = ("kai buys pair of shoes £31 , shirt £67. altogether, spends £") q3 = ("work out answer. 68 - 29 = ") q4 = ("a bike costs £260. price reduced in sale £90. sale price of bike ") q5 = ("work out answer. 32 x 30 = ") q6 = ("a box holds 22 apples. total number of apples in 20 boxes ") q7 = ("work out answer. 70 x 7 = ") q8 = ("for school show, 22 chairs arranged equally in 30 rows. total number of chairs ") q9 = ("a function machine changes 49 98 , changes 26 '?'. number in question mark ") q10 = ("what number fills gap? 35 x ? = 105. number ") question = [ (q1, "91"), (q2, "98"), (q3, "39"), (q4, "170"), (q5, "960"), (q6, "440"), (q7, "490"), (q8, "660"), (q9, "52"), (q10, "3") ] comments = ["correct, 1

uinavigationcontroller - How to disable the swipe feature to back view controller? -

i want disable swipe viewcontroller feature in uiviewcontroller . put line in viewdidload but not working. self.navigationcontroller.interactivepopgesturerecognizer.enabled = no; how can disable feature. because have side menue ( swrevealviewcontroller ). when swipe frontviewcontroller goes loging screen. how can avoide this? above line not working me. please me. thanks

Java no suitable constructor found -

for assignment have created class called agency store data talent agencies , have created required attributes. i've been given data file need read from. first test class. can use getter , setters fine display desired output want create new instance of object agency , add details error message saying no suitable constructor found. have matched settings constructor or @ least can't see mistake is. thanks. public class agency { //attributes class agency private string name; private string[] address; private string[] adminstaff; private int phonenumber; private string type; /** *constructor creates object agency */ public agency() { } /** * constructor creates object agency values * @param name * @param address * @param adminstaff * @param phonenumber * @param type */ public agency(string name, string[] address, string[] adminstaff, int phonenumber, string type) { this.name

c# - UpdatePanel change my Table style -

Image
i use nested usercontrol in form when page load dont have problem when checked checkbox in updatepanel whole style ruined problem ? foreach (tablecell item in tc_mdfitems) { foreach (var item2 in item.controls) { ((item2 mdfitem).findcontrol("chkb_select") checkbox).checked = this.wchk_rowselector.checked; } } when i'm not using update panel working want ajax i change code way <asp:updatepanel id="up_mdfrow" runat="server" updatemode="conditional" rendermode="inline"> <contenttemplate> <div id="tablediv" runat="server"></div> </contenttemplate> when add usercontrol's table div element works fine . thank all

javascript - phonegap + ionic using Content-Security-Policy to load maps.googleapis.com, how to? -

i have tried many ways of loading google maps , firebaseio without success: have now: <meta http-equiv="content-security-policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; script-src 'self' https://maps.googleapis.com/* 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';"> and get: refused load script 'https://maps.googleapis.com/maps/api/js?libraries=places' because violates following content security policy directive: "script-src 'self' https://maps.googleapis.com/* 'unsafe-inline' 'unsafe-eval'". refused load script 'https://test.firebaseio.com/.lp?start=t&ser=79549912&cb=1&v=5' because violates following content security policy directive: "script-src 'self' https://maps.googleapis.com/* 'unsafe-inline' 'unsafe-eval'". any ideas doing wrong? this did trick

ruby - Rails 4.2.3 `method_missing': undefined method `active_record' -

i tried create new rails app today, , app behaving though activerecord isn't there. i created app with: rails new myapp --database=mysql when running rake db:create, get: rake aborted! nomethoderror: undefined method `active_record' #<rails::application::configuration:0x007faad08b3058> /library/ruby/gems/2.0.0/gems/railties-4.2.3/lib/rails/railtie/configuration.rb:95:in `method_missing' /users/richard/dropbox/development/myapp/config/application.rb:24:in `<class:application>' /users/richard/dropbox/development/myapp/config/application.rb:10:in `<module:myapp>' /users/richard/dropbox/development/myapp/config/application.rb:9:in `<top (required)>' /users/richard/dropbox/development/myapp/rakefile:4:in `<top (required)>' (see full trace running task --trace) in fact, if comment out offending line , run rake -t: ... rake cache_digests:dependencies # lookup first-level dependencies template (like messages/show

Building a login module in Django -

i'm trying build login module in django works independently page on. i'm defining login module in base.html template contains header (the login module sits in header) other pages extend base template. my plan pass error through context dictionary, problem don't know how make function render() render template user attempted login. this view code: def login(request): context_dict = {} if request.post: username = request.post.get('login_username') password = request.post.get('login_password') user = authenticate(username=username, password=password) if not user: context_dict['error'] = 'שם משתמש או סיסמא אין נכונים' elif not user.is_active: context_dict['error'] = 'חשבונך נחסם, אם הינך חושב שזאת טעות צור קשר עם מנהל בהקדם.' else: login(request,user) redirect(request.meta.get('http_referer')) render(re

Using external lookup in Logstash -

i'm working on 2 logstash projects, 1 monitoring iis logs , 1 firewall. now iis logs high-usage servers generating 25gb of logs each month , there several of these. issue here not want enable reverse lookup, not on servers nor in logstash, external service can cache outside of dns lookup´function in logstash. the other problem want solve firewall project related lookup of standard, , non-standard ports. our firewall generates dest portnumber translate make our kibana dashboards more readable. firewall has around 10gb/s traffic , generates lot of syslog traffic. we run 8-16 workers on our logstash server. there easy (?) way make api call logstash , worth considering based on performance? another option i'm condering "offline" batch processing, ie running batch jobs directly towards elasticsearch, likley mean should have separate instance of elasticsearch or redis before frontend. the best option likley translation in kibana interface, scripted field, of u

ruby on rails - RoR Could not find fog-aws-0.7.0 in any of the sources -

Image
i have problem heroku, when try push it, not find fog-aws-0.7.0 in of sources. remote: not find fog-aws-0.7.0 in of sources remote: ! remote: ! failed install gems via bundler. remote: ! remote: remote: ! push rejected, failed compile ruby app remote: remote: verifying deploy.... remote: remote: ! push rejected sample-app-kong. remote: https://git.heroku.com/sample-app-kong.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed push refs 'https://git.heroku.com/sample-app-kong.git' version 0.7.0 of fog-aws gem has been removed rubygems server. if run bundle update fog-aws in project folder, bundler try load latest version of gem instead, , you'll able push heroku

ios - UIImage Stretching issue in Landscape mode -

Image
i had used uicollectionview show 3 images in each cell in portrait , landscape mode using autolayout . fetch images server load in uicollectionview data. in iphone 4s , 5 working little better iphone 6 , 6 plus image stretching issue in portrait , landscape mode. had tried aspectfit need fill image in full space. had spent more time how solve issue? please let me suggestions. thanks in advance fyi, screenshot you need use aspectfill aspectfit keeps aspect ration, showing image, therefore won't fill imageview, , aspectfill keeps aspect ratio, , filling imageview, therefore wont show image, think sort of cropping image fit in imageview.

vba - How to find a column with missing value in Excel -

i have sheet 200 columns. cells having 3 possible characters. want find out columns don't have 3 characters (in sequence, in repetition). lets say, if of character missed in column, formula should mark in cell below. sorry, not excel guy , needed put check in 200 such long workbooks. any appreciated. what use separate sheet, in shadow cells. each cell check if corresponding cell on other sheet valid. if show 0 , if isn't, show 1 . sum columns , if sum higher 0 column invalid.

javascript - internet explorer 7 Popup modal not opening -

i trying 2 days, not sure how fix issue. on firefox , chrome working fine. plus on latest ie works, on ie7 , ie8 popup dont open. http://webteezy.com/demos/prototype.html# what trying do. when clicked on baloon there popup opens small amount of data in it. when clicked on metadata in popup popup modal should open. works fine in other browswers, except ie7 , ie8. what do?? =-==-=-=-= e-g metadata button showing in modal when balloon pressed <p><a href=# class="butt cb00071">data</a><a href="#cb00071" class="butt hover cb00071">metadata</a></p> script goes below $('body').on('click','.cb00071',function(e){ $('#cb00071').css({'display':'inline-block', '*display': 'inline', 'zoom': '1'}); }); and modal show when button pressed. below modal. <div id="cb00071" class="overlay ligh

java - Searching in a unsorted tree recursively -

i'm trying search element e in tree, can see search(position,e) doesn't return position. when add "return null;" @ end of method. works when position i'm looking @ left children of parent , returns null otherwise. how can keep working until reaches end of tree? public position<e> search(e e) { return search(root(), e); } public position<e> search(position<e> p, e e) { if(p.getelement().equals(e)) return p; for(position<e> c: children(p)) return search(c, e); } i think issue in loop: for(position<e> c: children(p)) return search(c, e); imagine element you're searching in second child of node rather first. above code, on first iteration of loop, you'll recursively explore first child, returns false, return false without having had chance explore second child. in other words, method looks @ first child, might not find you're looking for. to fix this, try rewriting

How to run g4 file by ANTLR4 plugin in Eclipse -

Image
i installed antlrv4 plugin eclipse , created file hello.g4 : /** * define grammar called hello */ grammar hello; r : 'hello' id ; // match keyword hello followed identifier id : [a-z]+ ; // match lower-case identifiers ws : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines how can run g4 file in eclipse , how view parse tree ? the use of antlr plugin works in 2 phases: first, compile .g4 file in order produce .java code lexer/parser/visitor/listeners..., if open parse tree window. to that, project must have xtext nature, if nature not enabled: right click on project, configure->add xtext nature . once nature enabled, in project properties, should see antlr4 entry. can configure special options project here. each time save modifications on .g4 (if have opened antlr editor given plugin), trigger recompilation of files. to open parse tree window, select window->show view->other...->antlr4->parse tree . ope

audio - how to access wave viewer from another form in c#? -

i have 2 win forms. 1 form1.cs , other 1 record.cs in form1.cs have 2 wave viewers. when opened wave file form1, waveviewer1 showing wave nicely. in record.cs form i'm recording new wave , save it. after clicking stop button want show recorded file's wave in form1's wavewviewer2. how should that?? have tried lot. form1.cs open button code. private void openbutton_click(object sender, eventargs e) { openfiledialog filedlg = new openfiledialog(); if (filedlg.showdialog() == dialogresult.ok) { wavecontrol1.filename = filedlg.filename; wavecontrol1.read(); } }//this working fine.

html - Background-image being cut off when trying to make it fit around the element -

Image
i trying background-image fit around video , every time try making bigger top cut off , can't seem make fit around video , good. i want image border video. pretty sure has image going out side video div, mistaken. appreciated! html: <div class="videos"> <div id="video1"> <iframe width="450" height="315" src="https://www.youtube.com/embed/vr0dxfqqfnu" frameborder="0" allowfullscreen></iframe> </div> <div id="video2"> <iframe width="450" height="315" src="https://www.youtube.com/embed/fevkx229xbs" frameborder="0" allowfullscreen></iframe> <!--h <img src="images/vidborder2.png" class="vidborder2">--> </div> </div> css: div#video1 { float: right; background-image: url(images/vidborder.png); background-repeat: no-repeat;

Laravel creates a new session when opening facebook to login from my app -

app has been running while , i'm adding facebook login when app starts (running ionic laravel 4.2 @ back), fetches csrf_token server. when click on facebook login takes me inapp browser login there. login gets approved facebook problem somehow laravel loses track of session , changes csrf token. can make laravel keep same session in backend? why creating new one/changing token? thanks help!

sorting - Sort Descriptor not working in ios -

i used sort descriptor sort nsmutablearray 1 & multiple values,first tried sort price,it sort in other order here code me, create dictionary below code , added nsmutablearray for(int i=0;i<[pricearray count];i++) { celldict=[[nsmutabledictionary alloc]init]; [celldict setobject:namearray[i] forkey:@"name"]; [celldict setobject:splpricearray[i] forkey:@"percentage"]; [celldict setobject:pricearray[i] forkey:@"price"]; [resultarray addobject:celldict]; } // sort in ascending order nssortdescriptor *sort =[[nssortdescriptor alloc] initwithkey:@"price" ascending:yes]; nsarray *descriptors = [nsarray arraywithobjects:sort, nil]; nsarray *sortedarray=[resultarray sortedarrayusingdescriptors:descriptors]; nslog(@"result %@ sorted arr %@",resultarray, sortedarray); and output is: result ( { name = "black eyed peas"; percent

php - Setting a global attribute to an woocommerce product -

i add globally defined attribute product in woocommerce. tried function update_post_meta( get_the_id(),'_product_attributes',"pa_myglobalattribute"); that didn't work. tried, attribute terms , assign them globalattribute: update_post_meta( get_the_id(), 'pa_myglobalattribute',$attribute_array); the attribute array retrieved over: json_decode(json_encode(get_terms("pa_myglobalattribute")),true); that didn't work either. for me, important assign global attribute product, if different user edits attribute, changes assigned products. any suggestions? thank you!

ios - Linking Button to Next View Controller -

Image
i can't seem figure out xcode 6 how connect button go next view controller. in view controller scene, have 2 view controllers, vc1 , vc2. vc1 has button , want vc1 first, , have user click button, lead vc2. how do that? basically, how link button in vc1 vc2? just press control key , drag uibutton onto view controller

c++ - count the frequency of groups in vector using rtree ( or any other algorithm ) -

given following set of points in vector {( 100, 150 ), ( 101, 152 ), ( 102, 151 ), ( 105, 155 ), ( 50, 50 ), ( 51, 55 ), ( 55, 55 ), ( 150, 250 ), ( 190, 260 ) } i need identify neighboring points , count. let acceptable distance has been set 5. need following output: frequency of point ( 100, 150 ) in 5 units 4. frequency of point ( 50, 50 ) in 5 units 3 frequency of point ( 150, 250 ) within 5 units 1 frequency of point ( 190, 260 ) within 5 units 1 i have tried rtree solution problem couldn't determine logic exclude neighboring points candidates. means once have identified there 4 neighbors of ( 100, 150 ), don't want identify neighbors of neighbors. move on next value. here presumptions: 1. efficiency topmost concern 2. vector unsorted 3. vector may contain thousands of points. using c++ , boost implementation of rtree. please guide me how can achieve solution here code following code counts number of neighbors of unique points in vector. need guidance on e