Posts

Showing posts from September, 2012

transparency - ImageMagick: How to make both black and white transparent? -

Image
converting black , dark shades transparent works fine imagemagick. managed perform crop , resize in same line. convert input.png -background none -fuzz 45% -transparent black -flatten -crop 640x480+12+9 -resize 105% output.png however, input image contains number of white lines, convert transparent in output. how go that? possible within same command line? sure, add second -transparent . convert -size 512x512 gradient:black-white a.png # create initial black-to-white gradient convert -fuzz 20% a.png -transparent black -transparent white result.png # lose 20% off black end , white end or, fuzz... convert -fuzz 40% a.png -transparent black -transparent white result.png

"Not enough Points" Python -

st = 5 statadd = 5 there more had typed, none of relevant, copied this. while statadd > 0: addstat = raw_input("""you may distribute %s points base stats. add to? """ %(statadd)) if addstat == 'strength': pointdeduction = raw_input("how many points wish add strength? (up %s points)" %(statadd)) if pointdeduction <= statadd: st += pointdeduction statadd -= pointdeduction else: print "you not have many points distribute strength." you think should add points, keep getting same error "you not have many points distribute strength" when do. doing wrong here? try convert inputs to int ? otherwise it's string , doing arithmetic operations on lead unexpected results. while statadd > 0: addstat = int(raw_input("""you may distribute %s points base stats. add to? "

Windows 10 removableStorage SQLite database -

i trying create external sqlite database, follow , tested text files in removable storage , works. try create database in removable storage: public static async task<string> createdatabase(string name) { var folder = await findremovablestorage(); if (folder != null) { var file = await folder.createfileasync(name, creationcollisionoption.replaceexisting); if(file!=null) { var ret = $"{folder.name}{file.name}"; return ret; } } return null; } public async void thirdcase() { var path =await dataloggerservice.createdatabase("db.dat"); var connection = new sqlite.net.sqliteconnection(new sqliteplatformwinrt(), path); //cannot open } i testing on desktop, , returns cannotopen. has created database out typical local folder? more details of did here: datalogger when finish want implement in raspberry pi,

Neo4j in Android using REST -

i have been trying use neo4j in android app. wrote following code should response server. button mbutton; edittext medittext; private static final string server_root_uri = "http://localhost:7474/db/data/"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mbutton=(button)findviewbyid(r.id.mybutton); medittext=(edittext)findviewbyid(r.id.mytext); mbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { webresource resource= client.create() .resource(server_root_uri); clientresponse response=resource.get(clientresponse.class); string s=(string.format("get on [%s], status code [%d]", server_root_uri, response.getstatus() )); medittext.settext(s); response.close();

sql server - SSRS: How to SUM row data based on condition -

i have table of structure:- row1:- not inside details group. row 2:- dynamically populating row. sequence as:- a x a1 1 a2 2 b y b1 30 b2 40 i need calculate value of y(which value of b1+b2) , x(which value of a1+a2) also in row 1 need display x+y. please note:- not sure number of rows can there in either or b. y can b1+b2+b3.... on. also , b being populated same dataset. it's bit unclear how data set can't give answer summing based on condition you'd want like: =sum(iif(fields!a.value = "x", fields!unknown?.value, 0)) this sum of unknown field when field a = x . if isn't looking for, try adding field names , relate them values.

c - Cast to larger type in switch case -

during work saw following code snippet , wonder, if there reason casting "case-values" larger datatype. guess, used offer possibility of having more 256 different states later on, then, state variable must larger. here code talking about: #define state_1 (uint8_t)(0x00) #define state_2 (uint8_t)(0x01) ... #define state_n (uint8_t)(0x..) void handlestate(uint8_t state) { switch(state) { case (uint16_t)state_1: // handle state 1 break; case (uint16_t)state_2: // handle state 2 break; ... case (uint16_t)state_n: // handle state n break; default: break; } } is there reason this? it looks failed attempt rid of implicit integer promotions on 8-bit or 16-bit microcontroller. first of all, there no way integer promotion can cause harm here, preventing overly pedantic , reduces readability. @ glance looks nonsense. but. perhaps coding standard used enforced no implicit conversions allowed?

"saving as" excel file downloaded from html -

my problem i'm using ie9, use "application/vnd.ms-excel" content type, , file downloads correctly. problem after had downloaded file, opened excel, , pressed "save as" button, default format "*.htm, *.html", , need xls. there way change "default"? can't upload picture, because of reputation i appreciate help. i solved problem using aspbiff8, easy use, still doesn't support text formatting (i guess). can find going http://sourceforge.net/projects/aspbiff8/ if can fomat cells, plase share it.

node.js - Meteor CSV file upload -

i new meteor making app upload large csv file, when run app files uploaded home directory (ubuntu)and mongodb collection can see robomongo ,after receiving error on console (stderr) error: enoent, open '/imports/tdcdata.csv' have changed ./ ,~/ , home/user/imports not work. contribution in advance; here code : meteor.methods({ 'uploadfile': function(fileid, filename) { var fs = meteor.npmrequire('fs'); var file = uploads.find({ _id: fileid }); meteor.settimeout(function() { var filepath = '~/imports/' + filename; //var filepath = '/imports/uploads-' + fileid + '-' + filename; csv().from.stream( fs.createreadstream(filepath), { 'escape': '\\' }) .on('record', meteor.bindenvironment(function(row, index) { album.insert({ 'account number': row[0], 'album title

javascript - HTML 5 Canvas rotate mulitple text items around circular point -

i'm trying display numbers around spokes of bicycle wheel. in process of creating 'spokes' wheel can't seem text rotate without messing rotation of wheel. var arr = ['1','2','3','4','5','1','2','3','4','5','1','2','3','4','5','1','2','3','4','5']; function drawnumber() { var cid = document.getelementbyid('cogs'); var canw = cid.width, canh = cid.height; if (cid && cid.getcontext){ var ctx = cid.getcontext('2d'); if(ctx) { ctx.translate(ctx.canvas.width/2, ctx.canvas.height/2); var radian = (math.pi / 180) * 18; var = 0 (var degrees = 0; degrees < 360; degrees += 18) { var fillnum = arr[i]; ctx.font = "12pt arial" ctx.fillstyle =

linux - Append new line in all files of the folder -

i have 300 files in folder. have append 1 new line @ end of files in folder. how can achieve using grep. i tried following command not working sed 's/$/\n/' /path/filename.txt just echo "" >> file . append new line @ end of file . to in files in folder: for file in * echo "" >> "$file" done from comments, in case have say: for file in /path/*.txt echo "" >> "$file" done

Vb.net regex escaping optional backslash optional in the end of a string -

i have string , want know if includes pattern in end of it. want know if has "jobs" or "jobs/" "/" optional example: www.example.jobs/ www.example.jobs so far have this: \.(com|org|edu|net|jobs?/|gov)$ the problem if have string ends "jobs" doesn't catch it. just add ? optional quantifier / \.(com|org|edu|net|jobs?/?|gov)$ regex demo /? ensures / matched 0 or 1 time, making optional

ios - Arduino Robot: Switch from line-following to bluetooth control? -

i'm building prototype robot summer camp, , boss wants line follower can switch being controlled via bluetooth iphone. question is, can implement in terms of code make switch possible? there way can set time limit how long line following code can run, , after time limit, have switch bluetooth control? or there more effective? thanks. the best option can implement have robot connected via bluetooth phone, having option switch @ time line follower mode manual control. option offer best flexibility. is there way can set time limit how long line following code can run yes, there options that. simplistic way implement using timer robot microcontroller.

internet explorer 8 - Loading bootstrap font .eot in IE8 -

here's font-face declaration in customized bootstrap.css : @font-face { font-family: 'glyphicons halflings'; src: url('../../fonts/glyphicons-halflings-regular.eot'); src: url('../../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); } all these bootstrap fonts reside in virtual machine (192.168.137.4). when loading page, ie8 requires font download, whereas there's no problem every other browser (chrome, firefox , ie9,10,11). when tried replace ../../ cdn links these fonts (for example : https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/fonts/glyphicons-halflings-regular.eot ) worked in ie8 still need load them local. please advise,

c# - Find distinct values from a list of object by one field only -

how select distinct values list of objects? want list of specific field not list of whole object. for example collection queried: name year item1 2009 item2 2009 item3 2010 item4 2010 item5 2011 item6 2011 and want return distinct years below result collection 2009 2010 2011 2012 i tried distinctyears = mycollection.groupby(x => x.year).select(x => x.first()).tolist(); but return collection of whole object instead of year values. distinctyears = mycollection.select(x => x.year).distinct() will return ienumerable<int> (or whatever type year is) no need grouping - want year in result, grab that.

linux - installing mpich2 always installs me mpich -

i have mpif90 mpich version 3.0.4, want remove , install mpich2. there problem dislin library, need mpich2. while on debian distro sudo apt-get install mpich2 installs me mpif90 mpich2 version 1.4.1 (it right 1 need), if run (on ubuntu have mpich version 3.0.4) sudo apt-get remove libmpich10 libmpich-dev , sudo apt-get install mpich2 still installs mpif90 mpich version 3.0.4 how can do? update 1 thanks. if try install dpkg -i mpich2_1.4.1-1ubuntu1_amd64.deb first have remove previous version 3.0.4, because in conflict. i remove it, try install 1.4.1 there unsolved dependencies ( libmpich2-3 -1.4.1 not installable, libcr0 not installed, libhwloc4, hwloc-nox). suggested run apt-get -f install installs 3.0.4 on debian works fine, 64 bit, wheezy release. on ubuntu 14.04, 64 bit, doesn't work. you asking how can downgrade vendor-packaged mpich-3.0.4 mpich2-1.4.1 debian , ubuntu make upgrading easy. downgrading little tricky , might require pinning pa

Elasticsearch group and aggregate nested values -

i want in 1 request data build this: categories: - laptops (5) - accessories (50) - monitors (10) -- above part easy -- attributest actual category ex. laptops: - card reder: - mmc (1) - sd (5) - resolution: - 1024x768 (2) - 2048x1536 (3) first make mapping on elasticsearch this: { "mappings": { "product": { "properties": { "name": { "type": "string" }, "categoryname": { "type": "string", "index": "not_analyzed" }, "pricebrutto": { "type": "float" }, "categorycode": { "type": "integer" }, "productattributefields" : { "properties" : { "

php - How to store permanent non static value in Laravel -

i'm sorry being such vague question i'm unsure keywords search for. want store external number can use run schedule php program (that aims transfer data between databases), there's different id's , whatnot ... point need laravel remember 1 number (that latest id other server's db). question how store value? creating table store single value fells bit overkill. i've been looking cookies , flash memory, "for next request" , i'm not sure means , sounds irrelevant want. go far declare global variable number don't know how. so, put question in simple words ask how persist number using laravel 5 framework thanks. what saving id simple text file on filesystem? something like storage::disk('local')->put('lastid.txt', '165'); take @ http://laravel.com/docs/5.0/filesystem

Android ViewFlipper animating only the first URL image -

i have android activity viewflipper. picks images url , displays in layout. supposed animate though images. however, animates first url image , keeps repeating. not display other images. below code: public class dynamicviewflipper extends activity { /** * list of image url populate viewflipper */ private list<string> imageurls = arrays.aslist(new string[] { "http://example.com/image1.jpg", "http://example.com/image2.jpg", "http://example.com/image3.jpg", "http://example.com/image4.jpg"}); private int index = 0; private textview mtextview; private viewflipper mviewflipper; private button mnextbutton; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_view_flipper); mtextview = (textview) findviewbyid(r.id.title); mviewflipper = (viewflipper) findviewbyid(r.id.viewflipper); imagevie

html - How to make good grouping of elements? -

Image
i want make htmlpage . but dont want make 4 table 1 page. best way make (i add elements in cells after ) - panel , div , or else ? wait advice . p.s. write in asp.net / css . you didn't state contents should come on page , how should placed. i'm guessing page might , suggest use appropriate elements provided in html5. top area use: <header role="banner><!-- contents --></header> assuming contains title, logo or similar. the central part wrapped element main : <main role="main"> <section>section1</section> <section>section2</section> <section>section1</section> </main> the part taking menu i.e. navigation should marked with: <nav role="navigation"> <!-- menu entries --> </nav> the bottom part marked as: <footer role="footer"> <!-- if need 2 different containers inside --> <div id="footer-

java - Custom mapper for schema validation errors -

i've used camel validator , i'm catching errors schema validation : org.xml.sax.saxparseexception: cvc-minlength-valid: value '' length = '0' not facet-valid respect minlength '1' type is tool map errors prettier statements? can iterate on erros, split on them , prepare custom mapper, maybe there sth better this? :) saxon @ error reporting. validator gives understandable messages in first place.

input - Why JSF UI components are not displayed in Graphene WebDriver test browser instance? -

Image
i wonder why jsf 2.2 ui input components not rendered in arquillian drone graphene webdriver's test browser instance. test page follows: <?xml version="1.0" encoding="utf-8" ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>login</title> </h:head> <h:body> <h:form id="loginform"> <h3>login failure</h3> <h:panelgrid columns="2"> <h:outputlabel for="username">username:</h:outputlabel> <h:inputte

ruby on rails - Precompile all the assets without having to add them to app-ion.css/js -

how can precompile css, js , images ( and in subdirectories also ) under my_app/app/assets without having add of them (that don't want to) application.css/js? rake asset:precompile:all? all images precompiler running default task. if want precompile js , css, can add initializers/assest.rb config.assets.precompile += [dir["#{rails.root}/app/assets/javascripts/**/*"].reject { |fn| file.directory?(fn) }] config.assets.precompile += [dir["#{rails.root}/app/assets/stylesheets/**/*"].reject { |fn| file.directory?(fn) }]

javascript - How to redirect from the service to the controller with the response data in angularjs? -

Image
i need , i'm new angularjs. i have created app tours, here have 3 controllers each page , 1 service getting data response. i have 4 button (links spanish, france, india, america, etc.) on each page footer. my problem while clicking on location button in main controller (packagecontroller) i'm able access response data without redirecting because same controller, have other pages have controller 1 & 2, these controller need redirect main controller, i'm failing achieve this. app: var app = angular.module("dashboard"); service: app.factory('packageservice',function($http) { return { getdata: function (location) { var promise = $http({ method:'get', url:"index.php/tours" , params:{'keyword': location} }) .success(function (data, status, headers, config) { return data; })

ibm mobilefirst - Can you combine admin and console war into a single ear file -

you have deploy admin , console war on same cluster can combine admin , console war files single ear file , deploy manually on websphere. supported configuration ? yes supported since ear file type of packaging deploy applications in application server. , in fact when deploy war file in websphere resulting installed app ear file. applicationcenter example shipped 2 war files console , admin services ear file containing both (it case analytics).

javascript - How to scroll smoothly with Selenium WebDriver and/or Sikuli in Java -

as part of test suite measuring fps web application need perform smooth scroll of web page. is, same smoothness when user grabs scroll bar , moves mouse. so far have tried using simulating key presses sikuli, i.e. pressing arrow up/down keys multiple times scroll whole page. have tried using javascript approach: public void scrollsmooth(int durationofscroll){ long timewhenstarting = system.currenttimemillis() / 1000l; while (system.currenttimemillis() / 1000l - timewhenstarting < durationofscroll) { ((javascriptexecutor) driver).executescript("window.scrollby(0,10)", ""); } } both these approaches fails fulfill purpose, both generate step-by-step scroll, not suitable when simultaneously want measure fps (e.g. smoothnes of page when scrolling). the solution lot more simple expected. instead of using time-based condition loop tried following: public void scrollsmooth(){ for(int i=0;i<6000;i++) { ((javascriptexecutor)

Adding route to a modal/overlay in Ember.js -

i know ember's mantra url first , url should serialization of page contents, have scenario want create route component/page live in modal, , accessible various places throughout site. want url represent actual route of resource, not change if resource happened nested in route. a similar example pinterest. when looking @ feed of pins on root route. can search pins , directed /search/pins route. from both of these routes, can click on pin, open in modal/overlay, , change url url of pin. since can view pins different areas of site, background behind overlay various routes depending on click pin from, not serialized version of route. is type of functionality possible in ember? if so, resources/hints review? - ac. this question might pointer, have done before using render method inside of activate hook in route. so modal template injected named outlet (e.g {{outlet 'modal'}} ) when enter given route. here example of method described in project worki

c++ - Elements in empty unordered_multiset -

it's strange question, if i've deleted elements unordered_multiset , try print elements: for (std::unordered_multiset<int>::const_iterator i(a.begin()), end(a.end()); != end; ++i) { std::cout << "it's here" <<"\n"; std::cout << *i <<"\n"; } so, ok, if loop doesn't not work, mean "it's here" wasn't printed? how behaves empty multiset? if set empty begin() == end() true , loop never entered.

jenkins - Building multimodule maven project -

hi i've searched net, read bunch of articles, questions , documentation can not find solution, here problem. i have multimodule maven project contains 3 modules a,b , c. , b independent , c depend on , b, , of course have parent project. have jenkins server set build these projects, , nexus repository. my problem when build project maven builds , b correctly c downloads older artifact nexus repository , of course fails build module c. how can make maven use built jars installed local repository instead of older ones on nexus? version of , b , c set 1.1.{build_number}-snapshot maven version plugin, , understand maven should use newer local not it. not want post hundreds of lines of pom.xmls if need section provide it. any appreciated. thank you! i have been setting version numbers in submodule's poms , changed inherit version number parent pom. in module c 's pom module a , b versions set ${project.version}

sql server - Find and Replace All Special Character in SQL -

Image
this question has answer here: how strip non-alphabetic characters string in sql server? 19 answers i want copy row in new column replacing special character -. code below. my table design select * mycode update mycode set newname = replace(myname, '%[^0-9a-za-z]%', '-') it's getting copy code special character not replaced result try query declare @specialchar varchar(15) declare @getspecialchar cursor set @getspecialchar = cursor select distinct poschar master..spt_values s cross apply (select substring(newname ,number,1) poschar mycode ) t number > 0 , not (ascii(t.poschar) between 65 , 90 or ascii(t.poschar) between 97 , 122 or ascii(t.poschar) between 48 , 57) open @getspecialchar fetch next @getspecialchar @specialchar wh

ios - Use of undeclared type ‘UIContainerView’ -

i’m using xcode 7 , i’ve storyboard controller uicontainerview when i’m trying create outlet controller there error "use of undeclared type uicontainerview " it’s not bug of xcode 7 because there same error on xcode 6 i need create outlet because when switch segmented control have programmatically change embed of container it's error or mustn't create outlet container? it's seems there not called uicontainerview in library, it's strange there no such class called uicontainerview . need create outlet of uiview , connect container view. you can switch content of container view like: // property @property (nonatomic, weak) iboutlet uiview *container; @property (nonatomic, strong) uiviewcontroller *first; @property (nonatomic, strong) uiviewcontroller *second; // method removes first vc view , shows second vc // assumes first , second properties initialized - (void)showsecondvc { // removes first view controller [self.first.view r

java - Regex for circle and polygon string with decimal/integer values -

i'm trying create regex patterns used in java following 2 strings: circle ( (187.8562 ,-88.562 ) , 0.774 ) and polygon ( (17.766 55.76676,77.97666 -32.866888,54.97799 54.2131,67.666777 24.9771,17.766 55.76676) ) please note one/more white spaces may exist anywhere.exceptions not between alphabets.and not between digits of number. [updated] circle , polygon words fixed not case sensitive.[updated] for 2nd string number of point set not fixed.here i've given 5 set of points simplicity. points set of decimal/integer numbers [updated] positive decimal number can have + sign [updated] leading 0 not mandatory decimal number [updated] for polygon atleast 3 point set required.and first & last point set same (enclosed polygon) [updated] any or suggestion appreciated. i've tried as: (circle)(\\s+)(\\()(\\s+)(\\()(\\s+)([+-]?\\d*\\.\\d+)(?![-+0-9\\.])(\\s+)(,)(\\s+)([+-]?\\d*\\.\\d+)(?![-+0-9\\.])(\\s+)(\\))(\\s+)(,)(\\s+)([+-]?\\d*\\.\\d+)(?![-+0-9

How to do create a list of candidate objects in C#? -

i want find object best fits data. way i'm doing creating list of objects, each 1 tries fit data in different way, , @ end select 1 best fits data. this, created list of these objects, , want them same @ beginning, equal original object. way naively did just: list <tryobject> tryobjects = new list<tryobject>(); for(int = 0; i< numberofdifferenttries; i++) { tryobjects.add(new trupbject()); tryobjects[i].dataobject = originaldataobject; tryobjects[i].blabla = blablu; ...other assignments tryobjects[i].trytofitthedata(); } //select tryobject in tryobjects[] fits data best , return it. however, discovered doesn't work want, because each tryobjects[i].dataobject reference originaldataobject , whenever change each of dataobjects , of change, plus original one. i understand i'd need in case deep copy. however, methods found either use iclonable or special methods hard copy, such serialization, take bit effort or can bring headaches.

vb.net - move flowLayoutPanel content via two buttons from right to left -

i have flowlayoutpanel have contents (controls ) , 2 button , 1 @ right , left design in image i want make layout panel scroll content right button right , left button left , how can please ? i using code top buttom , need right , left the code is dim ypos integer the code in top button is if ypos > flowlayoutpanel1.horizontalscroll.maximum - 451 ypos = flowlayoutpanel1.horizontalscroll.maximum - 450 else ypos += 450 flowlayoutpanel1.autoscrollposition = new point(0, ypos) end if and buttom button if ypos < 1 ypos = 0 else ypos -= 450 flowlayoutpanel1.autoscrollposition = new point(0, ypos) end if thanks increase , decrease value of horizontalscroll.value in respective left , right button click events. ''' <summary> ''' determine approx total width of inner controls ''' </summary> ''' <returns></returns> ''' <remarks></re

c# - Application Insights: How to track crashes in Desktop (WPF) applications? -

i'm using application insights wpf application. tracking of pageviews , custom events working. now track crashes. idea to: private void appdispatcherunhandledexception(object sender, dispatcherunhandledexceptioneventargs e) { telemetryclient.trackexception(e.exception); telemetryclient.flush(); } the code called when unhandled exception occurs not shown "crash" in application insights portal. have read somewhere trackexception not count "crash" when application not crash. desktop (e.g. wpf) applications must use low level api of application insights. have not found way tell application insights wpf application crashing. how that? for wpf applications, there no inherent support capturing crashes. statement "the code called when unhandled exception occurs not shown "crash" in application insights portal. have read somewhere trackexception not count "crash" when application not crash." - true. here

python 3.x - django + tastypie: How do I POST to replace data without getting "duplicate key value violates unique constraint" -

i trying write rest api django project using tastypie. can use post data: curl --dump-header - -h "content-type: application/json" -x post --data '{"name": "environment1", "last_active": "2015-06-18t15:56:37"}' http://localhost:8000/api/v1/report_status/ which works gets put database, when come send second set of data enviroment name (i.e. resend same request), intention of replace first set of data sent, following error (abbreviated): {"error_message": "duplicate key value violates unique constraint \"<project_name>_environment_name_key\"\ndetail: key (name)=(production) exists.\n", "traceback": "traceback ... django.db.utils.integrityerror: duplicate key value violates unique constraint \"oilserver_environment_name_key\"\ndetail: key (name)=(production) exists. i understand have set environment name unique, i'm trying replace data, not upload enviro

patch - How to do delta extraction from GIT for patching? -

i new git , started working on mobapp how perform delta level extraction git (provided 'tags' created each change) ? please let me know various ways accomplish this thanks sathish kumar to create individual patches commits since abc , git format-patch abc . create 1 patch file per commit. if want see has changed since abc , git diff abc head .

javascript - How to use a functions parameter as attribute in dot notation with an object -

i have function parameter string. want use string attribut in object. here's example how be: var x = "somestring" function foo(attribute) { someobj.attribute = "something"; } foo(x); use subscript [] notation dynamic keys: someobj[attribute] = "something"; code var x = "somestring"; var someobj = {}; function foo(attribute) { someobj[attribute] = "something"; } foo(x);

c# - Getting Error in Xaml while Binding data with Converter -

Image
i getting "invalid xaml" error while binding data converter. see screenshot: this xaml code: <datatemplate> <border borderbrush="#cbc6c0" borderthickness="3" cornerradius="3" background="#fff9f6f4"> <grid margin="5"> <contentcontrol content="{binding converter={staticresource groupdetails}}" /> </grid> </border> </datatemplate> ... , c# code converter: public class listdetailsconverter : ivalueconverter { public object convert(object value, type targettype, object parameter, system.globalization.cultureinfo culture) { model_detail objdetail = value model_detail; textblock tbinfo = new tex

shell - Why zenity color selection piping to sed breaks the code? -

i trying use sed convert 12 digit hex code returned zenity's --color-selection dialogue 6 digit hex code. example: #dfe251a951a9 #df5151. use sed in following code breaks whole script, , when select "select" or "cancel" buttons dont respective echo! what's problem? before using sed: works nice 12 digit hex code. #!/bin/bash color=$(zenity --color-selection) if [[ $? == 0 ]] echo "you selected $color." else [[ $? == 1 ]] echo "no color selected." fi after using sed: when hit select button 6 digit hex code when hit cancel dont "no color selected", echoes "you selected ." #!/bin/bash color=$(zenity --color-selection | sed 's/\(#\?..\)../\1/g') if [[ $? == 0 ]] echo "you selected $color." else [[ $? == 1 ]] echo "no color selected." fi after color=$(zenity --color-selection | sed 's/\(#\?..\)../\1/g') $? exit status of sed (not zenity ) 1 , 0.

PHP - Get affected rows in ADODB -

i using adodb create connection database. update data in database, there no error. problem can't number of affected rows affected_rows() . tried simple code not working. here code: $sql = "update user set name=n'myname' id=1"; $conn = new com ("adodb.connection") or die("cannot start ado"); $cs = "provider=sqloledb;"."server=localhost;database=test;uid=admin;pwd=123456;max pool size=100"; $conn->open($cs); //there no error in connecting process. can add, update, delete normally. if($conn->execute($sql) === false) { trigger_error('wrong sql: ' . $sql . ' error: ' . $conn->errormsg(), e_user_error); } else { echo $conn->affected_rows(); //<-- error in here } i have read function in here . code above same example here . there other way number of affected rows in adodb-php? about affected_rows() , don't know why isn't working. there simple way number of affected

javascript - Node.js- "npm install express" error:0906D06C :PEM routines : PEM_read_bio npm -

i have installed node.js , has npm installed along it. in windows command prompt,when write "npm install express", gives me following error.how resolve this? c:\users>npm -v 2.11.2 c:\users>npm install express npm err! windows_nt 6.1.7601 npm err! argv "c:\program files\nodejs\\node.exe" "c:\program files\nodejs \node_modules\npm\bin\npm-cli.js" "install" "express" npm err! node v0.12.5 npm err! npm v2.11.2 npm err! error:0906d06c:pem routines:pem_read_bio:no start line npm err! npm err! if need help, may report error at: npm err! https://github.com/npm/npm/issues npm err! please include following file support request: npm err! c:\users\npm-debug.log

mysql - get more rows in JTable java -

i coded auto suggesting combo boxes. functionality is, *when user type first letter in either combo box , data retrieves mysql database , show in popup list, when user click on suggested item ,then press add button item added j table , clears combo boxes but when select item combo box , click add button before added 1 disappears *how can keep both or many items in j table according above situation * i'll post code: private void namecomboactionperformed(java.awt.event.actionevent evt) { string drugname = (string) namecombo.getselecteditem(); try{ string name = "select * druginfo itemname '"+drugname+"%'"; preparedstatement pstmt = conn.preparestatement(name); resultset rs = pstmt.executequery(); while (rs.next()){ idcombo.setselecteditem(rs.getstring("itemid")); } }catch(exception e){ joptionpane.showmessagedialog(null,"error "

ruby on rails - Scrape only HTML+Microdata with Nokogiri -

problem i need scrape html pages , extract html has microdata in it. example <div itemscope itemtype="http://schema.org/movie"> <span>something else</span> <script>something</script> <h1 itemprop="name"&g;avatar</h1> <div itemprop="director" itemscope itemtype="http://schema.org/person"> director: <span itemprop="name">james cameron</span> (born <span itemprop="birthdate">august 16, 1954)</span> <img url="doesnt matter" /> </div> <span itemprop="genre">science fiction</span> <a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">trailer</a> </div> <div>something else</div> <div itemscope itemtype="http://schema.org/product"> <span itemprop="brand">acme</span> <span itemprop=

html - i have Multiple svg elements when mouseover on 1 element all element must be show text hover at a same time -

i have multiple svg elements when mouseover on 1 element element must show text hover @ same time.. how can this? here code... <html> <head> <title>conservedclusters_fraal_16</title> </head> <body> <svg width="1500" height="500" xmlns="http://www.w3.org/2000/svg" version="1.1"> <style> .tooltip{ font-size: 16px; font-family: times new roman; } .tooltip_bg{ fill: white; stroke: black; stroke-width: 1; opacity: 0.9; } </style> <script type="text/ecmascript"> <![cdata[ function init(evt) { if ( window.svgdocument == null ) { svgdocument = evt.target.ownerdocument; } tooltip = svgdocument.getelementbyid('tooltip'); tooltip_bg = svgdocument.getelementbyid('tooltip_bg'); } function showtooltip(evt, mouseovertext, xpos, ypos) { tooltip

MongoDB ObjectID uniqueness in a Sharded Cluster -

if have mongodb sharded cluster multiple mongos instances, objectid in _id consistant whichever mongos write to? for example, if write data mongos#1 , _id ascends normally, if write using mongos#2 these _id's ascend in line other writes? seeing part of objectid based on machine hash , process id, can't see sorting on objectid useless. correct? whats recomendation here? how objectid generated give fair idea query. if type in mongo console, new objectid() you see objectid sample value as objectid("558bf61f9f49f303f72dd59b") now, lets break , see how mongo generates this. 558bf61f 9f49f3 03f7 2dd59b here first 8 characters (4 bytes) represents number of seconds (not milliseconds) timestamp. the next 3 bytes machine identifies. the next 2 bytes process id. and lastly 3-bytes random value. http://api.mongodb.org/libbson/current/bson_oid_t.html so, sure mongos connected with, time goes on in ascending order (because of first p

Makefile recompiles after cleaning objects (but not the name target) -

when call clean rule make clean objects correctly deleted. if after call all rule make recompiles objects again, if target there. as far know, should not recompile objects beacuse $(name) dependecy in all rule satisfied. indeed make clean erase object , not program target too. somebody can explain me how avoid recompiling after make clean call? thank you. here makefile: name = myprogram cc = clang++ cflags = -werror -wextra -wall -o3 -std=c++11 dir_srcs = srcs/ dir_objs = objs/ dir_incs = incs/ files = main.cpp \ file1.cpp \ files2.cpp \ file3.cpp \ objs = $(addprefix $(dir_objs), $(notdir $(addprefix $(dir_srcs), $(files:.cpp=.o)))) all: $(name) $(name): $(objs) $(cc) $(objs) $(cflags) -i$(dir_incs) -o $(name) $(dir_objs)%.o: $(dir_srcs)%.cpp mkdir -p $(dir_objs) $(cc) $(cflags) -i$(dir_incs) -c $< -o $@ clean: rm -rf $(dir_objs) fclean: clean rm -f $(name) re: fclean .phony: clean fclean re the

ios - How can I properly group and minimize style code for UITextfields? -

i'm trying implement standard universal styling of text fields based strictly on login/sign fields. so, designed them identical, think i'm reusing lot of code can condensed , maybe used in variable? i'm not sure how so. the way works, i'm sure can done better this. i'm there's way minimize code better practice. i'm still learning, want learn better practice in dev. here's example of sign view & styling of fields: class joinvc: uiviewcontroller, uitextfielddelegate {` @iboutlet weak var enteremailtextfield: uitextfield! @iboutlet weak var enterpasswordtextfield: uitextfield! @iboutlet weak var enternametextfield: uitextfield! override func viewdidload() { super.viewdidload() // field border corner + width self.enteremailtextfield.layer.cornerradius = 24.0 self.enteremailtextfield.layer.borderwidth = 1.5 self.enterpasswordtextfield.layer.cornerradius = 24.0 self.enterpassw