Posts

Showing posts from May, 2011

java - Can I use "return" in here or any ideas? -

i'm new java , of knowledge self- taught. can me figure out this. our teacher wants make menu java. output this.. menu 1 - java history 2- java keywords 3 - java arrays , on. . do want read 1 (yes/no): //if yes please enter menu number: // display information.. //my problem how can connect new entered value first method don't have write on again... this whats on mind.. im stuck.. import java.util.scanner; public class program { public static void main (string [] args) { system.out.println("please enter number:"); int x = nextint(); if (x == 1) { (int x = 5; x == 5;x++) // array of 1(first menu) system.out.println ("do want read another? (yes/no):"); system.out.println ("please enter menu number:") // return if it's new entered value.... } else if (x == 2) { loop of array 2 system.out.println ("do want read another? (yes/no):"); system.out.println ("please enter menu number:&qu

How Do I Run xUnit.NET Unit Tests in Monodevelop? -

how run xunit.net unit tests monodevelop? have version 5.9.6 installed on lmde , have installed xunit.net testing framework support add-in. have test project installed xunit.net nuget package , wrote test in it. afaik have set correctly. however, unit tests pad empty , can't run tests run -> run unit tests. know need test runner, can seem find 1 visual studio. have runner , not know it? i've never set testing environment before , @ loss else need do. edit i have found xunit.net console runner , installed it. can run tests console runner , can debug tests run -> debug application... however, tests still not recognized within monodevelop , still not show in unit tests pad. i run xunit-tests under monodevelop add-in. i noticed when have referenced unit-test framework in project, no tests appear in pad. try remove nunit.framework reference.

angularjs - $ionicScrollDelegate locks the view on the scrolled value -

when i'm getting list of results in cordova app, want roll specified element function: $scope.roll = function () { //var rankscroll = $ionicscrolldelegate.$getbyhandle('rank'); var meelement = document.getelementbyid('scroll'); if (!meelement) { $ionicscrolldelegate.scrollto(0, 0); return; } var top = meelement.getboundingclientrect().top - 50; $ionicscrolldelegate.scrollto(0, top); console.log(top); console.log($ionicscrolldelegate.getscrollview()); } it works nicely, can't scroll other place in list. want unlock scrolling in solution or find better one. should scroll on page loaded, not on click. all best that function lock scroll because of $scope's binding. if want function invoked when view loaded, should call once @ the time view loaded. you can way in controller: var roll = function () { //var rankscroll = $ionicscrolldelegat

java - web.xml invalidates my session -

i'm trying error-code handling page in web.xml. if placed code in webxml: <error-page> <error-code>404</error-code> <location>/errorpage.html</location> </error-page> my session invalidated after logging in. on error 404 codes since tried 403, didn't invalidate session. can tell me what's wrong webxml or server?

sql server - AutoHotkey formating SQL with continuation fails -

i'm new autohotkey , have read of documentation i've been able find on hotstrings , continuation, i'm experiencing problems getting working holstering insert short sql query. i have script in ahk script file: :* c1:sqlthing:: ( declare @var1 int ,@var2 varchar(10) ,@var3 int set @var1 = xx set @var2 = 'xx' select @var1 = col1 tbl1 (nolock) col2 = @var3 ) it comes out in sql studio (double tabs , 1 linefeed missing): declare @var1 int ,@var2 varchar(10) ,@var3 int set @var1 = xx set @var2 = 'xx' select @var1 = col1from tbl1 (nolock) col2 = @var3 and have no idea why. i've tried using escaped tab instead (`t), result same. i'm baffled fact line feed preceding 'from' line disappear. it's because sql studio auto-indents text being typed , autoreplace strings imitate typing. instead use clipboard: :* c1:sqlthing:: text= ( declare @var1 int ,@var2 varchar

Replace missing values in list from second list using python/pandas -

consider have 2 lists (or columns in pandas dataframe), each containing null values. want single list replaces null values in 1 list corresponding non-null values of other if 1 exists. example: s1 = [1, nan, nan] s2 = [nan, nan, 3] ## function result = [1, nan, 3] assume if both lists non-null @ position match, need not worry resolving conflicts. if so, know can solve list comprehension: [x if ~np.isnan(x) else y (x,y) in zip(s1,s2)] or if s1 , s2 columns in pandas dataframe df, can use similar logic , apply function: df.apply(lambda x: x.s1 if ~np.isnan(x.s1) else x.s2, axis=1) but there cleaner way this, perhaps using of pandas functionality? kind of operation called? kind of union, preserves ordering , null values when lacking alternative. i had recently. may have adapt put below depending on structure of column values. import pandas pd # example dataframe df = pd.dataframe({'col': ['a', 'b', none, 'd', 'e', none,

html - Adding columns to table depending on input number in angular js -

i have tried <div class="row"> <table border='2'> <tr> <th ng-repeat="o in callarr">{{o.callarr}}</th> </tr> //html table <td ng-repeat="x in makecall() track $index">this column #{{$index + 1}}</td> </tr> <table> i want draw table in angularjs specified number of columns given in text box..suppose input 6,6 columns should automaticaly drawn table....number of rows fixed..plz me.. this should started: <element ng-repeat="x in range(numcols) track $index">this column #{{$index + 1}}</element>

node.js - Using socket.io with net socket in nodejs -

Image
is there way can use socket.io net socket in nodejs ? @ end have main service listen on port , waiting connection (net socket) , main while listen client's want establish connection using socket.io . example scenario: main service running listing on port x connection request client service . client's open web browser connected main service using http server in case of incoming data client service (server b) through net socket , data sent through socket.io connected client opening browser . nodejs allow open 2 ports in same running process . following example shows : main service listing on port 8124 incoming socket connection using net socket . main service listen on port 8081 incoming http connection , client can receive data main service using socket.io expressjs version : 4.13.3 socket.io version : 1.3.7 example : main service var express = require('express'); var app = express(); var server = require("http").se

ios - How to display sub view or button on top of Google maps Xcode -

Image
i trying add button on top of google maps. tried no can me.. in xcode preview shows on top after running app come below google map. picture after running app how looks in xcode code of map import uikit import googlemaps class homeviewcontroller: uiviewcontroller, cllocationmanagerdelegate { @iboutlet weak var scrollview: uiscrollview! @ibaction func refreshlocation(sender: anyobject) { locationmanager.startupdatinglocation() } @iboutlet weak var gmapview: gmsmapview! let locationmanager = cllocationmanager() override func viewdidload() { super.viewdidload() locationmanager.delegate = self locationmanager.desiredaccuracy = kcllocationaccuracybestfornavigation locationmanager.requestalwaysauthorization() locationmanager.startupdatinglocation() self.scrollview.contentsize=cgsizemake(320, 700) let camera = gmscameraposition.camerawithlatitude(15.4989, longitude: 73.8278, zoom: 17) gmapv

javascript - PDFBox setOpenAction to print -

i'm new pdfbox, have requirement send pdf printer when opened. using pdfbox api generate pdfs. have used below code try setting action on open nothing worked. please help. have used different javascript window.print(); this.print(); print(); pddocument doc = new pddocument(); pdactionjavascript javascript=new pdactionjavascript("app.print();"); doc.getdocumentcatalog().setopenaction(javascript); try pdactionjavascript("this.print({bui: false, bsilent: true, bshrinktofit: true});");

sql - Query execution plan of same queries -

observation: i executing same query through .net code using cmd.executenonquery() , directly in sql server management studio passing parameter values. when execute through code runs long time (15-20min) whereas when execute in sql server same parameters completes within few seconds. the reason taking longer time performance issue of query , solved introduction of non-clustered indexes in 1 of tables. i still wonder, why taking few seconds earlier sql server although environmental conditions same. due difference in execution plan? idea?

java - parse json objects from a log file -

i want parse json objects log file. using json parser complete files has in json format not case me. there way can parse file line line , json objects. below log file format: 2015-10-19 11:24:35:701 info brokertcpclient:28 - set destination 2015-10-19 11:24:35:929 debug brokertcpclient:32 - received data: {type=data, payload={ "core" : [ { "id" : { "datatype" : "http://www.w3.org/2001/hk#long", "type" : "gh", "value" : "gh" }, "entity" : { "type" : "uri", "value" : "http://fg.fg.com/ext/g/fg" }, "sno" : { "type" : "literal", "value" : "fg" }] 2015-10-19 11:24:35:701 info brokertcpclient:28 - set destination 2015-10-19 11:24:35:929 debug brokertcpclient:32 "core" : [ { "id"

java - Should I try to decouple activities from their fragments in an Android app? -

i have main class swaps in few different fragments. fragments have invoke methods on parent activity class, therefore activity , fragments tightly coupled. worthwhile or better practice decouple these or fragments commonly coupled parent activities?

arrays - Explain the clone() function in java -

the output of following codeblock 'false'. why? byte[] = {1,2,3}; byte[] b = (byte[]) a.clone(); system.out.print(a==b); == identity operator in java. means, checks if 2 objects same thing. it's not logical equality, it's not containing same values. it's being same object. in example, not same object. clone method of array creates new object, same content original. new object have same content, have own identity. it's new object, distinct original. in contrast, equals method logical equality. is, 2 objects containing equal values. when cloning array, original , clone equal, because have same values. not identical, because have different identities. in terms of java's == operator , contract of equals method: if 2 arrays equal, not identical if 2 arrays identical, equal the importance of identity when 2 array variables have same identity (both pointing same object), modifying 1 of them appear modify both of them. when 2 arrays equ

Accessible variables at the root of a python script -

i've declared number of variables @ start of script, i'm using them in number of different methods ("functions" in python?). when try access them, can't seem value = or set them value matter. example: basefile = open('c:/users/<redacted>/documents/python dev/atm/data.icsf', 'a+') secfile = open('c:/users/<redacted>/documents/python dev/atm/security.icsf', 'a+') def usrinput(raw_input): if raw_input == "99999": self.close(true) else: identity = raw_input def splitvalues(source, string): if source == "ident": usrtitle = string.split('>')[1] usrfn = string.split('>')[2] usrln = string.split('>')[3] x = string.split('>')[4] usrbal = decimal(x) usrbaldisplay = str(locale.currency(usrbal)) elif source == "sec": usrpin = string.split('>')[1]

Detecting location of substring within string in R -

consider following string: "nike store covent garden" suppose attempting detect brand matches following vector: brands <- c("adidas", "nike", "puma", "covent", "converse") below did resulting output: library(stringr) > brands[str_detect("nike store covent garden", brands)] [1] "covent" "nike" clearly brand here "nike", , know consistently located before location. there way can define rule in case detect multiple brands, select 1 appears earlier in string? note: in example above conveniently have brand name appear in beginning of string. have case string considering of form "0123 nike store covent garden" you can consider using str_locate instead of str_detect. : brands[which.min(str_locate("nike store covent garden", brands)[,1])]

html - Check if img-src exists with angular -

i want simple determination if image source exists or not, can replace image default image. best case if possible in pure html maybe "ng-if" or this. <img ng-if="../images/{{id}}.png" src="../images/{{id}}.png"> this code doesn't work, think shows want. edit: new code got, work in opinion, doesn't work: <img ng-src='{{ "../images/{{id}}.png" || "../images/img.png" }}'/> debugger says wrong quotes in case. edit: i think second solution works, there bug in part: <img ng-src='{{"../images/{{id}}.png"}}'/> this part works: <img ng-src='{{"../images/img.png"}}'/> you can use onerror, here demo. <img ng-src="http://experenzia.com/images/431f5cfa87f2faf9317ccc89e980dcca/431f5cfa87f2faf9317ccc89e980dcca_t.jpg" onerror="this.src='http://www.experenzia.com/assets/images/planner/no-image-back.png'" alt=&q

ios - Parsing a JSON file(stored locally) and thus creating an array of objects in swift -

i beginner json parsing terminology. trying fetch data json file stored locally in swift project. have done things correct , can fetch data presently. but, unable create array of objects(objects created based on set of values coming json file) . , use array in view controller(companyviewcontroller.swift) class. have written json parsing code in different class(companyhandler.swift here..) , fields have been initialized in swift class(company.swift here..). my companyviewcontroller.swift controller file following: class companyviewcontroller: uiviewcontroller, uicollectionviewdatasource, uicollectionviewdelegateflowlayout { @iboutlet var collectionview: uicollectionview! override func viewdidload() { super.viewdidload() var customcollectionviewcell = customcollectionviewcell() collectionview.registernib(uinib(nibname: "customcollectionviewcell", bundle:nil), forcellwithreuseidentifier: "customcollectionviewcell") c

java - I am having challenges changing Project Build Target on Eclipse -

i running eclipse on windows , having challenges changing/adding project build target on project's properties. set android 4.4w default, , there no other options. it understanding android wear supports edittext, trying add on app building. unless, of course, wrong aw's support edittext. may please assisted this. a screenshot of project's properties

emacs - elpy with Winpython: how to configure? -

i'm trying setup elpy emacs on windows system, on i'm using winpython 3.4.3. i have installed dependencies such rope, flake8, etc... using pip. when type m-x elpy-config in emacs, "neither easy_install nor pip found". if run (executable-find "python") correct path winpython installation. what might problem? on windows 7 emacs 24.5 , python 2.7 worked me include actual directory containing pip (scripts) in exec-path ; using m-x customize-variable exec-path . apparently, including directory of python executable not enough.

html5 - Determine when a canvas is resized -

i trying determine when canvas resized repaint it. context: canvas inserted in flex layout , height gets set flexbox model , changes depending on other layout elements content , size may dynamically vary (e.g., result of ajax request inserts texts in nearby span, causes canvas grow by, say, 10 pixels vertically). it seems resize event sent window — resize event not trick here, canvas may change size when window not. how can notified when canvas resized? if multiple parts of code change canvas size, must indeed refactor each scriptlet notify when changes canvas size. an easy way create resizing function scriptlet must use resize canvas. if function called, know scriptlet has resized canvas: function resizecanvas(canvas,w,h){ canvas.width=w; canvas.height=h; // canvas resizing flow point // respond resizing here. console.log('the canvas has been resized'); }

sorting - Ordering the following from smallest to largest in terms of efficiency -

i have tried sort out smallest largest in terms of efficiency got wrong. any please? x e , e x , (x+sinx)x 20 , x e , ln 2 x, xlnx, x + sinx, 13 + 1/x, lgx, 1/x could define efficiency? want know how sort these regarding asymptotic complexity? link when x grow big: 1/x near 0 13 + 1/x near 13 lgx grow slow, lg(10000000000) = bit more 33) ln²x slow also, ln²(10000000000) = 530 x + sinx approximatively x when x big xlnx x^e x^2.71828 (x+sinx)x^20 = x^21 + x^20*sinx, si equal x^21 e^x fast growing function, e^20 4.85*10^8 if so, 1/x < 13 + 1/x < lgx < ln²x < x + sinx < xlnx < x^e < (x+sinx)x^20 < e^x

Detecting every MouseEvent in JavaFx scene -

i want detect every mouseevent in javafx scene , mouse clicks. following solution works clicks, on controls not every control. question is, there way detect every mousereleased event on nodes of scene ? scene.addeventhandler(mouseevent.any, (eventhandler<mouseevent>) event -> { eventtarget comp = event.gettarget(); logger.debug("## " + (comp != null ? comp.getclass().getsimplename() : event.getclass().getsimplename()) + " [" + event.geteventtype() + "] ## komponente: " + event.gettarget() + " --------> details:" + event); }); following @james_d suggestion, logging working. catch events, necessary use eventfilter because eventhandler missing event consumed. doc explains differences: addeventfilter registers event filter scene. filter called when scene receives event of specified type during capturing phase of event delivery. addeventhandler registers event handler scene. handler called when

c++ - How to add debug watch for dynamically allocated array in CodeLite? -

Image
i check content of elements in array, while debugging program. when add watch dynamically allocated array can see address pointer? is there way watch content of dynamically allocated array? went through below post, solution didn't seem work codelite. guess because of different debugger. how display dynamically allocated array in visual studio debugger? i've had success using casting style syntax watch value: (int[10]*)a this shows array values once expanded in watch window. declaration of a in code was: int *a = new int[10]; here watch window:

javascript - Can't pass html tag into title property -

Image
i'm trying pass in title property html tag this: var unavailableperiod = { 'title': ealang['unavailable'] + ' <br><small>' + ((val[i]['notes'].length > 30) ? val[i].substring(0, 30) + '...' : val[i['notes']) + '</small>', 'start': date.parse(val[i]['start_datetime']), 'end': date.parse(val[i]['end_datetime']), 'allday': false, 'color': '#879db4', 'editable': true, 'classname': 'fc-unavailable fc-custom', 'data': val[i], 'column' : column_operator }; $calendar.fullcalendar('renderevent', unavailableperiod, false); but in visualization displayed this: i'm using version 2.3.1 of fullcalendar, in past 1.6.1 working perfectly. doing wrong? they changed html in event.title escaped. can try injecting html through eventrender : var unavailableper

powershell - WMICLASS.Create(), returning variables? -

in powershell, running process remotely (software install): $computers = get-content "c:\computer.txt" foreach ($computer in $computers) { #the location of file $install = "\\$computer\c$\software" #the install string can have commands aswell $installstring = "$install\ie11-windows6.1-x64-en-us.exe $arguments" ([wmiclass]"\\$computer\root\cimv2:win32_process").create($installstring) #output install result local c drive out-file -filepath c:\installed.txt -append -inputobject "$computer"} is there way return variables or status of install? or wait until process done? locally, can use wait-process : $installprocess = ([wmiclass]"win32_process").create($installstring) wait-process -id $installprocess.processid unfortunately, wait-process doesn't support remoting. here's poor man's remote equivalent using get-process : $installprocess = ([wmiclass]"\\$computer\root

javascript - setting file name for download response in node.js -

how can set file name downloaded binary in following node response request,for downloads file , set name req.url string .get(function (req, res) { var filename = path.join(process.cwd(), ''); path.exists(filename, function (exists) { if (!exists) { res.writehead(404, { "content-type": "text/plain" }); res.write("file not found: 404 not found\n"); res.end(); return; } if (fs.statsync(filename).isdirectory()) { filename += '/' + category + '/' + 'undo.png'; } fs.readfile(filename, "binary", function (err, file) { if (err) { res.writehead(500, { "content-type": "binary" }); res.write(err + "\n"); res.end(); return; } res.writehead(200); res.write(file, "binary"); res.end(); }); }); }); .get(function (req, res)

ios - <Error>: ImageIO: PNG invalid PNG file: extra chunks between iDOT and IDAT -

just got funny looking error in swift project debugger. there invalid name of image somewhere, not sure extra chunks between idot , idat mean. do have idea causes it? this issue random , happened me few images. xcode bug. my image called "back2@2x.png" i renamed "back2.png" ran project (the image appear stretched) changed "back2@2x.png" ran project fixed?! good-luck hope helps!

mysql - how to get last entry in given date range from pivot table -

ok, i'm stuck , need pls. this setup: 1) table items: id, name 2) table statuses: id, title 3) table item_status: id, item_id, status_id, created_at item model has relation: public function statuses(){ return $this->belongstomany('status')->withtimestamps(); } now, want items latest statuses '7' or '9', created between 2015-10-19 , 2015-10-20 closest got is: $items = item::with('statuses')->wherehas('statuses', function ($q) { $q->where('created_at','>=','2015-10-19'); $q->where('created_at','<','2015-10-20'); $q->wherein('status_id',array('7','9')); } ); problem not working right. it gives items got 1 of these status_id's in date range . if ite

html - how to get a image to be either the full browser width or height depending on which is smaller -

i have square image want fill of users browser possible without overflow. problem on devices width greater height , vice versa. therefore if set width 100% on devices cause height overflow. how can set image load square , 100% width, if width smaller height , 100% height, if height smaller width? thanks you can use vmin value: http://jsfiddle.net/bt2s86vu/ <div></div> div { width: 100vmin; height: 100vmin; background: green; } note, in ie9 need use vm instead on vmin: http://caniuse.com/#feat=viewport-units

java - Regular expression with repetitive pattern -

i need regular expression match %foo(%bar) or %foo. i'm using code now: string code = "%foo(%bar)"; code.matches("%+[\w&&[^_]][\w0-9]+[\w0-9&&[^_]]"); but works in second case. edit : regular expression must check if variable contain numbers , letters , if start _ or end _. don't want match _%foo or %foo_ or _%foo_ . a correct java regular expression be pattern pat = pattern.compile("%\\w+(?:\\(%\\w+\\))?"); no underscores in first or last place: pattern pat = pattern.compile("%[\\w&&[^_]]\\w*[\\w&&[^_]]" + "(?:\\(%[\\w&&[^_]]\\w*[\\w&&[^_]]\\))?"); this pattern requires @ least 2 characters in name. if single non-underscore should accepted, second , third part can made optional: pattern pat = pattern.compile("%[\\w&&[^_]](?:\\w*[\\w&&[^_]])?" + "

C# input validation, first digit must be 1? -

i want make sure user input 6 digits , start digit 1. how can make sure input start 1? private static void getcustomerinfo(out string accnumberc) { string accnumberc; console.write("account number: "); accnumberc = console.readline(); if (accnumberc == "" || accnumberc.length < 6 || accnumberc.length > 6) { console.writeline("invalid data entered - no value redorded"); accnumberc = null; } } if (string.isnullorempty(accnumberc) || accnumberc.length != 6 || !accnumberc.startswith("1")) { console.writeline("invalid data entered - no value redorded"); }

ios - Why am I getting com.facebook.sdk.login error 308? -

Image
i using xcode 7.0, testing on ios 9.0.2 , using facebook sdk 4.7.0. when logging in user, of time works should, keep getting error , have no idea why! the operation couldn’t completed. (com.facebook.sdk.login error 308.) after researching have seen people getting error when logging in parse.com's fbutils , official fbsdk @ same time, using fbsdk in project. so question is, why getting error , how rid of it? edit - adding code here login logic: func loginwithfacebook(sender: uiviewcontroller, completion: (profile: fbsdkprofile?, token: string?, cancelled: bool, error: string?) -> void ) { fbsdkprofile.enableupdatesonaccesstokenchange(true) nsnotificationcenter.defaultcenter().addobserver( sender , selector: "onprofileupdated:", name:fbsdkprofiledidchangenotification, object: nil) let loginmanager = fbsdkloginmanager() loginmanager.loginwithreadpermissions(["email", "public_profile"], fromviewcontroller: sende

haskell - Parse error on guards -

factorial :: int -> int factorial 0 = 1 factorial n | n < 0 == error "cant call nagative number" | otherwise = n * factorial (n-1) can explain why getting error? haskell.hs:77:2: parse error on input ‘|’ you need use = not == in function definition: factorial :: int -> int factorial 0 = 1 factorial n | n < 0 = error "cant call nagative number" | otherwise = n * factorial (n-1) = syntactic atom used defining things; == function/operator used comparing values.

email - How can I create a file that is accessible by other applications on Android/iOS device using ngCordova File plugin? -

i working on application building on ionic platform , intend run on both android , ios platform. one function in application send email user specified address. text based file contains application generated data attached email. for example, use may use application experiment , generate test data. data saved in 'report.csv' file somewhere on device , send out email attachment user. i use ngcordova's file plugin generate file , use ngcordova's email composer plugin draft email. however, realised ngcordova's email composer plugin can populate draft email content , has rely on third party applications send email out. bring issue file generated application saved in private accessible area. the third party email application cannot access file attach email. so, here comes question: there way save file in 'public' area via ngcordova file plugin can accessed multiple applications? thanks.

Estimating the slope and intercept in python using linear regression -

for assignment have been asked run code below. # import numpy import numpy np import numpy.random npr import numpy.linalg npl # simulate data in end of lecture 4 - time of higher dimension n = 1000 npr.seed(123) x_1 = npr.uniform(0,10,n) x_2 = npr.uniform(0,10,n) x_3 = npr.uniform(0,10,n) x_4 = npr.uniform(0,10,n) y = 3 + 2*x_1 - x_2 + 0.5*x_3 - 0.1*x_4 + npr.normal(0,1,n) # create design matrix x 5 columns, first of 1 subsequent ones x_1, x_2, etc x = np.array(([1]*n,x_1,x_2,x_3,x_4)).t we asked use inv function , standard equation β = (x t x) -1 x t y estimates of slope , intercept parameters. we asked values intercept , coefficient of x_1 3d.p.? if explain great new python , appreciate guidance. asked use solve function estimate of β ?

Python + Pandas : Update ONE column in csv based on another csv -

i have 2 similar tables ("hist.csv") : historical : id | url | url2 | url3 | time 1 b c 5 2 d e f 8 and ("new.csv") : new : id | url | url2 | url3 | time 1 z k 9 2 g h 11 i want update new.time column historical.time value, if "url" columns match. i.e. desired output here url "a" updated : new2 : id | url | url2 | url3 | time 1 z k 5 2 g h 11 i tried following : historical = pd.dataframe.from_csv("hist.csv", index_col='id', sep='\t', encoding='utf-8') new = pd.dataframe.from_csv("new.csv", index_col='id', sep='\t', encoding='utf-8') index, row in new.iterrows(): new.loc[index,'time']=historical.loc[historical['url'] == row['url'],'time'] new.to_csv("new2.csv", sep='\t', encoding='utf-8') rai

javascript - How to destroy bootstrap colorpicker? -

i using bootstrap colorpicker in logic given below : - (var = 0; < abc.length; i++) { if (selectedvalue == abc[i].name) { var color = getcolor(selectedvalue); $('.colorpicker').colorpicker('setvalue', color).on( 'changecolor', function(ev) { var colorcode = ev.color.tohex(); changecolor(colorcode); }).on('hidepicker', function(ev) { alert("hiding colorpicker"); }); } } the above code gets called method everytime user select value in dropdown. problem : when open colorpicker , close defocusing it. alert "hiding colorpicker" once in first go. if select value dropdown fires above given code again , open , close color picker again. alert twice , on in increasing numbers. my understanding

mysql - php - Search query -

this question has answer here: mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row() expects parameter 1 resource 33 answers i built simple search query.when user fills input , sends , creates search query gets database information matches keywords given. but when send keywords, gives me error : warning: mysql_num_rows() expects parameter 1 resource, boolean given in c:\xampp\htdocs\www.c++.com\search-query.php on line 59 no results found "c++" my php file looks : <form id="search" method="get" action="search-query.php"> <input type="text" name="keywords" placeholder="search..." /> <input type="submit" value="go" style="margin:10px" /> </form> and search query script : <form id="search"

tabs - Don't want to refresh tabsactivity when call from activity android -

Image
i trying stop refreshing tabs activity, in below pictures, can see when start new activity tab fragment , close pressing button , returning tabs activity, tabs restarted. need somehow resume tabs activity, in codes below, call new activity: intent = new intent(context, new_activity.class); startactivity(i); and close in way: finish(); instead of finish use flag way intent intent = new intent(current_context, destination_activity.class); intent.setflags(intent.flag_activity_reorder_to_front); startactivity(intent);

ios - Issues with Xcode & Realm browser -

so i've been trying use realm browser xcode it's easier me see , test objects. seem running couple of problems this. the first issue realm browser i'm not able open files location using dropdown option 'open common locations' can open via iphone simulator. when open file using alternative methods keep on getting following error in console. userinfo = { error code=8, nslocalizeddescription=realm file open in process cannot share access process. processes sharing single file must same architecture. sharing files between realm browser , ios simulator, means must use 64-bit simulator. } which weird because macbook 64 bit since it's mid 2013 macbook air solve problem @ all? since make development easier if use browser application. so figured out , realised have running app using iphone 5s or higher

c - Warning: passing argument 2 of ‘type_specifier’ from incompatible pointer type -

can please explain these errors? don't have multidimensional array don't understand how i'm getting error. main.c:291: warning: passing argument 2 of ‘type_specifier’ incompatible pointer type main.c:263: note: expected ‘int *’ argument of type ‘int **’ main.c:291: warning: passing argument 3 of ‘type_specifier’ incompatible pointer type here code. call program() main try call declaration_list() program(). void declaration_list(char *strings_line_tokens[], int *big_boy_counter, int *lower_bound_of_big_boy_counter) { int cmp_str1 = 0; int cmp_str2 = 0; int cmp_str3 = 0; printf("declaration_list().\n"); cmp_str1 = strcmp("int", strings_line_tokens[*lower_bound_of_big_boy_counter]); cmp_str2 = strcmp("float", strings_line_tokens[*lower_bound_of_big_boy_counter]); cmp_str3 = strcmp("void", strings_line_tokens[*lower_bound_of_big_boy_counter]); if(cmp_str1 == 0 || cmp_str2 == 0 || cmp_str3 == 0)

vb.net - WPF Stretch Middle Content in DockPanel or Stackpanel -

how stretch content in middle section of stackpanel or dockpanel . know dockpanel stretch last item need stretch middle item. know use grid * middle section want able set left and/or right items collapsed depending on window size. you should still use dockpanel lastchildfill setted. dockpanel stretch last element put in it, not last 1 according view. can put element want stretch in last position , use dockpanel.dock="top/bottom/right/left" on others one.

One companies network is unable to access my Google App Engine website, anyone else having this issue? -

the website accessible else , online websites check see if website accessible come positive. this 1 organization, used able access website, of sudden unable access website other day. they've tried multiple computers in organization, keeps telling them website isn't able found. conclusion can come issue way network setup; cache, dns, needs whitelisted? have no way of knowing. people have no idea , it's hard solve issue network have no access to. i'm think following causing problem, https://cloud.google.com/appengine/kb/?hl=en#static-ip even knowing this, have no idea how resolve it. possible setup dedicated instance website , attach ip address instance , serve them single instance through maybe, backdoor.website.com or similar? ideas/suggestions welcome. on gae app side make sure don't have network blacklisted in dos protection configuration. on network side first check if host+domain name of server resolves 1 (or more) ip addresses. if doesn&#

polymer - Paper-dialog with iron-pages and inside each page paper-dialog-scrollable -

using polymer 1 i'm trying figure out way dinamically switch pages inside paper-dialog , inside each page have paper-dialog-scrollable element. here's short version of i'm trying do: <paper-dialog with-backdrop> <iron-pages selected="0"> <div> <paper-dialog-scrollable> long content 1 goes in here... </paper-dialog-scrollable> </div> <div> <paper-dialog-scrollable> long content 2 goes in here... </paper-dialog-scrollable> </div> </iron-pages> </paper-dialog> the issue paper-dialog-scrollable, when window resized, goes on paper-dialog edges , no scrollbars shown. i've looked code paper-dialog-scrollable , has "dialogelement" property default "this.parentnode". i've tried change code each page change cannot work. here's "code":

(C++) Dijkstra's Algorithm Backtracking issues -

i'm programming djikstra's algorithm in c++ , i'm getting correct distances source node end node i'm having trouble backtracking previous nodes visited. it's giving me sort of correct answer not correct answer. noticed different input data of 1 start node , 16 finish node algorithm using path's aren't allowed (it goes 1 -> 10 -> 8 when 8 isn't allowed) me getting path backtracking wrong. http://pastebin.ca/3188762 - input data (1st = max nodes , nodes(node num, x,y) max edges edges last line being start , finish node) http://textuploader.com/awp89 - output in console code: #include<iostream> #include<fstream> using namespace std; struct node { int nodenum; double x, y; }; void dji(double map[50][50],int startnode,int endnode,int maxnodes); int main() { int tempa, tempb, maxnodes, maxedges, startnode, endnode; double tempd; double map[50][50]; ifstream fin; fin.open("ass03.txt")

java - No such Element exception for matrix of integers? -

though code seems small , simple throwing no such element exception..the question take matrix of integers , should check if there elements around elements less element. , have replace element 'x'.no need check border elements... new java...so corrections appreciated!! import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class solution { public static void main(string[] args) { scanner in = new scanner(system.in); int n= in.nextint(); int a[][] = new int[n][n]; for(int i=0;i<n;i++) //getting input user { for(int j=0;j<n;j++) { a[i][j] = in.nextint(); } } for(int i=0;i<n;i++) // checking condition { for(int j=0;j<n;j++) { if(i!=0 && i!=n-1 && j!=0 && j!=n-1) { if(a[i-1][j]<a[i][j] && a[i+1][j]<a[i][j] && a[i][j-1]&l

javascript - AngularJS with Rails 4.2 - how to make $routeProvider.when() work properly? -

i using rails 4.2 angularjs-rails , angular-rails-templates gems. when first go home page (index.html) , try , click '#/kiteboards/{{kiteboard.id}}/users', hashbang'd url appears in browser bar, e.g., ' http://localhost:3000/#/kiteboards/1/users ', users.html.haml template (courtesy of angular-rails-templates) not being loaded. this should simple routing problem....is angularjs routing code wrong? or else? no js error messages appear in chrome dev tools console, seems angularjs wired correctly, maybe missing "/" somewhere in routing. angularjs code snippet var kiteapp = angular.module('kiteapp', ['ngresource', 'ngroute', 'templates']); kiteapp.controller('kitectr', ['$scope', 'kiteboardapi', kitectr]); kiteapp.factory('kiteboardapi', ['$resource', kiteboardapi]); kiteapp.config(['$routeprovider', function($routeprovider) { $routeprovider.when('/ki

ios - can't hide bottom bar in view controller after pushing segue -

Image
in 1 view controller appears bottom bar after pushing vc segue. i can't hided. don't want bottom bar appears. kind of bar this? how away? i have uitextfield in vc, calling bar? don't need keyboard or bar. i tried disable in storyboard, appears in vc. edit: textfield: .h @interface gameoverviewcontroller : uiviewcontroller <uitextfielddelegate> { } .m @implementation uitextfield (disablecopypaste) -(bool)canperformaction:(sel)action withsender:(id)sender { return no; return [super canperformaction:action withsender:sender]; } @end @implementation gameoverviewcontroller nsstring *text1; text1 = @""; uiview* testview = [[uiview alloc] init]; _namefield.inputview = testview; [_namefield becomefirstresponder]; _namefield.contentverticalalignment = uicontrolcontentverticalalignmentcenter; [[uitextfield appearance] settintcolor:[uicolor blackcolor]]; //set color of cursor buttons textfield: if (_namefield.text.length <=11) {

python - Pandas dataframe - deltas of data with same ids -

i have dataframe looks this: type unique_id val 0 x 1 11 1 x 2 12 2 y 1 20 3 y 2 30 the desired output is type unique_id val delta 0 x 1 11 9 1 x 2 12 18 2 y 1 20 0 3 y 2 30 0 namely, want match every x y has same unique_id (the id unique among x s, , separately unique among y s). then, want calculate difference of val each x , , respective y row. y s, value can 0. assuming unique_id in fact unique give type, can group on based on data filtered type y . gb = df[df.type == 'y'].groupby('unique_id').first() >>> gb type val unique_id 1 y 20 2 y 30 you join original dataframe: df = (df.set_index('unique_id') .join(gb, rsuffix='_')) >>> df type val type_ val_ unique_id 1 x 11 y 20 1

c# - WPF color matrix -

i have created class called matrix (matrix [,] matrix;) , there have , j attributes, refer corresponding row , column. let's say, example, [1,6] cell contains number 6 (the content not matter example), or want represent red color since 6 greater 5. what wondering best , easiest way represent matrix in grid (grid, datagrid, ...) , example change [1,6] element of grid red color, displaying original matrix. example had dows not work, in fact not create grid: system.data.datatable dt = new system.data.datatable(); ...loop dt... dt.columns.add(); dt.rows.add(); datagrid1.datasource = dt; thanks in advance! this 1 of many possible solutions: <itemscontrol itemssource="{binding somematrix}"> <itemscontrol.itemspanel> <itemspaneltemplate> <uniformgrid isitemshost="true" columns="{binding somematrix.columns}" /> </itemspaneltemplate> </itemscontrol.itemspanel> <

qt - QGuiApplication::primaryScreen() with multiple screens on mac -

this question has answer here: determine programmatically screens geometry in multi-desktop environment qt 1 answer i want capture screenshot in qt: originalpixmap = qpixmap(); qscreen *screen = qguiapplication::primaryscreen(); if (screen) { originalpixmap = screen->grabwindow(0); } that works fine. when have second monitor connected on mac, though, grabwindow() return 1 image shows both displays. there way capture screens individually? no, there's no such way. have split pixmap yourself, based on geometry of each screen. see this answer details of determining geometry.

php - Ajax getting cancelled in browser -

when click , run ajax script, see error in chrome: status: cancelled the json data returns page in url bar. sql table updating error message indicate above displaying , modal doesn't remain open. suspect there few problems here wonder if notice something. this ajax script inside php variable why may see escaped characters. here $row php array. please don't confused. $("document").ready(function() { $(".form-inline'.$row["userid"].'").submit(function(event) { event.preventdefault; var formdata = new formdata($(".form-inline'.$row["userid"].'")[0]); console.log(); $.ajax({ type: "post", datatype: "json", url: "sponsorship.php", data: formdata, success: function(response) { if (response.success) { $("#mymodal'.$row["userid"].'"

php - API-centric web application file upload -

i creating api-centric web application using php. have read lot of articles on api-centric arhitecture , design, have problem related file uploads. suppose have image , want upload api server. how should upload image , how receive link image? here how want create now: select image using <input type="file"> on client www.domain.com upload www.domain.com using post multipart/form-data send image put/post api call api.domain.com api.domain.com save image server static.domain.com , store image's id in database then, when need image, can use api call api.domain.com , receive image's url (something static.domain.com/image.jpg ) aditional questions: is approach right 1 or doing wrong? will need aditional server store uploaded files if application small, or can store files right on api server? if store images on same server api server, won't strange if image urls api.domain.com/image.jpg ? p.s: can skip lot of api-related things need

python - Include carriage return correctly in iPython notebooks when writing using json.dump -

i'm trying generate ipython notebooks json files python. i'm not sure how write carriage returns file in cells i've specified cell_type markdown. i've tried double spaces, suggested here , , can markdown make new line specifying <br /> if include header specification markdown treats whole input header. for instance: import json # single markdown cell dictionary cell = { "cell_type" : "markdown", "metadata" : {'collapsed': false, 'name': 'test'}, "source" : ["## header line", "<br />", "second line, not header...hopefully"], } # create ipython notebook dictionary nbdict = { 'metadata': {}, \ 'nbformat': 4, 'nbformat_minor': 0, 'cells': [cell] } open('test.ipynb', 'w') outfile: json.dump(nbdict, outfile) then if open ipython notebook test.ipynb have following output:

Git merge updated WordPress plugins -

i have few wordpress plugins required updates. know there changes plugin files made myself , others overwritten updating plugins. don't know changes made since other people made of them. i updated plugins , pushed them separate branch. so, had master branch changes made plugins, , updated branch overwrote changes. merged both branches , there no conflicts. am right think changes made plugin files have been merged updates or lost of them? the git branches this: -----updated plugins---- / \ / \ ------master-----------------------merged branch---- yes, plugin have been merged. if changes others have overlapped changes made you, have had conflicts solve (which it's not case, said). since updated master branch changes made others, , merged yours, merged master branch have both changes in it. you can check commit logs see changes other people were. regards.

How to Define Layouts for Landscape Orientation in Android? -

how define folder structure layout resources in android project, know there's generic folder structure like: layout layout-land layout-xhdpi layout-xxhdpi but wanna define separate landscape folders xhdpi , xxhdpi well? layout-land-xhdpi layout-land-xxhdpi i'm ubable use layout-land-xhdpi landscape resources, android studio preview not picking layout resources layout-land-xhdpi? you not using correct qualifiers - should large, xlarge, xlarge-land , etc , not xxhdpi , etc:. here list of qualifiers ( from docs ) designed work: res/layout/my_layout.xml // layout normal screen size ("default") res/layout-large/my_layout.xml // layout large screen size res/layout-xlarge/my_layout.xml // layout extra-large screen size res/layout-xlarge-land/my_layout.xml // layout extra-large in landscape orientation res/drawable-mdpi/graphic.png // bitmap medium-density res/drawable-hdpi/graphic.png // bitmap high