Posts

Showing posts from March, 2013

javascript - knockout.js foreach binding: property value to array of column names -

i have question knockout foreach binding table. i have array of columnnames , array of items . the items array has property called columnname . how use knockout foreach bind self.items self.columnnames? my view model looks this: var vm = function () { var self = this; self.items = ko.observablearray(); self.columnnames = [ "name", "age", "job"]; }; var vm = new vm(); ko.applybindings(vm); vm.items.push([ { 'columnname': 'name', 'value': 'john' }, { 'columnname': 'age', 'value': 25' } ]); vm.items.push([ { 'columnname': 'name', 'value': 'jane' }, { 'columnname': 'age', 'value': 26 }, { 'columnname': 'job', 'value': 'developer' } ]);

c# - How to return an object that's dependent on a chain of using statements? -

i'd write method similar one: c make() { using (var = new a()) using (var b = new b(a)) { return new c(b); } } this bad since when method returns, c keeps reference disposed object. note that: a implements idisposable . b implements idisposable . c not implement idisposable since author of c stated c not take ownership of b . your situation similar have seen when querying database. in attempt separate logic, see code this: var reader = executesql("select ..."); while (reader.read()) // <-- fails, because connection closed. { // process row... } public sqldatareader executesql(string sql) { using (sqlconnection conn = new sqlconnection("...")) { conn.open(); using (sqlcommand cmd = new sqlcommand(sql, conn)) { return cmd.executereader(); } } } but, of course, can't work, because time sqldatareader returns executesql method, connection

iphone - IOS: Passing session credentials between app and website -

i doing ios application has uiwebview. user login in ios side passing php api , after login have uiwebview use same credentials. keep user login without asking him credentials. is possible it? yes can store credentials in key chain , in webview can use javascript identify elements (textfields) , populate values accordingly

linker - How to fix the armadillo library to c++ -

i'm using macbook program bits of code here , there. wanted in c++ armadillo library. after installation , doesn't seem work. for instance can write arma::mat variable, etc when run code in textmate: vec q = randu<vec>(5); cout << normalise(q); i error output: "undefined symbols architecture x86_64: "_wrapper_dgesdd_", referenced from: void arma::lapack::gesdd<double>(char*, int*, int*, double*, int*, double*, double*, int*, double*, int*, double*, int*, int*, int*) in test-56d704.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) rm: /var/folders/sh/vr2n15ln47j0k33yh1j0_tyw0000gn/t/test.cpp.sfz5vezn: no such file or directory the weird thing if don't use normalise or norm functions compiles well. i include library #include '/usr/local/include/armadillo' edit: i've installed armadillo package both trying " brew install armadillo &q

javascript - Getting php results to show after AJAX call without page reload -

i have 3 sections on page. pending, accepted, , denied users. output of data through php while loop. next pending users section, each user in section have 2 buttons (accept , deny). when either of buttons pressed run ajax call php file updates users status either accepted or denied (whichever pressed). the issue having without letting page refresh user's data not moved updated status section(everything updates correctly on db side). however, if move out return false; code page refreshes, $('#success').html('user status changed!'); $('#success').delay(5000).fadeout(400); goes away right when page refreshes, instantly. i need way page not refresh, user's data moved appropriate section, success message still appears. $(document).ready(function () { $('.approve').click(function () { $.ajax({ url: 'userrequest_approve.php', type: 'post', data: { id: $(this).val(), //i

vmware - unable to install .vmdk file in windows 7 -

i need install .vmdk file in order setup base environment specific application software. below steps performed still struggling. installed vmware player (non commercial version) in system , while trying open .vmdk file through vmware player, started complaining "no operating system found". as next steps, tried install vmware-mount-5.5.0-18463.exe belive free software.but everytime in middle of installation,it showing "the wizard interrupted before vmware diskmount utility installed. system has not been modified. click finish exit installation". below system configuration: os: windows 7 ram: 4gb processor: i5-4200m cpu @ 2.50ghz dis space: 235 gb free. this first time trying install vmimage. please let me know 1. there wrong in approach? 2. there alternative way can install vmdk software? 3. there specific reason due getting above errors? in vmware world, vmdk image of virtual machine's hard drive. use vmdk, have create virtual machine,

When selecting an item in a datra frame, I obtain the item and the Levels R -

i have data frame , when select item, obtain next result, levels available in column. is there command desactivate this? or how should call element? this doing @ moment: a<-data$column[1] and obtain: [1] 1 1256 levels: 1 10 100 1000 ... 1000000 if want a number use: a <- as.numeric(paste(data$column[1])) [1] 1 if want a string use: a <- as.character(data$column[1]) [1] "1"

MongoDB index: totalDocsExamined returns 0 -

i have coded mongodb index using mongo java driver follows: mongoclient mongoclient = new mongoclient("localhost", 27017); db db = mongoclient.getdb("test"); dbcollection coll = db.getcollection("indexdemo"); coll.createindex(new basicdbobject("code",1)); (int ii=0;ii<100000;ii++) { dbobject doc = new basicdbobject("code", ii); coll.insert(doc); } when execute explain plan of index (mongodb 3.x), index bounds seems recognized totalkeysexamined 0 , totaldocsexamined 0 db.indextest.find({code: 5000}).explain("executionstats") { . . . . "executionstats":{ "executionsuccess":true, "nreturned":0, "executiontimemillis":0, "totalkeysexamined":0, "totaldocsexamined":0, "executionstages":{ "stage":"fetch", "nreturned":0, "executiontimemillise

typescript1.4 - Visual Studio TypeScript - Out of Stack Space -

we're using vs 2013 typescript 1.4 , have started getting following 'out of stack space' error during transpiling: 1>------ build started: project: client, configuration: debug cpu ------ 1>vstsc : tsc.js(15645, 21) javascript runtime error : out of stack space ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== there seems few other references error , error message not give go on. ideas? this appears message indicates. apparently had many string constants. once removed 'out of stack space' stopped occurring.

How to convert xml response using curl into array then store in database using php -

i invoking php curl method on server , response xml type. curl saving output (after removing tags) in scalar type variable. there way store in database it's easy parse? <response status="ok" responsetime="10"> <results> <wirelineservices> <blockfips>360775908001027</blockfips> <frn>0007556251</frn> <providername>time warner cable llc</providername> <doingbusinessas>time warner cable</doingbusinessas> <holdingcompanynumber>131352</holdingcompanynumber> <holdingcompanyname>time warner cable inc.</holdingcompanyname> <providerurl>www.timewarnercable.com</providerurl> <technologies> <technologycode>40</technologycode> <typicaldownloadspeed>0</typicaldownloadspeed> <typicaluploadspeed>0</typicaluploadspeed> <maximumadvertiseddownloadspeed>9</maximumadvertiseddownloadspeed> <maximumadvertiseduploadspeed>

jquery - alert in javascript not showing -

<!doctype html> <html> <head> <script type="text/javascript"> if (document.getelementbyid("popup")) { window.alert("hi"); } </script> </head> <body> <h1 id="popup">dfdfs</h1> </body> </html> i have simple javascript shows alert when h1 id exits ,but not getting alert message.code in jquery can help. put <script> tag @ end of body : <!doctype html> <html> <head> </head> <body> <h1 id="popup">dfdfs</h1> <script type="text/javascript"> if (document.getelementbyid("popup")) { window.alert("hi"); } </script> </body> </html>

Embedding LinkedIn company updates / feeds -

we have created sharepoint 2010 web part display our company feed https://www.linkedin.com/company/"name of company"/ . end-users need login first time (that ok). though login using personal linkedin profile, cannot see our company-feed. why that? if users set linkedin designated admins can see feed, otherwise cannot. we using <script type="text/javascript" src="//platform.linkedin.com/in.js"> api_key: "the key" lang: da_dk authorize: true onload: onlinkedinload </script> i hope can share knowledge. this why :'( https://developer.linkedin.com/blog/posts/2015/developer-program-changes starting on may 12, 2015, limiting open apis support following uses: allowing members represent professional identity via linkedin profile using our profile api. enabling members post certifications directly linkedin profile our add profile tools. enabling members share professional content linkedin network a

javascript - Concurrency transitions in D3 (circle following filling path) -

i trying create simple animated gauge charts, red points on end of each circle. whole example in here https://jsfiddle.net/yhlch8fc/3/ (please not solve text position, it's not problem). tried search on stack overflow, tutorials change starting point of alongpath animation not helping me, because path translated x,y , rotated. thing key part of code is: circle.transition().duration(_duration) .attrtween('cx', arccirclex(_mypath.node())) .attrtween('cy', arccircley(_mypath.node())); you can easy switch similar version (code stack overflow above): circle.transition().duration(_duration) .attrtween('transformation', circletween(_mypath.node())); i don't know why, seems red circle goes left side. maybe it's because original path translated , rotated. (the original version was, when try follow filling path, not work either.) instead of rotating hover path , rotate g element contains both path , circle : enter.appen

mysql - Select * from table where id = ? and order by priority -

i have database fields: id (int) name (text) priority (int) i want show values database id = (e.g) 13 , sort them priority. e.g: field id 13 , priority 1 first other field priority 2. how can it? select id,name,priority table_name id=13 order priority asc;

refresh - R Shiny: Updating .csv input on a schedule -

i have .csv auto-updates every minute new data. i'd have r shiny reupdate every hour new dataset. from i've seen, involve invalidatelater or autoinvalidate ; however, i'm not sure how these working (or more importantly, put them). ui.r pretty straightforward won't include it. server.r below: library(ggplot2) library(reshape2) library(scales) # data <- reactive({ # data refresh once day # 86400000ms 1 day # invalidatelater(10000, session) # 10s test # }) shinyserver(function(input, output, session) { autoinvalidate <- reactivetimer(10000, session) observe({ x <- read.csv("wait_times.csv", header=t, stringsasfactors=false) x <- rename(x, c("fall.river" = "fall river", "martha.s.vineyard" = "martha's vineyard", "new.bedford" = "new bedford", "north.adams" = "north adams", "south.yarmouth" = "south yarmouth")) citie

javascript - PHP - Show special characters -

snippet allow user input //fetch user input , pass in url alertify.prompt("please enter note/remarks form (optional):", function (e,value) { if (e) { alertify.success("form has been submitted"); $.post(site_url+"somecontroller/someaction",$("#frm_submit").serialize()+ "&user_id="+user_id+"&comment="+value, function( data ) { }); }else{ alertify.error("your form not submitted"); } }); user input: my project google r&d every googler when form post input not complete , shows below echo $_post['comment'] prints my project google r here if user inputs special characters & in comment, breaks input tried using htmlentities($_post['comment']) , htmlspecialchars($_post['comment'], ent_quotes, 'utf-8') not working. how allow user input special characters ? p.s : not s

Is java array with an element null is of length 1? -

below code: int[][][] @ = { {{9, 4}, null}, {null}, {{1, 2, 3}} }; system.out.println(at.length + " " + at[1].length); // 3 1 shows at[1].length 1 . is not that, length counted when have element of type int[][] @ second index in object pointed at ? if yes, why at[1] null of length 1? because null not of type int[][] similar example: mytype[] t = {null}; system.out.println(t.length); //1 for me t.length should 1 , when array has element {new mytype()} or element instance of subtype of mytype , like, mytype[] t = {new mytype()}; system.out.println(t.length); //1 yes. in fact, when declare , initialize array of object references, values inside null default. remember length of array never vary, despite contents ( null elements) in array. there's difference between length , size , length how many elements can stored in array, while size amount of valid elements in array. also, array is not list. example: string[] stringarray = {

python - Error using pytest tutorial -

i read unit-test brilliant feature write better code , assert features of target code stay same. wanted use it... i using anaconda on linux machine. i started using pytest working through manual's starter guide on homepage . after successful installation there appears first (unintended) error: strpeter@linuxcomputer:~$ py.test ================================================== test session starts =================================================== platform linux2 -- python 2.7.8 -- py-1.4.25 -- pytest-2.6.3 collected 0 items / 1 errors ========================================================= errors ========================================================= ___________________________________________________ error collecting . ___________________________________________________ anaconda/lib/python2.7/site-packages/py/_path/common.py:331: in visit x in visitor(fil, rec, ignore, bf, sort).gen(self): anaconda/lib/python2.7/site-packages/py/_path/common.py:377: in gen

object creation in java behind scenes (java object instantiation) -

i understand there 3 parts object creation: declaration instantiation initialization classa{} classb extends classa{} classa obj = new classb(1,1); instantiation it has create object using new operator , object must have fields related classb (initialized default values step give call default constructor?) instantiation mean step initialization using java's default constructor? initialization this object passed down hierarchy giving calls various constructor in way initialized (which comes under initialization) , final obj created 'classb(1,1)` constructor whith required initializations but how object mentioned in instantiation step being created available fields? please point out if said wrong if class has no constructor default constructor implicitly defined. constructors have method name <init> in stacktrace. a constructor call following: the object created, fields nulled: 0, 0.0, null, ... the super constructor called, po

mysql - Will I see performance gains by creating table relationships? -

i understand benefits of using table relationships in order create constraints, such preventing row being deleted 1 table when related row in another. but doing improve performance when running joined queries. eg. suppose have innodb tables user , userinfo shown below: user |field |type |null |key |default |extra --|id |int(11) |no |pri | |auto_increment | |email |varchar(700)|no | | | | |password|varchar(255)|no | | | | |active |varchar(1) |no | |n | | |created |timestamp |no | |current_timestamp| | | userinfo | |field |type |null |key |default |extra --|user |int(11) |no |pri | | |name |varchar(100)|no | | | |position|varchar(100)|no | | | ... is beneficial in terms of performance when running following q

c++ - Trouble understanding C++14 Relaxed constexpr restrictions -

i've came across new c++14 signature std::max function: template< class t > const t& max( const t& a, const t& b ); // (c++11) template< class t > constexpr const t& max( const t& a, const t& b );// (c++14) i've read relaxed constexpr restrictions proposal c++14 i'm still don't understand why function return value can constexpr example: std::vector<int> a, b; //this not compile understadnding of `constexpr` should int array[std::max(a.size(), b.size()]; (1) //this trivial use compile int array[std::max(1,2)]; (2) when calling std::max in (1) constexpr ignored ? the base issue isn't directly related relaxed constexpr rules, constexpr function constant expression if arguments constant expressions. in second case: int array[std::max(1,2)]; this works because integer literals indeed constant expressions. c++11 more specific in case, draft c++11 standard in section 5.19 [expr.const] lays out

html - display tooltip bottom of the button when hover state -

here website link in first row of button,, when hover, tooltip displayed , hidden background image. so need display bottom of button first row. i tried css: .swatch .tooltip, .bullet li .tooltip{ text-align:center; background:gray; color:#fff; bottom:80%; padding-top: 5px; padding-bottom: 5px; padding-left: 0px; padding-right: 0px; display:block; position:absolute; width:100px; left:-23px; margin-bottom:10px; /* make invisible default */ filter:alpha(opacity=0); -khtml-opacity: 0; -moz-opacity: 0; opacity:0; visibility:hidden; /* animations */ -webkit-transform: translatey(10px); -moz-transform: translatey(10px); -ms-transform: translatey(10px); -o-transform: translatey(10px); transform: translatey(10px); -webkit-transition: .25s ease-out; -moz-transition: .25s ease-out; -ms-transition: .25s ease-out; -o-transition: .25s ease-out; transition: .25s ease-out; -webkit-box-shad

osx - Signing a Package in MAC -

i have c++ code build on netbeans (8.0.1) on mac osx 10.10. now want package binary i'm using packagemaker. once build on packagemaker finishes asks sign it, clicked 'allow'. then open terminal , checked if package signed successfully, , got: codesign -v g16.pkg g16.pkg: code object not signed @ all. i login apple developer "certificates, identifiers & profiles" page , have: 2 developer id application certificate 4 developer id installer 1 mac app distribution 1 mac development 1 mac installer distribution in keychain have 1 certificate under "my certificate" , 6 under "certificate". so questions are: what differences between certificate? which certificate need use? what do wrong? please me!!! :) codesign signing of applications (not installers). should use productsign sign pkg files. certificate should using " developer id installer ". (full name of certificate shown in keychain) produ

javascript - How to avoid using overflow -

i creating navigation/menu bar , want move horizontally cursor moves on it. working not want set overflow property hidden because have drop down tabs should appear when cursor on menu option. if use overflow cut off @ point drop down cut off. inside scroll contains menu options. var sum = 0; $("#scroll li").each(function () { sum += $(this).width() + parseint($(this).css('paddingleft')) + parseint($(this).css('paddingright')) }); $("#scroll").css('width', sum); $("#holder").mousemove(function (e) { x = -(((e.pagex - $('#scroll').position().left) / $("#holder").width()) * ($("#scroll").width() + parseint($("#scroll").css('paddingleft')) + parseint($("#scroll").css('paddingright')) - $("#holder").width())); $("#scroll").css({ 'marginleft': x + 'px' }); }); #scroll{ height: 30px; line-height: 30

python - failedPrecondition when using google Oauth2 Service Account -

there're 3 types of google api client_id: 1. web application 2. service account 3. installed application i have used 3. installed application successfullly base on oauth2client , failed on 2. service account . wanna access own gmail inbox oauth2.0 credentials . import imaplib import json import urllib2 oauth2client.client import signedjwtassertioncredentials httplib2 import http apiclient.discovery import build import os reldir = os.path.dirname(os.path.relpath(__file__)) client_secret_file = os.path.join(reldir, 'gmail_service.json') oauth_scope = "https://mail.google.com" gmail_address = 'my_gmail_address@gmail.com' def jwt_oauth2(): ''' https://developers.google.com/identity/protocols/oauth2serviceaccount ''' open(client_secret_file) f: data = json.loads(f.read()) private_key = data['private_key'] client_email = data['client_email'] credentials = signedjwtasse

Java API for Google Analytics -

i've found great example here: https://developers.google.com/analytics/solutions/articles/data_over_time uses google.gdata, not google.api. credentials asking following: private static final string username = "username"; private static final string password = "password"; private static final string table_id = "table_id"; whereas in google.api, credentials needed following: private static final string key_file_location = "yourfile.p12"; private static final string service_account_email = "something@developer.gserviceaccount.com"; these 2 libraries (google.api , google.gdata) seem able similar things in fact different. meant username, password , table_id in first scenario? recommended java api google analytics? it recommended use google analytics java client libraries . example have pointed uses deprecated client login . you should use updated hello analytics api tutorial better example of using java api googl

android - Getting audio file path or uri from mediastore -

i making application lists songs on device onto screen , clicking on them opens sharing intent songs / audio file can shared across various devices through different method bluetooth, whatsapp etc. not able file path or location of audio file mediastore. this how getting songs- public void getsonglist() { //retrieve song info contentresolver musicresolver = getactivity().getcontentresolver(); uri musicuri = android.provider.mediastore.audio.media.external_content_uri; cursor musiccursor = musicresolver.query(musicuri, null, null, null, null); //iterate on results if valid if(musiccursor!=null && musiccursor.movetofirst()){ //get columns int titlecolumn = musiccursor.getcolumnindex (android.provider.mediastore.audio.media.title); int idcolumn = musiccursor.getcolumnindex (android.provider.mediastore.audio.media._id); int artistcolumn = musiccursor.getcolumnindex (andro

sql - Find the users pointing to my database postgresql -

i logged psql console delete databases, gives me error: error: database "production" being accessed other users detail: there 1 other session using database. how should find users pointing database? you can use pg_stat_activity view. show pretty of interest every open session, such user ( usename ), s/he connecting ( client_addr , client_hostname ), state (active, idle, etc) , last query (being) executed.

php - Best practice of writing custom authentication mechanism on Yii2 -

i need write specific authentication web application. there api on side accepts login + password pair , returns result (and, token). don't want store login information on yii2 side besides login token i've got api. , must way auth clients (so don't use oauth-like application). what best practive override "classic" code in yii2? use filters , modify user model? example: first, recieve token , save somewhere session: $token = gatewayapi::login($user, $password); then, every internal request this: $result = gatewayapi::addposition($token, $data); so, don't have database work with, cache , memory. handled on api side. my task implement login check - if token recieved api - it's considered success. , store token use within current session (probably in memcache, must not opened public). as matter of fact yii2 not require login/password anywhere. don't need modify or extend user model if mean \yii\web\user . need create own class i

android - How to disable all the buttons in the layout for a certain amount of time, java.NullPointerException -

secondscreen.java public class secondscreen extends activity implements view.onclicklistener { //drawables int res[] = new int[] {r.drawable.brownbars,r.drawable.centeredorangedot, r.drawable.dots, r.drawable.greenlines, r.drawable.lightbulb, r.drawable.orangedots, r.drawable.orangelines, r.drawable.tree, r.drawable.yellow, r.drawable.yellowwithred, r.drawable.brownbars,r.drawable.centeredorangedot, r.drawable.dots, r.drawable.greenlines, r.drawable.lightbulb, r.drawable.orangedots, r.drawable.orangelines, r.drawable.tree, r.drawable.yellow, r.drawable.yellowwithred}; int lay1, lay2, shufflecount = 0, gamecount = 0; imagebutton first, second; linearlayout layout; imagebutton b1; imagebutton b2; imagebutton b3; imagebutton b4; imagebutton b5; imagebutton b6; imagebutton b7; imagebutton b8; imagebutton b9; imagebutton b10; imagebutton b11; imagebutton b12; imagebutton b13; imagebutton b14; imagebutton b15; imagebutton b16; imagebutton b17; imagebutton b18; imagebutton b

asp.net - My form ignores Required attributes from model -

i'm having troubles form validation. reason form ignores [required] attribute have in model. model: (stripped down easy read) public class notemployeesmodel { public notemployeesmodel() { detailmodel = new notemployeesdetailmodel(); } public notemployeesdetailmodel detailmodel { get; set; } } public class notemployeesdetailmodel { public notemployeesdetailmodel() { } public notemployeesdocumentmodel documentmodel { get; set; } } public class notemployeesdocumentmodel { public notemployeesdocumentmodel() { } public notemployeedocumentinputmodel documentinput { get; set; } public class notemployeedocumentinputmodel { public notemployeedocumentinputmodel() { } public notemployeedocumentinputmodel(int notemployeeid) { notemployeeid = notemployeeid; } public int notemployeeid { get; set; } public int selecteddocumenttype { get; set

powershell - Regex to extract an IP address from a string -

this question has answer here: regular expression match dns hostname or ip address? 21 answers i'm trying retrieve ip address string. i'm not first ask question, couldn't find answer doing need. if there somewhere in string combination of xxx.xxx.xxx.xxx, regardless of text around it, should extract number dots in between. can used test-connection . i'm not trying determin if ip address valid, trying retrieve ip address string. if invalid, 900.999.800.254. example: input expected result ----- --------------- ip_10.57.50.91 10.57.50.91 10.57.50.73 10.57.50.73 10.58.4.37 ip 10.58.4.37 ip 10.63.1.22 10.63.1.22 belprlixh300 $false ip 10.63 $false i've tried far the regex's suggested here don't give ip address output in variable $matches . $ips = @('ip_10.57.50.91

ios - Failing to create distribution app in Xcode -

Image
i'm trying upload app app store through xcode, read few sites , set code signing "ios distribution" when tried archive, error appear "no provisioning profiles valid signing identity (i.e. certificate , private key pair) found." i've created new distribution provisioning profile in developer.apple.com , link app , selected distribution certificate it. downloaded profile , manage select in provisioning profile section in xcode->build settings->code signing. noticed can't select signing identity saying "no identities profile "profilename"". , trying archive popout same error paragraph above. if choose "fix issue" when error popup, resets signing identity "ios developer" , profile "automatic". archive process runs when tried validate or export error popup; "your account has valid ios distribution certificate". i read somewhere maybe due multiple certificates in keychain, i'm not

Travis CI python imports do not work -

on project, have issues test scripts on travis ci. installed packages needed using conda, , ran test scripts. build fails because of import errors. how can fix this? my travis yaml file such: language: python python: - "2.7" - "3.4" - "nightly" # command install dependencies # setup anaconda before_install: - wget http://repo.continuum.io/miniconda/miniconda-latest-linux-x86_64.sh -o miniconda.sh - chmod +x miniconda.sh - bash miniconda.sh -b -p $home/miniconda - export path="$home/miniconda/bin:$path" - conda update -y conda # install packages install: - conda install -y numpy scipy matplotlib networkx biopython - echo $path - python # command run tests script: py.test one of test scripts requires biopython, , test script fails because cannot find biopython. __________________ error collecting test_genotype_network.py ___________________ test_genotype_network.py:1: in <module> import genotype_netwo