Posts

Showing posts from May, 2010

excel - Create and auto-populate new sheets based on Master sheet -

my question how create new named page, set out in new layout, populated existing data. example, “new sheet” “c3” takes data “full info” “d5”, etc. having being named “a3”. i run small business 800 customers, , tbh, laid original sheet out wrong - although seemed sufficient @ time – 1 row per customer, several columns. have found code create , rename new sheet based on cell value (a3), , other code copy cell values 1 sheet another. works on pre-existing sheet, , don't know where, or how, fuse together. (i want unique customer page billing , archive purposes, unless has better solution). creating , renaming: sub createsheetsfromalist() dim mycell range, myrange range set myrange = sheets("full info").range("a3") set myrange = range(myrange, myrange.end(xldown)) each mycell in myrange sheets.add after:=sheets(sheets.count) 'creates new worksheet sheets(sheets.count).name = mycell.value ' renames new worksheet

node.js - How to capture the 'code' value into a variable? -

i'm using below code reset password on linux box using nodejs , ssh2 module: // file * ./workflow/ssh.js var client = require('ssh2').client; var conn = new client(); // var opts = require('optimist') // .options({ // user: { // demand: true, // alias: 'u' // }, // }).boolean('allow_discovery').argv; // definition of reset password; var resetpassword = function(user, host, loginuser, loginpassword){ var command = 'echo -e "linuxpassword\nlinuxpassword" | passwd '+ user; conn.on('ready', function() { console.log('client :: ready'); conn.exec(command, function(err, stream) { if (err) throw err; stream.on('close', function(code, signal) { console.log('stream :: close :: code: ' + code + ', signal: ' + signal); conn.end(); return(code); }).on('data', function(data) { console.log('stdout:

c - Sscanf doesn't give me a value -

i have piece of code: if(string_starts_with(line, "name: ") == 0){ //6th first char of name char name[30]; int count = 6; while(line[count] != '\0'){ name[count-6] = line[count]; ++count; } printf("custom string name: %s", name); strncpy(p.name, name, 30); } else if(string_starts_with(line, "age: ") == 0){ //6th first char of name printf("age line: %s", line); short age = 0; sscanf(line, "%d", age); printf("custom age: %d\n", age); } the if works, else if doesn't work. example output is: person: name: great custom string name: great age: 6000 age line: age: 6000 custom age: 0 i have changed lot, using &age in sscanf function, nothing works. if want store value short (why¿?) need use appropriate length modifier. also, if expecting number come after prefix string, need start scan after prefix string. finally, mention in pass

c# - assigning type to a variable and using it to initialize other objects -

is possible this: tybevariable = double; typevariable newdoublevariable = 5; i want define variable wich contain type , initialize objects it. you can use var keyword. implicitly type keyword. can read more here

vb.net - How to filter datagridview column -

for example have datagridview1 data imported text file , there 3 columns: id, name, gender. what want select/show male in gender column. i dont have database here can't use sql queries or there way manipulate datagridview using sql queries? this: select * datagridview1 gender='male' any response appreciated. i c# developer, don't know if there built in functions in vb this, simplest way think loop through datagridview , filter manually, can either remove row or make in invisible. you can implement basic search way too. of course not fastest nor effective way it, job done. alternatively can store data in list or array make loop run faster. improve performance can hide datagrid when loop started , show again when loop finished, way system won't waste time on showing datagrid animations. for example you have number column , want show rows have values between 50-100, simple code this: for(int i=0; i<datagridview1.rows.count; i++) { int t

android - OpenGL ES 2.0 diffuse lighting: model shows up black -

this problem bothers me week... tried load stl files , show on screen. file read properly. rendering without adding light pretty good. after add lighting , shader codes, model still there turns out black. i followed example downloaded link below article: http://www.learnopengles.com/android-lesson-two-ambient-and-diffuse-lighting/ the shader code same example. program links fine. shaders compile fine, too. can't find out problem is. plz me. my renderer: public class myglrenderer implements glsurfaceview.renderer { private test test; private light1 light1; private float range = 145; private final float[] mmvmmatrix = new float[16]; private final float[] mmvpmatrix = new float[16]; private final float[] mmodelmatrix = new float[16]; private final float[] mprojectionmatrix = new float[16]; private final float[] mviewmatrix = new float[16]; protected final static float[] mlightposineyespace = new float[4]; private final float[] mlightmodelmatrix = new float[16]

asp.net - Do .NET Core apps require the .NET runtime installed on the target machine? -

in video , scott hanselman interviews guy asp.net team. says 1 of goals of asp.net 5, on top of .net core, apps won't depend on .net framework , gac assemblies on hosting server. instead, .net core libraries released via nuget packages , apps deployed dependencies. one of reasons microsoft can release bug fix or new feature, , don't have wait until new version (of full framework) installed on our hosting environment. my question is: are apps built on .net core independent of version of .net installed on target machine, , can run without .net framework installed? yes, framework use in application independent of .net framework installed on target server, because core .net framework referenced via nuget packages , can bundled deployment via dnx utility , of interest dnu publish command. here excerpt, describing dnu publish does: publish ( dnu publish ) the publish command package application self-contained directory can launched. create following dire

c# - Cities Skylines Modding Remove all trees -

i not sure how it. foreach (uint tree in treestodelete.m_trees) { ????? } or for (int = 0; < treemanager.m_treecount; i++) { var tree = treemanager.instance.m_trees[i]; treemanager.instance.releasetree(tree); } don't know how finish first 1 , these errors when use second. an object reference required access non-static member treemanager.m_treecount cannot apply indexing [] expression of type array32 best overloaded method match treemanager.releasetree(uint) has invalid arguments thanks giving error. you're getting 2 errors there: an object reference required access non-static member treemanager.m_treecount' you need initialise treemanager class. an object reference required access non-static member var treemanager = new treemanager(); i'm not sure if takes constructor arguments. should help. you can access so: var treemanager = new treemanager(); (int = 0; < treemanager.m_treecount; i++) { var tr

android - Render Dialog elements with Material Design Style -

i'm creating dialog fragment layout uses checkboxes. however, i'm never able render them material design in pre-lollipop devices. however, i'm able done in regular activity. have when dealing dialogfragments? these parts of dialogfragment code: @override public dialog oncreatedialog(bundle savedinstancestate) { dialog dialog = super.oncreatedialog(savedinstancestate); setstyle(dialogfragment.style_normal, r.style.theme_appcompat_dialog); window window = dialog.getwindow(); window.requestfeature(window.feature_no_title); window.getattributes().windowanimations = r.style.share_multiplayer_animation; return dialog; } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.share_multiplayer_scorecard, container, false); butterknife.bind(this, view); viewgroup sharecontainer = butterknife.fin

ruby - Sinatra displaying all data to user (custom dictionary and definition app) instead of data for specific word -

trying make user custom dictionary. @ index, user present list of of custom words , have ability add more. can click link specific page on word user shown definitions , can add more. my problem definitions words displayed. below ruby code.. class word @@words = [] define_method(:initialize) |word| @word = word @id = @@words.length().+(1) @definitions = [] end define_singleton_method(:all) @@words end define_method(:save) @@words.push(self) end define_singleton_method(:clear) @@words = [] end define_method(:id) @id end define_singleton_method(:find) |ident| found_word = nil @@words.each() |word| if word.id.eql?(ident) found_word = word end end found_word end define_method(:add_definition) |definition| @definitions.push(definition) end define_method(

hdfs - Hadoop 2.0 data write operation acknowledgement -

Image
i have small query regarding hadoop data writes from apache documentation for common case, when replication factor three, hdfs’s placement policy put 1 replica on 1 node in local rack, on node in different (remote) rack, , last on different node in same remote rack. policy cuts inter-rack write traffic improves write performance. chance of rack failure far less of node failure; in below image, when write acknowledge treated successful? 1) writing data first data node? 2) writing data first data node + 2 other data nodes? i asking question because, have heard 2 conflicting statements in youtube videos. 1 video quoted write successful once data written 1 data node & other video quoted acknowledgement sent after writing data 3 nodes. step 1: client creates file calling create() method on distributedfilesystem. step 2: distributedfilesystem makes rpc call namenode create new file in filesystem’s namespace, no blocks associated it. the namenode p

node.js - passport node adding a parameter -

when use passport coinbase node passport.use(new coinbasestrategy({ clientid: coinbase_client_id, clientsecret: coinbase_client_secret, callbackurl: "http://127.0.0.1:3000/auth/coinbase/callback", scope: [ "send" ] , }, i error invalid amount meta[send_limit_amount] () what syntax adding parameter? tried 10 different things. the passport-coinbase library not recognise meta data there callback function in passport pick additional authorisation parameters i added after passport.use(...) things moving again // have handle metadata ourselves const metadata = { send_limit_amount : 50, send_limit_currency : 'usd', send_limit_period : 'day' }; passport._strategies.coinbase.authorizationparams = function(options) { var meta = {}; for(o in metadata){ meta['meta['+o+']'] = metadata[o]; }; return meta; };

android - Using Google Design Library how to hide FAB button on Scroll down? -

google have released design library, using compile 'com.android.support:design:22.2.1' however cant see code examples of how use library , how animate fab bar on scroll. guess can listen scroll events on listview , animate button myself, not baked api (is not point of support library). is there examples ? thanks if you're using recyclerview , you're looking simple, can try this: recyclerview.addonscrolllistener(new recyclerview.onscrolllistener(){ @override public void onscrolled(recyclerview recyclerview, int dx, int dy){ if (dy > 0) fabaddnew.hide(); else if (dy < 0) fabaddnew.show(); } }); by replacing 0 constant, can adjust sensitivity of triggering, providing smoother experience

python - Using subprocess module with curl command -

i'm getting error: function' object unsubscriptable when using subprocess module curl command. cmd (subprocess.check_call ['curl -x post -u "opt:gggguywqydfydwfh" ' + url + 'job/%s/%s/promotion/' % (job, num)]). i calling using function. def cmd(sh): proc = subprocess.popen(sh, shell=true, stderr=subprocess.pipe, stdout=subprocess.pipe). can point out problem? you forgot parens check_call : subprocess.check_call(["curl", "-x", "post", "-u", "opt:gggguywqydfydwfh",url + 'job/%s/%s/promotion/' % (job, num)]) you trying subprocess.check_call[... you passing function, check_call returns exit code trying pass 0 popen call sh going fail. if want output, forget function , use check_output , need pass list of args: out = subprocess.check_output(["curl", "-x", "post", "-u", "opt:gggguywqydfydwfh", url + 'job/%s/%s/

php - How can I establish connection between a client and a server where the server sends new messages to the client? -

i need establish connection between client , server via php websocket. the server need keeps checking external api new messages , send them client. i understand concept can code it. have questions me wrap around head. the client side keep making calls server via websocket every second using javascript's setinterval() function or make 1 call? how client know server have new messages? the server side create script runs infinite loop keep checking api , echo results? websocket how websocket know connection message belong to? i not sure if matter going use ratchet creating websocket on past days, solved problem via comet. , used php,node.js. should check comet technology , php , node.js. http://www.screenr.com/snh http://blog.jamieisaacs.com/2010/08/27/comet-with-nginx-and-jquery/ etc.

javascript - On a one-time self-re-defining function pattern -

consider following pattern: function foo /* aka outer_foo */ () { // === stage 1 === // declaration , initialization of closure variables var ... <closure_vars> ...; // initialization of closure_vars // (possibly expensive and/or depending on values known @ run-time) // === stage 2 === // one-time redefinition of foo foo = function /* inner_foo */ ( arg0, ... ) { var results; // code computing value of results based on closure_vars, arg0, ... // foo never modified here return results; }; // === stage 3 === // invocation of inner function , returning of result return foo.apply( this, arguments ); } for convenience, use terms outer_foo , inner_foo designate, respectively, outer , inner functions above, though code not use these identifiers. the body of outer_foo comprises 3 stages (the last 2 consisting of single statement each): declaration , initialization of closure variab

refactoring - Ruby: Improve complex initialize method -

i have piece of ruby code boils down this: class foo attr_reader :a, :b, :c def initialize build_a build_b build_c end private def build_a # complex results in @a = end def build_b # complex results in @b = end def build_c # complex results in @c = end end calling build_* in initialize method seems bit superfluous. there better way write this? of course i'm aware of lazy loading pattern: class def @a ||= something_complex end end but, need code thread safe, can't use pattern here. edit: main concern code, see fact build_a should called after initialisation, written @ definition of build_a instead of in initialize method. those callbacks real pain in ass test , maintain. wouldn't solution better?: class foo attr_reader :a, :b, :c def initialize # things belong in initialize end def self.call # or other name new.build_things end def build_things build_a build_b

android - How do I get this statement to work in Non Activity Classes? -

i need statement activate dep. injection.... ((app) getapplication()).inject(this); //or in fragment ((app) getactivity().getapplication()).inject(this);   this statement works fine in activities , fragments , services, how statement work in non-activity/fragment/service based classes? what dependency injection framework using? looks might dagger , in case can use constructor @inject annotation , have dependencies passed in through (where foo class , bar dependency): private final bar mbar; @inject public foo(bar bar) { mbar = bar; } in module you'll need like: @provides public foo providesfoo(foo foo) { return foo; } if aren't using dagger (and if are), i'd recommend making static method in application class instance of application avoid casting it, , allow accessible anywhere within app (although i'd call in activities/fragments/services/etc.). use this: private static app sinstance; public static app getinst

How to fix the jquery code below -

<h1>click me</h1> <div class="content"> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat nonproident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> <script type="text/javascript" src="jquery-1.11.3.min.js"></script> <script type="text/javascript"> $('.content').hide(); var $this = $('h1');`` var form = { enter: function(){ console.log('slidedown') // $this.next('div.content').slidedown(500) }, leave: function(){ console.log('slideup')

javascript - Method of array or sequence of ui-views with Angular UI-Router? -

i have application sections used series of routes in nested ui-view. in other words: feedback.html-- |--feedback-alerts.html |--feedback-progress.html and on, maybe 5-6 pages per section this. on main page sub-nav menu , ui-view hold views clicked in menu. works fine. problem is, client prefer see these subdocuments on 1 page, , have sub-menu links scroll down each sub-section clicked! i rather keep these templates separate. realize can ng-include s, , might still, wondering if there way have all-on-one-page experience views have... here's routes, few redundant ones removed. (function() { 'use strict'; angular.module('pb.ds.feedback').config(function($stateprovider) { $stateprovider.state('feedback', { abstract: true, url: '/feedback', templateurl: 'modules/feedback/templates/feedback.html', controller: 'feedbackcontroller feedback', data: {

WordPress Plugin Conflict with WooCommerce Product Page -

Image
our plugin displays red signup bar across entire site. on woo commerce pages only, signup bar going product description container shown here: this should doing, consistent rest of site: here code extract plugin: /*style sheet signup plugin teresa light august 16, 2015 version 1.0 */ #main.clearfix.width-100{ padding-right:0px!important; padding-left:0px!important; } /* overall container */ signup { margin: auto; padding: auto 0px!important; font-size:80%; background: #d03925; text-align: center; display: flex; /* new, spec - opera 12.1, firefox 20+ */ display: -webkit-flex; /* new - chrome */ display: -moz-box; /* old - firefox 19- (buggy works) */ -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; } /* begin flex */ .flex-container { text-align: center; display: flex; /* new, spec - opera 12.1, firefox 20+ */ display: -we

mysql - First order by (condition) and then by (condition) -

i want order sql request depending upon first user's statut , upon username. statut set column user_type : 1=active, 2=inactive , 3=founder. i use request doesn't work because want include in "active" members actives users (1) , founders (3) : select user_type, callsign, username, vid, 0php_hub_chef.hub_id id_hub 0php_users left join phpbb_users on phpbb_id = phpbb_users.user_id left join 0php_hub_chef on 0php_hub_chef.user_id = phpbb_users.user_id 0php_users.hub_id = 29 order user_type <> 1, username_clean asc i : order user_type <> 1 , 3, username_clean asc have idea? you can use in : order user_type in (1, 3) desc, username_clean asc in mysql, boolean expression treated integer in integer context. if user_type 1 or 3, evaluates 1 else 0 -- hence desc . if don't desc , can use not in : order user_type not in (1, 3), username_clean

android - Calculate image's Dimensions/Size without downloading it -

is there way image dimensions or size without downloading server. like if image hosted on https://500px.com/ or https://imgur.com/ , want calculations want save bandwidth . if image size quite large , user bandwidth not want queue image later. assuming api doesn't provide such information. in didrecieveresponse delegate method nsurlconnection recieve response contains such info. if , if has been set on server: the following gets disk size of image: - (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response { nshttpurlresponse *httpresponse = (nshttpurlresponse *) response; int state = [httpresponse statuscode]; if (state >= 400 && state <600) { // wrong happen } nslog(@"download response : %@", [response description]); // shows info. available server. int file_size = [response expectedcontentlength]; } you can check size , cancel connection if want to.

reactjs - How to write your own properties onto react-router's RouteHandler within typescript -

i using ts nightly, able use jsx bits. using react-router typings via definitelytyped ( tsd install react-router ). the following render of main route handler: render() { var name = this.context.router.getcurrentpath(); return ( <div> <routehandler key={name} hub={this.props.hub} state={this.state} /> </div>); } this code part has number of issues: context has been specified {} without chance modify it. i can fiddle around one. the properties pass onto routehandler not specified on corresponding type... error ts2339: property 'key' not exist on type 'routehandlerprop'. ... but understanding properties passed way passed react component rendered handler. does know can compile in typescript? context has been specified {} without chance modify it use fat arrow ()=> . more : https://www.youtube.com/watch?v=tvocucbcupa the properties pass onto routehandler not specified on corresponding t

javascript - Why are generator methods constructors? -

methods when declared methods (using es6 enhanced object literals or classes) not constructors / not have prototype chain. but generators when declared via method syntax, have prototype chain , constructors. take following example - (requires v8) 'use strict'; class x { *a() { this.b() } b() { print('class method'); } } let = new x(); i.a.prototype.b = function() { print('generator method'); }; i.a().next(); (new i.a()).next(); outputs, class method generator method while adding prototypes i.b , , calling new i.b() throw error because i.b not constructor, i'm able new i.a() , , this inside *a gets different context. why difference exist? what use case having prototype in generators defined methods? definitely odd quirk of es2015 spec. tc39 had long discussion back in july , , decided make generators non- new able . the official change spec landed last month , , while there little concern breaking things, v8 , spidermon

swift - Using Returned JSON Status in an if statement (Checking IAP Auto Renew Receipt ) -

im want check current subscription status of auto renew in app purchase. im getting receipt data via json, im after advice on how use/query returned data if let parsejson = json { println("recipt \(parsejson)") } returns recipt { environment = sandbox; status = 21004; } whilst know wouldn't compile, want to along lines of if statement like: if parsejson contains status = 21004 { //do } you might consider like if parsejson["status"] as? int == 21004 { // } this works because as? int automatically convert nsnumber swift integer, , because there version of == accepts optional arguments. public func ==<t : equatable>(lhs: t?, rhs: t?) -> bool

c - Single callback for multiple /proc entries - find the caller entry -

first of all, api /proc (linux 3.10+) seems different 1 specified in old kernel books. i creating several /proc entries, have same write function associated callback. same stands read function. if write or read 1 of /proc entries mentioned above, know entry written or read , able have information inside callback function. i using proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops) . the callback functions have following list of arguments: (struct file *filp, char *buf, size_t count, loff_t *offp) . i can't figure out give me clue regarding file has call been triggered. first thought struct file* might help. i've found struct file contains struct path contains struct dentry contains struct qstr contains const unsigned char *name . way thing should handled or easier, more elegant way (haven't tested char *name yet)? i recommend using struct proc_dir_entry *proc_create_data(const char *

javascript - Nodejs with Express... post data not received in users.js from jade form -

windows 8.1 nodejs express console output is... $ npm start > nodeauth@1.0.0 start e:\nodejs\_projects\nodeauth > node ./bin/www /users/register 200 525.115 ms - 2078 /stylesheets/style.css 304 7.118 ms - - /stylesheets/bootstrap.css 304 7.198 ms - - /javascripts/bootstrap.js 304 8.063 ms - - name is... undefined reqname... undefined pw is... undefined pw2 is.. undefined post /users/register 200 79.328 ms - 2340 /stylesheets/bootstrap.css 304 7.847 ms - - /stylesheets/style.css 304 7.378 ms - - /javascripts/bootstrap.js 304 8.676 ms - - register.jade is... form loads ok , appears correct extends layout block content h1 register p complete form site registration ul.errors if errors each error, in errors li.alert.alert-danger #{error.msg} form(method='post',action='/users/register',enctype='multipart/form-data') .form-group input.form-control(name='name', type

java - Accessing static method through an object instance -

i have learnt if wish call static method of class have write class name while calling static method. in below program, created object of employee class inside employee_impl class , using object, still able access count method. why allowing me use count method through object if static methods accessed using class name? mean static methods can accessed using objects class name, both? employee.java public class employee{ static int counter = 0; static int count(){ counter++; return counter; } } employee_impl.java class employee_impl public static void main(string args[]){ employee obj = new employee(); system.out.println(obj.count()); system.out.println(employee.count()); system.out.println(obj.count()); } } output 1 2 3 compiler automatically substitutes call call class name of variable ( not of it's value !). note, if object null, it work , no nullpointerexception thrown.

php - select query with 2 tables -

i have page people can post comments , page people can click "follow" on other people profiles (same on facebook) i have select query post comments have, order them follow way: first, print 2 newest comments (they must been posted week) of lastest people click follow. second, post rest of posted, order them create-date (i'm using linux time) can me sql query? this current select query. pull comment create-date: select id, userid, text, createdate `comments` comment (comment.refid = 0) , (comment.pagename = 'yard') , 1=1 order comment.createdate desc limit 0, 20 "followers" table looks this: userid ownerid createdate 1 2 1439019657 1 4 1438940399 "comments" table looks loke this: id userid pagename refid text createdate 220 1 yard 0 text1 1438030967 227 1 yard 0 text2 1438031704 228 1 yard 0 text3

javascript - node.js , ^ SyntaxError: Unexpected token ] -

this code : app.get("/posts/:slug", function(request, response) { var slug = request.params.slug; connection.query("select * `posts` slug = ?", [ slug ], function(err, rows) { var post = rows[]; response.render("post", { post: post, formatdate: formatdate }); }); }); when run index.js in terminal ; /home/yasser/yasser/index.js:33 var post = rows[]; ^ syntaxerror: unexpected token ] the error syntaxerror: unexpected token ] produced because var post = rows[]; invalid. when gets [ next thing expects number ( or string ) represents index of item in array. for example, if change var post = rows[0]; you'll first element in array.

Why MySQL where in (list) takes quite long? -

i try use mysql in (list) list 1000 items. takes me around 5 seconds. normal? my query select hex(hash) hash hash_table hash in (unhex("2c9ed97bb7cf48ddf74f"),....) i have 10 million rows in hash_table. how make faster?

javascript - Make collapsable panel close when another one is opened -

i'm using jquery slidetoggle content when button clicked. here's html: <div class="seasons"> <div class="container text-center"> <div class="row margin-top-medium"> <div class="col-md-12 1"> <div class="season hvr-shrink">12×01 chi cerca trova</div> <div class="content"> <div class="hvr-shrink">12×01 chi cerca trova</div> </div> </div> <div class="col-md-12"> <div class="season hvr-shrink">12×02 il mini peter</div> <div class="content"> <div class="hvr-shrink">12×01 chi cerca trova</div> </div> </div> <div class="col-md-12"> <a href="#"><div class="season hvr-shrink">12×0

cypher - Reliable (auto)incrementing identifiers for all nodes/relationships in Neo4j -

i'm looking way generate unique identifiers nodes/relationships in neo4j, based on incrementing counter (not big long uuids). the internal ids maintained neo4j engine known not reliable outside references. a solution comes close the code proposed in question , doesn't work when single create clause creates multiple new nodes: // unique id merge (id:uniqueid{name:'person'}) on create set id.count = 1 on match set id.count = id.count + 1 id.count uid // create new node attached every existing :something node match (n:something) create (:somethingrelated {id:uid}) -[:rel]-> (n) when there multiple (n:something) , every newly created (:somethingrelated) share same id. there way around this, using cypher? try allocate block of ids: // collect nodes connect match (n:crew) collect(n) nodes merge (id:uniqueid { name:'person' }) // reserve id-range set id.count = coalesce(id.count,0)+ size(nodes) nodes, id.count - size(nodes) base // each ind

arrays - appending non slice to map of slices -

my current code this: name := "john" id := "1234" c := make(map[string][]string) c["d"] = make([]string, len(d)) c["l"] = make([]string, len(l)) copy(c["d"], d) copy(c["l"], l) c["test"] = name c["id"] = id assuming d & l both []string. go not let me this. there way able achieve json this: { "name": "john", "id": "1234", "d": [ 123, 456 ], "l": [ 123, 456 ] } you need use map[string]interface{} instead. also don't need copy slices. example map[string]interface{} : name := "john" id := "1234" l, d := []string{"123", "456"}, []string{"789", "987"} c := map[string]interface{}{ "d": d, "l": l, "test": name, "id": id, } playground

eclipse - Removing all unused sound objects from android project -

i have android project contains lot of unused sound resources is there way automatically remove unused resources android project including sounds ? lint can tell resources unused can remove them: invoke via android studio or hand: lint --check unusedresources <project path> you can open generated r.java file , @ resources - unused highlighted same way other unused member (but careful it, java references count, not layout ones, or reference resource name via code) you can use https://github.com/keepsafe/android-resource-remover (based on lint report)

testing - Scala: replace method at runtime -

let's have class class original { def originalmethod = 1 } now, let's have instance of it val instance = new original is possible instance @ runtime replace originalmethod different method? (granted signature stays same) for example, now, when calling instance.originalmethod following code called println("test"); 1 edit can't call new original . have existing instance of it, have modify. edit 2 (@aleksey izmailov answer) nice solution, isn't i'm looking for. i'm thinking more in terms of testing - writing class "normally", without specifying functions variables rather methods ps. stumbled on question when trying mimic mockito spy this isn't possible on jvm — in either java or scala — not in way you're asking for. see e.g. in java, given object, possible override 1 of methods? being in scala instead of java doesn't gain additional leverage, since fundamentals of how classes , methods work in

.net - Reflection to add/set new custom attributes -

i trying figure way add new custom attribute @ runtime, realize might impossible settle adding customer attribute bit want try override/set size my class this public class poco1 <stringlength(15)> property firstname string property lastname string end class i try like dim lname stringlengthattribute = new stringlengthattribute(50) dim last propertyinfo = this.getproperty(("lastname")).add(lname)

How to get json object by javascript item -

so have array of json objects these below. retrieved using xmlhttp. want 'select' value name == "test" using javascript how do this? know can example data[0] not how want because id can change. [ {"name" : "test", "value": "something"}, {"name" : "test2", "value": "something else"} ] you can use loops this, can use array.filter , can first match, ex.: var items = [{"name" : "test", "value": "something"},{"name" : "test2", "value": "something else"}]; var = "name", = "test2" , select = items.filter(function(item){ return item[where] == is})[0]; console.log(select)

multithreading - C# how to handle a flag with a thread depending on external conditions -

i'm beginner c# , have following problem. idea is: have possible triggers [ water_level_threshold1 , water_level_threshold2 ]. if water_level_threshold2 active water_level_threshold1 false [threshold1=true means water level between 2 values]. depending on trigger want activate 2 sounds corresponding 2 alarms. conditions monitored every few milliseconds , alarms last seconds. need sounds played asynchronously because don't want stop water level monitoring. water level can of course changes randomly. @ moment, example first threshold, wrote like: if ((!water_level_threshold1_sound_already_started) && (water_level_threshold1)) { using (soundplayer player = new soundplayer(@"c:\users\antonino\desktop\water_level_threshold1_alarm.wav")) { player.playlooping(); } // avoid sound stuck on first msecs [sampling time] water_level_threshold1_sound_already_started = true; } as far know soundplayer can handle tune per time not overla

arduino - buf[i] returns the 8 bit max, ie 255, instead of character sent -

am having trouble understanding i'm getting in arduino setup. scenario is: i'm sending character (could character) tx board rx board using chipset running virtualwire. rx receiving message , buffer length 1. when print out buf[i] on serial monitor, 255 (which 8 bit maximum integer assume) instead of character a. here relevant code: tx file [code] void setup() { c = 'a'; //for testing only // wireless code...data pin on tx connected port 7...vw stands 'virtualwire' vw_setup(2000); // initialize tx transmission rate vw_set_tx_pin(7); // declare arduino pin data transmitter ... void loop() { ... vw_send((uint8_t *)c, 1); // turn buzzer on...transmit character rx file // rx data pin 8 void loop() { serial.println("looping"); delay(2000); uint8_t buflen = vw_max_message_len;// defines maximum length of message uint8_t buf[buflen]; // create array hold data; defines buffer holds message if(vw_have_message() == 1) // satement

c# style for private variable using _ or this? -

i know prefer way refer private field in c# code? is using underscore in front of variable _ or using this prefer way? what benefits , disadvantages of these 2 styles? in code private string _name; private void getname() { return string.format("{0} - hello", _name); } or second method private string name; private void getname() { return string.format("{0} - hello", this.name); } i prefer 2nd method, because clearer me variable name belong instance, , used them extensively in javascript, dont see them used in c#, first style prefer there isn't rule or general recommendation this. should pick 1 way , stick it, or agree on 1 if in team. the advantage of using underscore on this it's part of variable name. can access _name _name , not name . when use this can access name instead of this.name . javascript conventions doesn't translate c# private members, there no private members in javascript, , there no class