Posts

node.js - ReactJS: JSON file is fetched from localhost instead of project directory -

Image
i have following directory structure of project. i have following code in index.js file loading website.json file. index.js componentdidmount() { $.ajax({ url: "../website.json", type: "get", datatype: 'json', contenttype: 'application/json', success: function(data) { this.setstate({data: data}); console.log(data); }.bind(this), error: function(jqxhr) { console.log(jqxhr); }.bind(this) }) } the problem using npm start command server react app local directory of application. serves app @ http://localhost:3000/ . problem application tries load website.json file http://localhost:3000/website.json gives 404 not found error. so, question how website.json file can loaded project directory instead of localhost. note: project folder not @ localhost @ virtual host. update: asking why ajax call unable load data project folder (i us...

java - Closing an application programmaticly with custom error message? -

i want close android application method, should shown custom message (which define myself). found yet "how close application" , got more 10 ways close application haven't found way set custom message. @ moment if app crashes appears: [appname] has been stopped want this congratulations! found bug, please submit it. there way that? methods found closed activities or forced unresolveable error. i don't think need code me, if do, tell me. (language should java , javascript/jquery should avoided) you try making static stop method: public static void stop(string message) { log.d(message); system.exit(0); }

python - How does re.match and re.search with '^' differ? -

it seems re.match , re.search w/ '^' same thing, except re.search can use re.multiline flag making more flexible. string ="""u.s. stock-index futures pointed solidly higher open on monday north korea. issue overshadowed state of equity market, earnings have been strong @ time of high employment , low inflation, valuations ppear elevated many metrics, north korea""" import re re.search('^north korea\.?', string) # no match re.match('^north korea\.?', string) # no match re.search('^north korea\.?', string, flags = re.multiline ).group() #match are there benefits of using 1 on other? re.match() checks match @ beginning >>> re.match("c", "abcdef") # no match >>> re.search("c", "abcdef") # match <_sre.sre_match object @ ...> re.search() checks match anywhere in string. if want find substring, use re.search() >>> re.match(...

javascript - How to prevent d3-brush from adding "display:none" to .selection and .handle onmousedown -

i noticed after brushing area using d3-brush, if click within brush's extent outside of selection, selection becomes invisible. closer inspection revealed svg rect elements .selection and .handle given display: none property, in response mousedown event. this jsfiddle minimal example of behaviour. drag select within white area, click white area outside of selection. edit: ivan brought in comments, seems default behaviour empty selections. how can prevent it? tried adding empty mousedown event listener .overlay , doesn't work.

Python Error self.reader.next() -

i receiving error , don't know how fix it. error show below along program. beginner programming new me. program's goal read information based of year , location , print out corresponding information psse traceback (most recent call last): file "c:/users/roszkowskim/desktop/dictreader.py", line 75, in <module> row in reader: file "c:\python27\lib\csv.py", line 103, in next self.fieldnames file "c:\python27\lib\csv.py", line 90, in fieldnames self._fieldnames = self.reader.next() valueerror: i/o operation on closed file _ import csv load_gen_datafile = 'c:\users\roszkowskim\desktop\data_2017.csv' open(load_gen_datafile) csvfile: reader = csv.dictreader(csvfile) mydict = {} row in reader: year=row['year'] busnum=row['busnum'] area=row['area'] power=row['power'] tla=row['tla'] location=row['location'] yearlink=row['yearlink'] from=row['fr...

mysql - Failing to start my spring boot application due to 'javax.sql.DataSource' that could not be found -

i beginner in spring boot , trying write simple spring boot application. folder structure follows: -> project -> build.gradle -> settings.gradle -> src/main/java -> package -> main.java -> usercontroller.java -> userrespository.java -> dto -> user.java ->src/main/resouces -> application.properties my build.gradle follows : buildscript { repositories { jcenter() } dependencies { classpath( 'org.springframework.boot:spring-boot-gradle- plugin:1.5.6.release' ) classpath('mysql:mysql-connector-java:5.1.34') } } apply plugin: 'java' apply plugin: 'spring-boot' sourcecompatibility = 1.8 targetcompatibili...

Oracle SQL: Sampling a large number of rows from a table -

i want extract roughly 5 million row sample table contain somewhere between 10 million , 20 million rows. due large number of rows, efficiency key. such, trying avoid sorting rows possible, hence why avoiding dbms_random.value solution have seen in similar questions. i tried following: select * full_table sample (ceil(100 * 5000000 / (select count(*) full_table))); however, can't seem arithmetic in sample clause (ora-00933: sql command not ended - tried simple sample(10/2) , still same thing). is reasonable approach, and, if so, how calculate number of rows in sample clause? you use pl/sql dynamic sql this: declare cnt integer; begin select count(*) cnt full_table; dbms_output.put_line(cnt); execute immediate 'insert target_table' ||' select * full_tablesample (' || ceil(100 * 5000000/cnt) || ')'; end;