Posts

Showing posts from June, 2010

How to add multi-valued property to jcr node through python code using cURL? -

how add multivalue property jcr node through java code? says string array created pass node.setproperty() in java. however, in python, when create list , try pass curl command, error saying python cannot concatenate string , list. list = ["one","two"] subprocess.popen(['curl','-u','admin:admin','-d',"jcr:primarytype=nt:unstructured",'-d',"sling:resourcetype=xxxx",'-d',"accordiontype=please select",'-d',"accordions="+list,""+path]) please help. in list of parameters passed popen() you're trying concatenate "accordions=" , string, list , well, list. no wonder python confused. as far know, jcr specifications not required rest api. you're referring sling here, in case may want add sling in keywords attract experts' attention. i'd advice use requests python library instate of running external processes through sub...

windows - How to call C extern function and get return struct? -

i have extern function , struct defined in token.c : #include "stdio.h" typedef struct token { int start; int length; } t; extern t get_token(int, int); t get_token(int s, int l) { printf("[c] new token: start [%d] length [%d]\n\n", s, l); t m_t = {}; m_t.start = s; m_t.length = l; return m_t; } ... can call _get_token assembly , new token. in make_token.asm have following: section .data ; initialized data mtkn: db "call: token(%d, %d)", 10, 0 mlen db "length: %d", 10, 0 mstt: db "start: %d", 10, 0 mend: db 10, "*** end ***", 10, 0 section .text ; code extern _get_token extern _printf global _main _main: ; stash base stack pointer push ebp mov ebp, esp mov eax, 5 mov ebx, 10 push ebx ; length ...

ios - what's the bulletproof method to check if NSString is empty/null? -

this question has answer here: what right way check null string in objective-c? 17 answers ji building app want show cleaner's contact information in uibutton if cleaner has been assigned job, , not show uibutton otherwise. have "appointment" objects have cleaner , cleanerphone strings properties. tried using check whether print string: if(appt.cleanerphone) but prints button null phone number isn't helpful. tried if([appt.cleanerphone length]>2) that working yesterday started crashing app error message pointing line above: 2015-04-22 18:59:07.165 [640:158880] -[nsnull length]: unrecognized selector sent instance 0x37afd690 i tried if(appt.cleanerphone && [appt.cleanerphone length]>2) but leads same error. for reference, these come parsed json object->nsdictionary. if there no cleaner, here's nsdictionary sho...

How to print out a numbered list in Python 3 -

how print out index location of each of python list starts @ 1, rather 0. here's idea of want like: blob = ["a", "b", "c", "d", "e", "f"] in blob: print(???) output: 1 2 b 3 c 4 d 5 e what need know how numbers show alongside i'm trying print out? can a-e printed out no problem, can't figure out how number list. for a, b in enumerate(blob, 1): print '{} {}'.format(a, b)

python - "xlwings" : does not support writing of .xlsm files? -

i've tried simple test using "xlwings_0.3.4" open excel .xltm file , save again, make sure vba modules kept. couldn't work. if give file extension in save step, file saved .xlsx file. module carried along, extension change isn't recognized valid vba module. if not specify file extension, automatically saved .xlsx: wb=xlwings.workbook('template.xltm') wb.save('outfile') wb.close() this gives xlsx file. trying set file xlsm generates error: wb.save('outfile.xlsm') wb.close() xl_workbook.saveas(path) will generate error: xl_workbook.saveas(path) file "<comobject open>", line 7, in saveas pywintypes.com_error: (-2147352567, 'exception occurred.', (0, u'microsoft excel', u'this extension can not used selected file type. change file extension in file name text box or select different file type changing save type.', u'xlmain11.chm', 0, -2146827284), none) this seems inh...

gcloud in version Google Cloud SDK 0.9.57 breaks deploy of application -

as of 04/22/15, update of gcloud latest version breaks deploy command. version of app set current timestamp (eg: 20150422t202108). , doing a: gcloud preview app deploy . returns error "error: directories not supported [.]. must provide explicit yaml files." and deploying application using individual .yaml files complains version specified in module update set app version timestamp. "the version [1] declared in [/users/username/app.yaml, /users/username/app2.yaml] not match current gcloud version [20150422t202108]." is bug or did config options change? don't find differences on documentation page. the version deployment explicit , never taken yaml files. there 2 possible cases: 1) if use --version flag, whatever version specify used. error if not match values in yaml file. 2) if not use --version flag, version number generated you. error seeing because, again, version not match in yaml file. the proper solution here remove versi...

hadoop - get filename and extension of files in hdfs with Python -

is there equivalent of os module in python read filesystem (hadoop 2.6)? in particular interested getting extension of file , base name (not including full path). no need " an equivalent ", os.path.basename same hdfs . i.e.: import os.path path print path.basename("/path/to/file.txt") # file.txt os.path — common pathname manipulations

oracle - Function to count words, from not where expected -

i trying function count words in string ignoring spaces, dots, comas, etc... started ignoring simple spaces, far works select length ('hello world') - length(regexp_replace('hello world', '( ){1,}', '')) numdepalabras + 1 dual; but when trying make function gets parameter string , return number or words isn't working right error keyword not found expected. any ideas of how can work? create or replace function wcount ( txt in varchar2 ) return varchar2 resul varchar2(100); begin select length (txt) - length(regexp_replace(txt, '( ){1,}', '')) numdepalabras + 1 dual; return resul; exception when others raise_application_error(-20001,'se ha encontrado un error - '||sqlcode||' -error- '||sqlerrm); end; sql> create or replace function countword(txt varchar2) return varchar2 2 resul varchar2(100); 3 begin 4 5 ...

Python-Turning a string into and integer while keeping leading zeros -

i trying convert string, such 'ab0001', integer appears '001' i trying: x='ab0001' z=int(x[2:len(x)]) though output is: 1 i need integer used in: format_string=r'/home/me/desktop/file/ab'+r'%05s'+r'.txt' % z thank time , please let me know how acquire following outcome: format_string=r'/home/me/desktop/file/ab0001.txt' you cannot have leading zeros @ in python3 , in python 2 signify octal numbers. if going pass string keep string. if want pad 0's can zfill: print(x[2:].zfill(5)) i don't see why slice @ thought when seem want exact same output original string. format_string=r'/home/me/desktop/file/{}.txt'.format(x) will give want.

c++ - Issue With My School Assignment on Classes -

so have assignment due in c++ class on classes, , i'm having trouble. here description of assignment: programming challenge 7 on page 499 of text asks design , inventory class can hold information item in retail store's inventory. given code creation of class along code implementation of functions. demonstrate class writing simple program uses it. program should demonstrate each function works correctly. submit .cpp file using link provided. and here contents of file sent (it's quite lengthy): // chapter 7---files programming challenge 13---inventory class // inventory.h file. // contains inventory class declaration. #ifndef inventory_h #define inventory_h class inventory { private: int itemnumber; int quantity; double cost; double totalcost; public: // default constructor inventory() { itemnumber = quantity = cost = totalcost = 0; } // overloaded constructor inventory(int, int, double); // defined in inventory.cpp ...

python Genfromtxt how convert negative integer in to 0 -

img = np.genfromtxt (path+file,dtype=int, invalid_raise=false, missing_values= (all negatives), <<<--------------- usemask=false, filling_values=0) i need catch negative integers , replace them 0. maybe can write code? you can using .clip() follows: img = img.clip(0)

jquery - X-editable and Select2 with remote data not working -

i'm trying make x-editable , select2 work remote search. here html blade templating. table id "table". <td> <a href="#" id="{{ $template->id }}" data-value="{{ $template->food_item_id }}" name="food_item" data-type="select2" data-pk="{{ $template->id }}" data-title="" class="editable-click food_item"> {{ $template->food_item_name }} </a> </td> i'm using selector setup x-editable $('#table').editable({ selector: 'tbody tr td .food_item', url: '/update', select2: { cachedatasource: true, allowclear: true, placeholder: 'select food item', width: '200px', id: function (item) { return item.id; }, ajax: { url: '/json', datatyp...

In the below java code, how can I ask the user to input how many shots they would like in each of their coffee cups (Given they order more than 1)? -

import java.util.scanner; public class coffeebot { public static void main(string[] args) { scanner keyboard = new scanner (system.in); system.out.println("hello, what's name?"); string name = scanner.nextline(); system.out.println("would order coffee, "+name+(y/n)?") string response = scanner.nextline() { if response = y system.out.println("great! lets started.") system.out.println("there 6 coffee cups in stock , each costs $2.00."); system.out.println("there 8 coffee shot in stock , each costs $1.00."); system.out.println("how many cups of coffee like?"); int cups; cups = keyboard.nextint(); { if cups = 0; system.out.println("no cups, no coffee. goodbye."); system.exit(); if cups < 0; system.out.println("does not compute. system terminating."); ...

excel - Cell numeric value -

Image
i created assessment form on excel , willing upgrade below intended feature. table looks like: +--------------------+---+---+---+---+---+ | | 1 | 2 | 3 | 4 | 5 | +--------------------+---+---+---+---+---+ | computer knowledge | | | | | | +--------------------+---+---+---+---+---+ | office knowledge | | | | | | +--------------------+---+---+---+---+---+ | relationships | | | | | | +--------------------+---+---+---+---+---+ when put x or character on table want excel assign column value , summary score below: +-------------+----+ | total score | 17 | +-------------+----+ does have suggestion? if understand question correctly, assume following table yield total score of 10: technically put character want in cells, counting non-empty cells in columns , multiplying each factor should accomplish want. cell b6 following: =(counta(b2:b4)*1)+(counta(c2:c4)*2)+(counta(d2:d4)*3)+(counta(e2:e4)*4)+(counta(f2:...

mysql - One Row to Match Them All -

so have situation have 2 tables. 1 base table (called _keys in example), unique primary key. there table multiple rows of data each id in _keys (this second table extra ). i need select largest value each primary key in _keys extra. have made sqlfiddle model problem here . this query i'm using, issue select 1 value table, not 1 value per row. select * _keys left join (select * order value2 desc limit 1) e on e.id = _keys.id; for example sql fiddle used database schema: create table _keys(id int, value int); insert _keys (id, value) values (1, 5),(2, 3),(3, 4); create table extra(id int, value2 int); insert (id, value2) values (1, 3),(1, 1),(2, 4),(2, 6),(3, 3),(3, 5); basically result here . first row _keys table gets data second table. in mysql, how can achieve selecting 1 row extras each row in _keys? i believe understand trying i'm not sure. you getting null values because of limit , returns first row. need use group by . to largest value, ...

git push - GIT: fatal: 'master' does not appear to be a git repository -

i pushing master branch git repo , go error fatal: 'master' not appear git repository on advice of stack question typed git remote -v and got heroku https://git.heroku.com/peaceful-cove-8372.git (fetch) heroku https://git.heroku.com/peaceful-cove-8372.git (push) origin https://github.com/simonwalsh1000/breathe.git (fetch) origin https://github.com/simonwalsh1000/breathe.git (push) i typed simonalice$ git push -u origin master and worked said branch master set track remote branch master origin. i new git , not sure has happened. grateful if explain sequence me. haven't been able clear answers. master branch now, master branch in git or clone? many thanks and worked said branch master set track remote branch master origin. do git config --local -l you see local branch master set track upstream branch origin/master see " difference between git checkout --track origin/branch , git checkout -b br...

jquery - If it has children remove href from parent, else -

i have list of menu items sub uls , sub-sub uls. sub-sub uls i'd remove href parent if parent has children. this have far, not sure how transform if -> else statements. $('#menu-sidebar-menu > li > ul:has(li) > a').children(['li']).find('a:first').removeattr('href'); <li class="cat-item cat-item-89"><a href="#" title="detailed posts products.">products</a> <ul class='children'> <li class="cat-item cat-item-100"><a href="#" title="detailed posts products.">all</a> </li> <li class="cat-item cat-item-94"><a href="#" title="post products ducati sportbikes.">ducati</a> </li> <li class="cat-item cat-item-91"><a href="#" title="posts products honda sportbikes.">honda</a> <ul class='children'> ...

ocaml - Loading a batteries dependent file into ocamltop -- the interfaces disagree -

here simple ocaml file, meant me understand how load program uses batteries library ocamltop. batteryassault.ml open batteries let main = print_string "hello, world ... powered on" i compile bytecode ocamlfind ocamlc -package batteries -linkpkg batteryassault.ml resulting in batteryassault.cmo , batteryassault.cmi, , no errors nor warnings. then, start battery-powered ocamltop with rlwrap ocamlfind batteries/ocaml finally, load file in ocamltop: #load "batteryassault.cmo" ;; and error. the files batteryassault.cmo , /usr/lib/ocaml/batteries/batteries.cma disagree on interface batteries i think going on ubuntu installs batteries 2.2.1, reason (installing merlin?) have batteries 2.3.1 installed in opam folder, , moreover, when starting ocamltop batteries above, indicates ocamltop using 2.2.1 version. further, compiling ocamlfind ocamlc -package batteries -linkpkg batteryassault.ml -verbose i find ocamlc using library in opam, i.e...

javascript - Difference between test expressions -

i'm implementing obligatory slider in project. , following code worked fine: else if( current - 1 === sliderlength ){ current = 1; loc = 0 } but didn't work expected: else if( current === sliderlength - 1 ){ current = 1; loc = 0 } so, difference between current === sliderlength - 1 , current - 1 === sliderlength ? i rename variable x , y brevity, , include pertinent part: if (x - 1 === y) vs if (x === y - 1) if have hard time seeing difference, try them both out random values x , y. let's try x = 3 , y = 2 so, first 1 becomes: if (3 - 1 === 2) , or if ((3 - 1) === 2) , or if (2 === 2) (i.e. true ) second 1 becomes: if (3 === 2 - 1) , or if (3 === (2 - 1)) , or if (3 === 1) (i.e. false ) the important thing note comparison operation ( === ) happens after subtraction operation. that's not important in case, note.

How to theme node delete page in drupal? -

i want theme node delete page in drupal 7 . doesn't seems working template in new theme active .i have made template page in theme , made code in template.php based on form_id . same thing did other forms node create form different different content types . delete node not working . knows process . i guess "theme delete page", mean writing custom css rules affect confirmation step page used delete node. then, can such rule: body.page-node-delete .theselectorsyouneed { color: red; /* ... + rules need */ } drupal 'injects' context-depending css classes body tag of template. example: .not-front , .not-logged-in , ... and, need, .page-node-delete . source

How do I deploy a directory to GitHub with Travis CI? -

i deploy entire directory github release on successful build of project. however, when try provide directory file deploy option complains directory. i not want list every file hand change on time , don't want have update .travis.yml file every time add/remove file to/from project. it possible not using github releases correctly. previously, have released creating orphan tag contains files want release. hoping travis releases deployment simplify process. .travis.yml: deploy: provider: releases api_key: ${github_api_key} file: "output/system" skip_cleanup: true on: tags: true error: /home/travis/.rvm/gems/ruby-1.9.3-p551/gems/octokit-3.8.0/lib/octokit/client/releases.rb:86:in `initialize': directory - output/system (errno::eisdir) you're looking use file_glob option, allows define wildcard in file definition. try this: deploy: provider: releases api_key: ${github_api_key} file_glob: true file: "output/syst...

c++builder - Indy > BroadCast to 172.30.58.255 fail -

my environment: c++ builder xe4 indy 10.5.8.3 i trying broadcast network 172.30.58.x subnet mask 255.255.255.0. using tidudpclient, tried following resulting in fail (no response). // case1 idudpclient1->broadcastenabled = true; idudpclient1->broadcast(cmd, port, l"172.30.58.255"); instead, following works, unlimited network (also including other 172.30.58.xxx) // case2 idudpclient1->broadcastenabled = true; idudpclient1->broadcast(cmd, port, l"255.255.255.255"); with indy, how can broadcast 172.30.58.xxx? before doing accesses tidudpclient.binding property (such broadcast() , connect() / active , send/receivebuffer() , etc), set tidudpclient.boundip property local ip connected 172.30.58.xxx network.

javascript - lazy loading of components in angular with browserify -

i in process of outlining architecture of complex application based on angular. started angular-seed project , seems starting point. bothers me angular apps nature involves loading upfront. script loaders, there doesn't seems clean way around. i came backbone.js background , there quiet straight use require.js lazy loading based on router callbacks. in angular routes defined below: // declare app level module depends on views, , components angular.module('myapp', [ 'ngroute' ]). config(['$routeprovider', function($routeprovider) { $routeprovider.when({templateurl:'../tmpl.html',controller:'view1ctrl'}) .when({templateurl:'../tmpl.html',controller:'view1ctrl'}) .otherwise({redirectto: '/view1'}); }]); now here, $routeprovider.when({templateurl:'../tmpl.html',controller:'view1ctrl'}) lazily load controller , template. tempted use like: $routeprovider.when({templateurl:'../tmpl.html...

sql server - How to see the SQL expression of an X++ select statement? -

i have below statement in job in ax: select recid pjitable join pid, type, prid sjtable pjitable.prid == sjtable.prid && (sjtable.type == pjtype::timematerial || sjtable.type == pjtype::fixedprice); i have use in sql server. how can convert select statement sql , use in sql server management studio? for debugging purposes can change select query , use getsqlstatement method on table: select generateonly forceliterals recid pjitable join pid, type, prid sjtable pjitable.prid == sjtable.prid && (sjtable.type == pjtype::timematerial || sjtable.type == pjtype::fixedprice); info(pjitable.getsqlstatement()); this show sql statement without executing statement.

java - Apply multiple analyzers in hibernate search? -

can use multiple analyzers on field search text using hibernate search?? for example : want use japanese analyzer if nothing found n-gram analyzer picked automatically searching. is there support above in hibernate search?? , if not how can achieve this? a single field in lucene should processed single analyzer, , should consistent across index or becomes hard define queries: defining correct query needs know analyzer being used specific field. if need properties analyzed in multiple different ways, correct approach use @fields (plural form) annotation map property multiple index fields.

subscripted value is neither array nor pointer nor vector in c -

how remove error tried everything.... program finding 5 closest number array... in main part take array, num , size , passes through function void printclosest(int arr[], int x, int n) { int diff[30]; int i,j,k,p,a; (i = 0; < n; ++i) { (j = + 1; j < n; ++j) { if (arr[i] > arr[j]) { = arr[i]; arr[i] = arr[j]; arr[j] = a; } } } for(i=0;i<n;i++) { diff[i]=abs(a[i]-x); } (k = 0; k < n; ++k) { (p = k + 1; p < n; ++p) { if (diff[k] > diff[p]) { = arr[k]; arr[k] = arr[p]; arr[p] = a; } } } for(i=0;i<5;i++) { printf("%d",arr[i]); } } a declared int , yet try use array here: diff[i]=abs(a[i]-x);

vb.net - Improving the arrangement and layout of my listbox -

Image
i'm having trouble visual basic. i'm trying make listbox this: however ends this: is there way can organise data? also, how can make total number of universities fixed @ bottom , "university name" "abbreviation"at top? how add vertical scroll bar? also, how can calculate total number of students @ bottom? this code: private sub piclist_click(byval sender system.object, byval e system.eventargs) handles piclist.click frmlist.show() frmlist.lstshow.items.clear() dim fmtstr string = "{0,-0}{1,-20}{2,-15}{3,-20}{4,-25}" dim integer frmlist.lstshow.items .add(string.format(fmtstr, "university name", "abbreviation", "state", "accredited year", "total students")) = 0 n - 1 .add(string.format(fmtstr, names(a), abbreviation(a), state(a), accredited(a), total(a))) next .add(string.format(fmtstr, "", "", ...

Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza -

could not find class 'android.app.appopsmanager', referenced method com.google.android.gms.common.googleplayservicesutil.zza authorization failure. please see https://developers.google.com/maps/documentation/android/start how correctly set map. in google developer console ( https://console.developers.google.com ) ensure "google maps android api v2" enabled. ensure following android key exists: api key: android application (;): fd:9e:49:cd:63:;com.xxx.xxx well, if still wondering...i had same issue , figured out. appopsmanager added in api level 19 . make sure targetsdkversion in androidmanifest.xml right one.

java - timeout [error]configuration not set properly . missing value for session -

i have play java application , have integrate deadbolt2 , google juice . when try run application cmd shows me error. timeout [error]configuration not set . missing value session. i think problem somewhere in global class. haven't been able find solution this. appreciated.

javascript - Express.js proxy pipe translate XML to JSON -

for front-end (angular) app, need connect external api, not support cors. so way around have simple proxy in node.js / express.js pass requests. additional benefit can set api-credentials @ proxy level, , don't have pass them front-end user might steal/abuse them. this working perfectly. here's code, record: var request = require('request'); var config = require('./config'); var url = config.api.endpoint; var uname = config.api.uname; var pword = config.api.pword; var headers = { "authorization" : 'basic ' + new buffer(uname + ':' + pword).tostring('base64'), "accept" : "application/json" }; exports.get = function(req, res) { var api_url = url+req.url; var r = request({url: api_url, headers: headers}); req.pipe(r).pipe(res); }; the api-endpoint have use has xml output format. use xml2js on front-end convert xml reponse json. this working great, lighten load client, , xml -...

python - How to generate and add an instance method to a class in runtime but compiling a method only once? -

i'm trying implement mixin adds method instance mangles name of base class's specific field name. code looks this class timeseriesobjectretrievermixin(object): """time series object retriever mixin. offers reverse related object retrieval methods mixed in model reverse relation contains time related fields(datefield, datetimefield). """ # todo: serious performance bottleneck due function code compilation every # instantiation. fix this. def __init__(self, *args, **kwargs): self._n = {} time_series_object_name, time_series_field_name in self.time_series: time_series_object = getattr(self, time_series_object_name) time_series_field = time_series_object.model._meta.get_field(time_series_field_name) # time series field has 1 of datefield or datetimefield. assert(isinstance(time_series_field, datefield) or isinstance(time_series_field, datetimefield)) self._add_get_in_last_...

c# - Entity Framework: Only Seed when building initial database -

i'm using entity framework 6 dbmigrationsconfiguration : public sealed class configuration : dbmigrationsconfiguration<datacontext> { public configuration() { automaticmigrationsenabled = true; } protected override void seed(danfoss.energyefficiency.data.datacontext context) { //adding initial data context context.savechanges(); } } i'm using in webapi in way: public static void register(httpconfiguration config) { database.setinitializer(new migratedatabasetolatestversion<datacontext, configuration>()); } i have noticed seed function running every time application start up. how can prevent this? run first time runs, when build initial tables. the dbmigrationsconfiguration.seed method called every time call update-database . reasoning behind explained in blog one unicorn . that means have write seed code cope existing data. if don't that, can vote change on codeplex . in meantim...

sql - Error: An aggregate may not appear UPDATE statement -

i trying update column of temp table using following query: update t set t.consumedquantity = sum(ma.quantity) @temptable t join defaultshopview dsv on dsv.operationid =@opid join myspec ms with(nolock) on ms.workrequest = dsv.workrequest join myactual ma with(nolock) on ma.specid = ms.specid but getting error: an aggregate may not appear in set list of update statement. how update values? you can use this: update t set t.consumedquantity = (select sum(ma.quantity) @temptable join defaultshopview dsv on dsv.operationid =@opid join myspec ms with(nolock) on ms.workrequest = dsv.workrequest join myactual ma with(nolock) on ma.specid = ms.specid ) @temptable t join defaultshopview dsv on dsv.operationid =@opid join myspec ms with(nolock) on ms.workrequest = dsv.workrequest join myactual ma with(nolock) on ma.specid = ms.specid

haskell - Defining multiplication over functions in Python? -

i'm trying define multiplication on functions in python, in pseudocode is: this should return function in x, given f(x), g(x) multiply_two_functions((f(x), g(x)) = f(x) * g(x) i can in haskell so: mult :: (num b) => (a -> b) -> (a -> b) -> (a -> b) mult f g = h h x = (f x) * (g x) you might ask why i'd want - have list of functions [f], , want reduce these multiplication. again, in haskell: reduce_mult list = foldl mult 1 list edit: how i'm using in python, completeness: def prod_reduce(f_list): def identity(x): return 1 def f_mult(f, g): def multiplied(x): return f(x) * g(x) return multiplied prod = identity f in f_list: prod = f_mult(prod, f) return prod does have tips python implementation? just write function returns new function returns product of results of other functions: def multiply_funcs(f, g): def multiplied(x): return f(x) * g(x) ...

unix - Difference between sed -e and sed -f -

what difference between sed -e , sed -f options. of these should used in place editing. not able understand meaning man pages. according manual page of sed -e script --expression=script add commands in script set of commands run while processing input this means sed executing commands passed directly on command-line such sed -e 's/foo/bar/g' where as, -f script-file --file=script-file add commands contained in file script-file set of commands run while processing input. while using -f sed expecting commands in file specified after -f option. useful complex operations. as long in place editing concerned, of options can used. example: sed -i -e 's/foo/bar/g'

java - POI: output blank if formula returns blank -

i have formula in excel: =if(a1="foo";"";"0") if formula returns blank value want no value in resultiong csv file created poi. if formula returns 0 want 0 in csv file. this part of code (it's question of how stripping code down): iterator<row> rowiterator = sheet.rowiterator(); while (rowiterator.hasnext()) { row row = rowiterator.next(); iterator<cell> celliterator = row.celliterator(); boolean isfirst = true; (int cn = 0; cn < row.getlastcellnum(); cn++) { cell cell = row.getcell(cn, row.create_null_as_blank); if (!isfirst) { buffer.write(delimiter.getbytes(charset)); } else { isfirst = false; } // numeric cell type (0) // string cell type (1) // formula cell type (2) // blank cell type (3) // boolean cell type (4) // error cell type (5) if (cell.getcelltype() == 0 || cell.getcelltype() == 2) ...

c++ - Rank-Preserving Data Structure other than std:: vector? -

i faced application have design container has random access (or @ least better o(n)) has inexpensive (o(1)) insert , removal, , stores data according order (rank) specified @ insertion. for example if have following array: [2, 9, 10, 3, 4, 6] i can call remove on index 2 remove 10 , can call insert on index 1 inserting 13 . after 2 operations have: [2, 13, 9, 3, 4, 6] the numbers stored in sequence , insert/remove operations require index parameter specify number should inserted or number should removed. my question is, kind of data structures, besides linked list , vector, maintain this? leaning towards heap prioritizes on next available index. have been seeing fusion tree being useful (but more in theoretical sense). what kind of data structures give me optimal running time while still keeping memory consumption down? have been playing around insertion order preserving hash table, has been unsuccessful far. the reason tossing out using std:: vector straight...

algorithm - Execute a loop x times without loop or if statements -

how can rewrite following program in order not use loop , branch constructs? (no if, while, break, continue, switch, ...) for(int i=0; < 5; i++){ // stuff } the approach can think of use ugly goto statements: loop: // stuff goto loop; but how can exit loop after 5 runs? or there different way? edit: solution should not recursive. function calls not yet allowed in course. you can use recursive function , pass argument counter. decrease counter each time before calling. int func(int a,int counter) { int c; // .. logic return counter==0?a:func(a,counter-1); } this line return counter==0?a:func(a,counter-1); helps handling condition when counter==0 without using if.

ios - How to Customize the Apple Watch Vertical Scrollbar -

Image
i thinking, not possible @ time change color of vertical scrollbar in apple watch. but saw app on apple site , here screen shot of app i want change color of scrollbar default desired color above picture shows green scrollbar scroller. i found no way access it, in wkwindowsfeatures , not accessible in storyboard. global tint color -the title string in status bar -the app name in short notifications so how can change desired color. there no api customize scrollbar's color @ time. changes in color see controlled os.

ffmpeg - iOS Playing Video from memorystream -

my ios app downloading encrypted mp4 file server document folder. i'll decrypt mp4 memory , play video memory. for security, app should not make decrypted mp4 file doc folder. how can play video memorystream? i'm trying ffmpeg..or there other solutions? can customize avio_open2() , avformat_open_input()? please me.... set avformatcontext->pb self-created aviocontext wraps memory stream. important read_packet() , seek() function callbacks, application should implement actual packet reading , seeking (mp4) demuxer. can @ earlier questions along same path.

Bellman ford queue based approach from Sedgewick and Wayne - Algorithms, 4th edition -

i studying queue-based approach bellman-ford algorithm for single source shortest path robert sedgewick , kevin wayne - algorithms, 4th edition source code algorithm book present @ link http://algs4.cs.princeton.edu/44sp/bellmanfordsp.java . i have 2 points 1 doubt , other code improvement suggestion. in above approach following code relax method relaxing distance vertices. for (directededge e : g.adj(v)) { int w = e.to(); if (distto[w] > distto[v] + e.weight()) { distto[w] = distto[v] + e.weight(); edgeto[w] = e; if (!onqueue[w]) { queue.enqueue(w); onqueue[w] = true; } } if (cost++ % g.v() == 0){ findnegativecycle(); } } in method below condition used before finding negative cycle. if (cost++ % g.v() == 0){ findnegativecycle(); } above dividing cost number of vertices in graph check negative cycle . may because relaxation done v-1 times , if relaxation run vth time mea...

angularjs - ui.router + spring security - redirect upon required log in -

i'm building mvc web application using spring-security securing app , angular.js clent side framework. ui.router changes content of page depanding on selected state. problem starts when user tries select page referring page lacks privilages access, spring returns login page, , ui.router inserts login page body of page. what do, redirect login page if login required instead of inserting current page. how can acheive that? i created 2 different angular modules, , each module had own routing. the 2 angular modules are: 1) loginmodule (with own ui-router configuration, es. login, retrieve password, forgot password , on...) 2) securedmodule: authenticated part i created 2 main pages entry point each ui-router /signin -> signin.html -> (loginmodule) -> ui-routing login /secured -> secured.html -> (securedmodule) -> ui-routing secure now can configure un spring configuration , assign /signin login page , path /secured authentic...

html - Different layouts on firefox and chrome -

i'm developing site header has cart button , search bar. fiddle my question in chrome , firefox see different spaces between cart button , search input. chrome version should right layout. suggestions? appreciated. body { background: #000000; } img[alt="cart-icon"] { width: 20px; } img[alt="telephone-icon"] { /*width: 18px;*/ margin-top: -4px; margin-right: 3px; } .right { float: right; text-align: right; margin-top: 21px; } .tel-no { color: #fff; margin-top: -7px; margin-right: 19px; font-weight: normal; text-align: right; font-size: 15px; font-family: avenirreg; } .tel-no p { margin-bottom: 0; display: inline; } .cart1 { float: right; margin-top: 9px; margin-right: 7px; } .top-cart .truncated { display: none; } .header-search-form { float: right; } .right input[type='text'] { background-color: rgba(0, 0, 0, 0); border: 1px solid #7b7672; border-ra...

apache spark - Submiting jobs with --conf not working -

i've tried add jmx spark executors "spark.driver.extrajavaoptions". i've put --conf "spark.executor.extrajavaoptions=\"my options\"" in sumbit file, started job, verified if configuration visible on webui. have verified jmx netstat -an , there no listening on port have specified. have put same options in spark-defaults.conf , works fine. what doing wrong? i tried --conf "\"spark.executor.extrajavaoptions=my options\"" same effect. try \\ instead of \ might work. check if setting configurations using .setconf() method on spark context in code solves problem.

sql - is null vs. equals null -

i have rough understanding of why = null in sql , is null not same, questions this one . but then, why is update table set column = null a valid sql statement (at least in oracle)? from answer , know null can seen "unknown" , therefore , sql-statement where column = null "should" return rows, because value of column no longer an unknown value. set null explicitly ;) where wrong/ not understand? so, if question maybe unclear: why = null valid in set clause, not in where clause of sql statement? sql doesn't have different graphical signs assignment , equality operators languages such c or java have. in such languages, = assignment operator , while == equality operator . in sql, = used both cases, , interpreted contextually. in where clause, = acts equality operator (similar == in c). i.e., checks if both operands equal, , returns true if are. mentioned, null not value - it's lack of value. therefore, cannot equal ...

terminal - z/OS SDSF log auto update AND scroll down -

is there way in sdsf mimic direct z/os console autorefresh and autoscroll down end of log? figured out can autoupdate &<time> , doesn't scroll down end of log gets updated. ideas? lol! easy. had use bot &<time> example: bot &5 . bot scrolling bottom of log , &<time> so command gets repeated in 5 sec interval.

javascript - Text handling and grouping -

Image
the main idea have string, no defined length (dynamic), , need group multiple columns (like in image example, ignore image part) . so, can see has precise. main idea have split string intro array of words, append each word container , check if text container fits parent container (that fixed). although idea might work, seems overkill, so, have better idea on how handle this? cannot use css property makes this, has done strictly js, because have further group text images in columns. just clear, don't have 3 columns, dynamic, can have 1 4 columns. if don't need support ie < 10, simpler: http://www.w3schools.com/css/css3_multiple_columns.asp

asp.net mvc5 fullcalendar end parameter issue -

i'm making asp.net mvc program using fullcalendar works fine except 'end' factor. caused 'end' reserved word @ query. $('#calendar').fullcalendar({ //defaultdate: '2015-04-09', header: { left: '', center: 'title' }, editable: true, eventlimit: true, // allow "more" link when many events selectable: true, events: '/home/getevents' }); public class task { public int id { get; set; } public string title { get; set; } public string start { get; set; } public string endtime { get; set; } } public list<task> getall() { list<task> tasklist = new list<task>(); tasklist = this._db.query<task>( @"select taskid id , tasknm title , convert(varchar(10), taskf...

gitbook - Is it possible to have a custom footer on the PDF version of book? -

i'd include small logo in footer on every page on pdf version of book not on html version. is possible? pointers on how might achieve this? i'm using git book version 2.0.1 thanks million. ct as far know not possible add logo pdf , not html version. i think 1 possibility achieve goal make second html version. first 1 gitbook, second 1 copy of first one, logo @ end of each page. can convert second 1 pdf. another possibility search watermark tool pdf files , add logo way. sadly both ways additional expenses, see no other way

Why are integer types promoted during addition in C? -

so had field issue, , after days of debugging, narrowed down problem particular bit of code, processing in while loop wasn't happening : // heavily redacted code // numbera , numberb both of uint16_t // important stuff happens in while loop while ( numbera + 1 == numberb ) { // processing } this had run fine, until hit uint16 limit of 65535. bunch of print statements later, discovered numbera + 1 had value of 65536 , while numberb wrapped 0 . failed check , no processing done. this got me curious, put quick c program (compiled gcc 4.9.2) check this: #include <stdio.h> #include <stdint.h> int main() { uint16_t numbera, numberb; numbera = 65535; numberb = numbera + 1; uint32_t numberc, numberd; numberc = 4294967295; numberd = numberc + 1; printf("numbera = %d\n", numbera + 1); printf("numberb = %d\n", numberb); printf("numberc = %d\n", numberc + 1); printf("numberd = %d\n...

c# - Diagnostic.Process merge StandardOutput and StandardErrorOutput -

i'm running cmd.exe .net program using process class , passing in various commands execute programs i.e. ipconfig, netstat etc. issue these programs output error text, sent standarderror, there no way of knowing during standard output error printed. error message separately. possible combine standardoutput , standarderror 1 synchronized stream data in order? if not, how organize output 2 different streams it's in proper order? well. guess can't expect stdout , stderr come in exact order have been output. because @ system level, stdout , stderr have own buffer respectively. can imagine such case - (1) when 'command' writes stdout first, buffer might not flushed immediately. (2) 'command' writes stderr, however, time buffer stderr might flushed. in case, though (1) comes first, (2) comes first. hope following snippet - (improved code) class outputcontext { public const int buffersize = 1024; public bool iseof {...

javascript - Hapijs onPreResponse, forwarded response -

Image
for api need have md5 result routes, use: server.ext('onpreresponse', function(request, reply) { var content = request.response.source; var code = request.response.statuscode; if(typeof request.headers.md5 != 'undefined' && code == 200) { content = md5(content); } if(!debug && code != 200){ content = "error"; } reply(content).code(code); }); when response 404 error, request.response doesn't have response.statuscode ... can handle with: if(typeof code == 'undefined'){ code = 404; } but when try view documentation generated lout, have this: how can forward code message? you want use reply.continue() rather reply().code() a similar question answered here: https://github.com/hapijs/discuss/issues/103

Php Curl Login Cookie return error that no cookie -

i have site try login, cookies set , saved file, after send postfiend login page, website redirect me page warring me cookies not enabled. $post = "username=".$user."&password=".$pswd."&loginbutton=1"; $options = array( curlopt_useragent => 'mozilla/4.0 (compatible; msie 6.0; windows nt 5.0)', curlopt_post => true, //using post curlopt_url => $address, //where go curlopt_postfields => $post, //input params curlopt_returntransfer => true, //returns string value of request curlopt_ssl_verifypeer => false, //avoid ssl problems curlopt_header => 1, curlopt_failonerror => true, //curlopt_followlocation => true, curlopt_cookiejar => 'cookies.txt', curlopt_cookiefile => 'cookie.txt', //save cookies curlopt_cookiesession => true, ); //cookies located $ch = curl_init(); //initialize curl in $ch curl_setopt_array($ch, $options); //add params values $ch $content = curl...

php - Using Model Events Listener in Laravel 5 -

i make sure correctly used model events listeners in laravel 5 , didn't messed nothing (listener vs handler?). solution works fine, wonder if developed according concept , convention of laravel 5. goal: set $issue->status_id on value when model saving. in app\providers\eventserviceprovider.php <?php namespace app\providers; ... class eventserviceprovider extends serviceprovider { ... public function boot(dispatchercontract $events) { parent::boot($events); issue::saving('app\handlers\events\setissuestatus'); } } in app\handlers\events\setissuestatus.php <?php namespace app\handlers\events; ... class setissuestatus { ... public function handle(issue $issue) { if (something) { $issuestatus = issuestatus::where(somethingelse)->firstorfail(); } else { $issuestatus = issuestatus::where(somethinganother)->firstorfail(); } ...