Posts

Showing posts from September, 2014

shell - Calling R from Stata -

for annoying reason, not able call r-scripts directly @ data center. allowed call stata , , stata have call r scripts. for now, trying use shell command: capture cd c:\\correct\dir shell “c:\\program files\r-3.1.2\bin\rscript.exe" "myfile.r" the paths correct, blue screen when running in stata, , nothing else happens. there message in blue screen, disappears immediately, have no clue says. how can proceed debugging this? there better way doing this? i'd prefer not using additional packages rsource , need certified before installed in data center , lengthy process. i think presence of double backslash causing problem. following works me: stata cd "path\of\choice" shell "c:\program files\r\r-3.1.2\bin\rscript.exe" "test.r" test.r setwd("path\\of\\choice") data(mtcars) mtcars write.csv(mtcars, "cars.csv")

javascript - AngularJS: Access controller properties inside script tag in the view -

in app.js have controller wrapped in closure: (function(){ var app = angular.module('myapp', []); app.controller('areainfo', function($http){...}); })() in index.html, have: <body ng-app="myapp" ng-controller="areainfo ctrlareainfo">...</body> i have no trouble accessing controller's properties in html between body tags, need access properties within <script> tag so: <body ng-app="myapp" ng-controller="areainfo ctrlareainfo"> ... <script> var myvar = ctrlareainfo.property; </script> </body> obviously, code above doesn't work; how access controller's property within <script> tag? i ended using ngmap ( https://github.com/allenhwkim/angularjs-google-maps ) display google maps , works charm.

linux - how to direct a sh script to run a python script? -

i wrote python script calls 2 files perform calculations , asks name new file place calculation in code runs this: python code.py in_file1 in_file2 outfile now, have several files need same calculation , names change last numbers, wanted script takes different needed files in folder performs python script , name outputs changing las number according given in_file1 (infield_2 not change). i tried simple not working #!/bin/bash python code.py in_file[19]* infile_2 outfile[19]* i error usage of python saying usage: python code.py [-h] in in2 out unrecognized arguments i know sure code.py works, wanted spare 1 file @ time. thank you. new in python , linux, appreciate can give. you can in python : import os name = "in_file%d" in range(1, 21): os.system("python code.py in_file{} in_file2 outfile{}".format(i, i)) this works following, os library calling outputted strings: >>> in range(1, 21): ... "python code.py in_fil

php - For loop with column titles -

is there anyway can make code have loop creates actual select box each column title? i have forloop in place information in database not column titles </select><br> <label for="fo">footrest options: </label> <select name="fo"> <option>----</option> <? foreach ($liftsecond $lift){ echo '<option>'.$lift["footrest options"].'</option>'; } ?> </select><br> <label for="sw">seat width: </label> <select name="sw"> <option>----</option> <? foreach ($liftsecond $lift){ echo '<option>'.$lift["seat width"].'</option>'; } ?> </select><br> <label for="ss">seat style: </label> <select name="ss"> <option>----</option> <? foreach ($liftsecond $lift){ echo '&l

Jira - Table formatting alignment -

i have following table format in jira: ||a || b || c || || || 0059||warranty|| ||offer display||offer display name |lite| || ||offer details display| reconditioned genie lite | || ||aa |$0| || ||bb |n/a| || ||cc |n/a| i need row headers "aa", "bb" , "cc" aligned left. have checked following link https://jira.atlassian.com/secure/wikirendererhelpaction.jspa?section=all haven't seen way align table headers. does know how align headers (in case, row headers) either right or left? to left aligned, don't table headers, instead make them strong: |*a* | *b* | *c* | | |0059|warranty| |*offer display*|offer display name |lite| | |offer details display| reconditioned genie lite | | |aa |$0| | |bb |n/a| | |cc |n/a| if want right aligned, doesn't there's clean

python - Move files (directory to directory) on a remote file system using python2.7 -

i move files 1 directory on remote linux (centos) server directory on same server. using python27. i'm told 'move' copy/delete process on remote file system, , appear case (large) files take long time move. there quick way move these huge files? os.rename you can use os.rename os.rename("path/to/file.txt", "path/to/new/file.txt")

How to get the value user typed in on a search bar in android and use that value in all other activities -

in 1 of activities in android app, going have search bar , no matter user types in there, need string , use in of other activities. does know how can that? need value accessible in each activity. i've looked online, haven't found on this. can more clear on requirement. as far understood, want pass search query search activity other activities. you can search query entered ' onquerytextchange ' callback method, assign entered query global string , pass other activites via bundle.

angularjs - Issue with angular animation and undefined javascript values -

i trying angular animation triggered upon unsuccessful login (either when server sends 4xx (e.g. 403) or when no credentials provided). here controller: .controller('signinctrl', ['$scope', '$rootscope', '$cookies', '$state', '$animate', 'signinservice', function ($scope, $rootscope, $cookies, $state, $animate, signinservice) { $scope.signin = function () { $scope.shake = false; if ($scope.credentials) { signinservice.signin($scope.credentials, function (status, memberrole) { $scope.shake = false; //todo: necessary check status? if (status === 200) { ... } }, function () { $scope.shake = true; }); } else { //todo: shakes/works once!

php - Symfony 1.4 functional test - reduce memory usage -

i have csv file defines routes test, , expected status code each route should return. i working on functional test iterates on csv file , makes request each route, checks see if proper status code returned. $browser = new sftestfunctional(new sfbrowser()); foreach ($routes $route) { $browser-> get($route['path'])-> with('response')->begin()-> isstatuscode($route['code'])-> end() ; print(memory_get_usage()); } /*************** output: ************************* ok 1 - status code 200 97953280# /first_path ok 2 - status code 200 109607536# /second_path ok 3 - status code 403 119152936# /third_path ok 4 - status code 200 130283760# /fourth_path ok 5 - status code 200 140082888# /fifth_path ... /***************************************************/ this continues until allowed memory exhausted error. i have increased amount of allowed memory, temporarily solved problem. not permanent s

java - How is mutex internally implemented -

i've spent time trying understand how mutexes implemented in several languages. there multiple links describing topic (*) if understand correctly, hardware provides atomic operations may distinguish should in turn now. in software used busy waiting (try cas or test-and-set , wait in while cycle if not successful), how scheduler know should take away process/thread cpu because waits? there support in os provided example java synchronization uses in order signal "i blocked, please let other threads run instead"? think is, since busy-waiting alternative use lock(); (so should not same) *source: http://en.wikipedia.org/wiki/mutual_exclusion how mutex , lock structures implemented? in linux jdk soure c code uses pthread library part of standard c library. that, in turn, uses linux kernel futex feature ( man futex ). far can understand, implemented using kernel scheduler put calling thread sleep , wake when signal received. scheduler relies on timer in

oracle11g - Connecting db in host machine from Virtualbox - -

i installed win7 (32 bit) on virtual box v4.3.20. i'll installing informatica powercenter v9.5.1 in windows environment. host os win8 virtual box installed. but, have database oracle xe 11.2.0.4.0 installed on win8 host os. my doubt - able access database inside virtual win7 os ? if yes, how? please assist. appreciated. thanks , regards, -ranit there @ least 1 similar question here on stackoverflow - how access oracle db in virtualbox host (windows) and searching web able see relatively recent post - https://superuser.com/questions/310697/connect-to-the-host-machine-from-a-virtualbox-guest-os that said, looks biggest problem may firewall running on client os, in case win 7. need open appropriate port(s) oracle using. relative win 7 client running in virtualbox, oracle running on host not different oracle running on box somewhere else. still tcp connection oracle server. setup in similar fashion. gives starting point.

c# - cannot find the SPSite name space -

Image
i unable find name space spsite i have imported these far: using system; using system.collections.generic; using system.linq; using system.text; using system.net; using microsoft.sharepoint; using system.collections; using microsoft.sharepoint.client; using microsoft.sharepoint; using system.data.sqlclient; using sp = microsoft.sharepoint.client; using system.data; namespace grandpermission { class program { static void main(string[] args) { spsite ospsite = new spsite("http://spdevserver:1002/"); } } } and spsite still has red line under it. this error occurs since spsite class part of server side object model api: server side object model api utilized only on machine sharepoint server/foundation installed. since using client object model api (referenced assembly in project microsoft.sharepoint.client.dll part of sharepoint server 2013 client components sdk ) recommend utilize api. so, li

autohotkey - Send hotkeys own default behavior -

how can send keys default (from hardware) behavior in own key definition. mean code: vcerc = 0 +c:: vcerc := !vcerc return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; kkey = 0 $k:: if vcerc { kkey := !kkey if kkey sendinput {k down} else sendinput {k up} } else { send, k } return in end part send, k sends word k . in multi language environment means if switch other, key still sends k rather sending 1 second language (assume Ù† ). how can make send default? (from hardware no matter language is) two things seem off me: 1) initial kkey declaration never hit since falls after hotkey (and return). declare variables @ top. 2) if kkey true, script has holding down k button indefinitely. expected? 3) looking lowercase k's sending uppercase k's. expected? at rate, example should point in right direction. vcerc = 0 kkey = 0 +c:: vcerc := !vcerc return $k:: { if (vcerc) { kkey := !kkey if (kkey) { msgbox, k

How to get loggers in java.util.logging so i can change their log level at runtime? -

i using java.util.logging in different classes. log level's default value info . example in 1 class class1 setup way: import java.util.logging.handler; import java.util.logging.level; import java.util.logging.logger; public class class1 { private static final logger logger = logger.getlogger(class1.class.getname()); static { logger.setlevel(level.info); (handler handler : logger.gethandlers()) { handler.setlevel(level.info); } } ... } the above same way setup in different classes. now log level changed @ runtime. example suppose changed finest @ runtime. in case want loggers have been created far , change log level finest . how can that? thinking creating class logrepository has java.util.list , whenever logger created, add java.util.list of logrepository . think there may better way. i believe matter of setting level of parent logger of instances inherit from. logger.getlogger("").setlevel

android - Show route direction in Google Maps -

googlemap = ((supportmapfragment) getsupportfragmentmanager() .findfragmentbyid(r.id.map)).getmap(); googlemap.addmarker(new markeroptions() .position( new latlng(float.parsefloat(latitude), float .parsefloat(longitude))) .title("marker").title(title)); **googlemap.addpolyline(new polylineoptions() .add(new latlng( double.parsedouble(latitude1), double.parsedouble(longitude1)), new latlng( double.parsedouble(latitude), double.parsedouble(longitude))) .width(5).color(color.blue).geodesic(true));;** googlemap.animatecamera(cameraupdatefactory.newlatlngzoom( cameralatlng, 17)); so that's have done, code draws line source destination. however, not want draw line, want show route direction. like picture http://s7.postimg.org/dwdbkq6h7/screenshot_2015_04

java - Can't figure out why this big double inner join isn't working, but when split it does -

here queries split work fine... string sqlstatement = "select wblinkwebsiteid, wblinkcategoryparentid, wblinktitle, wblinkurl websitecategory_table wblinkcategoryid = ?"; string[] args = { categorysubid }; part 2 sqlstatement = "select locations_table.locationwebsiteid, " + "locations_table.locationcity, " + "locations_table.locationstate, " + "locations_table.locationcountry, locations_table.locationtype, " + "locations_table.locationurl, " + "pref_table.pref_savedtitle " + "from pref_table inner join " + "locations_table on pref_table.pref_locationid = locations_table.locationid " + "where " + "pref_table.pref_savedtitle = '" + thesavedpref + "' order locations_table.locationstate, locations_table.locationcity"; now here attempt combine 2 instead of having 2 go in row back , burn time/resources... string newsqlstatement = "

drop down menu - MVC5 DropDownList -

i trying create dropdownlist selection department, based on selected department table should filtered. kind of viewbag example here: http://www.codeproject.com/articles/687061/multiple-models-in-a-view-in-asp-net-mvc-mvc //controller using system; using system.collections.generic; using system.data; using system.data.entity; using system.linq; using system.net; using system.web; using system.web.mvc; using ucontoso.models; namespace ucontoso.controllers { public class dashboardcontroller : controller { private univcontosoentities db = new univcontosoentities(); // get: /student/ public actionresult index() { var deptquery = db.faculties.include(f => f.department); return view(deptquery.tolist()); } protected override void dispose(bool disposing) { if (disposing) { db.dispose(); } base.dispose(disposing); } } } //model(department) namespace ucontoso.models { using sy

c# - ref and out with value type variables -

msdn documentation on out says parameter passed out must assigned value inside function. example website: class outexample { static void method(out int i) { = 44; } static void main() { int value; method(out value); // value 44 } } according understanding when int "value" declared assigned default value of 0 (since int value type , cannot null.) why necessary "method" modify value? similarly, if "ref" used instead of out, there need of initializing "value"? there questions what's difference between 'ref' , 'out' keywords? no 1 wants put 2 , 2 together. according understanding when int "value" declared assigned default value of 0 (since int value type , cannot null.) no, that's not correct. a local variable isn't assigned value when created. space local variables created moving stack pointer make room them on stack. memo

javascript - Get X numbers from arrayA[5000] into arrayB[] in groups -

i have array this: arraya = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2]; i need separated numbers in groups this: arrayb = [1234,5678,9123,4567,8912]; as can see same arraya in groups of 4 values new numbers. i able make work bug this: arrayb=[undefined1234,undefined5678]; code: for (var = 0; < 20; i++) { if (i/4== n+1){ arrayb[n] = temp; n++; } temp += arraya[i]; } and thats it. understand bug, because of += not sure how other way. this code trick var arraya = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2,3,4]; var arrayb = []; (var x = 0; x < arraya.length; x += 4) { arrayb.push(arraya.slice(x, x + 4).join('')); } console.log(arrayb); update millie has raised fair point. if need numbers in result array, use following statement in for loop arrayb.push(parseint(arraya.slice(x, x + 4).join('')));

javascript - Node.js EventEmitter inheritance not working -

i cannot seem inherit eventemitter in node.js. the lines @on used check @emit console.log inside @on block never executed. confused because got inheritance of eventemitter working in project wont work here. src code in gist. https://gist.github.com/z3t0/8d7a6eca218f35355476 thanks

javascript - Is it a good practice to allow a string or an array as argument to a function? -

here's example of i'm talking about: with grunt, have function: grunt.file.match([options, ] patterns, filepaths) in doc, say: both patterns , filepaths argument can single string or array of strings. so, practice allow different types same parameter? official doc in short, yes. in other languages can overload method different parameters. in javascript, not have luxury, have weak-type declarations. javascript not care pass, job make sure function accepts possible arguments. edit @jwatts1980 suggested, function should flexible enough handle potential arguments. if have parameter called name , should expect null , , chance might have receive array of names , in case might choose iterate on names ( name ) , whatever 1 name .

github - is it possible to connect two portlets in liferay? -

i dont know if i´m right in community. i´m trying evaluate possibilities of liferay . in project want show many sources (like jira , github , nas ) in 1 page in dashboard. question is, possible connect portlets ? for example if i´m clicking on jira -task want see commits github . i want have "search-portlet" can search people. result of search should show me github -commits, jira -tasks,.. user. i dont have experience liferay , has ideas if possible , maybe give me starting advices? thank you! yes, can !! from experience, liferay best option you. liferay portal a portal defined software platform building websites , web applications. modern portals have added multiple features make them best choice wide array of web applications , able communicate between portlet easily. liferay portal overview portlet it liferay plugin project type (i call independent project). in case may dashboard containing sources of jira, , more. should create search po

java - Gradle Hibernate Configuration Requires Mapped Classes -

i'm using gradle manage dependencies hibernate (i using maven), i've encountered strange. when try save trivial instance of annotated class database wind getting mappingexception saying said class not mapped. situation unique because of way i've been storing instances. assume situation this: have annotated hibernate class saved using session entitymanager using saveorupdate() . have persistance.xml, no hibernate configuration files. i'm relying on entitymanager s auto detection of mapped classes feed session can recognized annotated. i'm using hibernate 4.3.8. code worked before switch. method calls take place in transactional context , transaction committed , session flushed. exception: caused by: org.hibernate.mappingexception: unknown entity: com.gmail.sarah.project.rank gradle dependencies: compile "org.hibernate:hibernate-core:4.3.8.final" compile "org.hibernate:hibernate-entitymanager:4.3.8.final" compile "org.hibernate

Change default CMake version, Ubuntu 14.04 -

as far i've understood, need use @ least cmake 3.1 in order use c++11. ubuntu 14.04 comes 2.8.x. i followed guide suggesting 1 should install cmake /opt , have cmake installed /opt/cmake-3.2.1-linux-x86_64 , added /opt/cmake-3.2.1-linux-x86_64/bin path (as first element) in .bashrc. if try apt-get remove cmake process wants remove not cmake ros (so yes, i've stopped ubuntu: upgrading software (cmake) - version disambiguation (local compile) , conclude couldn't use answers) result of cmake --version : cmake version 3.2.1 setting minimum required version 3.1 , running catkin_make in same terminal yields: cmake 3.1 or higher required. running version 2.8.12.2 how can make catkin use new (/correct) version of cmake? two things going on here: according catkin_make file, isn't copying shell environment python subprocess 'cmake' invocation. catkin_make : ... if args.no_color: run_command(cmd, build_path) else: run_comman

winapi - Can non-white-listed APIs in a Win32 library be used in a WinRT app? -

i'm building windows store app in c++ desktop only, , need use win32 api not white-listed. background, only white-listed win32 apis available winrt apps. know win32 libraries can used in winrt apps, question can library contain non-white-listed api calls? matter if library dll or static lib? not going submit app windows store, long app works, i'm not concerned getting approved ms. if can same behavior through supported api i'd recommend that. if not, take @ brokered windows runtime components allow sideloaded windows runtime app call component in desktop environment can use desktop api. if deploy through store app must pass certification , can use or link allowed api. app won't pass certification if contains library references blocked api. if aren't deploying through store passing certification recommended not required. app can link , call api not permitted windows store apps, behavior not guaranteed. functions may not work desired windows store a

javascript external function with event handler to generate DOM elements is not outputting html -

i trying dynamically generate , remove input boxes based on selection. however, have been tweaking code hours cant figure out why it's not generating html elements. <!doctype html><html><head><title> calculator</title> <link rel="stylesheet" href="css/main.css." type="text/css" <script src="js/addinputs.js"></script> <script> function addlisteners() { if (window.addeventlistener) { document.getelementbyid('sel_value').addeventlistener("change", yourselection, false); } function youselection() { // create 3 inputs 3 labels fro array if (document.getelementbyid('sel_value').value == 1) { addinputs(4,panel01);} // create 6 inputs 6 labels array else if (document.getelementbyid('sel_value').value == 2) { addinpu

ios - preferredMaxLayoutWidth not working in Swift? -

Image
i have tried make uilabel width using preferredmaxlayoutwidth no matter won't work. can me? have tries many different combinations make work. @ibaction func addbottomtextbutton(sender: anyobject) { if addbottomtextfield.text.isempty == false { let halfscreenwidth = screensize.width * 0.5 let bottomscreenposition = screensize.width memebottomtext = addbottomtextfield.text fontname = "impact" let memebottomtextcaps = memebottomtext.uppercasestring // --> string! labelbottom.text = memebottomtextcaps labelbottom.textcolor = uicolor.blackcolor() labelbottom.textalignment = .center labelbottom.font = uifont(name: fontname, size: 32.0) labelbottom.sizetofit() labelbottom.userinteractionenabled = true labelbottom.adjustsfontsizetofitwidth = true labelbottom.numberoflines = 1 labelbottom.preferredmaxlayoutwidth = screensize.width labelbottom.settranslatesautoresizingmaskinto

ios - Format String to NSString in swift -

i'm trying set tableviewcell properties different labels. keep getting errors regarding strings. i've started hooking array this. cell.titleviewlabel.text = arraynews[indexpath.row].title however keep getting error cannot assign value of type nsstring value of type string how can format above title nsstring don't error in cellforrowatindexpath? or due else? problem: the root of problem follows: cell.titleviewlabel.text nsstring arraynews[indexpath.row].title string solution: you need cast string nsstring . try following syntax cell.titleviewlabel.text = arraynews[indexpath.row].title nsstring

oauth - Migrating users from Wordpress database to Parse -

a mobile app being built replicate functionality of wordpress site 5,000 registered users. dev team going using parse lot of back-end stuff user management , online/offline content sync. i've done quite bit of searching have found little on topic of migrating users wordpress database parse's. in addition, half of user base registered through wordpress social login. curious if else had undertaken such migration or might have ideas might best start. feel there must faster way of doing hand-coding script somehow scrapes wordpress , social-plugin database user accounts , gracefully recreates them parse framework. thanks in advance!

c# - Finding an instance of a private class in a separate assembly -

in unity project, utilizing networking library which, understandably, keeps track of inbound/outbound traffic. reason, developer decided leave info available in editor, instead of making publicly accessible @ runtime. but, traffic benchmarking, , change code flow @ runtime depending on traffic. using reflection, instance internal class (and private field) keeps track of networked traffic, not resolve because won't same instance actual separate assembly utilizes, value zero. so... there way find valid instance of known class inside assembly project references?

css - flexbox | flex item being pushed out of containing div (off screen) -

Image
i'm using flexbox layout style list of past tasks. task description , time going of variable lengths. everything looks great until task description entered long enough wrap onto second line , 'time' item (on far right of screen) pushed right - off screen - hiding of content. you can see short description displays below, long 1 pushes should '00:08' off screen , task description moves left well!! here's a fiddle code (which below per stackoverflow's rules). if resize pane containing result '00:08' doesn't fall off page move far right. the above screenshot in chrome or safari (the 2 browsers using) when shrinking width of window until description wraps onto second line. i display per first (short description) line if possible! , understand why behaving is. p.s. have tried using floats , using table display layout both of these techniques caused quite few bugs, because of variable length content (so please don't suggest th

multithreading - Peterson's Algorithm with Threads and Linked List (C language) -

i have following situation: first of all, created int linked list (already working, no problems this) , need perform following task: using 2 threads, 1 thread remove first element of list , after same thread must add new element @ end of list (the list follows fifo structure). the second thread same: delete first element , add 1 @ end of list. i need perform operation more once, done using loop. when create thread, use following function: for(i=0, i<num_threads; i++) pthread_create (&thread[i], null, threadbody, (void *) i); in num_threads variable containing number of threads use (in case, 2), , thread declared as: pthread_t thread [num_threads] ; so, questions are: do need perform operations i've meant before (add , delete elements on list) on threadbody function or function empty? in case threadbody function isn't meant operation, how use threads i've created perform operations? done using pthread_join function? another point

How to make a context free grammar for a particular case -

the problem this create cfg generates {a^i b^j: 2i < j + 2 < 3i}. problem there way many cases here. example not work j=1,2,4. j=5,6,7,8,9 need have i=3,3,4,4,4. how handle this, there tricks doing stuff or making harder looks. you're making harder is. coming grammars classic recursive analysis technique. recursion, need ask 2 questions: how next step? how know when i'm done? the second question easy: you've figured out base case aabbb (that is, i=2, j=3 ). no shorter word can part of grammar. now, suppose have longer word, means i must greater 2. how next step? in other words, how find shorter valid word? can remove a (decrement i ), need fix j . inequalities, it's clear j can decremented either 2 or 3 (it's possible both work, 1 of 2 must work). that result in ambiguous grammar, question doesn't grammar needs unambiguous. however, it's easy come unambiguous grammar, based on strategy of resolving decision (two or three) i

javascript - How to get the after question mark value PHP echo -

i need value of add_cart after question mark? echo "<a href='index.php?add_cart=<?php echo $pro_id; ?>' name='shto' class='sp' '><button style='float:right;'>cart</button></a> "; something $value = add_cart; try like: $value = 4544545; //the item number echo "<a href='index.php?add_cart=$value' name='shto' class='sp' '><button style='float:right;'>cart</button></a> "; and in index.php value with: $valuefromaddcart = $_get['add_cart'];

MATLAB: save a class property -

i'd save particular class property disk, while ignoring rest of class properties. think matlab allows saveobj method overridden purpose. however, saves class object property attached. want save property itself, without of class information. i might think suitable method like: classdef myclass properties myprop end methods def b = saveobj(a) b = a.myprop; end def save(a,fname) save(fname,'a.myprop'); end end end but neither of these have desired effect. can me, please? you can overload save function without having go through saveobj : classdef myclass properties myprop end methods function [] = save(a,fname,varargin) myprop = a.myprop; %#ok<prop,nasgu> save(fname,'myprop',varargin{:}); end end end then on command window: >> foo = myclass(); >> foo.myprop = 4; >> foo.save

Java String- How to get a part of package name in android? -

its getting string value between 2 characters. has many questions related this. like: how part of string in java? how string between 2 characters? extract string between 2 strings in java and more. felt quiet confusing while dealing multiple dots in string , getting value between 2 dots. i have got package name : au.com.newline.myact i need value between "com." , next "dot(.)". in case "newline". tried pattern pattern = pattern.compile("com.(.*)."); matcher matcher = pattern.matcher(beforetask); while (matcher.find()) { int ct = matcher.group(); i tried using substrings , indexof also. couldn't intended answer. because package name in android varies different number of dots , characters, cannot use fixed index. please suggest idea. as know (based on .* part in regex) dot . special character in regular expressions representing character (except line separators). make dot represent dot need escape it. c

regex - R: (*SKIP)(*FAIL) for multiple patterns -

given test <- c('met','meet','eel','elm') , need single line of code matches e not in 'me' or 'ee'. wrote (ee|me)(*skip)(*f)|e , exclude 'met' , 'eel', not 'meet'. because | exclusive or? @ rate, there solution returns 'elm'? for record, know can (?<![me])e(?!e) , know solution (*skip)(*f) , why line wrong. this correct solution (*skip)(*f) : (?:me+|ee+)(*skip)(*fail)|e demo on regex101 , using following test cases: met meet eel elm degree zookeeper meee only e in elm , first e in degree , last e in zookeeper matched. since e in ee forbidden, e in after m forbidden, , e in substring of consecutive e forbidden. explains sub-pattern (?:me+|ee+) . while aware method not extensible, @ least logically correct. analysis of other solutions solution 0 (ee|me)(*skip)(*f)|e let's use meet example: meet # (ee|me)(*skip)(*f)|e ^ # ^ meet

How do I call the "writing voice" which is on the google android keyboard? -

the new google android keyboard, comes button activate "writing voice." how enable "writing voice" of new google android keyboard click of button (without having create new window "writing voice", use exists in google android keyboard)? you wouldn't. if want voice input, use texttospeech api. there's no way sure google default keyboard available (some devs such samsung replace keyboard own). otherwise let user activate default keyboard's voice input if wishes.

python - Matplotlib Histogram not equal data sets -

Image
i create histogram use following. know because lengths of menmeans , womenmeans not equal. if not hard coding list, , possible wanted add more list later provide more bars how this? best way scale graph knowing bars not have sets of values. import numpy np import matplotlib.pyplot plt fig = plt.figure() ax = fig.add_subplot(111) ## data n = 5 menmeans = [18, 35, 30, 35, 27] ### len=5 womenmeans = [25, 32, 34, 20, 25,42] ### len =6 ## necessary variables ind = np.arange(n) # x locations groups width = 0.35 # width of bars ## bars rects1 = ax.bar(ind, menmeans, width, color='black') rects2 = ax.bar(ind+width, womenmeans, width, color='red') # axes , labels ax.set_xlim(-width,len(ind)+width) ax.set_ylim(0,45) ax.set_ylabel('scores') ax.set_title('scores group , gender') xtickmarks = ['group'+str(i) in range(1,7)] ax.set_xticks(ind+width) xticknames = ax.set_xticklab

java - How to override the JPopupMenu method show? -

Image
my goal highlight jlist item after rightclick show jpopupmenu.. read advice overriding method show way.. in case declare jpopupmenu @ beginning of class jpopupmenu popupmenu = new jpopupmenu(); jmenuitem masterlist,settings; then have method set menuitems public void setpopupmenu(int depth//ignore var){ //popupmenu = new jpopupmenu(); popupmenu.removeall(); masterlist = new jmenuitem("masterlist"); settings = new jmenuitem("settings"); //action marsterlist masterlist.addactionlistener(new actionlistener(){ //stuff here } }); //action settings settings.addactionlistener(new actionlistener(){ //stuff here } }); popupmenu.add(masterlist); popupmenu.add(settings); } and list in different method list.setselectionmode(listselectionmodel.single_selection); list.setlayoutorientation(jlist.horizontal_wrap); li

r - Replace NaNs in dataframe with values from another dataframe based on two criteria -

hi first post stackoverflow. have been trying solve problem, have not been able figure out answer alone nor find other posts answer question. i need replace missing values dataset values dataframe; however, gets tricky values need match have factor associated them, matching dates. here simplified version of first dataframe: > df1 date site value 1991-07-08 22.5 1991-07-09 nan 1992-07-13 b 23.1 1992-07-14 nan 1993-07-07 b 27.3 here simplified version of second dataframe: > df2 date site value 1991-07-08 22.5 1991-07-09 nan 1992-07-14 nan 1991-07-08 b 10.6 1992-07-09 b 23 1992-07-14 b nan 1992-07-09 c 11.3 1992-07-14 c 12.4 what want when there missing value replace value b (with same date), , if there not value b, using value of c (with same date). thus, resulting dataframe this: > dffin date site

javascript - What is the "scope" that gets passed to a $scope.$watch function? -

$scope.$watch( function(scope) {return scope.anumber;}, function(newvalue, oldvalue) {alert("value changed");} ); }); what "scope" $scope.$watch takes in first function? (everything after info tangentially related). know "scope" without $ represent variable, in directive link function (scope, element, attributes, ngcontroller), etc. have no idea "comes from" here. it's connected controller's $scope, how? also, official doc states "the watchexpression called on every call $digest() , should return value watched. (since $digest() reruns when detects changes watchexpression can execute multiple times per $digest() , should idempotent.)" what's advantage doing return function rather saying $scope.valuetowatch (which doesn't work me, have seen people it). plunk working watch hell of it, don't need q: http://plnkr.co/edit/y86wr93xliao3wtwvst8?p=preview for reading same q later: article on $watch:

java - Android how to initiate a BroadcastReceiver when phone restarted -

how can initiate broadcastreceiver whenever user phone has been restarted. , if user kill app, can broadcastreceiver keep running in ground ? i created parsepushbroadcastreceiver receive push notification parse.com. app receive notification if user opens app. public class myparsereceiver extends parsepushbroadcastreceiver { @override public void onreceive(context context, intent intent) { super.onreceive(context, intent); log.i(tag, "onreceive called"); if (intent == null) { log.e(tag, "receiver intent null"); } else { // parse push message , handle accordingly log.d(tag, "receiver intent data => " + intent.tostring()); } }//end onreceive @override public void onpushopen(context context, intent intent) { ... my manifest: <activity android:name=".splashactivity" android:label="@string/app_name"