Posts

Showing posts from January, 2015

javascript - Why should I use immutablejs over object.freeze? -

i have researched on net benefits of immutablejs on object.freeze() didn't find satisfying! my question why should use library , work non native data structures when can freeze plain old javascript object? i don't think understood immutablejs offers. it's not library turns objects immutable, it's library around working immutable values. without repeating docs , mission statement , i'll state 2 things provides: types. implemented (immutable) infinite ranges, stacks, ordered sets, lists, ... all of types implemented persistent data structures . i lied, here's quote of mission statement: immutable data cannot changed once created, leading simpler application development, no defensive copying, , enabling advanced memoization , change detection techniques simple logic. persistent data presents mutative api not update data in-place, instead yields new updated data. i urge read articles , videos link , more persistent data structures (...

java - How does Collections.sort(...) work? -

to clear, trying find out how collections.sort(list, new mycomp()) method calls compare method in sequence. i have linkedlist employees , personal number (k): numbers are: {1,2,3,4,5,6} compare(object o1, object o2) method in mycomparator gives number (which not relevant concern). how sort() call method compare? call parameters 1,2 then, 2,3 3,4 4,5 5,6? debug there's strange sequence jumps , compares 1,3. what compare? pattern? the specific comparisons made depend on algorithm, internally, collections.sort method using sort elements. according javadoc collections.sort : the documentation polymorphic algorithms contained in class includes brief description of implementation. such descriptions should regarded implementation notes, rather parts of specification. implementors should feel free substitute other algorithms, long specification adhered to. (for example, algorithm used sort not have mergesort, have stable.) in other words, java implementations free...

java - Where is the Deadlock? -

this tutorial java docs deadlock. don't threads blocked. since synchronized thought 1 thread 'll enter bow. both entered bow. [one waits [but when?]] then issue? when add comments [print statements trace]. there's no deadlock. how? public class deadlock { static class friend { private final string name; public friend(string name) { this.name = name; } public string getname() { return this.name; } public synchronized void bow(friend bower) { system.out.format("%s: %s" + " has bowed me!%n", this.name, bower.getname()); bower.bowback(this); } public synchronized void bowback(friend bower) { system.out.format("%s: %s" + " has bowed me!%n", this.name, bower.getname()); } } public static void main(string[] args) { final friend alphonse ...

python - How to swap configuration files for Production and Development? -

some time ago created script using python, script execute actions in instance based on configuration file. this issue, created 2 configuration files. config.py instance= <production url> value1= value2= b ... testconfig.py instance= <development url> value1= c value2= d ... so when want script execute tasks in development instance tests, import testconfig.py instead of config.py. main.py # config import * testconfig import * the problem comes when update script using git. if want run script in development have modify file manually, means have uncommited changes in server. doing change takes 1 min of time feel i'm doing wrong. do know if there's standard or right way accomplish kind of tasks? export environment variables on machines, , chose settings based on environment variable.

laravel - Registering Spark API Token -

i have created spark api token , trying register spark token using command spark register token-value but getting error cannot open source file register.ada does have idea on might causing error on ubuntu o.s? you need buy spark api token. when have it, replace token-value api key.

asp.net core mvc - Multi-Language Website with RESX Files -

i've been looking around example on how use resx files localization on mvc6 , far not able find example. my website have dropdown list avalible languages. dont want application automatically detect localization. ideia user select language , view select appropriate language (maybe keep language cookie) resx folder. so far i've created folder resources.resx, resources.en-en.resx, resources.es-es.resx. does have working example this? thank much!

JUnit test with Spring and mongodb: could not autowire repository -

i have problem writing test spring , junit test mongodb respository. message "could not autowire. no beans of ... type found" repository is public interface projectrepository extends mongorepository<project, string> { public project findbyname(string name); } while configuration file is @configuration @enablemongorepositories(basepackageclasses = repositorypackage.class) public class springmongoconfiguration extends abstractmongoconfiguration{ @override protected string getdatabasename() { return "test"; } @bean public mongoclient mongo() throws exception { mongoclient client = new mongoclient("localhost"); return client; } @bean public mongotemplate mongotemplate() throws exception { return new mongotemplate(mongo(), getdatabasename()); } } where repositorypackage in same package of repository. test is @runwith(springjunit4classrunner.class) @contextconfiguration(classes = springmongoconfiguration.class) public...

javascript - how to properly include source files for jasmine-node test runner -

i'm using jasmine spec library along jasmine-node runner node.js. right way run tests (the command in cli) both includes source files , spec files? i've got lib directory sources want include , unit.spec.js includes tests. when following, error: tomasz.ducin@wawlt548 mingw64 ~/development/json-schema-faker/json-schema-faker (master) $ ./node_modules/.bin/jasmine-node lib unit.spec.js --nostacktrace --captureexceptions f. failures: 1) suite contains spec expectation message: referenceerror: booleangenerator not defined finished in 0.007 seconds 2 tests, 1 failures, 0 skipped the booleangenerator defined in lib directory - somehow doesn't loaded... dunno why. is commonjs require function right way? paths pass in cli separate during jasmine runtime? the directory pass in via command prompt jasmine-node folder specs kept. so yes, need require additonal functions have defined in lib directory in spec files. there's article here...

c# - Button Control is not visible to other class -

i have code gets value sql query , place value in textbox. want put class, , access main class. problem is, class wont recognize button(txtbox_ticketnum) main class. help! using (sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring)) { using (sqlcommand com_retrieve = new sqlcommand("usp_selecttop1ticket", con)) { com_retrieve.commandtype = commandtype.storedprocedure; con.open(); try { txtbox_ticketnum.text = com_retrieve.executescalar().tostring(); messagebox.show("ticket has been saved. ticket number: " + com_retrieve.executescalar().tostring(), "ticket filed"); } catch (sqlexception) { messagebox.show("the database has encountered error"); } ...

ios - UITableView not filling the bottom on the screen -

Image
so have looked @ examples , blog tutorial already. problem tableview is not filling bottom of screen. in view have tableview filling bottom of screen. here layout of storyboard: now here looks when run it: how can extend tableviewcells bottom of screen? , time. in interface builder when have viewcontroller selected try unchecking "adjust scroll view insets" parameter.

mongodb - Difference between a driver and a library? -

looking @ mongodb project, seems have many drivers . has c driver, java driver, ruby driver, etc... how these different client libraries? seems each of provide interface use product (in case mongodb) 1 of languages. is there technical difference between 2 terms? thanks! an application communicates mongodb way of client library, called driver, handles interaction database in language appropriate application. source: https://docs.mongodb.org/manual/applications/drivers/

python - Does kivy has some function which could turn an app into widget -

for example have made custom app file browser. problem is, want use app widget in app can browse files on app. is possible ? if yes, best way ? you should have created file browser widget @ beginning. it's practice leave main app class alone, , put app logic custom widgets, later used modules in future apps. general app behaviors should contained there. your best choice right rewriting file browser seperate widget - if still want keep it.

xamarin - MvvmCross no bindings created -

i upgraded project older version of mvvmcross latest version, , i'm having trouble bindings. i'm aware of linkerpleaseinclude hack, , looks (at least of) properties i'm using listed there. i'm concerned usage of views , viewmodels. here's example. public partial class homeview : mvxviewcontroller<homeviewmodel> ... public override void viewdidload () { base.viewdidload(); this.createbinding(budgettrackerbutton).to((homeviewmodel vm) => vm.budgettracker).apply(); this.createbinding(loginbutton).for("title").to ((homeviewmodel vm) => vm.logmessage).apply(); this.createbinding(loginbutton).to((homeviewmodel vm) => vm.login).apply(); this.createbinding(contactapprisenbutton).to((homeviewmodel vm) => vm.contact).apply(); this.createbinding(aboutapprisenbutton).to((homeviewmodel vm) => vm.about).apply(); this.createbinding(aboutthisappbutton).to((homeviewmodel vm) => vm.aboutapp).apply(); this....

MATLAB Code not working. Trying to store input into an array -

i wrote 2 functions, first 1 encrypt prompt = 'enter sentence encrypt'; dlg_title = 'input'; num_lines = 5; defaultans = {'hello'}; answer = inputdlg(prompt,dlg_title,num_lines,defaultans); answer = answer{1}; % find out how big square matrix data should = 1:length(answer) % should never run far anyway if (i^2) > length(answer) break; end end mat_len = i; % predefine square matrix of numbers forcing matrixa number type matrixa = zeros(mat_len,mat_len); % iterate through square matrix assigning answer values positions = 1:mat_len j = 1:mat_len if (((i-1)*mat_len)+j) <= length(answer) matrixa(i,j) = answer(((i-1)*mat_len)+j); else break; end end end matrixa(1)=matrixa(1)*10 matrixa' this stores ascii code array matrixa , simple matrix operations hide message. instance hello be 720 108 0 101 111 0 108 0 0 the second function problem is, sp...

cocoa - How to initialize NSTableRowView subclass? -

the compiler crashses on line 3 , cant find information on nstablerowview initializers anywhere class itemrowview: nstablerowview { convenience override init(frame: nsrect) { self.init(frame: frame) // exc bad access self.draggingdestinationfeedbackstyle = nstableviewdraggingdestinationfeedbackstyle.none } first, init( frame: nsrect ) is designated initializer, keyword convenience wrong in place. meant call super initializer own method recursively. @ last you'll need implement required initializer init?(coder: nscoder) the following code should going: class itemrowview: nstablerowview { override init(frame: nsrect) { super.init(frame: frame) // super - not self self.draggingdestinationfeedbackstyle = nstableviewdraggingdestinationfeedbackstyle.none } required init?(coder: nscoder) { // write useful here, or leave default implementation fatalerror("init(coder:) has not been implemented...

asp.net - List.Find throwing Nullable object must have a value error -

dim sipff systeminfopropertiesforform = listsysteminfopropertiesforform.find(function(f) f.showfieldpropertytypeid = cint(systeminfopropertyids.showmilestone)) systeminfopropertiesforform complex type items nullable. cint(systeminfopropertyids.showmilestone) = 900 listsysteminfopropertiesforform has 10 items any idea ? fixed using below code dim sipff systeminfopropertiesforform = listsysteminfopropertiesforform.find(function(f) f.showfieldpropertytypeid.hasvalue andalso f.showfieldpropertytypeid.value = cint(systeminfopropertyids.showmilestone))

full text search - Using Django Haystack without using Django models -

i'm seeking add fulltext capabilities django application using haystack . seems haystack can index , search django model instances. fulltext index, however, on objects not live in django database. can use haystack index non-django objects (documents)? i'm interested in fulltext engine abstraction layer, not on django model integration.

mysql - PHP: How to add an extra field and value in this array -

i have array stores values specific fields. want here add field name , value array. how can it? array_walk($files_data, 'array_sanitize'); $fields = '`'.implode('` , `', array_keys($files_data)).'`'; $data = '\''.implode('\', \'',$files_data).'\''; mysqli_query($dbcon,"insert users_info($fields) values ($data) "); $files_data['yourfieldname'] = $yourvalue; array_walk($files_data, 'array_sanitize'); $fields = '`'.implode('` , `', array_keys($files_data)).'`'; $data = '\''.implode('\', \'',$files_data).'\''; mysqli_query($dbcon,"insert users_info($fields) values ($data) ");

How to get the values and keys from a json deserialized/parsed string in C#? -

i have cookie string array put c# looks this: questionnaire a: [{"8872":"yes", "9900":"bob", "2222":"sagat"}] where numbers number question id db (key) , value customers response. time questionnaire doesn't have same question ids in it, cannot make model read ids. example: questionnaire b: [{"2222":"no","6756":"brown","5416":"jerry","4684":"tom"}] all want pull users response question question 9900. this work have done far , crashing: c# var arrstring = ""[{\"8872\" : \"yes\",\"9900\" : \"bob\",\"2222\" : \"sagat\"}]" var arr = jsonconvert.deserializeobject(arrstring); foreach (var attendee in (ienumerable) attendeearray) { var theresponseofquestion9900 = attendee.9900 } attendee.9900 give me error @ '.' unexpected token . i think b...

Option to not add line breaks in no-op (empty) functions in JavaScript (IntelliJ Web/PHP storm) -

i can not life of me find formatter option turn off automatic line breaks inside no-op function braces. line breaks added automatically both arrow functions , regular functions. frustrating when example passing no op functions other functions (as hook or callback), i.e. wrapwithcommonerrors(() => {}) . function() {} becomes function() { } () => {} becomes () => { } have tried simple blocks in 1 line option? you can find at file -> settings -> code style -> javascript -> wrapping , braces -> keep when reformatting

javascript - Replace function using jquery -

i have code here: txtname.value = txtname.value.replace(/(\r?\n){2,}/, '\n').replace(/^\r?\n|\r?\n$/, ''); txturl.value = txturl.value.replace(/(\r?\n){2,}/, '\n').replace(/^\r?\n|\r?\n$/, ''); txtusage.value = txtusage.value.replace(/(\r?\n){2,}/, '\n').replace(/^\r?\n|\r?\n$/, ''); how put in jquery? i've tried many things , doesn't work. txtname = $('#emotename'); txturl = $('#emoteurl'); txtusage = $('#emoteusage'); var $txtname = $('#emotename'), $txturl = $('#emoteurl'), $txtusage = $('#emoteusage'); $txtname.val($txtname.val().replace(/(\r?\n){2,}/, '\n').replace(/^\r?\n|\r?\n$/, '')); $txturl.val($txturl.val().replace(/(\r?\n){2,}/, '\n').replace(/^\r?\n|\r?\n$/, '')); $txtusage.val($txtusage.val().replace(/(\r?\n){2,}/, '\n').replace(/^\r?\n|\r?\n$/, '')); mind take @ particular article...

javascript - Form Validation? -

i'm trying make check form validation. shouldn't let form submit unless filled in, should total if works. i'm new , have no idea going on, showing blue box @ top of screen default, , submitting/accepting regardless of form being filled out or not. html: <!doctype html> <html> <head> <meta charset="utf-8"> <title>hands-on project 6 - order</title> <link rel="stylesheet" href="styles.css"> <script src="script.js"></script> </head> <body> <section> <article> <h2>pizza order form</h2> <div id="errormessage"> </div> <form action="results.html" id="orderform"> <input type="hidden" name="hidden" id="hidden"> <fieldset> <legend>delivery information</legend> ...

javascript - ng-repeat not updating after search -

i've got ionic app in development, , i'm having unusual error occur. have main "jobs" template current user see of jobs have been assigned them: <ion-view cache-view="false" ng-controller="jobsctrl"> <ion-content> <ion-list> <ion-item ng-repeat="job in jobs" class="item-icon-right item-text-wrap"> <a href="#" style="text-decoration:none; color: #444;" ng-click="loadjob(job.jobid)"> {{job.jobid}} - {{job.surname}} - {{job.suburb}} - {{job.jobtype}}<i class="icon ion-chevron-right icon-accessory"></i> </a> </ion-item> </ion-list> </ion-content> </ion-view> this view populated, so: $http.get(apiendpoint.url + '/getjobs').then(function (resp) { $scope.jobs = resp.data; $ionicloading.hide(); }, fun...

premake - premake5 how to set outdir based on platform + configuration? -

i'd set outdir/targetdir each combination of platform + configuration. function setlibtargetdir(platforms, configs) i2,c in ipairs(configs) i,p in ipairs(platforms) filter ("configurations:" .. c, "platforms:" .. p) targetdir("bin/" .. p .. "/" .. c) libdirs ("bin/" .. p .. "/" .. c) libdirs ("bin_prebuilt/" .. p .. "/" .. c)--manually generated libs/dlls premake5 can't handle end end end setlibtargetdir({"win32", "win64"}, {"debug", "release", "final"}) i tried using code, while gets config right(debug/release/final). places in win64, 32 bit files & 64 files end in same directory. what doing wrong here? i'd each combination of platform + configuration have own output dir , library paths. thanks stumbled across answer: https://github.com/premake/p...

python - Call a function in a DLL and use an array as argument -

i calling function dll written in c. in documentation of dll says 1 of arguments of function should be: an address of array of 32-bit floating point numbers populated results. i not familiar c , tell me c feature. not quite sure should use argument. i using ctypes. here example documentation of dll: float fresult; long lretval = d2r_getsingleresult( "e:\\folder", "e:\\folder\\proj1", 2001001, &fresult, 1, null, null ); another approach declare function type ctypes deduce itself: d2r = ctypes.cdll.loadlibrary("d2r.so") d2r_getsingleresult = d2r.d2r_getsingleresult d2r_getsingleresult.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ctypes.pointer(ctypes.c_float), ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p) d2r_getsingleresult.restype = ctypes.c_int ... fresult = ctypes.c_fl...

hadoop - MapReduce output as ArrayList -

how call map reduce method in normal java project , possible return reducer output arraylist / hashmap instead of flat file, , how access mapreduce method jboss appserver. here sample program uses multipleoutput public void reduce(text key, iterator<intwritable> values, outputcollector<text, intwritable> output, reporter reporter) throws ioexception { int total = 0; (; values.hasnext();) { total += values.next().get(); mos.getcollector("text", reporter).collect(key, new intwritable(total)); mos.getcollector("seq", reporter).collect(key, new intwritable(total)); } } you need create multipleoutputs instance in configure method. private multipleoutputs mos; @override public void configure(jobconf job) { mos = new multipleoutputs(job); } in driver class need tell inputformats wan...

applescript - Exporting messages selected in Mail.app as emlx -

i want export selected emails given mailbox finder. found script on internet , altered likes. doen't seems export. know going wrong? tell application "mail" set msgs message of mailbox "test1" of account "info" if length of msgs not 0 display dialog "export selected message(s)?" if button returned of result "ok" -- set month parsing value french vanilla algorithm set fixeddate current date --or other date set month of fixeddate january -- set thefolder "macintosh hd:users:rajsingh:desktop:" alias set thefolder choose folder prompt "save exported messages to..." without invisibles repeat msg in msgs -- path message set mb mailbox of msg set mba account of mb -- mtype returning 'constant **** etim' when should imap (for ogc account) ...

java - How to change variable outside a loop -

this question has answer here: scanner skipping nextline() after using next(), nextint() or other nextfoo()? 14 answers public static void main(string[] args) { scanner keyboard = new scanner (system.in); double budget, total, expensetotal; system.out.print("enter budget month: "); budget = keyboard.nextdouble(); system.out.println("type -99 stop calculations\n"); byte start = 1; double expense = 0; while (expense != -99) { system.out.print("enter expense " + start + " :"); expense = keyboard.nextdouble(); start++; if (expense == -99) { system.out.println(); total = (budget - expense) - 99; system.out.printf("your current total budget is: $%,.2f \n" , total); } } } ...

Importing library in Java -

i new in java , learning book called "thinking in java". author wrote 1 library called net ease understanding. example, print in place of system.out.println , likewise. so, how can import library? update: author in example following: import static net.mindview.util.range.*; import static net.mindview.util.print.*; and looked @ source codes , found build.xml in net folder basically, compile project externally provided library, should add classpath. there multiple ways based on tools using. if go "rough" way using text editor , javac (recommended beginners), can this: javac -classpath .:/path/to/the/folder/containing/your/library myclass.java in case if folder net in folder d:\libraries compilation command this: javac -classpath .:d:\libraries myclass.java then in source code can import library way author does, i.e. copy past code: import static net.mindview.util.range.*; import static net.mindview.util.print.*; public class myc...

javascript - Code to add mouseover functionality to line chart -

Image
hi i'm trying mouseover function work line chart can hover on line chart , see values of each point. tried using mouse function didn't work. how can this? included picture of line chart <!doctype html> <html> <head> <meta charset="utf-8"> <title>unemployment ward bar chart</title> <style type="text/css"> .axis text{ font-family: arial; font-size: 13px; color: #333333; text-anchor: end; } path { stroke: steelblue; stroke-width: 2; fill: none; } .axis path, .axis line { fill: none; stroke: grey; stroke-width: 1; shape-rendering: crispedges; } .textlabel{ font-family: arial; font-size:13px; color: #333333; text-anchor: middle; } } </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> <script> // set dimensions of canvas / graph var margin = {top: 20, right: 0, bottom: 60, left: 60}, width = 475; height = 350; padding ...

Native compiled stored procedure in SQL Server 2014, update table joining anothoer one for values -

in sql server 2014, can't work native compiled stored procedure. possible modify code below table updated values table? create procedure [dbo].[bsp_setmincompetitorprices_mo] @spid int, @mincompetitorsprices dbo.bt_mincompetitorsprices_mo readonly native_compilation, schemabinding, execute owner begin atomic (transaction isolation level = snapshot, language = n'us_english') update otu set otu.competitorpricenat = mincp.mincompetitorprice tt_offerstoupdate_mo otu inner join @mincompetitorsprices mincp on mincp.concreteproductid = otu.concreteproductid otu.spid = @spid end getting error: using clause in delete or update statement not supported natively compiled stored procedures i understand that, there workaround this? thank you

javascript - angular $cookies doesnt work in internet explorer 11 -

i using angular-cookie version 1.5.5 , ie 11. using angular factory $cookie set , value. setting cookies @ 1 page , retrieve @ page based on show div. solution working fine in chrome , mozilla fine. not working in ie. cookies enabled in ie. app.factory('sharedcookieservice', function ($cookies) { var expiredate = new date(); return { getcookiedata: function (key) { return $cookies.get(key); }, setcookiedata: function (key, value) { $cookies.put(key, value, { expires: expiredate }); }, .... page var xx = getcookiedata(key) getting undefined though setcookie data on b page.

r - ggplot: confusing about user-defined bin number in density plot -

Image
my basic question how set bin number (default 30) geom_density. i found density in y-axis did not change bin has been modified. here example: values <- runif(1000, 1, 100) ind <- as.factor(rep(c(1:2), each=500)) inout <- as.factor(rep(c(1:2), each =500)) df <- data.frame(values,ind,inout) ggplot(df,aes(x=values, ..density..)) + geom_freqpoly(aes(group=interaction(ind,inout), colour=factor(inout)), alpha=1, bins=1) the density should 1, because bin number defined 1. however, result did not show expected. do know miss here? tips define bin number or bin threshold ggplot geom_density? thanks lot. in ggplot don't set number of bins per se, instead set width of bins using binwidth (default range/30). bin isn't term geom_freqpoly understands ignored in example code. i think example using range 0-1 (instead of 1-100) better illustrate expecting see: values <- runif(1000, 0, 1) # generate values between 0 , 1 ind <- as.factor(rep...

c# - Is there any way to get botUserData for other user in conversation on MS bot framework -

is there way botuserdata other user in conversation. now when have bot.connector.message can get/change global data current user, , data conversation users. want access gobal data others user in conversation. can participants list dialog ilist participants, how user data these participant? thanks help. i haven't tried yet, think using connectorclient make trick. has method "getperuserconversationdata" under bots collection can specify botid, conversationid , userid. hope helps, ez.

java - How to enable basic metric diagnostics on an Azure VM? -

i'm using azure java sdk vm creation on azure account. noticed diagnostics turned off default when create vm. how enable basic metrics in diagnostic section while creating vm? i'm using following code submit request create vm: virtualmachine request = new virtualmachine(); request.setlocation(); request.setnetworkprofile(); ... ... computemanagementclient.getvirtualmachineoperations().createorupdate(request); i see there request.setdiagnosticprofile() method, takes in bootdiagnostics object , not enable basic metric diagnostics. is there way can enable basic metric diagnostics through code? i can't find java sdk apis enabling basic metric diagnostics via reviewing related source codes & javadocs azure java sdk. but seems can try refer article "enabling azure diagnostics in azure cloud services" , create diagnostics setting azure insights rest api azure vm. hope helps. any concern, please feel free let me know.

weblogic12c - Deploying OSGi bundle on Oracle 12c throws NPE -

Image
on weblogic 12.2.1, trying deploy simple osgi bundle war file using admin console throws npe following logs. caused by: java.lang.nullpointerexception: @ org.apache.felix.framework.cache.jarrevision.getmainattributes(jarrevision.java:210) @ org.apache.felix.framework.cache.jarrevision.getmanifestheader(jarrevision.java:104) @ org.apache.felix.framework.bundleimpl.createrevision(bundleimpl.java:1235) @ org.apache.felix.framework.bundleimpl.<init>(bundleimpl.java:112) @ org.apache.felix.framework.felix.installbundle(felix.java:2905) @ org.apache.felix.framework.bundlecontextimpl.installbundle(bundlecontextimpl.java:165) as prerequisite created osgi framework (services->osgi frameworks) based on apache felix. bundle api project few interfaces wrapped in war file. structure of war file below: myapi-project.war - meta-inf - web-inf - classes - lib - osgi-lib - api-proj...

regex - How to escape parenthesis in Perl Regular Expressions? -

if have string such as: journal yeast 10 (11), 1503-1509 (1994) how 2 numbers in parenthesis( 11 , 1994) ? 1 way attempted using: /\s+journal\s+.*\((\d+).*\((\d+))/ but doesn't work. 2 questions: how escape parenthesis can use match them in re ? how above 2 numbers ? i doing in perl. ! try this \((\d+)\) regex demo explanation: \ : escapes special character sample ( … ) : capturing group sample + : 1 or more sample

javascript - Function is undefined -

i new javascript, here deal: i'm trying implement reading-position-indicator wordpress theme. therefore hooked div directly behind footer near script-tags, cause position-bar should stick on bottom of screen. tried implement kind of custom.js, should vary width of position-indicator depending on how far user has scrolled down. fails, , don't know why, aware fact cardinal fault i've made based on lacking experience js. evertime console sends "reference error: xyz not defined" here code, can inspected on jsfiddle (, although might little bit useless, cause script runs in wordpress environment, can't emulated there). html/php-hook markup: add_action('wp_footer', 'tg_wp_footer'); function tg_wp_footer() { if ( is_singular() ) echo '<div id="reading-position-indicator"></div>'; } js-markup: if( '"is_singular && reading_indicator"' ){ var reading_content = $the_post.find(...

python - Having used Kirsch's filter for segmentation of blood vessels, I want to remove an unwanted part -

Image
i've used kirsch's filter obtain following result, want remove circular detection (which aren't vessels) i've pointed red arrow below: how go removing circular detection, not blood vessel? here's code current segmentation: h1 = np.array([[5, -3, -3], [5, 0, -3], [5, -3, -3]], dtype=np.float32)/ 15 h2 = np.array([[-3, -3, 5], [-3, 0, 5], [-3, -3, 5]], dtype=np.float32) / 15 h3 = np.array([[-3, -3, -3], [5, 0, -3], [5, 5, -3]], dtype=np.float32) / 15 h4 = np.array([[-3, 5, 5], [-3, 0, 5], [-3, -3, -3]], dtype=np.float32) / 15 h5 = np.array([[-3, -3, -3], [-3, 0, -3], [5, 5, 5]], dtype=np.float32) / 15 h6 = np.array([[5, 5, 5], [-3, 0, -3], [-3, -3, -3]], dtype=np.float32) / 15 h7 = np.array([[-3, -3, -3], [-3, 0, 5], [-3, 5, 5]], dtype=np.float32) / 15 h8 = np.array([[5, 5, -3], [5, 0, -3], [-3, -3, -3]], dtype=np.float32) / 15 my desired result (note segmentation of different image): i try thresholding first image (plain otsu method may suffice...

javascript - Can one add React Keys after instantiation? -

i’m making collection of react elements , displaying them; follows trivial example frame problem of how-would-one-modify-an-preexisting-instantiated-element only. var c = [ <div>a</div>, <div>b</div>, // ... <div>z</div> ]; var listcomponents = react.createclass({ render: function() { return <div>{c}</div>; } }); reactdom.render(<listcomponents/>, document.getelementbyid('root')); while code above “works,” renders console message i’d rather not ignore: warning: each child in array or iterator should have unique "key" prop. check render method of `listcomponents`. see https://fb.me/react-warning-keys more information. superficially, add unique key="…" string each element in c , done it. however, seems quite verbose, since have data in indexed array , functional language in theory can assign each key matching index value without manually having enter source ...

elasticsearch - How to use couch2elastic4sync -

Image
i have used couchdb 1.6.1 , elastic 1.7.3 want elasticsearch couchdb integration, found couch2elastics4sync don't know npm. installed couch2elastic4sync , ran it, it's not working... how use it? i success.. edit couch2elastic4sync root@dev:/usr/bin#vim couch2elastic4sync var config = require('rc')('couch2elastic4sync', { addraw: false, rawfield: 'raw', endoncatchup: false, removemeta: true, urltemplate: false, load: { swallowerrors: false }, concurrency: 5, checkpointsize: 20, retry: { times: 10, interval: 200 }, elasticsearch: ' http://localhost:9200/couchdb/ektorp ', database: ' http://localhost:5984/ektorp ' }) root@dev:/usr/bin#couch2elastic4sync work...

linux - Github Permission denied (publickey) SSH keys in wrong directory? -

i've installed stack on aws ec2: https://aws.amazon.com/marketplace/pp/b00no1hj56/ref=srh_res_product_title?ie=utf8&sr=0-2&qid=1461119036279 the instance's system log says ssh keys installed here: generating public/private rsa key pair. identification has been saved in /etc/ssh/ssh_host_rsa_key. public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. i have added public key github account , the fingerprints match. when cloning repo get: permission denied (publickey). from github section https://help.github.com/articles/error-permission-denied-publickey i run: ssh -vt git@github.com , get: openssh_6.6.1, openssl 1.0.1f 6 jan 2014 debug1: reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: applying options * debug1: /etc/ssh/ssh_config line 56: applying options * debug1: connecting github.com [192.30.252.122] port 22. debug1: connection established. debug1: identity file /home/bitnami/.ssh/id_rsa type -1 debug1: identi...

java - Why can I not convert my integer to a double? -

i trying work out average of array cannot convert int double? why happening? private void avgofarray(){ mywindow.clearout(); int total = 0; int[] = new int[4]; int = 0; double avg = 0.0; while (i < a.length) { a[i] = 1 + (int) (math.random() * 10); mywindow.writeoutline(a[i]); total += a[i]; i++; } avg = (double) i; mywindow.writeoutline(total/double.parsedouble(i)); } the correct way calculate average like, double avg = total / (double) i; mywindow.writeoutline(avg); boxing int double doesn't make sense, try , parse it.

c++ - Floating point equality and tolerances -

comparing 2 floating point number a_float == b_float looking trouble since a_float / 3.0 * 3.0 might not equal a_float due round off error. what 1 fabs(a_float - b_float) < tol . how 1 calculate tol ? ideally tolerance should larger value of 1 or 2 of least significant figures. if single precision floating point number use tol = 10e-6 should right. not work general case a_float might small or might large. how 1 calculate tol correctly general cases? interested in c or c++ cases specifically. this blogpost contains example, foolproof implementation, , detailed theory behind http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ 1 of series, can read more. in short: use ulp numbers, use epsilon numbers near zero, there still caveats. if want sure floating point math recommend reading whole series.

ios - Application settings does not contain location service -

i have application requires location access. if location service under settings->privacy in on , installed application location service available under app settings app listed under location services list. when location service under settings->privacy off , installed app, show alert turn on location service in settings->privacy app not listed under location services list, in app settings location service not available turn on/off. please let me know, if there way location service in app settings or bug apple itself. thanks in advance. after many times of reading question, got you're trying say. did following: turned off location services in settings. result: of course list of apps uses location services became hidden. installed project uses location services. result: popup - "turn on location services allow "app_name" determine location". has 2 buttons: settings , cancel. clicked settings button. after being redirected se...

data analysis - Different Slicers for Different Visualizations in PowerBI -

i new power bi. let's have data containing student's english proficiency tests. name of data englishscores . columns inside data listening , writing , speaking , , studentids . created measurement called studentgrade studentid differentiate them based on grades on (fourth grade, fifth grade, , sixth grade). want create 3 visualizations each of scores (total number of viz: 3) , slicers each of these visualizations (3 slicers) based on student grades. i create visualization , slicer listening column. problem when create slicer studentgrade other scores, links previous slicers , visualizations. how can make new slicers filter visualizations? thank you you can accomplish need editing interaction settings filters , visualizations. assuming you're using power bi desktop: in short, select slicer , click "edit" button in visual interactions group on ribbon menu. can figure out there, or check video more details. you'll repeat each filter/visua...

html - How can I blend black background into the top of a b+w image using css? -

not sure how blend solid black background black , white image, posted in jfiddle <div class="background2"> </div> <div class="background3"> </div> they both backgrounds of div boxes. by blend if mean black background go on image, can make .background2 position: absolute; , edit according that. eg: .background2 { background: rgba(0,0,0,.7); position: absolute; height: 100%; width: 100%; z-index: 1; } here link updated fiddle

java - Incremental Math Trouble -

i've been perplexed how write math small game i'm creating. game own personal journey learning more java , largely based off of monolith, http://monolith.greenpixel.ca/ . i've looked @ source code game can't ascertain how developer math. here code have far. package damagedealer; import javax.swing.*; import java.awt.*; import java.awt.gridbaglayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; public class take1 { int dmg = 0; int epoints = 1000; int intunit1 = 0; public static void main(string[] args) { new take1(); } public take1() { javax.swing.swingutilities.invokelater(new runnable() { @override public void run() { try { uimanager.setlookandfeel(uimanager.getsystemlookandfeelclassname()); } catch (unsupportedlookandfeelexception ex) { ex.printstacktrace(); } catch (illegalacce...