Posts

Showing posts from April, 2013

javascript - CodeMirror custom helper -

i create code mirror helper / widget mimic medium.com entry writing ux. upon user hitting enter , getting new line circle + or other icon appear in gutter area , when user clicks open menu example commands, when user picks command it's full text entered document in current pos. what's best way that?

r - lapply and interp (akima) -

i'd interpolate on many individual data.frames stored within list using akima package. having split original data frame: store <- split(data, data$frameid) i tried this... results <- lapply(store, interp, x = lon, y = lat, z = precip) but error message error in interp(x = lon, y = lat, z = precip) : object 'lat' not found . single results can successfully generated following.. results <-list() # create , empty list results results[[i]]<-with(store$`600`, interp(x = lon, y = lat, z = precip)). where 600 represents name of 1 of data.frames within list. however attempting generalise entire list using loop-approach.. i=1 (i in i:length(store)){ results[[i]]<-with(store$`i`, interp(x = lon, y = lat, z = precip)) } i again receive error in interp(x = lon, y = lat, z = precip) : object 'lat' not found . any advice appreciated. using suggestions, , accounting duplicate points (same lat , lon stations) job. i=...

node.js - Assigning javascript object to new object as copy -

i have array of object obj.arr in javascript. assigned new object. var obj_arr_new = obj.arr; the problem when modify obj_arr_new , obj.arr gets modified well. not want that. how can make obj_arr_new copy of obj.arr , when modify obj_arr_new , obj.arr untouched? i using node.js v6. open using node.js module. told me lodash can job. answer using lodash helpful. lodash indeed has _.clonedeep(value) purpose. var obj_arr_new = _.clonedeep(obj.arr); it recursively clone "arrays, array buffers, booleans, date objects, maps, numbers, object objects, regexes, sets, strings, symbols, , typed arrays" modifying bits of clone doesn't affect original, or vice versa. documentation

python - duplicate returns more numbers than required -

a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] if len(set(a)) > len(set(b)): # finds biggest list largest = smallest = b else: largest = b smallest = common = largest in largest: if not in smallest: common.remove(i) print(common) prints: [1, 2, 3, 5, 7, 8, 10, 12, 13] 7, 9, 10, 11, 12 shouldnt in list. because aint in smaller list. what doing wrong? your code relies on assumption statements like largest=a copy list largest. this not true in python. rather statement makes largest reference old list a. your code, copy lists properly, should this: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] if len(set(a)) > len(set(b)): # finds biggest list largest = list(a) smallest = list(b) else: largest = list(b) smallest = list(a) common = list(largest) in largest: if not in smallest: common.remove(i) print(com...

html - Merging two rows together in a table so that no cells are visble -

Image
table { border-spacing:0 10px; border-collapse:separate; } td { padding:2px 10px; border-top:1px solid #ddd; border-bottom:1px solid #ddd; } td.gray { background:#ddd } td:last-child { border-right:1px solid #ddd; } <table> <tr> <td class="gray"> module description </td> </tr> <tr rowspan = "2"> <td> module aims provide comprehensive knowledge , experience of relational database model , its effective design, administration , implementation in order to support data driven applications.</td> </table> below images of want table , have @ moment. cant table rows merge , rid of division between first , second row. this want table like: this have far: setting padding , removing border-spacing trick: table { border: 1px solid #ddd; padding: 0; border-collapse: collapse; } td { padding: 2px 10px; } td.gray { ...

Issue in urlencoding using MySQL/PHP -

i have few textfiles input mysql database. these textfiles contain characters é , ë. have struggled getting data database , seems i've got right. however, know if there better way way describe here. the textfiles utf-8 encoded. the php scripts utf-8 encoded well. i've read important. all html output done using header this: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> the mysql database created using collation of latin1_swedish_ci (the character set left blank) all columns contain characters (varchar) defined using collation of latin1_swedish_ci i assume right way store url encoded strings when see character é stored %c3%a9 in database. found mysql function urlencoding here . when open phpmyadmin see character é presented %c3%a3%c2%a9. i can add statement replace characters in database, tells me there more efficient way achieve this. any appreciated. in advance. what missing list of 5 things is i te...

javascript - Send a file in socket.io without changing the user's window location -

i looking see if there way send html file socket.io connection without disconnecting them , changing window location. right have set if tries access website prompted enter name. when name entered , user presses play sent /game directory on website. emit name along connection info. @ moment when connect /game directory disconnects user causing information (including name) removed player list. when player joins onto /game directory have name of null , info entirely new info coordinates , things. here code use detect request /game: //sends home page asks name. app.get('/',function(req, res){ res.sendfile(__dirname + "/client/home.html"); }); //sends game file when /game requested app.get('/game',function(req, res){ res.sendfile(__dirname + "/client/game.html"); }); is there way stop user disconnecting when change game screen? way can keep info? or there else can fix problem? every time change uri in browser should rec...

postgresql - How to get size of posgresql jsonb field? -

i have table jsonb field in table. create table data.items ( id serial not null, datab jsonb ) how size of field in query this: select id, size(datab) data.items for number of bytes used store: select id, pg_column_size(datab) data.items; for number of elements on jsonb object: select id, jsonb_array_length(datab) data.items;

sqlite - using several query in cursor in android -

i want go information in sqllite database in android.but dont know what. code is: public cursor getdata() { string mypath = db_path + db_name; db = sqlitedatabase.opendatabase(mypath, null, sqlitedatabase.open_readonly); cursor c = db.rawquery("select text,_id tbl_laws parent_id = 0",null); // note: master 1 table in external db. here trying access records of table external db. cursor c1 = db.rawquery("select text,_id tbl_nokte parent_id = 0",null); // note: master 1 table in external db. here trying access records of table external db. return c; return c1; } can me? the solution adjust sql-select-query. you use rawquery information, 2 different cusors. not work. the solution needed information single cursor be: public cursor getdata() { string mypath = db_path + db_name; db = sqlitedatabase.opendatabase(mypath, null, ...

webserver - Serve files in folder with an Android Web Server -

i'd serve files (.html , .css files, example) of local folder recreate usual behavior of "real" local website. here 2 examples of applications work how i'd mine work: tiny web server free , kws - android web server . i searched lot google couldn't find anything... i tried nanohttpd appears can't set root or home directory , able return http code returning response object serve() method. that's not want. i'd able set root directory, example sdcard/www/ , index.html includes images sdcard/www/img/ subfolder... also, found this answer , not want. consists in returning content of .html file in response object serve() method. how i'd do?

javascript - Firebase Web update() deletes all other child nodes -

hello getting weird behaviour here. try update 1 specific child node, when user clicks button. here code: var updates2 = {}; var offer = { minusaccandshare: 2, } updates2['/offerlight/' + keyreal] = offer; updates2['/offer/' + keyreal] = offer; return firebase.database().ref().update(updates2); everything working fine correct nodes updated while updating minusaccandshare else deleted the structure like: offer jifdjsiavdas minusaccandshare: -6 offername: "replacement" offertext: "you have choice to..." ... and becomes offer jifdjsiavdas minusaccandshare: 2 i used approach described in firebase guides multiple times , worked charm. there created completly new nodes new key there nothing deleted. thanks :d what happening in code folowing: you writing entirely key thereby wiping off whole properties in dataset. this updates2['/offer/' + keyreal] = offer; wipes out whole data in partic...

python-cant install scipy from wheel -

i trying install scipy using pip wheel file: scipy-0.18.1-cp27-cp27m-win32.whl have install numpy+mkl of same python version , win32 version. numpy installed successfully, when tried installing scipy, showing these error messages : c:\users\saurav agarwal\downloads>pip install scipy-0.18.1-cp27-cp27m-win32.whl processing c:\users\saurav agarwal\downloads\scipy-0.18.1-cp27-cp27m-win32.whl exception: traceback (most recent call last): file "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) file "c:\python27\lib\site-packages\pip\commands\install.py", line 335, in run wb.build(autobuilding=true) file "c:\python27\lib\site-packages\pip\wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) file "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) file "c:\python27\l...

php - Running resize logo script on wordpress -

i'm trying implement custom logo shrink on website, i'm doing wrong , can't locate mistake. maybe can give small advice. so did: 1.child theme style.css, functions.php, assets/js/my_shrinker.js 2.i added function load my-shrinker.js in functions.php function shrinker() { wp_enqueue_script( 'my_shrinker', get_stylesheet_directory_uri().'/assets/js/my_shrinker.js', array( 'jquery' ), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'shrinker' ); 3.added code perform shrink when scrolling in my-shrinker.js function my_shrinker() { window.addeventlistener('scroll', function(event){ var distancey = window.pageyoffset || document.documentelement.scrolltop, shrinkon = 300, d = document.getelementsbytagname("kad-header-left"); if (distancey > shrinkon) { d.classname += " shrinkedlogoyo"; } else { d.classlist....

osx - Python 2 subprocess arguments error under Mac -

i'm trying mac version of program runs fine under windows, using python 2.7. under mac (os x el capitan running in virtualbox), fails because arguments pass shell not recognized properly. original code: for item in source_files: # core process output = sub.popen(["mhl", "verify", "-vv", "-f", item, ">", text_report], shell=true, stdout=sub.pipe, stderr=sub.pipe) stdout_value, stderr_value = output.communicate() under mac 'mhl' argument recognized tried this: sub.popen(['mhl verify -vv -f', item, '>', text_report] now command works item (a .mhl file) not recognized tried this: sub.popen(['mhl verify -vv -f', '/users/simon/documents/documents.mhl', '>', text_report] and this: sub.popen(['mhl verify -vv -f', r'/users/simon/documents/documents.mhl', '>'...

pandas - Using scalar values in series as variables in user defined function -

i want define function applied element wise each row in dataframe, comparing each element scalar value in separate series. started function below. def greater_than(array, value): g = array[array >= value].count(axis=1) return g but applying mask along axis 0 , need apply along axis 1. can do? e.g. in [3]: df = pd.dataframe(np.arange(16).reshape(4,4)) in [4]: df out[4]: 0 1 2 3 0 0 1 2 3 1 4 5 6 7 2 8 9 10 11 3 12 13 14 15 in [26]: s out[26]: array([ 1, 1000, 1000, 1000]) in [25]: greater_than(df,s) out[25]: 0 0 1 1 2 1 3 1 dtype: int64 in [27]: g = df[df >= s] in [28]: g out[28]: 0 1 2 3 0 nan nan nan nan 1 4.0 nan nan nan 2 8.0 nan nan nan 3 12.0 nan nan nan the result should like: in [29]: greater_than(df,s) out[29]: 0 3 1 0 2 0 3 0 dtype: int64 as 1,2, & 3 >= 1 , none of remaining values greater or equal 1000. your best bet may transpose...

laravel - Require/Use npm module in elixir -

Image
i'm tring use es2015 elixir (first time) , have problem jquery validator: uncaught typeerror: $(...).validate not function(…) . my code: i try use require('jquery-validation/dist/jquery.validate') don't work. what doing wrong?

python - How to change the shape of a Pandas Dataframe (row number with an "L")? -

i have 1 column pandas dataframe of shape (362l,) , , change (362, 103) . how can that? just figured out, since object of shape (362l,) pandas series, need change dataframe, this: pd.dataframe(df) that's it!

ios - PVR compression versus PNG -

i'm testing different compressions spritesheets game on ios. in surprising way, more important memory (ram) use pvr 2 bits alpha instead of png 32 (rgba 4444). consumption 25% higher pvr 2 bits instead of png 32 once spritesheets loaded inside memory. i'm using instruments xcode verify memory use on physical device (ipad air 2) i'm using texturepacker generate spritesheets. i've read evrywhere pvr 2 or 4 less memory consumer png 32. how possible ? edit: this strange because according observations, pvrtc 4 bits rgba uses lot more memory (ram) png 32, neraly 3 times more according instruments xcode. pvrtc 2 bits rgba 25% higher png 32 rgba 4444. i'm talking live ram consomption, not disque size has nothing , not problem. seems ios manages pvr differently it's supposed do, when loading them ram. edit2: my textures 2048x2048, there pot , have square format. evrything work fine, except ram consomption higher should be. make tests physical ipad air 2 d...

python 2.7 - How to restrict sympy FiniteSet containing symbol -

i new sympy. tried solve system of linear equations linsolve(). yields solution can reproduced 2 following lines. d = symbols("d") solution = sets.finiteset((d + 1, -d + 4, -d + 5, d)) my solution obeys restriction, 4 values must positive integers. happens d = 0, 1, 2, 3, 4. i able evaluate solution @ fixed d (e. g. d = 0) with solution.subs({d : 0}) what have restrict set of solutions valid ones automatically. mathematically amounts intersection \mathbb{n^0}^4. in practice output from for d_fixed in range(5): solution.subs({d : d_fixed}) i. e. {(1, 4, 5, 0)} {(2, 3, 4, 1)} {(3, 2, 3, 2)} {(4, 1, 2, 3)} {(5, 0, 1, 4)} how can this? i think along these lines it, little magic you. >>> sympy import * >>> var('d') d >>> solution = sets.finiteset((d+1,-d+4,-d+5,d)) >>> list(list(solution)[0]) [d + 1, -d + 4, -d + 5, d] >>> sympy.solvers.inequalities import reduce_inequalities >>> red...

jquery - PHP data not sent by ajax -

Image
i trying pass value ajax get-data.php . have lot research on stackoverflow. however, still cannot work , not sure why case. whenever var_dump $_post , array(0) . index.php <select id="cis_major"> <option disabled selected value> -- select option -- </option> <option value="cs150">cs150</option><option value="cs180">cs180</option> <option value="cs240">cs240</option><option value="cs280">cs280</option> < option value="cs350">cs350</option><option value="cs360">cs360</option> <option value="cs401">cs401</option><option value="cs402">cs402</option> <option value="cs421">cs421</option><option value="cs440">cs440</option> <option value="cs460">cs460</option>...

ios - Unicode non-breaking space is removed end of label -

i'm using tableview , use 1 cell create many columns.my column number not fixed had create columns using loop inside cellforrowat function.i want give spaces between labels inside cell.this piece of code succesfully inserts non-breaking spaces head of label removes end of label.thanks help. let spaces = string(repeating:"\u{00a0}",count : columnspacecount) if globalsubviewheaderstructarray[i].type == "numeric"{ if globalsubviewheaderstructarray[i].digitsaftercomma != "0" { var datanumber = applycomma(comma : globalsubviewheaderstructarray[i].digitsaftercomma , data : globalsubviewdataarray[indexpath.row][i]) var newstring = "\(spaces)\(checkcurrency(option: globalsubviewheaderstructarray[i].currency, data: datanumber))\(spaces)" newlabel.text = newstring }else{ var newstring = "\(spaces)\(checkcurrency(option: globalsubviewheader...

How to resolve ambiguity in Spring constructor injection -

i trying learn constructor injection using spring 4.3. i having class structure stated below. @component public class student { private address address; private city city; public student(address address, city city) { this.address = address; this.city = city; } public student(city city, address address) { this.address = address; this.city = city; } public student(city city) { this.city = city; } public student(address address) { this.address = address; } } java based configuration class: @configuration @componentscan(basepackages = "com.spring.constructorinjection") public class studentconfiguration { } client code: applicationcontext context = new annotationconfigapplicationcontext(studentconfiguration.class); student student = context.getbean(student.class); system.out.println(student.getcity()); system.out.println(student.getaddress()); how can structure java based configuration class assure specific cons...

php - How can I load a library in Codeigniter via autoload composer? -

i have installed autoload via composer in codeigniter , tested if file autoload.php included , it's. so, if have library called pager in libraries, how can instantiate (load) pager class? it's fresh codeigniter installation, version 3.1.2 i set in config this: $config['composer_autoload'] = true; i have try following ways in welcome controller: $pager = new libraries\pager(); //class 'libraries\pager' not found $pager = new \libraries\pager(); //class 'libraries\pager' not found $pager = new \library\pager(); // class 'library\pager' not found $pager = new pager(); // class 'library\pager' not found and here pager class libraries directory: class pager { function __construct() { parent::__construct(); echo __class__; } } thank help! this in fact unrelated codeigniter. you need tell composer have own php classes aren't among autoloaded files. in composer.j...

matlab - Return Unique Element with a Tolerance -

in matlab, there unique command returns thew unique rows in array. handy command. but problem can't assign tolerance it-- in double precision, have compare 2 elements within precision. there built-in command returns unique elements, within tolerance? with r2015a, question has simple answer (see my other answer question details). releases prior r2015a, there such built-in (undocumented) function: _mergesimpts . safe guess @ composition of name "merge similar points". the function called following syntax: xmerged = builtin('_mergesimpts',x,tol,[type]) the data array x n-by-d , n number of points, , d number of dimensions. tolerances each dimension specified d -element row vector, tol . optional input argument type string ( 'first' (default) or 'average' ) indicating how merge similar elements. the output xmerged m-by-d , m<=n . it sorted . examples, 1d data : >> x = [1; 1.1; 1.05]; % elements ...

android - java.lang.NullPointerException: Attempt to invoke virtual method' on a null object reference -

this question has answer here: null pointer exception - findviewbyid() 9 answers what nullpointerexception, , how fix it? 12 answers i tried see every answer question did not work me i know counter view return null don not know why tried in code did not worked public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub layoutinflater inflater=activity.getlayoutinflater(); if(convertview == null){ convertview=inflater.inflate(r.layout.column_row, null); txtfirst=(textview) convertview.findviewbyid(r.id.name); txtsecond=(textview) convertview.findviewbyid(r.id.gender); txtthird=(textview) convertview.findviewbyid(r.id.age); //txtfourth=(textview) convertview.findvi...

regex - Java replaceAll remove spaces from empty lines -

i'm trying remove spaces lines in block of text contain nothing spaces, leaving line breaks in place. i tried following: str = " text\n \n \n text"; str = str .replaceall("\\a +\\n", "\n") .replaceall("(\\n +\\n)", "\n\n") .replaceall("\\n +\\z", "\n"); i expecting output be " text\n\n\n text" but instead was " text\n\n \n text" the space in third line of block had not been removed. doing wrong here? use multiline flag, ^ , $ match beginning , end of each line. problem regex is capturing newline character, next match advance past it, , cannot match. str.replaceall("(?m)^ +$", "")

swift - Ambiguous type inference -

i'm getting compiler error swift 3.0.1 that's got me stumped. error states there's ambiguity in type of computed property can't see how. i have protocol generic property root . protocol has generic constraint root must subclass of type root . class root { } protocol generic { associatedtype roottype: root var root: roottype { } } i define protocol extension states: if generic subclass of root , return self root property. so basically: if it's root , can forward self . extension generic self: root { var root: self { return self } } i have genericwrapper class subclass of root , wraps instance of generic (to perform root operations generic proxy). class genericwrapper<t: generic>: root { var generic: t init(generic: t) { self.generic = generic } } finally, define specialised protocol, , extension states: if specialised implements generic , return genericwrapper root proper...

apache - Removing .php extension won't work -

i using laravel, , .php removed using: # handle front controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] but using below force www , ssl , seems break above code , .php extension not removed anymore, doing wrong? rewritecond %{https} !=on rewritecond %{http:x-forwarded-proto} !https #if neither above conditions met, redirect https rewriterule ^ https://%{http_host}%{request_uri} [l,r=301] #force www rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] full code <ifmodule mod_rewrite.c> <ifmodule mod_negotiation.c> options -multiviews </ifmodule> rewriteengine on # redirect trailing slashes if not folder... rewritecond %{request_filename} !-d rewriterule ^(.*)/$ /$1 [l,r=301] # handle front controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ i...

c++ - Receiving information from serial port in while loop -

i'm reading information serial port using code: struct termios tio; memset(&tio, 0, sizeof(tio)); // open serial port in mode `8n1', non-blocking tio.c_cflag = cs8 | cread | clocal; tio.c_cc[vmin] = 1; tio.c_cc[vtime] = 10; int fd = open("/dev/ttyacm1", o_rdonly); cfsetospeed(&tio, b9600); cfsetispeed(&tio, b9600); tcsetattr(fd, tcsanow, &tio); unsigned char byte = '0'; // check input arduino while (!quit) { keyboardinput(quit); read(fd, &byte, 1); if ((byte == '1' || quit) { oldbytedoor = '1'; break; } } where keyboardinput(quit) sets quit true when close button of window pressed. if nothing in serial port gets stuck @ read(fd, &byte, 1) forever. how can prevent this? thanks

javascript - React Component's onClick handler not binding to "this" -

i have react component in trying pass span tag onclick event handler. event handler called "askquestion". bind onclick event handler context of component .bind(this, parameter) function. despite attempt bind "this" i'm still getting error in dev tools console saying "cannot read property askquestion of undefined." i'm pretty sure error means askquestion not bound context of component. need binding askquestion properly. here component: class questions extends component { askquestion(question) { alert("hello"); } addquestion(question, index) { return ( <div key={index} classname="col-xs-12 col-sm-6 col-md-3"> <span onclick={this.askquestion.bind(this, question)}> {question.q} </span> </div> ); } render() { return ( <div id="questions" classname="row"> <h2>questions</h2> {thi...

Read string contents from HDFS in Scala -

what easy way read hdfs in scala, , able create unit tests rely on hdfs without having requirement of access hdfs? somehow mock/stub hdfs? i suggest using spark . val textfile = sc.textfile("hdfs://...") val counts = textfile.flatmap(line => line.split(" ")) .map(word => (word, 1)) .reducebykey(_ + _) counts.saveastextfile("hdfs://...")

theory - Valid Huffman Codes? -

i'm trying solve huffman coding problem, i'm not sure understand topic completely. trying figure out if following valid huffman code: a: 0 b: 01 c: 11 d: 110 e: 111 what i'm thinking is not valid, because a, or 1, infringe on b, or 01. i'm not positive though. enlighten me on this? edit: i'm sorry meant type 0 , not 1. no. huffman code prefix code, means no code can prefix of other code. in example, prefix of b, , c prefix of both d , e. a valid prefix code be: a: 0 b: 10 c: 11 that's far can go codes of length 1, 2, , 2. other codes prefix of those. not possible have prefix code lengths 1, 2, 2, 3, , 3. this valid prefix code 5 symbols: a: 0 b: 10 c: 110 d: 1110 e: 1111 as this: a: 00 b: 01 c: 10 d: 110 e: 111

javascript - Angular Copy clicked object to another controller -

i have list of items , if click on 1 of them current object should copied controller , displayed there, i've created factory save clicked item, not being displayed in second controller view, dont understand why not showing. here's plnker https://plnkr.co/edit/hwjfjcjcq3vtvefzfmoy and code. <!doctype html> <html> <head> <title>angucomplete</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body ng-app="myapp"> <div class="container"> <div class="container" ng-controller="controllerone"> <h3>controller...

google analytics - Sending an event after sucessful ajax form submission -

Image
so have created custom goal in ga: and have ajax e-mail form want send event when form correctly submitted (using analytics.js ): jquery.post(url, {name:name, surname:surname, email:email, country:country}, function(data) { if(data) { if(data=="some fields missing.") { // } else if(data=="invalid email address.") { // } else if(data=="already subscribed.") { // } else { // successful message ga('send', 'event', { eventcategory: 'form', eventaction: 'optin', eventlabel: '7 dicas para o sucesso nas redes' }); } } else { // } } ); the form working fine, every time add user list, analytics goal still stuck @ 0.

google chrome - Python Selenium Element is not clickable -

i'm trying gather information on website using python 3.6 , selenium, however, page loads right away on chrome(54.0.2840.87(64-bit)), goes tab(case logs) half second, changes tab(alerts). i tried find using 'find_element_by', clicking @ point, finding text on tab(case logs). if use 'find_element_by_xpath', 'element not clickable @ point (488, 93). other element receive click'. here code: from selenium import webdriver time import sleep selenium.webdriver.common.keys import keys selenium.webdriver.common.by import selenium.webdriver.support.ui import webdriverwait selenium.webdriver.support import expected_conditions ec selenium.webdriver.common.action_chains import actionchains #enter credentials user = input('user: ') password = input('password: ') case = input('case: ') #open page driver= webdriver.chrome() driver.maximize_window() driver.get('.com') #login elem = driver.find_element_by_id("user") ele...

eval - process embedded variable within a string using PHP -

how process variable embedded within string? string came database, here example: 1: $b='world!'; 2: $a='hello $b'; #note, used single quote purposely emulate string database (i know different of using ' or "). 3: eval($c=$a.";"); #i know not work, trying $c="hello $b"; #with line 3 php code, trying outcome of $c='hello world!'; if want eval line of code $c='hello world'; should have string when echo ed that: $c="hello $b"; . so - start, $c variable should inside string (and not variable); '$c' next - = sign should inside string (and not part of php code, otherwise preprocessor try assign value on right variable on left. how one: $new_str = '$c=' . $a . ';'; echo $new_str; now can see value inside $new_str actually: $c=hello $b; which not valid php code (because don't have hello in php. want have hello $b part inside double-quote: $new_str = '$c...

java - spring data native query interesting bug with Lob column -

i have entity: @entity public class knowledgebase { private long id; private string link; private string content; @id @sequencegenerator(name = "knowledgebase_id_generator", sequencename = "knowledgebase_id_sequence", allocationsize = 1) @generatedvalue(strategy = generationtype.sequence, generator = "knowledgebase_id_generator") public long getid() { return id; } public void setid(long id) { this.id = id; } public string getlink() { return link; } public void setlink(string link) { this.link = link; } public string getcontent() { return content; } public void setcontent(string content) { this.content = content; } } and have spring data repository @repository public interface knowledgebaserepository extends abstractrepository<knowledgebase, long> { @query(value = "select c.id id,c.link link, c.cont...

asp.net mvc - An exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.SqlServer.dll but was not handled in user code -

Image
i new asp.net mvc, facing exception, connection string looks perfect still, exception raised, appreciate if give me why happening. thank guys model 1 namespace mvctwice.models { public class studentcontext : dbcontext { public dbset<student> studs { get; set; } } } model 2 namespace mvctwice.models { [table("tblstudents")] public class student { public int id { get; set; } public string name { get; set; } public string gender { get; set; } public string totalmarks { get; set; } } } action method public actionresult index() { studentcontext studentcontext = new studentcontext(); //student emp = studentcontext.studs.select(emp=>emp.) list<student> emp=studentcontext.studs.tolist(); return view(emp); } view @model mvctwice.models.student @{ layout = null; } <!doctype html> <html> <head> ...

matlab - After using `uniquetol` to an array, how can i find back where the entries are in the array? -

>> = [12345678.123456789, 12345678.123456788] = 1.0e+07 * 1.234567812345679 1.234567812345679 >> unique(a) ans = 1.0e+07 * 1.234567812345679 1.234567812345679 >> uniquetol(a,eps) ans = 1.234567812345679e+07 so 2 numbers considered same within tolerance of eps . however, after obtaining 1.234567812345679e+07 . want know entries in a match 1.234567812345679e+07 within tolerance of eps (which reasonable after use uniquetol eps tolerance before.) but find(abs(a-uniquetol(a,eps))<eps) ans = 2 even >> find(abs(a-uniquetol(a,eps))<=eps) ans = 2 >> find(abs(a-uniquetol(a,eps))<=eps*10) ans = 2 does not give me 2 entries. it >> find(abs(a-uniquetol(a,eps))<=eps*10000000) ans = 1 2 or >> find(abs(a-uniquetol(a,eps))<=eps(uniquetol(a,eps))) ans = 1 2 will give me first entries. ( find(abs(a-uniquetol(a,eps))<=eps(uniquetol(a,eps))) not work numbers.) ...

Begining Python os.fork output -

i new python. i know os.fork create copy. what output of ? , please explain. pid = os.fork() if pid == 0: print(1, end = '') print(3, end = '') else: print(3, end = '') print(2, end = '') print(0, end = '') make 2 identical copies of address spaces, 1 parent , other child os.fork does refer this

importing project in android Studio built with eclipse and libGDX -

first, import project in android studio, since project had many modules avoid errors appears, should add details gradle (dependencies ...). so, fixed errors , building of project finished 1 warning when tried run project got many errors. messages of build (warnings) information:gradle tasks [clean, :projectnameandroid:generatedebugsources, :projectnameandroid:mockableandroidjar, :projectnameandroid:preparedebugunittestdependencies, :projectnameandroid:generatedebugandroidtestsources, :projectnameandroid:compiledebugsources, :projectnameandroid:compiledebugunittestsources, :projectnameandroid:compiledebugandroidtestsources] warning:[options] bootstrap class path not set in conjunction -source 1.7 information:build successful information:total time: 1 mins 1.934 secs information:0 errors information:1 warning information:see complete output in console messages of run(errors) information:gradle tasks [:projectnameandroid:clean, :projectnameandroid:generatedebugsources, :proje...

html5 - Javascript setTimeout() function repeats previous functions -

i'm creating simple pong game javascript , html5 canvas. when user or computer scores point, want display text on screen 3 seconds saying: "player 1/2 got point!" before 'reset()' function called. before display text make script add 1 point score. whenever call settimeout() function, wait, during wait time repeats add score function until wait up. here snippet of code: window.onload = function() { c = document.getelementbyid("gc"); ctx = c.getcontext('2d'); setinterval(update, 1000/30); c.addeventlistener('mousemove', function(e) { p1y=e.clienty-ph/2; }); } function update() { bx+=xv; by+=yv; if(by<2 && yv<0) { yv=-yv; } if(by>c.height-bd && yv>0) { yv=-yv; } if(by>p1y && by<p1y+ph) { xv=-xv; dy=by-(p1y+ph/2); yv=dy*0.3; } else { // add score player 2 score2++; // draw text on screen ctx.fillstyle='red'; ...

python - PyQt: QFileSystemModel checkbox filter -

Image
i trying make utility using python/pyqt create *.tar archive qfilesystemmodel (including items checked). want control of qfilesystemmodel checkboxes filter filename / filetype / filesize. how can check/uncheck qfilesystemmodel checkboxes outside of class wildcard search on filename / filetype / filesize? class checkabledirmodel(qtgui.qfilesystemmodel): def __init__(self, parent=none): qtgui.qfilesystemmodel.__init__(self, none) self.checks = {} def data(self, index, role=qtcore.qt.displayrole): if role != qtcore.qt.checkstaterole: return qtgui.qfilesystemmodel.data(self, index, role) else: if index.column() == 0: return self.checkstate(index) def flags(self, index): return qtgui.qfilesystemmodel.flags(self, index) | qtcore.qt.itemisusercheckable def checkstate(self, index): if index in self.checks: return self.checks[index] else: return q...

c - How can I pass an array of structures to a function by reference? -

this question has answer here: passing array of structs in c 9 answers #include <stdio.h> void changevalues(struct item *item[]); struct item { int number; }; int main(void) { struct item items[10]; (int = 0; < 10; i++) { items[i].number = i;//initialize printf("before:: %d\n", items[i].number); } changevalues(items); (int = 0; < 10; i++) { items[i].number = i; printf("after:: %d\n", items[i].number); } return 0; } void changevalues(struct item *item[]) { (int = 0; < 10; i++) item[i] -> number += 5; } i trying pass array of structures function. need change values of structures members within function reference , not value. odd reason when print results after function called values remain same prior function call. in c can't pass refe...

Getting adjacent objects to interact [C#] -

i'm doing basic game in c#, , i'm running on problem can't solve. here's (relevant) code: public class gamemanager { public gamemap mainmap; public entitymanager gameworld; public systemmanager gamesystems; public gamemanager() { entitymanager gameworld = new entitymanager(); systemmanager gamesystems = new systemmanager(); gamemap mainmap = new gamemap(61, 41); } public void inputhandler(string trigger) { switch (trigger) { case "north": gamesystems.move(gameworld, mainmap, 0, 8); break; //etc } } } public class systemmanager { public rkcposition _position; public systemmanager() { } public bool move(entitymanager targetworld, gamemap targetmap, int targetid, int targetdirection) ...