Posts

Showing posts from February, 2010

Extract parent and child node from python tree -

i using nltk's tree data structure.below sample nltk.tree. (s (s (advp (rb recently)) (np (nn someone)) (vp (vbd mentioned) (np (dt the) (nn word) (nn malaria)) (pp (to to) (np (prp me))))) (, ,) (cc and) (in so) (s (np (np (cd one) (jj whole) (nn flood)) (pp (in of) (np (nns memories)))) (vp (vbd came) (s (vp (vbg pouring) (advp (rb back)))))) (. .)) i not aware of nltk.tree datastructure. want extract parent , super parent node every leaf node e.g. 'recently' want (advp, rb), , 'someone' (np, nn)this final outcome want.earlier answer used eval() function want avoid. [('advp', 'rb'), ('np', 'nn'), ('vp', 'vbd'), ('np', 'dt'), ('np', 'nn'), ('np', 'nn'), ('pp', 'to'), ('np', 'prp'), ('s', 'cc'), ('s', 'in'), ('np', 'cd'),

java - JavaFX SceneBuilder ImageView not working -

i need create gui scenebuilder. added imageview interface , set path image correctly. image showing inside scenebuilder, when run application, image not there. i put image inside "img/placeholder.png", , directly root directory. doesn't matter put it, isn't working. the path gui.fxml file: /src/gui/gui.fxml the path image file: /placeholder.png can me please? another solution in particular context (maven related) given /src/main/resources/foo/gui.fxml , /src/main/resources/foo/img/foo.png , if create image view in scenebuilder , set image foo.png, url reads @img/foo.png . unfortunately image not show in application. if change image url @/foo/img/foo.png image won't show anymore in scenebuilder show in application. scenebuilder 8.2.0, jdk 1.8, intellj idea 2016.1

normal distribution - C++11 normal_distribution and MATLAB normpdf -

i have develop normpdf matlab function in c++ environment. got problem.. normpdf(x, u, sigma) in matlab similar normal_distribution gaussian(u, sigma); where x values? means want gaussian function not gaussian random. how sample output value gaussian distribution? thanks. you write normpdf yourself inline double squared(double x) { return x*x; } double normpdf(double x, double u, double s) { return (1.0/(s*sqrt(2.0*m_pi)))*exp(-0.5*squared(x-u)/squared(s)); } update this 1 might bit faster, less 1 multiplication const double one_over_sqrt_2pi = 0.39894228040143267793994605993438; double normpdf(double x, double u, double s) { return (one_over_sqrt_2pi/s)*exp(-0.5*squared((x-u)/s)); }

linux - shell-init: error retrieving current directory: getcwd -- The usual fixes do not wor -

i have simple script: #!/bin/bash server in $(~/.ansible/ansible_hosts) ssh $server "hostname; readlink /opt/mydir/mylink;" done it works fine - program returns correct hostname , link - except following error on not of servers: shell-init: error retrieving current directory: getcwd: cannot access parent directories: no such file or directory all directories exist. 1 of common suggestions has been add cd, cd -, or cd /. happens when step added additional: chdir: error retrieving current directory: getcwd: cannot access parent directories: no such file or directory i tried kickstarting nfs daemon on off chance there confusion homedir , substituted /etc/init.d in case problem /opt. no difference this annoyance except when try use ansible playbook instead of simple ssh command fails server. any insights appreciated. i believe error not related script @ all. issue is: directory @ when try run script not exist anymore. example have 2 terminals, cd

ios - Get distance from user's location to nearest point on GMSPath -

Image
i working google maps api , have drawn gmspolyline s on map. know "node" (lat , long position turning point) on map closest user's location, , know next upcoming nodes. given information, how 1 obtain distance user's current location nearest point on closest path? in diagram below, how x when know 3 gps coordinates? looking @ geometry problem instead of programming problem might make little easier. there exists library or api little more couple lines of code, approach should still yield result little no overhead. disclaimer: approach works straight lines. you have 2 points on path , 1 point not on path. using basic algebra can find line parallel path , runs through user's location, , invert line find shortest line between user's location , path. it's finding intersection of 2 lines. one thing note, larger distance between nodes less accurate euclidean distance be. should negligible nodes closer ~100 miles.

python 3.x - django-nocaptcha-recaptcha always shows additional verification box -

i installed django-nocaptcha-recaptcha , integrated form: from nocaptcha_recaptcha.fields import norecaptchafield class clientform(forms.modelform): captcha = norecaptchafield() it shows fine on form, whenever click on additional dialog pops asking enter text , verify. happens every time. tested computer on network , still asks additional verification after clicking box. this looks like: additional verification dialog box here's how i'm handling form: @xframe_options_exempt def registration(request): if request.method == 'post': clientform = clientform(request.post) # check whether it's valid: if clientform.is_valid(): new_client = clientform.save() ... what doing wrong? problem django-nocaptcha-recaptcha? should use else? p.s. i'm using django 1.7.1 python 3.4 restart server , don't forget clear browser's cache. hope helps.

excel - Return headers if column contains certain string -

i have sheet called input. top row, a1:o1 contains parent, , rows underneath (of varying length) contains urls. of urls shared between parents, , want return list of urls, , parents are. have tried concatenate(if(index(match formula becomes large. similar questions i've seen looking 1 output, number. open vba solutions, have very minimal understanding create own code. example: news --- celebrity ---- finance cnn------complex --------forbes forbes---cnn i want return cnn news celebrity, forbes new finance, complex celebrity. don't mind how output formatted. since have data in a:o, assuming column q blank. in column q, make list of unique values (so in example, q1 "cnn", q2 "complex" , q3 "forbes". can use "remove duplicates" list of unique urls). code loop through used range column o (from row 2 last used row) , put "answer" in column r. sub test() dim headerrange range, uniquename string, integer, totaln

android - how to LoopJ AndroidAsyncHttp with retry dialog -

i try extends asynchttpclient 1 boolean argument on true show dialog , retry connection don't how can access user sent asynchttpresponsehandler onfailure event, , can't show retry dialog so retry extends asynchttpresponsehandler this: import org.apache.http.header; import android.graphics.color; import android.graphics.drawable.colordrawable; import android.view.view; import android.view.view.onclicklistener; import com.loopj.android.http.asynchttpclient; import com.loopj.android.http.asynchttpresponsehandler; public class cuasynchttpresponsehandler extends asynchttpresponsehandler { private cuactivity activity; private boolean retry; private cuasynchttpresponsehandler response; public void cuasynchttpresponsehandler(cuactivity activity) { this.activity = activity; this.retry = false; this.response = this; } public cuasynchttpresponsehandler(cuactivity activity, boolean retry) { this.activity = activity;

javascript - Cannot return string from value of element in protractor test -

so i'm trying string value returned value of element on resolution of promise. want pass raw string value function i'm building inside protractor test. this element: <div style='hidden' > <input id="group-sendgrid-hidden-input" ng-model='groupcode' value='dangyo' > </div> i'm looking way @ either model value or attribute value (either work). model value might better. this attempt resolve promise here , return result: // first element driver object var groupcode = element(by.id('group-sendgrid-hidden-input')); // next resolve promise provided element groupcode.getattribute('value').then(function(value){ console.log( 'should string: ' + value); return value; }); here console.log( 'should string: ' + value); returns null value , nothing can seems resolve this. i'm sure i'm doing wrong because new protractor , seems simple. else experience behavior?

javafx - Why -fx-border-color reset border radius of TextField? -

Image
i want change background , border color of textfield use javafx css. don't understand why -fx-border-color reset border radius of textfield? as can see second textfield doesn't have border radius. sample/style.css : .validation-error { -fx-background-color: #fff0f0; -fx-border-color: #dbb1b1; } sample/main.java package sample; import javafx.application.application; import javafx.geometry.insets; import javafx.scene.scene; import javafx.scene.control.textfield; import javafx.scene.layout.vbox; import javafx.stage.stage; public class main extends application { @override public void start(stage primarystage) throws exception{ textfield txtwithoutstyle = new textfield(); txtwithoutstyle.settext("without style"); textfield txtwithstyle = new textfield(); txtwithstyle.settext("with style"); txtwithstyle.getstyleclass().add("validation-error"); vbox root = new vbox();

php - Wordpress - WP_Query, pulling in multiple post -

somewhat new wordpress , php , trying work though issue. have page ( http://www.moderateindividual.com.php53-13.dfw1-1.websitetestlink.com/ ) , twards bottom can see section 6 images, need pulled in custom post type custom taxonomy. have pulling in 1 post on , over, how make pull in 6 latest post in category? here code have far <?php //define custom post type name in arguments $args = array( 'post_type' => 'news', 'tax_query' => array( array( 'taxonomy' => 'news_category', 'field' => 'id', 'terms' => '47', ), ), ); //define loop based on arguments $loop = new wp_query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="st_views"> <div class="tab-1 st_view"> <div class="st_view_inner"> <div c

ios - Setting other font than system in WatchKit (Apple Watch) -

i have 1 apple watch app using menlo bold font label. in first version of xcode supported watchkit able change font of label in storyboard menlo bold 36 , working fine. in curent version (xcode 6.2) not possible more, found tutorial on how set custom font in apple watch, http://www.tech-recipes.com/rx/53710/how-do-i-use-custom-fonts-in-my-apple-watch-app/ i tutorial found code: func printfonts() { let fontfamilynames = uifont.familynames() familyname in fontfamilynames { println("------------------------------") println("font family name = [\(familyname)]") let names = uifont.fontnamesforfamilyname(familyname string) println("font names = [\(names)]") } } this code print available fonts. used see why name of font have added. at stage have not added custom font, run function see font available on apple watch default. after running found: /* lot of fonts before */ -------------------------

c++ - How to change Firefox Homepage using GPO (Group policy) -

so far, have developed solution in c# doesn't use gpo. modifies prefs.js file. this have tried far using c#: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.io; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace firefoxhomepagechanger { public partial class form1 : form { public form1() { initializecomponent(); } public static void setmozilla(string strurl) { try { string strsystemuname = environment.username.tostring().trim(); string systemdrive = environment.expandenvironmentvariables("%systemdrive%"); string strdirectory = ""; string strpreffolder = ""; if (directory.exists(systemdrive + "\\documents , settings\\" + strsystemuname +

javascript - animate div movement relative to another div size change -

having issue making animation work me. essentially have vertical scrolling page several div elements vary in size based on content being displayed. what's happening these size changes occur other elements jumping abruptly based. i'd make these bit more smooth. this part of massive project (angular) can't bring in external libraries. i've created jfiddle illustrates problem. $('.close').click(function () { $(this).parent().parent().height(0); $(this).parent().parent().slideup(500);// in case if want move second div up. }); http://jsfiddle.net/zberq/5/ so summarize, issue not element who's height changing. issue elements below instantly jumping or down in response height change. i first removed line $(this).parent().parent().height(0); - not sure if u need or not. then in remaining removed .parent , seems smoother, margin jump. fiddle https://jsfiddle.net/hastig/zberq/17/ js $('.close').click(function() {

java - How to know original class name if wrapped into proxy by Spring? -

i trying obtain classes name getclass().getsimplename() under spring , returns myclass$$enhancerbyspringcglib$$somehex this because spring wraps class proxy. is there portable way obtain original class name? spring provides utility this. http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/classutils.html#getuserclass-java.lang.class- public static class<?> getuserclass(class<?> clazz) "return user-defined class given class: given class, original class in case of cglib-generated subclass."

Magento recently viewed products not working -

i facing problem showing viewed products in product page. here local.xml code: <catalog_product_view translate="label"> reference name="root"> <action method="settemplate">page/1column.phtml <block type="reports/product_viewed" name="product.recently.viewed" as="product_recently_viewed" template="reports/product_viewed.phtml"/></block></reference> here footer.phtml code: <div class="footer-container"> <div class="footer"> <?php $manipage = $this->geturl(''); $currenturl = mage::helper('core/url')->getcurrenturl(); $url = mage::getsingleton('core/url')->parseurl($currenturl); if ($manipage == $currenturl){ echo $this->takecategory(12,1) /*12 = brands category 1 = show images*/ ; } ?>

salt stack - Copy local file in Saltstack -

i in masterless salt-minion, manage file locally. how copy local file around in saltstack .sls file? e.g. like /etc/mymodule/proxy.conf: file.managed: - source: /mymodule.conf i guess want take @ file.copy instead of file.managed . state file.managed uses source key download content uri (can salt:// , http:// , etc.) - won't intelligently guess that, if there no uri scheme in source value, should use local path on minion runs at.

Is it possible to launch the Google Drive image viewer? -

basically, want reproduce behaviour of when double-click on image in google drive folder , presented image viewer images , videos contained in folder. possible? if so, how? thanks! what you're looking known google drive viewer . close guess though. far know, isn't service can use. however, here facebook's explanation how implemented theirs. hope gives idea helps decide whether wanna implement or not.

Breeze issue with complexType change tracking -

i use angular , breeze in app , use "haschangeschanged" event handling state of entities stored in entitymanager. have problem when have entity property complextype , isscalar=false. problem occurs when make request twice (without changing entity) , same entity. on second request "haschangeschanged" event fired haschanges=true. in moment when event fired entity has state "modified", after data loaded state changed "unchanged". i've wrote (jasmine) unit test. in comments information assertion throws error. var entity, haschanges = false, listeners = { onchange: function (event) { console.log('change', event.haschanges); } }; spyon(listeners, 'onchange'); $httpbackend.expectget('json/sampleentity?').respond(200, [ { id: 1, name: 'some name', data: {}, $type: 'sampleentit

php - how to union all this query code in codeigniter -

"table 1" $this->db->select('referral1.*, client.*, employee.* '); $this->db->from('client'); $this->db->join('referral1', 'client.referral_id = referral1.referral1_id', 'inner' ); $this->db->join('assign_psychotherapist ', 'assign_psychotherapist.a_referral_id = client.referral_id', 'inner' ); $this->db->join('employee ', 'assign_psychotherapist.a_psychotherapist_id = employee.empid', 'inner' ); $this->db->where("referral_status ='assigned' or referral_status ='accepted' "); $this->db->order_by("referral_date", "desc"); "table2" $this->db->select('referral1.*, client.*, volunteer.* '); $this->db->from('client'); $this->db->join('referral1', 'client.referral_id = referral1.referral1_id&

angularjs - How to resolve promises of child controller on route change? -

i have angular ionic app. assigned controller, template , resolve promises in routes. working fine main controller loads after promises of parent controller resolved. if route contains child controller promises. here problem page need load after promises of parent , child controller resolved. punker var app = angular.module('testapp', ['ionic']); app.config(function($stateprovider, $urlrouterprovider) { $stateprovider.state('dashboard', { url: "/dashboard", templateurl: "dashboard.html", controller: 'dashboardcontroller', title: 'dashboard', resolve: { userdetails: function(dataservice) { return dataservice.getuserdetails(1); }, dashboarddetails: function(dataservice) { return dataservice.getdashboarddetails(); } } }); $urlrouterprovider.otherwise('/dashboard'); }); app.factory('dataservice'

mouseevent - JavaFX Circle object not registering mouse events properly -

i want user able drag-move circles around pane. circles dont seem register (almost) no mouse events (as defined in end). have same exact code empty pane works fine. if change circle1.setonmousedragged to paneforcircles.setonmousedragged it works fine not want because need manipulate both circles. ideas ? appreciate if tell me how hide part of circle overlaps adjacent elements if center close pane border. import javafx.application.application; import javafx.geometry.insets; import javafx.geometry.pos; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.control.contentdisplay; import javafx.scene.control.label; import javafx.scene.control.textfield; import javafx.scene.layout.hbox; import javafx.scene.layout.pane; import javafx.scene.layout.vbox; import javafx.scene.paint.color; import javafx.scene.shape.circle; import javafx.stage.stage; public class ex168 extends application { @override public void start(stage primarystage) throws excepti

android - xxhdpi density added in API 16, what in <16 if I provide only xxhdpi resources? -

Image
i'm working on porting ios android, , since ios guy gave me @3x versions of graphic resources, have placed them in res/drawable-xxhdpi folder. know it's not practice not provide alternative low-res resources, according official documentation: by default, android scales bitmap drawables [...] render @ appropriate physical size on each device. example, if application provides bitmap drawables [...] medium screen density (mdpi), system scales them when on high-density screen, , scales them down when on low-density screen. now, documentation says: xxhdpi: extra-extra-high-density screens; approximately 480dpi. added in api level 16 then, question. don't give bitmap alternatives aside xxhdpi , on devices running android api <16 drawables rendered @ all? tried app on api 10 emulator, , stuff there. should be? if yes, why ?!? the answer yes, resources rendered on devices api < 16. why yes? this finding: if inside contents of output apk res

java - Spring false positive circular dependency reported -

spring reports false positive circular dependency error when dependency order looks below factorybean depends on list (example animalfeeder) animalfeeder depends on list of strings. interesting things are issue not observed when spring instantiation order changes ie) factorybean comes before animalfeeder. issue seen when animalfeeder comes before factorybean. this happens when factorybean involved. issue not observed when simple bean class used instead of factorybean. here source code public interface feeder { void feed(); } public class animalfeederimpl implements feeder { private list<string> feedingtypes; public animalfeederimpl(list<string> feedingtypes) { this.feedingtypes = feedingtypes; } @override public void feed() { //feed here } } public class feedermanager { private final list<feeder> feeders; public feedermanager(list<feeder> feeders) { this.feeders = feeders; } //this method trigger feed

sql - How to optimize the downloading of data to the server in SSIS -

good day. need records oracle database database in sql server. data source type (odbc) performed using sql command, taking possible indices according requirement. process runs fine, problem takes long time , need quick. process can not performed lookup, requires merge or merge join, load table oracle sql under conditions. thank help check limiting factor. there 3 points check: remote server slow. source db can run low on memory, read speed or free cpu. substitute query straight select statement no where clause or join s , see if ssis package runs faster. target db. may have indexes enabled, high write latency on hdd or not enough cpu. run insert target table , see how longer takes. problem may in middle: transfer between 2 servers. network main bottleneck. ssis hosted on same server sql server? have 2 network connections + possible hardware bottleneck on dedicated ssis machine. depending on bottleneck there different solutions. if have network capacity , bo

Get highest percentage value from a column based on value from another column in mySQL -

i have query percentages of different values in specific column: select dma, count(*) / const.cnt *100 my_percent full_db3 cross join (select count(*) cnt full_db3) const group dma order my_percent desc limit 10; step one: need amend gives me top 10 values in column dma based on value of column. example, if value in column gender "f", top 10 values in column dma . (which doesn't work, of course). select dma, count(*) gender = 'female' / const.cnt *100 my_percent full_db3 cross join (select count(*) cnt full_db3) const group dma order my_percent desc limit 10; the above throws error, should point across. step 2 looping through columns , returning top 10 values in every column (not dma ) give value of specific column (e.g., gender = 'female'). what's best way this?

javascript - x-editable post value is undefined -

i created x-editable form : <a href='#' class='username' data-pk='<?php echo $key['idca']; ?>' data-type="text" data-placement="right"> <?php echo $key['categoryname']; ?> </a> then created javascript function handle x-editable form : $.fn.editable.defaults.success = function() { $(this).show() }; $.fn.editable.defaults.mode = 'inline'; $('.username').editable({ url:'edit.php', pk:'1', type:'text', send:'always', ajaxoptions:{ datatype:'json' }, success: function(response, newvalue) { window.alert('oke'); }, error: function(response, newvalue) { window.alert('failed'); } }); and in php create follow : <?php $pk = $_post['pk']; $val = $_post['value']; $nam

matlab - Different results between a mex file and C file -

i have matlab code in computationally expensive part converted c mex file. mex file is: /* copyright henrik stewenius*/ /************************************************* indata : 9x4 matrix data out: 10x20 matrix *************************************************/ #include "mex.h" #include <math.h> void mexfunction(int nlhs, mxarray *plhs[], int nrhs, const mxarray *prhs[]) /*nlhs number of expected mxarrays. plhs pointer array of null pointers. nrhs number of input mxarrays. prhs pointer array of input mxarrays. */ { double *ee, *a; double e00,e01,e02,e03,e04,e05,e06,e07,e08; double e10,e11,e12,e13,e14,e15,e16,e17,e18; double e20,e21,e22,e23,e24,e25,e26,e27,e28; double e30,e31,e32,e33,e34,e35,e36,e37,e38; double e002,e012,e022,e032,e042,e052,e062,e072,e082; double e102,e112,e122,e132,e142,e152,e162,e172,e182; double e202,e212,e222,e232,e242,e252,e262,e272,e282; double e302,e312,e322,e332,e342,e3

ios - Is there any way to enable NSURLSession to run more than 4 NSURLSessionUploadTasks concurrently? -

when create , start 20 nsurlsessionuploadtasks 3-4 run @ time, when httpmaximumconnectionsperhost set 20! i understand can limit number of max uploads httpmaximumconnectionsperhost. however, want increase number of concurrent uploads. have started 'resumed' 20 new tasks 3 or 4 run concurrently. when 1 batch finishes, 3 or 4 more start until tasks have completed. not ok, because server requires substantial amount of time process each upload, meaning i'm not getting out of user's available bandwidth while server working respond post requests. how can make nsurlsession run httpmaximumconnectionsperhost? httpmaximumconnectionsperhost works fine limit number of concurrent uploads, nsurlsession appears throttle down 3 or 4 regardless of value set httpmaximumconnectionsperhost. means httpmaximumconnectionsperhost allows choose between 1 , 4 concurrent uploads, instead of between 1 , your_max concurrent uploads!! to clear, question is, there way run 5 or more co