Posts

Showing posts from July, 2011

java - Is it necessary to resolve the errors shown in the output window of Netbeans IDE even if my code is working the way I want? -

say want 'of' typed in input user i making app, not finishing off in dumb output screen (this example) import java.util.*; scanner input = new scanner(system.in); string text = input.nextline(); int check = 0; for(int = 0; < text.length(); i++;){ if(text.substring(i, + 2) .equals("of")){ check = 0; } } if user enters abofd , surely recognises of @ position @ 2-4. when i value 4 checks position 4-6, position 6 not present not present gives error. know thinking me set i < text.length() - 1 @ line 5, original code needs run until end! it good idea validate input coming user, overcomplicating things! worse, wrote down outright wrong code: string text = input.nextline(); int check = 0; for(int = 0; < text.length(); i++;){ if(text.substring(i, + 2) .equals("of")){ the above can't work! see, i iterates 0 text length. using i+2 substring text. (so: hello first arrayindexoutofboundsexception). i...

wpf - Reading file async still blocks the UI -

i have simple treeview, when click on treeview item load text file here code: private async void notestreeview_onselecteditemchanged(object sender, routedpropertychangedeventargs<object> e) { var clickedmodel = e.newvalue treefileitem; if (clickedmodel != null && file.exists(clickedmodel.filepath)) { _viewmodel.noteloadinginprogress = true; using (var reader = file.opentext(clickedmodel.filepath)) { var filecontent = await reader.readtoendasync(); _viewmodel.activenote = filecontent; } _viewmodel.noteloadinginprogress = false; } } this works, when click on treeview item ui frozen, until file read complete. why such behavior? have other async methods in code , don't block ui. edit: seems issue not in reading file, in setting large amount of text textbox.text properti via databinding, though setting directly take lot of time , make ui freeze the ui frozen, until file...

c - Read Tags for few MP3 files -

this code work read 1 mp3 file id3v1 tags. have directory few mp3 files. add allow program read mp3 files in directory. , have export id3v1 tags csv file. i don't know how that, appreciated. #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ char tag[3]; char title[30]; char artist[30]; char album[30]; char year[4]; char comment[30]; unsigned char genre; }mp3info; int main (int argc, char *argv[]) { if ( argc != 1 ) { printf( "please choose 1 file: %s <song.mp3> \n", argv[0] ); } type file, file = fopen("song.mp3", "rb"); if (file == null) { printf("i couldn't open: %s reading.\n"); exit(0); } else { mp3info tag_in; fseek(file, -sizeof(mp3info), seek_end); if (fread(&tag_in, sizeof(mp3info), 1, file) != 1) { printf("could not read tag\n"); exit (0); } if (memcmp(tag_in.tag, "tag", 3) == 0) { printf("title: %.30s\n", tag_in.title); printf(...

security - How to secure Amazon EC2 with Tomcat7 and mySQL -

i'm new ec2. have tomcat 7 , mysql installed. security group have setup is custom tcp rule tcp 8080 ssh tcp 22 mysql tcp 3306 for outbound traffic. i got report amazon said below instance id: i-1e42db06 aws id: 772517067349 reported activity: dos what should stop it? and got bill below $0.090 per gb - first 10 tb / month data transfer out beyond global free tier 637.521 gb please advice me steps protect instance in ec2 updated: email amazon we've received report(s) ec2 instance(s) aws id: 772517067349 instance id: i-1e42db06 ip address: 172.31.25.202 has been implicated in activity resembles denial of service attack against remote hosts; please review information provided below activity. please take action stop reported activity , reply directly email details of corrective actions have taken. if not consider activity described in these reports abusive, please reply email details of use case. if you're unaware of activity, it's p...

c# - Why does i cant bind the datasource to my datagridview with result from stored procedure? -

Image
my sp : my c#: i can't method .tolist() in eksekusi datasource in datagridview, how solve this? the result of stored procedure collection of items ( ienumerable<t> / iqueryable<t> ). when perform firstordefault retrieve first item in collection or default(t) if collection empty. the t have not ienumerable<t> object representing single record 3 properties, not have tolist() extension method. please refer so linq firstordefault documentation understand more

java - How to build executable jar using maven-jar-plugin and groovy? -

i have example app main class in groovy , main class in java. maven-jar-plugin builds executable jar when java class specified main class not when groovy class is. let me demonstrate. here build: <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> <version>3.0.2</version> <configuration> <archive> <manifest> <mainclass>com.example.hello.javahello</mainclass> </manifest> </archive> </configuration> </plugin> <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>3.1</version> <configuration> <compilerid>groovy-eclipse-compiler</compilerid> <verbose>false</verbose> <source>${java.compiler.version}</source...

Java if statement to change a variable value -

i've started java, done 5-6 hours have no idea how approach task. i'm doing tax system hotel. standard rate of tax used (20%). however, program asks user if want change rate asking user input "yes" or "no", if yes, proceed enter new value of variable tax , if no, keeps standard rate of (20%). there's lot more task. however, issue i'm struggling with. can tell me how write such if statement? have absolutely no idea how such specific user input. any sort of or suggestions appreciate can play around it. perhaps can find solution within following example. please note it's quick , dirty example without errorhandling or gui. import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; public class demo { private int rate; public static void main(string[] args) { demo demo = new demo(); demo.work(); } private void work() { rate = 20; system.out.println("would use defaul...

Can't handle events of Dialog Box Controls - WinForms C# -

i error when make method or add eventhandler control added on dialog box. make clearer, dialog looks this: public static class promptmonth { public static string showmonthdialog(string caption) { form prompt = new form() { width = 200, height = 150, formborderstyle = formborderstyle.fixeddialog, text = caption, startposition = formstartposition.centerparent }; label textlabel = new label() { left = 25, top = 10, text = "pick month" }; combobox combomonth = new combobox() { left = 25, top = 35 }; button ok = new button() { text = "ok", left = 25, width = 100, top = 70, dialogresult = dialogresult.ok }; ok.click += (sender, e) => { prompt.close(); }; textlabel.autosize = true; combomonth.dropdownstyle = comboboxstyle.dropdownlist; combomonth.items.add("january"); combomonth.items.add("february"); combomonth.items.add("march"); combomont...

How can I change the keyboard shortcuts of Unity desktop (Ubuntu 14.04)? -

i want change default shorcuts touchpad events , key combinations, example swiping left or right 3 fingers switching workspaces, using super + k opening terminal , on. can do? thanks! click on shutdown button --> system setting --> keyboard-->shortcut , choose 1 element left list modify want

sql server - Sql Select Query Timeout -

hello guys working on query , every thing working fine except when run query more 2-3 times return timeout there wrong in query or server error kindly suggest me here query select category_feature_mapping.feature_id, category_feature_mapping.category_id, option_table.option_id, option_table.title, feature_table.title featuretitle, feature_table.type category_feature_mapping inner join feature_table on category_feature_mapping.feature_id = feature_table.feature_id inner join option_table on feature_table.feature_id = option_table.feature_id category_feature_mapping.category_id = @catid , feature_table.feature_id=@feid , feature_table.feature_id not in (select feature_id vendor_value_table ...

javascript - Function to pass html into bootstrap modal using ajax and jquery .load() -

i have list of elements have different ids @ moment using these specific ids call identical functions shows modal , loads html html file based on id of button clicked using ajax , jquery. works fine except have repeat same function again , again changing id of button clicked , id of html loaded. want find way use same function every button. below how have repeat fucntion different buttons: $("#theconjuringpreview").click(function(){ $("#mymodal").show(); $("#mymodal").on('shown.bs.modal', function () { $("#preview-content").load("ajax.html #theconjuring"); }); }); /*different button clicked*/ $("#sinisterpreview").click(function(){ $("#mymodal").show(); $("#mymodal").on('shown.bs.modal', function () { $("#preview-content").load("ajax.html #sinister"); }); }); i thinking work: putting showmodal() function onclick attribu...

c# - How can i fill 2 dimensional array with unique random numbers -

how can fill 2 dimensional array unique random numbers (different numbers in row/colum)? i have done 1 dimensional array: class program { static void main(string[] args) { random r = new random(); int[] x = new int[10]; for(int = 0; < x.length; i++) { x[i] = r.next(9); for(int j = 0; j < i; j++) { if(x[i] == x[j]) { i--; break; } } } for(int = 0; < x.length; i++) { console.writeline(x[i]); } console.readkey(); } } since don't want duplicates, using random repeatedly until have 1 of each not best approach. theoretically, algorithm run very long time, if randomizer not provide desired values on. since know values want, want them in random order, shuffle algorithm better approach. shuffle algorithm allow generate array o...

c# - How get String from Textbox in windows Form -

i sccm administrator ,so planing make automation powershell using gui so need input values windowsform. can me value texbox [void] [system.reflection.assembly]::loadwithpartialname("system.drawing") [void] [system.reflection.assembly]::loadwithpartialname("system.windows.forms") #creating form $objform = new-object system.windows.forms.form $objform.text = "data entry form" $objform.size = new-object system.drawing.size(300,500) $objform.startposition = "centerscreen" #creating label $objlabel = new-object system.windows.forms.label $objlabel.location = new-object system.drawing.size(10,20) $objlabel.size = new-object system.drawing.size(280,20) $objlabel.text = "enter collection name" $objform.controls.add($objlabel) #creating teextbox $objtextbox = new-object system.windows.forms.textbox $objtextbox.location = new-object system.drawing.size(10,40) $objtextbox.size = new-object system.draw...

swift - NSCoding for a non-compliant object (MKMapItem) -

trying save mkmapitem part of custom class. import uikit import mapkit class place: nsobject, nscoding { var mapitem : mkmapitem! var type : category! init(mapitem: mkmapitem, type: category) { self.mapitem = mapitem self.type = type } // mark: nscoding required init?(coder decoder: nscoder) { mapitem = decoder.decodeobject(forkey: "mapitem") as! mkmapitem? type = decoder.decodeobject(forkey: "type") as! category? } func encode(with coder: nscoder) { coder.encode(mapitem, forkey: "mapitem") coder.encode(type, forkey: "type") } } but won't work because mkmapitem not nscoding-compliant (compiler doesn't complain though). understand how encode custom classes, can't figure out how object defined ios. i know there 1 answer out there objective-c on this, swift solution. thanks. ps have tried subclass mkmapitem , provide "new" initializers, though take con...

eclipse - How to build an app that will work with all Android versions? -

in eclipse when export project app doesn't work on device uses android 4.2. gives me message: app has stopped how build app work android versions "app has stopped" seems crash, if app doesn't work on device, doesn't launch. use debug know error or crash. if think pversion problem, check in gradle include sdk version 4.2.

algorithm - Interspace program in Haskell -

insert :: eq(a) => -> -> [a] -> [a] insert m n [] = [] insert m n (x:xs) | m==x = n : x : insert m n xs | otherwise = x : insert m n xs the insert function above working function inserts value n list before instances of value m . i need writing interspace function inserts value n between values m , q in list. have far: interspace :: eq(a) => -> -> a->[a] -> [a] interspace m n q[] = [] interspace m n q (x:xs)| m==x && q==(head xs) = n: x : insert m n (headxs)++interspace m n q (xs) | otherwise = x : interspace m n q xs since adding values front of list, insert function unnecessary. (:) suffice instead. in insert , pass recursively on list. since want check if 2 values match @ time , call function recursively on different lists based on whether or not find match, it's idea pattern match (x1:x2:xs) rather (x:xs) . if m matches x1 , q matches x2 , place onto head of li...

NULLIF truncating date values only when in a UNION ALL Statement in MySql -

i using statement similar union results 2 similar tables. select sale_time, nullif(sale_time, '0000-00-00') 'nullif_sale_time' tblcompletedsales union select sale_time, nullif(sale_time, '0000-00-00') 'nullif_sale_time' tblopensales; sale_time timestamp field on both tables. instead of getting full date, in nullif_sale_time, truncated version. in other words, if sale_time '2015-08-12 09:33:46' nullif_sale_time '2015-0'. true records both tblcompletedsales , tblopensales. example: sale_time nullif_sale_time 2015-06-15 10:44:44 2015-0 if run either statement without union both work expected. has worked expected until today. happening on local machine remote server. what cause this? there missing? edit: here fiddle shows same thing.

Fix timezone issue with database in Rails on Heroku -

my rails app hosted on heroku postgress database. model i'm asking user chose day , time, combine date before saving model: def create_timestamp self.date = day.to_datetime + time.seconds_since_midnight.seconds end when chose instance today @ 20:50:00 , store in database, record looks this: <report id: 1, account_id: 1, date: "2016-11-05 20:50:00", description: "test", created_at: "2016-11-05 19:50:57", updated_at: "2016-11-05 19:50:57", deleted_at: nil, user_id: 1, report_category_id: 2, time: "2000-01-01 20:50:00", day: "2016-11-05"> as might notice, created_at date different, because it's in different timezone. while created_at stored in utc +0000, custom date, uses local timezone cet +0100. so when type in console: report.find(1).date , returns 2016-11-05 21:50:00 +0100. how can store correct date in initial set, or make database return correct timezone when querying? thanks ...

How to set same appearance for dynamically created custom listview in android? -

i'm getting problem in setting equal width space elements of dynamically created custom listview in fragment. elements arranged in same listview. please give idea how make unique in custom view.please see image. me. in advance!!!! screeshort of design. code ------> <?xml version="1.0" encoding="utf-8"?> <tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <tablerow> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="20dp" android:textsize="18sp" android:textcolor="#800080" android:id="@+id/txt1"> </textview> <textview android:layout_width="match_parent" android:layout_height="wrap_content" ...

javascript - Can't call variable from another object -

i have 2 objects: myobject1 , myobject2 . trying call private variable myobject1 using my0bject2 method called increment , console.log says nan . there way call myobject1 variable directly myobject2 method? maybe extend somehow? var myobject1 = function() { var x = 0; return{} }(); var myobject2 = function() { return{ increment: function() { myobject1.x +=1; console.log(myobject1.x); } } }(); myobject2.increment(); when specify var x within myobject1 declaring variable private. thing has access variable methods within myobject1 . noted, variable private. you didn't make clear if wanted keep private or not assume want access it. couple of things here. attach variable object property of myobject1 via this . this refers current scope ( myobject1 ) saying this.x within myobject1 saying myobject1.x . function, need return this instances of can access of public properties. var myobject1 = function() { this.x = 0...

javascript - Bootstrap modal like behavior in React -

i'm handling image click on object display pop-up box. code. <a href="#" onclick={this.handleclick} data-id={image.id}> this handleclick method. handleclick(event) { event.preventdefault(); let mediaid = event.currenttarget.attributes['data-id'].value; this.setstate({overlay: <overlay mediaid={mediaid}/>}); } this relevant css .overlay { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 300px; width: 500px; background-image: linear-gradient(to top right, #7282fb, #755bf9, #7934f7); box-shadow: 10px 10px 20px gray; } i want pop-up slide page top, bootstrap modal. also want overlay go, if click anywhere outside box. how can achieve this. thanks. looks need use library archive desired behavior. there react, can found "modal", "overlay" keywords. lot of alternatives exist. take @ https://github.com/fckt/react-layer-stack ...

c# - How can I determine whether a parallel foreach loop is going to have better performance than a foreach loop? -

i did simple test in .net fiddle of sorting 100 random integer arrays of length 1000 , seeing whether doing paralell.foreach loop faster plain old foreach loop. here code (i put fast, please ignore repetition , overall bad of code) using system; using system.net; using system.collections.generic; using system.threading; using system.threading.tasks; using system.linq; public class program { public static int[] randomarray(int minval, int maxval, int arrsize) { random randnum = new random(); int[] rand = enumerable .repeat(0, arrsize) .select(i => randnum.next(minval, maxval)) .toarray(); return rand; } public static void sortonethousandarrayssync() { var arrs = new list<int[]>(100); for(int = 0; < 100; ++i) arrs.add(randomarray(int32.minvalue,int32.maxvalue,1000)); parallel.foreach(arrs, (arr) => { array.sort(arr); }...

uitableview - Hi there , I'm new to iOS development and I'm having a hard time populating a tableview embedded in a UIviewcontroller with json data -

i'm new ios development , i'm having hard time populating tableview embedded in uiviewcontroller json data. ''import uikit class firstviewcontroller:uiviewcontroller,uitableviewdatasource,uitableviewdelegate{ @iboutlet weak var tableview: uitableview! var tabledata:array< string > = array < string >() var valuetopass:string! override func viewdidload() { super.viewdidload() get_data_from_url("http://www.kaleidosblog.com/tutorial/tutorial.json") } override func didreceivememorywarning() { super.didreceivememorywarning() } func numberofsections(in tableview: uitableview) -> int { return 1 } func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int { return tabledata.count } func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecell(withidentifier: "firstviewcell"...

java - How to open device flashlight in Android N? -

i'm trying make simple button turn on/off device flashlight. don't understand why android.hardware.camera obsolete. have in order make code working on devices , ones older version of android ? this code: if (isflashlighton) { if (getpackagemanager().hassystemfeature( packagemanager.feature_camera_flash)) { cam = camera.open(); camera.parameters p = cam.getparameters(); p.setflashmode(camera.parameters.flash_mode_torch); cam.setparameters(p); cam.startpreview(); } else { try { cam.stoppreview(); cam.release(); cam = null; } catch (exception ex) { // ignore exception } } } there mistake in logic of code. it's not related specific android version. checking if device has camera flashlight , then, turns on. in else block turning camera flashlight off in case when device has no camera flashlight what never happen if device has flashlight. i think code should below. toggle...

python - Pandas KeyError: Year for csv file dataframe -

i have dataframe similar tot one: birthyear sex area count 2015 w dhaka 6 2015 m dhaka 3 2015 w khulna 1 2015 m khulna 8 2014 m dhaka 13 2014 w dhaka 20 2014 m khulna 9 2014 w khulna 6 2013 w dhaka 11 2013 m dhaka 2 2013 w khulna 8 2013 m khulna 5 2012 m dhaka 12 2012 w dhaka 4 2012 w khulna 7 2012 m khulna 1 now want create barchart in pandas male & female born on 2015 shown. code : df = pd.read_csv('out.csv') df=df.reset_index() df=df.loc[df["birthyear"]==2015] agg_df = df.groupby(['sex']).sum() agg_df.reset_index(inplace=true) piv_df = agg_df.pivot(columns='sex', values='count') piv_df.plot.bar(stacked=true) plt.show() and after execution,idle shows error: traceb...

Python/OpenCv: VideoCapture file from a server is not working -

i'm using python 2.7 , opencv. when i'm trying read video file pc cap = cv2.videocapture('pirkagia.avi') i can see video. but when i'm trying read video file server, can't read file cv2.videocapture . is there read video file server? my file in http://www.cs.ucy.ac.cy/~zanton01/epl445/pirkagia.avi

Eclipse plugin development plugin requires second update site for installation -

Image
i'm developing plugin in eclipse , when try add plugin brand new cdt installation fails following error: cannot complete install because 1 or more required items not found. software being installed: sloeber 4.0.0.201611052308 (io.sloeber.feature.feature.group 4.0.0.201611052308) missing requirement: ui 4.0.0.201611052308 (io.sloeber.ui 4.0.0.201611052308) requires 'package org.eclipse.nebula.widgets.oscilloscope.multichannel 0.0.0' not found cannot satisfy dependency: from: sloeber 4.0.0.201611052308 (io.sloeber.feature.feature.group 4.0.0.201611052308) to: io.sloeber.ui [4.0.0.201611052308] i know need update site http://download.eclipse.org/nebula/snapshot 1 contains plugin plugin dependent upon. if add link "software installation sites" plugin install fine. not want users have add link manually before can install plugin. try fix problem, have added nebula url category.xml of update site in "repository properties" "addi...

r - lapply with two column arguments -

these dataframes library(data.table) df <- fread(' account date nextdate 2016-01-01 2016-02-01 2016-02-01 2016-11-05 b 2016-03-10 2016-11-05') ab <- fread(' date amount 2015-06-01 55 2016-01-31 55 2016-02-28 65 2016-03-31 75') i want create list doing loop of each row in df , pick rows ab ab$date greater df$date , less df$nextdate output looks this: [[1]] date amount 2016-01-31 55 [[2]] date amount 2016-02-28 65 2016-03-31 75 [[3]] date amount 2016-03-31 75 this attempt: list<- lapply(df$date, function(x,y) br[date > x & date < y ],y=df$nextdate) create vector checks whether rows of ab meet conditions, use select rows of ab . lapply(1:nrow(df), function(x) { ab[which(ab$date > df[x, get("date")] & ab$date < df[x, get("ne...

bash - awk command to match multiple patterns -

i using awk command find entries in log file between 2 different times. have used command, , works: awk '$0 >= "oct 04 12:00:00" && $0 <= "oct 04 12:30:00"' /var/log/messages i want know how can search specific port allowed or blocked during time. example: if searching port 22 blocked between 12:00 12:30, how can search using awk command? content of /var/log/messages file: nov 5 8:44:30 system1 kernel [022525 252748] output dropped=eth0 out= mac=ff:ff:ff:ff:ff:ff:01:00:25:97:b2:47:01:00 src=10.0.0.1 dst=192.168.4.141 len=221 tos=0x00 prec=0x00 ttl=128 id=23315 proto=udp spt=183 dpt=183 len=209 the entries in log file similar above. want know how can match information between, let's say, 12:00 12:30 spt=80 , dpt=80 you can add more conditions && doing dates. can put regular expression between 2 forward slashes match against whole line/record. awk '/port 22 (blocked|allowed)/ && $0 >= "oc...

javascript - How can I get an array element out of an array in the value of a form element? -

i have html form element value set array. want 1 of these values out of array via jquery. how done? here code. maybe can speak if explanation wasn't clear. thank you! var lat = 0; var long = 0; //gets latitude , longitude when user clicks on place on map map.on('click', function(e) { lat = e.latlng.lat; long = e.latlng.lng; //store lat , long in array var latlong = [lat, long]; //here setting value of element in form array of lat , long document.getelement(".<?= $this->getname() ?>").set("value", latlong); var getlatlong = jquery(".<?= $this->getname() ?>").val(); console.log("retrieved: " + getlatlong); //it saves , retrieves properly. //the problem here //the problem here var lat = $(".<?= $this->getname() ?>").val()[0]; var long = $(".<?= $this->getname() ?>").val()[1]...

matlab - How to tell if two numbers are really different or they are actually the same due to floating point error -

for example, 0.168033639538270 , 0.168033639538270 are 2 double type numbers 2 different calculations (some further calculations eigenvalues of matrix). but treated different matlab (by unique or == ). how know if matlab treats them different due floating point error eps = 2.220446049250313e-16 , or if different (the digits behind first 15 digits not same, matlab not display them). matlab treats 2 number same display value same, different, want know if different. you can print formatted version of number @ required precision using sprintf , , compare 2 strings using strcmp .

java - Android - Main menu for simple app -

i'm making simple android app, , i'm trying work out best way make main menu. users of app not sophisticated, want make simple possible. so want first screen see when app opens menu - click on want, , takes them part of app (not pressing "menu" button bring across left, common nowdays). so, want menu bit this: http://cloud.addictivetips.com/wp-content/uploads/2012/10/appzapp-android-menu.jpg , minus search box, , strip down right hand side. (also looks 1 of menus slide out left, dont want) i have had menus ( https://developer.android.com/guide/topics/ui/menus.html#options-menu ), seems more used contextual stuff, or letting user select option), navigation menu. so - best way this? create list , put button in each item? based on requirement , use navigation drawer see below link. navigation drawer tutorial navigationdrawersample after used navigation drawer, need add search view on navigation header.for more info see link searchview tutoria...

bash - evaluating variable that comes in an array in shell script -

i trying read xcode build settings via shell script, i.e. if there build setting called product_name, read value writing echo ${product_name} in shell script. now, product_name in array, lets call myarr having 1 element product_name. loop on array as for in "${myarr[@]}" : echo $i done echo $i output product_name. however, want write evaluate ${product_name} , give me results. i have tried eval echo $i outputs product_name only solved using echo "${!i}" the second line gives output desired. have taken answer here: how variable value if variable name stored string?

visual studio code - VSCODE task.json keep accumulating error message when `isWatching=true` -

below setup of tasks.json { // see https://go.microsoft.com/fwlink/?linkid=733558 // documentation tasks.json format "version": "0.1.0", "command": "node", "options": { "cwd": "${workspaceroot}" }, "isshellcommand": true, "args": ["./watcher.js"], "showoutput": "always", "iswatching": true, "problemmatcher": { "filelocation": "absolute", "owner": "ocaml", "pattern": [{ "regexp": "^file \"(.*)\", line (\\d+)(?:, characters (\\d+)-(\\d+))?:$", "file": 1, "line": 2, "column": 3, "endcolumn": 4 }, { "regexp": "^(?:(?:parse\\s+)?(warning|[ee]rror)(?:\\s+\\d+)?:)?\\s+(.*)$", "severi...

Using dplyr in R: How to summarise data on same column with different criteria -

i have data set user_id business_id date stars review_length pos_words neg_words net_sentiment xqd0dzhaiyrqvh3wrg7hzg vcnawilm4dr7d2nwwj7nca 17/05/07 5 94 4 1 3 h1kh6qzv7le4zqtrnxozow vcnawilm4dr7d2nwwj7nca 22/03/10 2 114 3 7 -4 zvjccrpm2yozrxkffwgqla vcnawilm4dr7d2nwwj7nca 14/02/12 4 55 6 0 6 kblw4wja_fwowmmhihrvoa vcnawilm4dr7d2nwwj7nca 2/03/12 4 97 0 3 -3 zvjccrpm2yozrxkffwgqla vcnawilm4dr7d2nwwj7nca 15/05/12 4 53 1 2 -1 yelp<- read.csv("yelp_ratings.csv") colnames(yelp) [1] "user_id" "business_id" "date" "stars" "review_length" [6] "pos_words" "neg_words" "net_sentiment" i need use dplyr determine businesses have best , wor...

html - navbar not visible in mobile display -

i have following navbar in site:- <nav class="navbar navbar-default no-margin show"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"> <button class="navbar-toggle collapse in" data-toggle="collapse" id="menu-toggle-2"> <span class="fa-stack"> <i class="fa fa-bars fa-stack-2x "></i></span></button> </li> </ul> <div style="text-align: center; font-size: 20px; padding-top: 7px;"> <a href="http://sunlightfoundation.com/" target="_blank"><img src="images/logo.png"></a> <p style="display: inline"><b>congress api</b></p> </div> </div> ...

Clojure - Using a variable as a function call -

i trying make simple clojure macro applies inputted function twice: (f (f args)) , (e.g (inc (inc 4)) => 6 ) the problem is, when run below code using (reapply-function '(inc 4)) , nil . doesn't make sense me since can print out both value of f , result inc , 5 . there must simple thing i'm missing. can see issue? (defmacro reapply-function [args] (list 'let ['f (list 'first (list 'quote args)) 'result args] (list 'f 'result))) initial note this answer provided assuming you're trying learn use macros own sake. agree @thumbnail's answer : don't use macros except when absolutely, positively cannot avoid -- , not 1 of times. shorter implementation consider: (defmacro reapply-function [[func & rest]] `(~func (~func ~@rest))) macroexpand demonstrates how works: user=> (macroexpand '(reapply-function (inc 4))) (inc (inc 4)) ...and functions in repl: user=> (rea...

How should I go about a long JavaScript file using the module pattern? -

i learning design pattern in javascript, , i'm going use module pattern. i'm puzzled 2 things. 1 - if create plugin, can use module pattern, , have private , public methods/variables. if have full javascript file, don't need private , public methods, since 1 part of program has nothing part. what's point of private , public methods? 2 - since javascript file long, should have nested module's? how should go full file of javascript? (1) when javascript files loaded, scripts in files in 1 file. script in 1 file can access (read, update, delete) global variables in other files. there lot of questions on this, can search those. of course, "one part of program has nothing part", in case in team many members, each works on part of system (or in cases, file). then, there chance 1 person accidentally changes variables created person. kinds of error quite easy detect. if can modularize script, can avoid kinds of error altogether. (2) you ca...

ruby - Rubocop guard clause dilemma -

i have piece of code: def validate_index index # change sizeerror raise argumenterror, "size of index (#{index.size}) not matches"\ "size of vector (#{size})" if size != index.size end on this, rubocop gives offence: style/multilineifmodifier: favor normal if-statement on modifier clause in multiline statement. i modified code this: def validate_index index # change sizeerror if size != index.size raise argumenterror, "size of index (#{index.size}) not matches"\ "size of vector (#{size})" end end but gives offence: style/guardclause: use guard clause instead of wrapping code inside conditional expression. am doing wrong or bug? rubocop wants write this: def validate_index index # change sizeerror return if size == index.size raise argumenterror, "size of index (#{index.size}) not matches"\ "size of vector (#{size})" end it if want go route. either way, rubocop re...

c# - parsing pasted text in console application -

i have console application made of c# it allows user paste text following aaaaa bbbbb ccccc i know console.readline() wont take it, used console.in.readtoend() string input = console.in.readtoend(); list<string> inputlist = input.split('\n').tolist(); i need parse input text line line above code works, after pasting, in order conintue, user has hit enter once, hit ctrl+z hit enter again. im wondering if there better way requires hit enter key once any suggestions? thanks in console if paste block of lines not executed immediately. if paste aaaa bbbb cccc nothing happens. once hit enter, read method starts doing it's job. , readline() returns after every new line. way it, , imo it's easiest way: list<string> lines = new list<string>(); string line; while ((line = console.readline()) != null) { // either here each line separately or lines.add(line); } // of lines here my first stacko...

ios - How to change the tab bar item relationship with view controller? -

i new ios . how change when embedded tab-bar controller in 3 view controller .when embedded default relationship historyviewcontroller ,but want 1st tab item recentnewsviewcontroller , run time first viewed . thanks, if need information let me know please note: below answer based on conversation between question owner. if want 1st vc recentnewsviewcontroller .you can simple drag , move tabbaritem . ever want set in tabbarcontroller .

jquery - animations on html page load -

i want same animation effect on html div blocks in website http://rpglobal.ae/ -> section. kindly let me know jquery , css need use achieve this. thanks you use https://daneden.github.io/animate.css/ - more slideinright , slideinleft . i'm using in work along time, it's easy implement , looks (also on mobiles). here can find documentation , source code https://github.com/daneden/animate.css

Java MongoDB 3.0+ query between timestamps -

how query database entries within 2 timestamps in java mongodb 3.0? currently using java method, doesnt in returning set of documents within start , end timestamp criteria. code bit broken because returns latest entry if falls within timestamp. public static reading getreadingsbetween(string type,timestamp starttime,timestamp endtime) { mongoclient mongo = new mongoclient("localhost", 27017); mongodatabase db = mongo.getdatabase("sampledb"); mongocollection<document> newcoll; gson gson = new gson(); newcoll = db.getcollection("samplecollection"); document latestentry = newcoll.find().iterator().next(); string json = latestentry.tojson(); reading reading = gson.fromjson(json, reading.class); string thistimestamp = reading.getgw_timestamp(); dateformat df = new simpledateformat("yyyy-mm-dd hh:mm:ss"); date parsedtimestamp = null; try { parsedtimestamp = df.parse(thistimestamp...

Hadoop: MapReduce job giving java library error -

when running mapreduce job in cloudera vm, below warning occurring 4-5 times in continues manner. please let me know how fix it. 16/11/06 00:47:38 warn hdfs.dfsclient: caught exception java.lang.interruptedexception @ java.lang.object.wait(native method) @ java.lang.thread.join(thread.java:1281) @ java.lang.thread.join(thread.java:1355) @ org.apache.hadoop.hdfs.dfsoutputstream$datastreamer.closeresponder(dfsoutputstream.java:862) @ org.apache.hadoop.hdfs.dfsoutputstream$datastreamer.endblock(dfsoutputstream.java:600) @ org.apache.hadoop.hdfs.dfsoutputstream$datastreamer.run(dfsoutputstream.java:789) occurring in middle of execution of sqoop jobs created. not when hive job executed.

java - javascript error when accesssing flash redirect attribute (thymeleaf, springmvc) -

i'm stuck following problem springmvc, thymeleaf , javascript. 1) server-side: under circumstances add flash redirect attribute in controller before redirecting page. redirectattributes.addflashattribute("mycondition", true); 2) client-side: in case attribute exists, want javascript function execute additional code. window.onload = function() { ... if([[${mycondition}]]) { //do } } this works fine after redirect, on first enter redirect attribute not exist, results in following javascript code being rendered: window.onload = function() { if() { //do } } this code not valid , therefore produces javascript error. i'm not sure how check javascript if redirect attribute exists? has run similar problem before? can try following code , let me know if works declare variable mycondition var mycondition = [[${mycondition}]]; if(mycondition) { //do } hope helps

Python regex to find words, which also excludes particular words -

i'm new programming. i've searched site , google, can't seem resolve issue. i'm finding similar topics, still can't figure out... i have text file containing large list of words. words numbered , categorized 'noun', 'adjective' or 'verb'. i'd extract words list, exclude numbers , following 3 words, 'noun', 'adjective' , 'verb.' i know need use caret character, can't seem make work. import re import os textfile = open('/users/mycomputer/wordlist.txt') textfilecontent = textfile.read() wordfinder = re.compile(r""" [a-z]+ # finds words [^noun|adjective|verb] # wrong """, re.verbose | re.i) regexresults = wordfinder.findall(textfilecontent) import re open('wordlist.txt') f: line in f: if re.search("^(?!noun|adjective|verb|\d)", line): print(line)

ios - Detecting with KVO when Adjusting focus is done - not correct on iPhone 6+ -

i want take still image avcapturestillimageoutput , when adjusting focus done, i'm using key-value observing so, when testing on iphone 6+ ios 10 method - (void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context { if( [keypath isequaltostring:@"adjustingfocus"] ) { bool adjustingfocus = [ [change objectforkey:nskeyvaluechangenewkey] isequaltonumber:[nsnumber numberwithint:1] ]; if (adjustingfocus) { nslog(@"adjusting focus started"); } else { nslog(@"adjustingfocus done"); } } } some times gets called several times, first time detect focus done screen blurry , still image captured. i've noticed in case (blurry image) method called 2 more times (when starting , finishing adjust focus). there way detect focus not adjusted , wait next call or way called once? i've found singl...

c# - Subscribe to an event raised by a Controller in other project -

i have 2 projects in same solution. 1 asp.net mvc application (a) , other console application (c). want c subscribe event raised controller in a. using singleton class raises event , can take subscriptions event. i subscribed event , checked (using debugger) subscription indeed stored , can confirm event gets raised @ right time. the problem happens when start using projects - though c subscribes event, when raises subscription not in eventhandler listener list event not cought in c. it singleton goes out of scope or same instance not used between projects. kinda filling have 2 instances of singleton. my goal receive event controller in project. singleton class can avoided if not necessary. any appreciated. controller (in project a) [httppost] public void processcommandmessage(message message) { messagespy.instance.onmessagereceived(message); } messagespy (in project a) { private static readonly messagespy _instance = new messagespy(); public static m...

nlp - How to translate syntatic parse to a dependency parse tree? -

using link grammar can have syntaxic parse of sentences following: +-------------------xp------------------+ +------->wv------->+------ost------+ | +-----wd----+ | +----ds**x---+ | | +ds**c+--ss--+ +-phc+---a---+ | | | | | | | | | left-wall koala.n is.v cute.a animal.n . +---------------------xp--------------------+ +------->wv------>+---------osm--------+ | +-----wd----+ | +------ds**x------+ | | +ds**c+--ss-+ +--phc-+-----a----+ | | | | | | | | | left-wall wolf.n is.v dangerous.a animal.n . +--------------------xp--------------------+ +------->wv------>+--------ost--------+ | +-----wd----+ | +------ds**x-----+ | | +ds**c+--ss-+ +--phc-+----a----+ | | | | | | | | | left-wall dog.n is.v faithful.a animal.n . +-----------------------xp--------------...

jquery - Get item index when using filter in javascript -

i'm using code items match particular keyword. var match_data = function(search_str, items) { var reg = new regexp(search_str.split('').join('\\w*').replace(/\w/, ""), 'i'); return items.filter(function(item_data) { if (item_data.match(reg)) { return item_data; } }); }; is there way can index of matched item ? also keep getting warning when search string comtains \ anywhere in it: uncaught syntaxerror: invalid regular expression: /iw*m\w*\/: \ @ end of pattern(…) can guys please me solve error well. thanks in advance. you use array , index callback api of array#filter . var match_data = function(search_str, items) { var reg = new regexp(search_str.split('').join('\\w*').replace(/\w/, ""), 'i'), indices = []; return { result: items.filter(function(item_data, index) { if (item_data.match(reg)) ...

html - Content & Google Map full height and width of each column in Bootstrap 2-column layout -

Image
i using bootstrap 3.3.7 , have webpage fixed header, fixed footer , 2 responsive columns (sm-4 , sm-8). what i'd is: have both columns fill rest of height between header , footer have right-hand column filled google map the text div position above map div when collapsed smaller screen i've managed load in map cannot display full height , width of 1 column only. if try set width: 100% jumps full width of screen rather column. i've tried setting left div right 30% left 0 , right div left 70% , right 0 affects responsiveness on mobile device. found lots of other posts mess responsiveness i'm trying achieve. this want achieve on larger screen: and on smaller screen i'd 2 divs stack on top of each other in between header , footer. this container both columns: <div class="container"> <div class="row"> <div class="col-sm-4" id="testing_employers"> texttexttexttexttexttexttext...