Posts

Showing posts from August, 2010

java - Illegal access error when initializing SparkConf - MLLIB -

team, i'm playing around spark , mllib. installed scala , spark, versions mentioned below. scala - 2.11.7 spark - 1.4.0 (did mvn package -dscala-2.11) i'm trying run java classification, clustering examples came along documentation. however, i'm getting illegal access error when i'm trying initialize sparkconf object. i'm trying basic : > sparkconf conf = new sparkconf().setappname("svm classifier example"); > sparkcontext sc = new sparkcontext(conf); please find error trace below : exception in thread "main" java.lang.illegalaccesserror: tried access method scala.collection.mutable.hashset.()v class org.apache.spark.util.utils$ @ org.apache.spark.util.utils$.(utils.scala:195) @ org.apache.spark.util.utils$.(utils.scala) @ org.apache.spark.sparkconf.(sparkconf.scala:58) @ multinomiallogisticregressionexample.main(multinomiallogisticregressionexample.java:15) how go this? did googling , couldn'

javascript - Is there a way to detect changes within the same route? -

with iron router, have following route set up: router.route('/:cat', { name: "goods", waiton: function() { session.setdefault('limit', 20) var limit = session.get('limit') || 20 meteor.subscribe('goods', this.params.cat, limit) } }) the idea user can press bunch of buttons change cat (egory), filtering out data remaining on same route. classic stuff. right sets default limit of 20 , user scrolls down, increased. if clicks button change category, doesn't make sense instantly load 100 new items, set limit 20 again. problem is, can't think of way that. removing setdefault use session.set won't work. can think of right logging cat in session , use check if category has been changed, hoping there better way. how using template manage state (instead of sessions , route. for example, using reactivate variable (reactive-var package), , passing category through route template.

c# - AdoNetAppender writes to wrong Azure database -

i'm using log4net log sql database in azure. i've got config file setup , working properly. log data getting written. application imports, translates , loads unique set of data each of our customers. in azure create new database each customer. in logging utility have following method should set logging connection string proper client database: private static void setdbconnection(string connectionstring) { var appender = ((adonetappender)(log.logger.repository.getappenders()[0])); appender.connectionstring = connectionstring; appender.activateoptions(); } this seems working, however, consitently getting logs client in database client b, , client c , client d , , forth , around. one thing application multi-threaded, , noticing instance, of client b's data in thread 20, of client c's data in thread 8 etc. looks consistent across databases. my main question is, how can ensure client a's logs client a's database? i inherited application, , i

The maximum number of element in a list when generate all the permutations of a list in Python -

i using itertools generate permutations of python list import itertools lt = [0,1,2,3] print list(set(itertools.permutations(lt))) it works when length of list less 7, when length of list grater 7 ([0,1,2,3,4,5,6,7]), takes lot of time generate permutations, , program frozen. wondering if there way generate permutations big list, thank you! itertools return generator in ns time. it's slow conversion set() . 8! >>> lt = [i in xrange(8)] >>> %timeit itertools.permutations(lt) 1000000 loops, best of 3: 547 ns per loop >>> %timeit set(itertools.permutations(lt)) 100 loops, best of 3: 13.4 ms per loop >>> %timeit list(set(itertools.permutations(lt))) 10 loops, best of 3: 19.1 ms per loop >>> %timeit list(itertools.permutations(lt)) 100 loops, best of 3: 4.9 ms per loop 9! = 362880 >>> lt = [i in xrange(9)] >>> %timeit itertools.permutations(lt) 1000000 loops, best of 3: 557 ns per loop >

c++ - Dynamic Programming : Timus Online Judge 1119 Metro -

i trying problem http://acm.timus.ru/problem.aspx?space=1&num=1119 on timus online judge. however, strange reason recursive function doesn't work. if print final value returned prints : "-nan". when print its's rounded form prints garbage value. #include <iostream> #include <cstring> #include <cmath> #define min(x,y) ((x<y) ? (x) : (y)) using namespace std; int x,y; float dp[1001][1001]; //for memoization bool d[1001][1001]; // storing whether diagonal movement possible or not float solve(int x,int y) { if (dp[x][y]!= -1.0) return dp[x][y]; if (x == 0 && y == 0) return (dp[x][y] = 0.0); if (x == 0 ) return (dp[x][y] = y*100); if (y == 0) return (dp[x][y] = x*100); float ret; float r1,r2,r3; r1 = 100.0 + solve(x-1,y); r2 = 100.0 + solve(x,y-1); ret = min(r1,r2); if (d[x][y]) { r3 = solve(x-1,y-1); r3 = r3 + 141.42; ret = min(r

android - NoActivityResumedException when testing activity and fragment -

i have 1 activity on button and, inside activity, added fragment user can choose videos, , then, click on button on activity, , goes activity. i'm testing espresso, , when select videos , try click on button, see this android.support.test.espresso.noactivityresumedexception: no activities in stage resumed. did forget launch activity. (test.getactivity() or similar)? here test public void testvideosselecttomix(){ selectvideoat(0); selectvideoat(1); // fails @ line: commit button on activity onview(allof(withid(r.id.commit))).perform(click()); onview(withtext(r.string.title_video_merge_fragment)).check(matches(isdisplayed())); } i think may related listener on commit button, calls finish(); why work on emulator/device , not on tests?

ios - Get black & white image from UIImage in iPhone SDK? -

Image
i want convert image pure black & white. tried , got result left image have attached , result should right image have attached according requirements of application. i have used lots of cifilter ( cicolormonochrome, cicolorcontrols, ciphotoeffecttonal etc.) none of working. please check below code , attached result of images. - (uiimage *)imageblackandwhite { ciimage *beginimage = [ciimage imagewithdata: uiimagejpegrepresentation(self.captureimage.image, .1)]; //ciimage *beginimage = [ciimage imagewithcgimage:self.cgimage]; ciimage *output = [cifilter filterwithname:@"cicolormonochrome" keysandvalues:kciinputimagekey, beginimage, @"inputintensity", [nsnumber numberwithfloat:1.0], @"inputcolor", [[cicolor alloc] initwithcolor:[uicolor whitecolor]], nil].outputimage; cicontext *context = [cicontext contextwithoptions:nil]; cgimageref cgiimage = [context createcgimage:output fromrect:output.extent]; uiimage *newima

java - Sorting int field of the wrapper class spring -

i have navigation class dynamically creating navigation having 2 tables folder(it directory contains files) , content(it files or pages render content on public site). have created navigation class in having wrapper class merging fields of content folder. have tried using @orderby , @ordercolumn came know work collections. list<folder> folder = folderrepository.findallbynavdepthlessthanorderbynavdepthasc(3); here sorting navdepth(this column belongs folder entity) want sort navorder(this column belongs content entity) @service public class navigationservice { @qualifier("jdbcmysql") private jdbctemplate jdbctemplate; private folderrepository folderrepository; private folderservice folderservice; @autowired public navigationservice(jdbctemplate jdbctemplate, folderrepository folderrepository, folderservice folderservice) { this.jdbctemplate = jdbctemplate; this.folderrepository = folderrepositor

html - How to fetch textbox value in radio button value in php -

i have 3 radio buttons in form. 2 of them have static values , 3rd 1 has radio button should have same value number entered in textbox. able fetch first 2 radio buttons values using $_post method on next page 3rd radio button, value null. please me textbox value 3rd radio button. code : <input type="radio" name="radio" value="500000" checked="checked" />purchase more 5 lakhs <input type="radio" name="radio" value="2000000" />purchase more 20 lakhs <input type="radio" name="radio" value="" />purchase more : <input type="text" name="radio" /> if want solve using php, try approach: <input type="radio" name="radio" value="500000" checked="checked" />purchase more 5 lakhs <input type="radio" name="radio" value="2000000" />purchase more 2

r - How to convert my spatiotemporal NetCDF data to spatial data? -

i beginner in r. , totally struck problem. can download netcdf file link below take look. https://drive.google.com/file/d/0byy3oaw62eshbkf6vwnfukrymmm/view?usp=sharing ^this netcdf atmospheric data file 8 variable , 8 dimension. here,my variables of interest are: timsid number of site (its include urban site, rural site etc.) urban :: number of urban sites [urban 3 row 250 column matrix. row1 number of urban sites , row2 latidude, row 3 longitude.] time :: data collected 1 march 2012 may 2012 [encoding 'time' yyyymmddhh] pm10 :: hourly particulate matter concentration measured @ every station of every site i need work these 4 variables large data set. i have separate data of pm10 values @ urban sites "1 march 2012". (actually need find in timsid variable sites urban sites , match corresponding pm10 value urban sites 01 march 2012.) for example, in timsid, different type of sites exist urban, rural etc named 111121,111122,111123,111124 urban s

How to group an array of variables based on flags assigned to them with minimal code in C# -

i have array has 4 elements example : int[] = new int[5]; the value : a[0] = 10,a[1]=5,a[2]=15,a[3]=10,a[4]=0; i have flag , public bool[] flag = new bool[4]{false,false,false,false}; based on need assign above values variable named b[5] . if flag false ,it add existing values of b , else reset values of a b . i have tried following code seems lengthy count[0]=20,count[1]=20;count[2]=20;count[3]=20; flag[0]=true,flag[1]=true,flag[2]=true,flag[3]=false; void display(int[] count,int[]flag) { if (flag[0] == true) { resetcount[0] = count[0]; } if(flag[1]==true) { resetcount[1] = count[1]; } if (flag[2] == true) { resetcount[2] = count[2]; } if(flag[3]==true) { resetcount[3] = count[3]; } if (flag[0] == false) { resetcount[0] += count[0]; } if (flag[1] == false) { resetcount[1] += count[1]; } if (flag[2] == false) { res

How to calculate percentage in c# -

i trying calculate percentage of given long value. following code returning 0 . how calculate percentage in c# long value = (fsize / tsize) * (long)100; here fsize , tsize long values. try this var value = ((double)fsize / tsize) * 100; var percentage = convert.toint32(math.round(value, 0));

sql - Avoid indexes for DML in a particular procedure (MySQL) -

i have 1 procedure multiple update statements(dmls). so there way avoid index particular table improve performance of update statements. you can use ignore index in dml inside procedure. otherwise, cannot particularly procedure. further syntax details on update usage docs

log4j2 - Log files not getting cleared of old log entries during daily rollover -

we using log4j2.3 on apache tomcat. upgraded log4j1.2 log4j2.0. working fine except 1 issue. use rollingfile appender rollover log files daily. files rollover right after midnight expected, current log file not cleared of log entries previous day. end log files keep growing in size , contain entries previous days well. this our rolling file appender configuration: any ideas? found following jira appeared describe problem seeing well: https://issues.apache.org/jira/browse/log4j2-904?jql=project%20%3d%20log4j2%20and%20resolution%20%3d%20unresolved%20order%20by%20priority%20desc also, adopted solution described in following question slight change overwrite file after rollover , has fixed problem: log4j2 rollingfile appender - add custom info @ start of each logfile

input - Inputting a smaller size vector to a Verilog Module -

i wondering happen if created module size vector declaration input, , fed smaller sized vector while instantiating later. example, create module so: module example(input, ....); input[15:0] input; ... endmodule and instantiate later, pass smaller vector size input so: wire[11:0] foo; example bar(foo, ....); so happens input in case? since input supposed 16 bits, 0 pad foo on left? the default value of wire ' z'(high-impedance) . since 4 bits of inputs not connected remaining input bits [12:15] takes default value in condition remaining bits connected driving input. eliminate these kind of errors in larger rtl designs running static tool on code recommended.

ssl - Websphere application server not supporting Deutsche Telekom Root certificate -

we consuming xml different datasources. http , https. https verisign certificates working without issues. however, urls deutsche telekom root certificate not working. web sphere application server having default root certificate generated while creating profile. have add other special certificate make deutsche telekom root certificate work ? kind of appreciated. i don't think know enough setup yet. default websphere creates it's own root certificate, nothing trust verisign certificate. wonder using make https connection? manages bypass websphere socket factories , using jre's default, , cacerts file trust. verisign certs in cacerts file there no deutsche telekom far can tell. or verisign certificate added websphere truststore @ time? typically have establish trust make websphere trust server. retrieving certificate port way that. alaine

c++ - How to add additional dll search directories for native unit tests? -

i'm working on big code base has many solutions , many more projects. when write unit tests depend on number of dlls being present built other solutions different output folders current solution. i add build steps copy required dll's current solution's output folder can found when run unit tests. can end in lot of wasted space , confusion duplicate dlls , master copy of each dll 1 should go installer. is there better way of adding additional search directories? i considering having test_module_initialize adddlldirectory() , marking dll's delay loaded when load added dll directory searched. but, don't think works have mark dll's delay loaded in exe. but, exe testrunner out of control. it may not best method, since you're using visual studio 2013, should test settings control deployed when run tests. inside of test settings can specify files or folders in deployment section allow select files outside of current solution. can create mult

ios - Unpinning HomeKit accessory -

Image
the homekit accessory simulator wee little botton allows unfair device. given it's accessory simulator presume there hardware programming specifications allow write un-pairing function. however, make sense implement part of homekit framework , allow client developers via homescontroller class (and derivates). --> short version: is there method in hmservice or hmcharacteristic or in homekit framework unpair characteristic/service home? service or characteristic can not unpair, practically not require do. 1 can unpair accessory home. you can call method of hmhome class remove/unpair accessory. - (void)removeaccessory:(hmaccessory *)accessory completionhandler:(void (^)(nserror *error))completion; and pairing - reset button given in homekit accessory simulator option, can unpair accessory ios app. reset may require if don't have same device @ time or homekit configuration reseted settings in ios app.

winapi - returning a buffer in c -

i have couple of questions. need write program(winapi) create buffer of fixed size, append strings , returns it. 1. possible "main" return buffer? 2. how should create, append string , return it? not new c, have little experience buffers , strings handling. thank you! is possible "main" return buffer? no , shouldn't. what should main() return in c , c++? how should create, append string , return it? char astring[fixed_size]; memset(astring, 0, sizeof astring); strcpy(astring, "this string");

Create the new hash from the old one with Ruby -

i have simple_hash: old_hash = {"new"=>"0"} i wan convert new format: new_hash = old_hash.keys.each |key| hash = hash.new hash[key] = {count: old_hash[key]} hash end but code returns me: ["new"] instead of: {"new"=>{:count=>"0"}} and question why? you confusing syntax of block of method. in code, new_hash gets value of old_hash.keys , not want. a little modification works: new_hash = hash.new old_hash.keys.each |key| new_hash[key] = {count: old_hash[key]} end

group - Create sequence based on grouping variable in R -

this question has answer here: add index contiguous runs of equal values 3 answers i'm looking way create sequence of numbers ($c) ascend every time string changes in($a). contingent on grouping variable ($b). example: a b c a1 1 1 a1 1 1 a1 1 1 a10 1 2 a10 1 2 a2 1 3 a1 2 1 a20 2 2 a30 2 3 or dplyr df %>% group_by(b) %>% mutate(c = match(a, unique(a))) # source: local data frame [9 x 3] # groups: b # # b c # 1 a1 1 1 # 2 a1 1 1 # 3 a1 1 1 # 4 a10 1 2 # 5 a10 1 2 # 6 a2 1 3 # 7 a1 2 1 # 8 a20 2 2 # 9 a30 2 3 with base r df$c <- with(df, ave(as.character(a), b, fun=function(x) match(x, unique(x))))

ios - method returns before completionhandler -

i developing networkutil project, need method gets url , returns json received url using nsurlsessiondatatask json server. method following: + (nsdictionary*) getjsondatafromurl:(nsstring *)urlstring{ __block nsdictionary* jsonresponse; nsurlsession *session = [nsurlsession sharedsession]; nsurlsessiondatatask *datatask = [session datataskwithurl:[nsurl urlwithstring:urlstring] completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) { jsonresponse = [nsjsonserialization jsonobjectwithdata:data options:0 error:nil]; nslog(@"%@", jsonresponse); }]; [datatask resume]; return jsonresponse; } the problem completionhandler inside method , method itself run on different threads , in last line jsonresponse nil how should set jsonresponse returned json urlstring ? best practice issue? block running in nsurlsession running on different thread - method doesn't wait block finish. you have 2 option

javascript - Convert data value to decimals? -

i have function argument called value . used pass integer value of value array. i want take value returns , set 2 decimal places using tofixed(), not sure @ point can this. function getarrayofitems(value, id, title) { return { size: value }; }; var thedata = [ getarrayofitems(data.average, 'average', 'average'), getarrayofitems(data.smallest, 'smallest', 'smallest'), getarrayofitems(data.largest, 'largest', 'largest') ]; it passed object such var options = { amount: value, id: id, title: title }; so value determined value of data.average etc, returns 4 or 5 digit value. want parse value 2 decimal places. possible? use .tofixed(2) here getarrayofitems(data.average.tofixed(2), 'average', 'average'), getarrayofitems(data.smallest.tofixed(2), 'smallest', 'smallest'), getarrayofitems(data.largest.tofixed(2), 'largest', &

javascript - Print " Read more .. " inside a div after the content exceds fixed height -

as question indicates below html code :- html: <div class="compresscontent"> //the main div <div class="text"> // lets max width 400px .text <p style=""> <b style=""> // content should not exceed after height 400px , should display "read more .. " </b> </p> </div> </div> css: .compresscontent { position: relative; font-family: sans-serif; display: block; width: 244px; height: auto; overflow: hidden; } .compresscontent .text { color: #333; padding: 20px; width: 204px; height: 400px; overflow: hidden; background: #e0e0e0; font-size: .95em; li

javascript - Showing current location with Google Places -

i used sample code below show autocomplete search google places. defaults current location sydney, australia. https://developers.google.com/maps/documentation/javascript/examples/places-searchbox i gathering user location latitude , longitude: schema.rb create_table "users", force: :cascade |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.float "latitude" t.float "longitude" end how modify assume part (not sure why there 2 sets of coordinates there) var defaultbounds = new google.maps.latlngbounds( new google.maps.latlng(-33.8902, 151.1759), new google.maps.latlng(-33.8474, 151.2631)); map.fitbounds(defaultbounds); to default user's current location? i have built similar solution in rails. make ajax request method in rails controller , return user record json can used setup our map. have adapted code fit exact needs. let's start set

r - `quantmod`'s `getSymbols.FRED` not working as expected -

this question has answer here: quantmod error 'cannot open url' 4 answers the following lines quantmod 's manual (p54): library(quantmod) getsymbols('cpiaucns',src='fred') returns: error in download.file(paste(fred.url, "/", symbols[[i]], "/", "downloaddata/", : cannot open url 'http://research.stlouisfed.org/fred2/series/cpiaucns/downloaddata/cpiaucns.csv' how fix this? (using latest version of both r , quantmod ) use https:// url instead.

Template Haskell: Is there a function (or special syntax) that parses a String and returns Q Exp? -

i trying learn bit of template haskell , quasi quotation, , looking function takes string , parses q exp , type is: string -> q exp tried searching hoogle, results saw had lifting string literals q exp , , closest found language.haskell.th.dyn quite want, single variable. are there other options? e.g. special syntax? i'm in process of familiarizing myself [||] , $() , maybe there purpose too? an example of how imagine work: runq (parse "(1+)") == infixe (just (lite (integerl 1))) (vare ghc.num.+) nothing also, aware of this runq [| (1+) |] == infixe (just (lite (integerl 1))) (vare ghc.num.+) nothing but wont work variable strings because -- understandably -- string inside taken literal. runq [| "(1+)" |] == lite (stringl "(1+)") edit (2015-07-25): i've started using haskell-src-meta , , seems work far. take quite bit of time cabal install (about 10 minutes on machine). shame, package rather small, , if install quick

Dart- How to convert map data into form by angular dart interface? -

i have map data following: { "recipeid" :"000682", "recipename" :"my favaorite one", "updateuser" :"tek" } how should convert map form including label , text input, example, label (key) : text input(value) - recipeid : _______________ - recipename : _______________ - updateuser : _______________ i tried following method, seems fail. <span ng-model="selectedrecipe"> <form ng-repeat="items in selectedrecipe"> <label>items[keys]</label> <input type="text" ng-model="items[values]"></input> </form> </span> assuming selectedrecipe map<string,string> , , workaround this issue , add getter access keys of map iterable : get selectedrecipekeys => selectedrecipe.keys; and then, can use in ng-repeat way: <span ng-model="selectedrecipe"> <form ng-repeat=

python - What's causing this SWIG syntax error? -

error message: error: syntax error in input(1) my swig file: %module interfaces %{ #include <vector> #include <list> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/linestring.hpp> typedef boost::geometry::model::d2::point_xy<double> point; typedef boost::geometry::model::polygon<point, true, false> polygon; %} %include "std_vector.i" %template(multipolygon) std::vector<polygon>; %template(pgon) polygon; if comment out last line, compiles // %template(pgon) polygon; i've been re-reading swig section on templates , can't understand @ what's wrong. doing wrong , how fix it? even though polygon typedef or alias specialization still need use %template actual template care about, e.g.: %template(pgon) polygon<point, true, false>; you'll need show swig enough

angularjs - Angular: broadcast event from service -

i create custom event in angular. goal event broadcast service , must catched in controller. i have in service : function dosomething() { // something... $rootscope.$broadcast("bced"); $rootscope.$emit("emitted"); console.log('event'); } and controller : $rootscope.$on("bced",function(){ console.log("catched"); }); $rootscope.$on("emitted",function(){ console.log("catched"); }); $scope.$on("bced",function(){ console.log("catched"); }); $scope.$on("emitted",function(){ console.log("catched"); }); but can't catch events in controller. console.log('event') shown can't catch events. explain me how please? $rootscope correctly declared in service , in controller. checkout working demo: var app = angular.module('core', []); app.service('someservice', function($timeout, $r

Why do phpinfo() and the php command show different .ini file paths? -

i have spend time trying figure out why setting php.ini wasn't correctly loading, when know sure have changed in file. after trying out old <?php phpinfo(); ?> code through php file, opposed reading output php -i command in console, turns out paths different. phpinfo() output: +------------------------------------+--------------------------------+ + configuration file (php.ini) path + /etc/php5/apache2 + +------------------------------------+--------------------------------+ + loaded configuration file + /etc/php5/apache2/php.ini + +------------------------------------+--------------------------------+ php -i | grep "php.ini" output: configuration file (php.ini) path => /etc/php5/cli loaded configuration file => /etc/php5/cli/php.ini but why happen, why there 2 configurations, , why these 2 environments using separate ones? also, shouldn't php command same 1 apache2 using when executes scripts, , therefore

sql - What is it called when there are two columns in a table that are individually unique? -

as question asks i'm wondering call when row uniquely identified 2 separate columns. i apologize lack of formatting, here goes: columna: 1,2,3,4,5 columnb: a,b,c,d,e columnc: 1,2,1,2,1 columnd: a,a,b,b,a so both column , column b each individually primary keys? don't think correct, call in terms of "keys"? if mean every row has unique value , every row has unique b value each of them "superkey". (actually, sets {a} , {b}.) so answer is, table has 2 one-column superkeys. but according data no smaller set of columns of either superkey superkey, each "candidate key". (the smaller set {}, it's not superkey given data.) so here equivalent answer is, table has 2 one-column candidate keys. a base table , can hold example data in 5nf. there no benefit in decomposing other tables. there tradition pick candidate key "primary key". each other 1 "alternate key". not particularly helpful tradition. in

php - Do not update with empty vars on UPDATE statement -

i trying run sql update dont want update when post vars empty. code run : require '../includes/db.php'; $settings_owner = ( isset($_post[wb_owner_field]) ? $_post[wb_owner_field] : false ); $settings_title = ( isset($_post[wb_title_field]) ? $_post[wb_title_field] : false ); $settings_description = ( isset($_post[wb_descr_field]) ? $_post[wb_descr_field] : false ); $settings_keywords = ( isset($_post[wb_keywd_field]) ? $_post[wb_keywd_field] : false ); $settings_id = ( isset($_post[wb_id]) ? $_post[wb_id] : false ); try { $sql = "update website set website_owner = '$settings_owner', website_title = '$settings_title', website_description = '$settings_description', website_keywords = '$settings_keywords' _id = '$settings_id' "; // prepare statement $stmt = $conn->prepare($sql); // execute query $stmt->execute(); // echo message update succeeded echo $stmt->rowcount() . " r

javascript - Canvas disappearing -

i've written simple script in js. when put hit html document (at bottom of body tag), works fine. when try put external document , link it, script runs canvas element disappears (just checked: works when put script in bottom, not in head tag). version works: var c = document.getelementbyid("canvasid"); var ctx = c.getcontext("2d"); var text = "nazwa pomiaru"; var boxwidth = 200; var boxheight = 200; var minvalue = 0; var maxvalue = 100; var midvalue = (math.abs(minvalue) + math.abs(maxvalue))/2; var unit = "%"; var indicwidth = 50; var indicheight = 0.6 * boxheight; var textposition = 0.875; var leftmargin = 0.375; var topmargin = 0.15; var bottommargin = 0.75; var value = math.floor(math.random() * 101); var warningtop = 90; var dangertop = 95; var warningbottom = 10; var dangerbottom = 5; var thresholdtrasparency = 0.6; var strokecolor = "

unix - To count quickly until first match and stop in megastring -

i want count number of characters until pattern 030 in megarow (do not read data forward point) such not read whole megarow in in memory. should return 28. megastring data 48000000fe5a1eda480000000d00030001000000cd010000020000000000000000000000000000000000000000000000000000000200000001000000ffffffff57ea5e55ff640c00585e0000fe5a1eda480000000d00030007000000cd010000010000000000000002000000000000800000000000000000000000 my initial idea split @ first instance of 030 did not succeed this. not familiar split command's capability read until end of pattern. how can count until first match? if megarow in file named megarow_file following: #!/bin/bash input=megarow_file search_string="030" comp_string="" while ifs= read -r -n1 char char_count=`expr $char_count + 1` comp_string="${comp_string}${char}" comp_string_length=${#comp_string} if [ $comp_string_length -eq 3 ]; # echo comparing value $comp_string

javascript - Protractor ElementArrayFinder.filter() running only once? -

i having trouble filtering elementarrayfinder of <tr> elements more once in page object. second filter being called right after first one. in following code, first verifying number in table, , filtering again click on it. reason don't combine these because in functions rely on parameter batchnumber of function, , different. filter: function verifybatchinlist(batchnumber){ batch_list_table.filter(function(elem, i){ return elem.element(by.xpath('./td[1]')).gettext().then(function(text){ text = text.trim(); return text === batchnumber; }); }).then(function(results){ if(results.length < 1){ throw new error('could not find batch "'+batchnumber+'" in batch list'); } }); } function editbatch(batchnumber){ selectbatch(batchnumber); edit_button.click(); //this never happens } function selectbatch(batchnumber){ batch_list_table.filter(function(elem,

compiler construction - Pretty printing type of values in llvm pass -

i trying print type , name of values used inside loop follows: (value->gettype())->print(cout); errs() << " type: " << cout.str() << " "; errs() << " name: " << (value->getname()) << "\n"; i following output: type: i32* name: sum type: [25 x %struct.book]* name: books is possible pretty print type in way used in program? instance, as: type: int name: sum type: struct book name: books you should write own function. example, see original function typeprinting::print .

c# - Why do I get a ContentLoadException in Monogame? -

i try load picture named kodo.jpg. made copy of picture in content folder. public texture2d kodo; content.rootdirectory = "content"; kodo = content.load<texture2d>("kodo"); in last line error contentloadexception. why? right-click on picture-file, go quick properties , set: copy output directory.

eclipse - R cannot be resolved - Android error -

i downloaded , installed new android sdk. wanted create simple application test drive it. the wizard created code: package eu.mauriziopz.gps; import android.app.activity; import android.os.bundle; public class ggps extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } } but eclipse gives me error r cannot resolved on line setcontentview(r.layout.main); why? ps: have xml file named main.xml under res/layout/ . after tracking down problem well, found note in android documentation: http://source.android.com/source/using-eclipse.html *note: eclipse likes add "import android.r" statement @ top of files use resources, when ask eclipse sort or otherwise manage imports. cause make break. out these erroneous import statements , delete them.* while going throug

How to create array of the numbers in the loop in python -

i created while loop that's random each time run , need save values of x , y arrays. don't know how because values different each time run code. have far import numpy np x = 5 y = 5 while true: = np.random.rand(1) print x if < .5: x = x + 1 y = y - 1 print x print y if > .5: y = y + 1 x = x - 1 print x print y if x == 0: print x break if y == 0: print y break you can create empty list each 1 , append new values go. for example: import numpy np x = 5 xs = [] y = 5 ys = [] while true: = np.random.rand(1) print x if &

cassandra - Chunked data writes with the Datastax Java driver -

when using astyanax client library cassandra there's chunked object store feature storing large files. can't find documentation or examples related datastax driver shows can store large files astyanax (chunked , multiple threads). can done datastax driver , in such case, how? the answer no. in end i've implemented own chunked persister on top of datastax driver runs own 10 threads executor , split/merge objects on save , get.

To open Vim in ":" mode and die after enter -

command vim +"%s/fafa//gn" /tmp/1 which shows count correctly opens vim (not wanted). want use vim computation, although know inefficient. pseudocommand vim +"%s/fafa//gn" +"q" /tmp/1 but not show count, dies. think there should sort of conditional operator, instance and. how can show count in ":" mode , die after user pressing enter? you can combine commands in command mode pipes, similar how doing multiple command line arguments. such, try this: vim +"%s/fafa//gne|exec getchar()|q" /tmp/1 without bit in middle, same original example. however, exec getchar() command bit of vimscript -- how used here -- waits keyboard input, doesn't exit immediately.

/bootstrap/ directory doesn't exist. Where do I run `npm install`? (Part of bootstrap tutorial.) -

i following this bootstrap tutorial: installing grunt to install grunt, must first download , install node.js (which includes npm). npm stands node packaged modules , way manage development dependencies through node.js. then, command line: install grunt-cli globally npm install -g grunt-cli. navigate root /bootstrap/ directory, run npm install. npm @ package.json file , automatically install necessary local dependencies listed there. when completed, you'll able run various grunt commands provided command line. regarding part in bold: navigate root /bootstrap/ directory, run npm install i can't navigate /bootstrap/ directory. $ cd /bootstrap/ -bash: cd: /bootstrap/: no such file or directory i installed node.js. tried running npm install (with , without sudo ) in bootstrap-3.3.5-dist directory, , got error: $ npm install npm err! install couldn't read dependencies npm err! darwin 13.4.0 npm err! argv

Angularjs: Should I use mocks when Unit Testing a REST API dependent app? -

there quite bit of ambiguities i've found when researching topic of mocks, stubs, & spies within angularjs unit testing. i need straightforward answer how , why supposed implement unit tests proper way (if there one) on rest-dependent application. do have use mocks when testing, or stubbing/spying suitable? is there difference between spying , stubbing? when mock http request, need separate mock function using particular http request? how modularized tests need be? take unit test example, using karma-jasmine testing framework: describe('put request & edituser() test', function() { beforeeach(function() { $httpbackend.whenput('http://localhost:24149/users/:id'); }); it('should put request server', function() { $httpbackend.expect('get', 'http://localhost:24149/users').respond(); $scope.userslist[0] = user; $scope.selecteduser = 0;

reporting services - TFS 2013: Uploading new report -

we have working tfs 2013 , have access default reports of process template using. created new report , try make appear in team explorer of vs2013. searching internet indicated possible option download process template, change reporting part (e.g. adding new report default report) , upload "default" reports via command line tool (tfpt addprojectreports ...) since changing (including adding) areas, iterations , other stuff can done in "live" system (without editing process template), hard me believe there no way add reports without changing process template. know how upload new report? of course, in end see report in team explorer... try http://yourreportingserver/reports/pages/folder.aspx navigate via collection, project folder want report show in, "upload file".

ios8 - Can we have 2 ios apps with same bundle id target different ios? -

can have 2 ios apps same bundle id target different ios? in scenario, keep app supporting ios 8 , create new app scratch supporting ios 9 same bundle id. user on ios 8 able install existing app , ios 9 user can install new app. is possible? based on comment, sounds looking latest compatible version feature apple provides automatically. if have existing app in app store supports ios 8, , release updated version of app supports ios 9, previous version still available ios 8 users download. when try install app, message asking if want download compatible version. also note if want turn off feature , not make previous versions available, see this question .

Getting ORA-01652 error when Run oracle sql query join into approx 10 tables -

i have 3 users on oracle , have same tablespace, when run following query getting following problem when executing query. , while executing takes hell lot of time :( ora-01652: unable extend temp segment 128 in tablespace temp 01652. 00000 - "unable extend temp segment %s in tablespace %s" *cause: failed allocate extent of required number of blocks temporary segment in tablespace indicated. *action: use alter tablespace add datafile statement add 1 or more files tablespace indicated. query: select a.* lea_agreement_dtl_rcl a, nbfc_customer_m b, db1.nbfc_product_m c, db1.lea_instrument_dtl e, db1.lea_loantype_m f, db1.nbfc_branch_m g, etrupti_cust_agrmnt_mapping h, (select a.caseid, sum ( case when b.chargecodeid = 82 , a.advicetype = 'r' nvl (a.adviceamt, 0) - nvl (a.txnadjustedamt, 0) - nvl (a.amtinprocess, 0) else 0 end) pre