Posts

Showing posts from August, 2015

swift - Play sound with AKAudioPlayer - iOS -

how declare akaudioplayer ? i'm using audiokit lib , need play .wav file change file button. import uikit import audiokit class viewcontroller: uiviewcontroller { let file = nsbundle.mainbundle().pathforresource("song", oftype: "wav") let song = akaudioplayer(file!) // <--- error = instance member 'file' cannot used on type override func viewdidload() { super.viewdidload() audiokit.output = song audiokit.start() song.play() } @ibaction func btn(sender: anyobject) { song.replacefile("newfile") song.play() } } this fast solution problem. can done better @ least can idea. first try make new class function play file , function reload new replacement file this. class playmymusic { var songfile = nsbundle.mainbundle() var

python - How to turn off autoscaling in matplotlib.pyplot -

i using matplotlib.pyplot in python plot data. problem image generates seems autoscaled. how can turn off when plot @ (0,0) placed fixed in center? you want autoscale function: from matplotlib import pyplot plt # set limits of plot plt.xlim(-1, 1) plt.ylim(-1, 1) # don't mess limits! plt.autoscale(false) # plot want plt.plot([0, 1])

linux - Redirect stdout to stderr in shell -

i unable shell command output ran on ssh. for example output=$(utility_function ssh $host "pwd 2>&1" 2>&1) the problem run ssh command, utility_function , utility_function returns "exit code" in stdout. so, because stdout being, used function exit code that's why can't able command output. trying redirect stdout stderr command i'm not capturing output. output=$(utility_function ssh $host "pwd 2>&1" 2>&1) the problem in functions, , without more info can't there. if know how, can clone stdout file descriptor 3, , have functions use it, instead of &1 write exit code. also, if function isn't written right, redirect being ignored-- no way know info. assuming don't, need not redirect pwd command, , instead filter out return code-- if this, lose echo'd return codes function. this work no matter how function written-- though guessing @ number on tail, b/c don't know how o

ansible - Can I use inventory data from a web service within a playbook? -

i run playbooks via # ansible-playbook -i myscript.py myplaybook.yaml where myscript.py generates relevant host information (per documentation ) , myplaybook.py starts with --- - hosts: (...) this works fine. i to receive inventory via web service: include within playbook call web service , receive inventory in appropriate format, whatever (i control web service) as make use of inventory directly within playbook, without -i parameter, having host: all directive understand supposed use it. is possible in ansible? under impression inventory needed @ start of playbook (= cannot generated within playbook) you can create inventory dynamically add_host module. start , modify needs: --- - hosts: localhost tasks: - add_host: name={{item}} group=hosts_from_webservice with_url: https://mywebservice/host_list_as_simple_strings # in example web service should return 1 ip/hostname line: # 10.1.1.1 # 10.1.1.2 # 10.1.1.3

Mongodb- how to unwind a object not an array -

i have collection this, need unwind "myuser" object. {"_id" : objectid("578508630420bec15ea9876c"), "current" : "selectcategory", "myuser" : { "_id" : "56c49c540d9e391243ce2752", "myoptions" : [ { "id" : "jobs", "name" : "emploi" } ], "mychannel" : "ussd", "mycreatedate" : "2016-02-17t16:14:12.899z", "myemail" : "", "mygender" : "", "myhidemsisdn" : "no", "mylang" : "fr", "mylastupdate" : "2016-02-26t11:32:29.786z", "myyob" : -1 }, "userinput" : "continue", "ussdsession" : "303819320" } i'm looking output myuser : ["_id","myoptions","mychannel&quo

javascript - Why does null == undefined evaluate to true? -

i have code below not clear me var = null; if(a==undefined) alert("true"); else alert("false"); when ran above code alerts true. can explain whats reason or concept behind this? it's true because == loose equality operator, , null , undefined loosely equal ( null == undefined true). if use strict equality operator, === , not equal ( null === undefined false). basically, loose equality operator coerce operands if they're of different types (see abtract equality comparison in spec). 0 == "" true, instance, because if coerce "" number, it's 0 . strict equality operator considers operands of different types not equal (see strict equality comparison ); not coerce.

jsrender - Replace $& regex group -

boris moore's great jsrender library has 1 bug . neither understand meaning of $& (lastmatch) in regex replace groups nor have idea how resolve. this article telling me to not use function in production environments , , indirectly not use jsrender live. could explain me , give replacement of line: tmplfn(tmplormarkup.replace(rescapequotes, "\\$&"), tmpl); regards edit: hopeless unfortunately jsrender , jdk leave other holding baby. jsrender says: $% works fine, jdk never specified , not bug. that not in fact bug. mdn article link non-standard regex.lastmatch() api, programmatic way of accessing last match. jsrender not using api. in fact jsrender using "$&" replacement pattern in replacement string, in somestring.replace(regex, replacementstring) call - standard usage in javascript regex scenarios. see https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/replace , says: the rep

node.js - What happens when you do "import someModuleName from someModule" in Javascript -

i understand when want reuse module @ several places. do: module.exports = yourmoduleclassname in make module exportable. next, when want use in other places, import it, so: import yourmoduleclassname 'yourmodulepath' i totally understand above concept , have no doubts in that. today, more concerned about, happens when import package: like importing redux-form package: so first do: npm install redux-form what happens next do: import redux-form redux-form use in module. now, when npm installed package. example; when redux-form folder under node-modules folder. it's complete project server.js , package.json of own, same happens other npm package installs also. totally independent modules(but bigger one) , work in same way local independent modules. but didn't find module.exports there, how importable. of course, nodejs doing magic make them importable across projects. but, how doing that. let's keep module inside node_modules folder, don

How to define headers in a post request from RequestHelpers in Rails 4 -

i want test rails webhooks , can't manage have post() sending proper headers here : require 'test_helper' module hooks class hookscontrollertest < actioncontroller::testcase test 'non-json request fails 406' post :update, headers: {'content-type' => 'application/x-www-form-urlencoded'} assert_response 406 end #... this controller : module hooks class hookscontroller < applicationcontroller skip_before_filter :verify_authenticity_token def update byebug #... and in request object receive : request.headers['content-type'] # nil and have field in headers : ["query_string", "content-type=application%2fx-www-form-urlencoded"] note : when use hurl.it send post request same defined header field works fine , field this ["content_type", "application/x-www-form-urlencoded"] i using post method wrong? thank you.

c# - ASP.NET MVC multiple parameters and models -

description : have model workorder contains workorderform model ( start_date, end_date, organization ), list of models (the actual orders) , page parameters ( page, page_size, page_count ). main idea display work orders, , because there large amount of them have filter data; work orders pulled database server (not local). on initial view prompt start_date , end_date , use datatype.date , organization use string , information get's stored in model pass in httppost . extracts data , displays it. now, because there lot of orders, made costume pages sort data, , use 2 variables, page , page_size , displayed , can set on view after valid workorderform submitted. problem : problem facing right can't seem pass 2 parameters page , page_size , view controller @ same time. both of them work seem reset each other, example: on page 4, set page_size 20 50, , resets page 1, 1 alright, main on when chose page , reset page_size default (20). submitting has happen inside html.

webvr - Aframe - how to load textures for obj? -

i'm trying load .obj has several .jpgs textures. .obj rendering - without applying material. the .mtl looks like newmtl material_0 ka 0.200000 0.200000 0.200000 kd 1.000000 1.000000 1.000000 ks 1.000000 1.000000 1.000000 tr 1.000000 illum 2 ns 0.000000 map_kd tex_0.jpg i assume path .jpgs correct - if change it, see 404 errors in console. my aframe code is: <a-scene> <a-assets> <a-asset-item id="moore-obj" src="obj/moore.obj"></a-asset-item> <a-asset-item id="moore-mtl" src="obj/moore.obj.mtl"></a-asset-item> </a-assets> <a-entity obj-model="obj: #moore-obj; mtl: #moore-mtl" scale="1 1 1" rotation="0 0 0" position="1 1 1"></a-entity> </a-scene> the 3d model appears in scene - there no textures overlayed on it. i'm running on localhost, , i'm

python - Is their any complete documentation about sending email with Odoo? -

i'm trying send mails odoo. want create button, create different qweb report every res.partner society in database , send them it. (e.g. have 70 society, i'd each of them personnal email sent, personnal report.) i'm not asking give me solution since lot of work if go details, can't find documentation sending e-mail odoo. @ least 1 simpliest exemple of do, or better 1 shows option have it? (i mean python , xml side). i found people giving answers specifics question on forums, none explain each option , couldn't find documentation. if have give, i'm thankful. edit: i'm looking source code of basic addon "email_template" , find interresting options don't know how trigger it, function should redefined, how call it..

python - Hi, I am trying to add weekstart column -

in current table having date column , column able find out weekday.by using to_timedelta have created week_start column not giving correct date. here code is: final_data['weekday'] = final_data['dateofinvoice'].dt.weekday final_data['weekstart'] = final_data['dateofinvoice'] - pd.to_timedelta(final_data['weekday'],unit='ns', box=true, coerce=true) output as: date weekday weekstart 2016-07-23 5 2016-07-22 iiuc can construct timedeltaindex , subtract other column: in [152]: df['weekstart'] = df['date'] - pd.timedeltaindex(df['weekday'], unit='d') df out[152]: date weekday weekstart 0 2016-07-23 5 2016-07-18 in fact weekday column unnecessary: in [153]: df['weekstart'] = df['date'] - pd.timedeltaindex(df['date'].dt.dayofweek, unit='d') df out[153]: date weekday weekstart 0 2016-07-23 5 2016-07-18

apache pig - Perform arithmetic operation Pig -

i want make query hbase pig. rowkeys stored using reverse timestamp ( long.max_value - timestamp ). pig script, want store in variable current date in format ( long.max_value - currenttime ) query. load 'mydata' using org.apache.pig.backend.hadoop.hbase.hbasestorage('d:column', '-caster=hbasebinaryconverter -gte $minrowkey* -lte $maxrowkey -loadkey true' ) (rowkey:chararray,json:chararray); so this: %default maxrowkey "date +%s" and perform subtraction long.max_value - maxrowkey query. possible ? thanks i did not know of existence of hbasestorage options: -mintimestamp= scan's timestamp min timerange -maxtimestamp= scan's timestamp max timerange that did trick me.

python - Pandas: selecting multiple groups for inset plot -

Image
i have group data frame ( grouped_df ) used plotting in following way: grouped_df[['col1','col2','col3']].sum().plot(kind='bar') resulting in expected plot, contains group-wise sum 3 columns. however, of groups these sums small compared rest , hence not easy display in same bar plot (see image below). i want have inset plot these groups. trying, grouped_df[['col1','col2','col3']].sum() < "cut-off" returns boolean "list" of these groups cannot use further slicing/selection subset of groups of data frame. of course, generate 2 lists of groups , loop through grouped_df not think bright solution problem. for clarity , consistence provide sample data frame grouped grpcol : grpcol col1 col2 col3 comment 0.0505 0.0134 0.0534 foo b 0.0505 0.0134 0.2034 bar 0.0505 0.0134 0.0134 bar c 0.0505 0.0134 0.0331 none d

Python 3: PyQt: Make checkbox disabled + not grayed out + display tooltip -

the way found here: how make qcheckbox readonly, not grayed-out . this, however, disables mouse interactions control. need tooltip displayed when mouse on control. how can achieve this? if i've understood correctly, you'd asking for, disabled checkbox showing tooltips: import sys pyqt4 import qtgui, qtcore class example(qtgui.qwidget): def __init__(self): super(example, self).__init__() self.initui() def initui(self): self.cb = qtgui.qcheckbox('disabled checkbox showing tooltips', self) self.cb.move(20, 20) self.cb.toggle() # self.cb.setenabled(false) # self.cb.setstylesheet("color: black") # self.cb.setattribute(qtcore.qt.wa_alwaysshowtooltips) self.cb.settooltip ('my checkbox') self.cb.toggled.connect(self.prevent_toggle) self.setgeometry(300, 300, 250, 50) self.setwindowtitle('qtgu

GIT Smart Http - R any DENIED by fallthru -

i have installed git on red hat linux server used centralized repository , using http username , password control user access our windows notebook. based on testing.git repo comes sample repository, seems fine when try create new repository, getting error while trying clone it. c:\users\kwkoh\messaging>git clone http://10.89.20.91/git/testing.git cloning 'testing'... remote: counting objects: 36, done. remote: compressing objects: 100% (33/33), done. remote: total 36 (delta 9), reused 0 (delta 0) unpacking objects: 100% (36/36), done. checking connectivity... done. on linux server, have created new repository using command below [git@a0110tapidev01 repositories]$ git init --bare --shared messaging_v1.git initialized empty shared git repository in /home/git/repositories/messaging_v1.git/ c:\users\kwkoh\messaging>git clone http://10.89.20.91/git/messaging_v1.git cloning 'messaging_v1'... ****fatal: remote error: fatal: r messaging_v1 edmund denied fallt

java - Not able to send JSON object to Ajax from Jersey REST web service -

i'm writing simple jersey rest web service i'm consuming json object , sending json object. workaround. throws following error. org.codehaus.jackson.map.jsonmappingexception: no serializer found class org.json.jsonobject , no properties discovered create beanserializer (to avoid exception, disable serializationconfig.feature.fail_on_empty_beans) ) ajax code $('#click').click(function() { $.ajax({ url: "http://localhost:8080/test/rest/myservice/jsonpost", method: "post", data: jsonobj, datatype: 'application/json', contenttype: "application/json", success: function(result){ alert(result); }, error(){ alert("error"); console.log('error'); } }); }); my code : @post @path("/jsonpost") @consumes(mediatype.a

Variable in Command in bash script -

hello want automate setting users on servers. started simple bash #! /bin/bash if [ $# -ne 2 ] echo "usage: $(basename $0) username password" exit 1 fi user_name=$1 password_var=$2 exec useradd -m $user_name usermod -s /bin/bash #echo "$2" | exec chpasswd $user_name --stdin usermod -ag www-data "${user_name}" i have problem last line. user created not assigned group www-data . when use last line , comment everthing else , feed 1 user script able add myself, can explain me why faling? exec useradd -m $user_name substitutes current process ie bash here useradd -m $user_name . don't see practical advantage of using exec here. also, linux password can have whitespaces, suggest doing password_var="$2" #prevents word splitting with error checking, final script be password_var="$2" useradd -mp "$password_var" "$user_name" # haven't used password if [ $? -ne 0 ] # checking exit sta

loops - How to output HTML from array in PHP -

sorry if subject bit strange. didn't know else name it. i style peace of code fit style of website. <?php global $post; $opties = wp_get_post_terms($post->id, 'items', array("fields" => "names")); if (count($opties) > 0) { echo implode(', ', $opties); } ?> right echo's item 1, item 2, item 3, etc... i have echo following: <i class="fa fa-check" aria-hidden="true"></i>item 1<br> <i class="fa fa-check" aria-hidden="true"></i>item 2<br> <i class="fa fa-check" aria-hidden="true"></i>item 3<br> how code that? in advance! you can combine html using alternative syntax foreach . <?php global $post; $opties = wp_get_post_terms($post->id, 'items', array("fields" => "names")); foreach ($opties $o): ?> <i class="fa

jquery - Get Label Value of radio button outside of element -

i have following html/razor of settings view defined el , outside of defined element 3 radio buttons , labels. settings view <div id="settingsview" class="cardheader">@resources.decisionsupport.index.timetable <span id="currentttheader"></span> <i id="settingsbutton" class="octicon octicon-gear dsttsettingsbutton dsdisabledelement"></i> <span id="selectedsettings"></span> </div> <div class="cardbody"> <div id="calendar"></div> </div> radio buttons <div id="settingsradios"> <div class="radio radio-info radio-inline"> <input type="radio" id="simpleradio" name="settingsradio" /> <label for="simpleradio">@resources.decisionsupport.index.simpleviewlabel</label> </div> <span class="dssetting

ios - How to segue to a new ViewController from infowindow of Google Maps in Swift? -

i'm trying figure out video:( https://www.youtube.com/watch?v=573hrwijjeo ), , i'm still trying implement on swift project unsuccessful lot. curious , have 2 questions it, help? how create "info icon" , "image" in infowindow of google maps? (0:18) how click info icon, segue next viewcontroller? (0:20) any advice appreciated. time , help! i think video google can that. explains here how place image inside info window, not image only. disccused here how design or make custom info window. video includes sample code in how make it. here steps need in building custom infowindow construct new nib file named infowindow create uiview subclass called custominfowindow configure uilabels content , load photo for more information, check related so question .

excel - How to copy and paste rows with filtering and hidden columns? -

i trying copy , paste row in spreadsheet has filtering , hidden columns. reason, when filtering on, excel doesn't copy hidden columns , when paste row, omitting hidden columns. is there workaround problem? maybe secret shortcut copies cells in selection, including hidden ones? thanks. easy solution here (you loop through sheet , store indexes of hidden columns, think might take more time making copied sheet) sub copyhiddencolumns() dim destinationsheet worksheet, tempsheet worksheet, copysheet worksheet set destinationsheet = thisworkbook.worksheets("destsheet") set copysheet = thisworkbook.worksheets("copysheet") copysheet.copy before:=thisworkbook.worksheets(1) set tempsheet = thisworkbook.worksheets(1) tempsheet.usedrange.hidden = false tempsheet.usedrange.copy destination:= destinationsheet.range("a1") application.displayalerts = false tempsheet.delete application.displayalerts = true en

java - JAVA_HOME default in ubuntu -

i using ubuntu 14.0.4... java_home /usr/lib/jvm/java-7-oracle though uninstalled java... i manually set /usr/lib/jvm/jdk1.8.0_71 in etc/environment . $echo java_home shows /usr/lib/jvm/java-7-oracle . how resolve issue , how use jdk1.8.0_71 in java_home . try edit ~/.profile . add line @ bottom: java_home="/usr/lib/jvm/jdk1.8.0_71" after editing, close console (terminal) window , open new. test echo java_home.

freebsd - A quesiton about "Warning: Object directory not changed from original" when executing "make" command -

i post issue on freebsd mailing list , unfortunately can't receive response. repost question here, , hope behavor doesn't violate conduct code of so. i writing simple freebsd kernel module. after rebooting machine (i not sure whether reason), find " make " command can't work, , prompts following words: # make warning: object directory not changed original /root/hello even though delete , upload new file, issue still exists. after referring post , try " make obj " command, " make " works: # make obj /usr/obj/root/hello created /root/hello # make @ -> /usr/src/sys machine -> /usr/src/sys/amd64/include x86 -> /usr/src/sys/x86/include ...... i can't figure out root cause behind it: (1) why make complain " warning: object directory not changed original /root/hello " although have updated file? (2) why " make obj " can save " make "?

html - How can call a function in service on click event in angular2? -

this working plunker : http://plnkr.co/edit/fojhoflsglrb4po5li6b?p=preview . on clicking classes corresponding content @ bottom changes, hardcoded & possible have makes content come service : export class subjectservice { getclass(id : number) : { if(id==15) return [{label: 'science', state: false},{label: 'computer science', state: false},{label: 'social science', state: false},{label: 'environmental studies', state: false}]; else if (id==68) return [{label: 'english', state: false},{label: 'hindi', state: false},{label: 'mathematics', state: false},{label: 'science', state: false}]; else if (id==910) return [{label: 'english', state: false},{label: 'hindi', state: false}{label: 'social science', state: false},{label: 'sanskrit', state: false}]; else return [{label: 'english', state: false}{label: 'pol science',

azure service fabric - Increase timeout for RunAsync -

i creating number of service bus clients in runasync method on statefull service. the method takes longer 4 seconds allowed when running in development environment , application fail start. it fails because of appears latency between dev machine , azure. i in thailand. azure in south central us. can 4000 millisecond timeout increased locally on dev box? the error is: { { "message": "runasync has been cancelled stateful service replica. cancellation considered 'slow' if runasync not halt execution within 4000 milliseconds. "level": "informational", "keywords": "0x0000f00000000000", "eventname": "statefulrunasynccancellation", "payload": { [...] "slowcancellationtimemillis": 4000.0 } } the problem not runasync takes long run, it's takes long cancel . service fabric has default (hard-coded) timeout 4 seconds reporting "slow&q

typescript - Angular 2 cannot find file name 'Set' -

currently, updating project angular2 beta15 rc4. when compiling, getting error: path/node_modules/@angular/common/src/directives/ng_class.d.ts(81,35): error ts2304: cannot find name 'set'. my tsconfig.json looks following: { "compileroptions": { "target": "es5", "module": "commonjs", "sourcemap": true, "emitdecoratormetadata": true, "experimentaldecorators": true, "moduleresolution": "node", "removecomments": false, "noimplicitany": true, "suppressimplicitanyindexerrors": false, "declaration": true, "outdir": "tmp/app" }, "exclude": [ "node_modules", "dist", "tmp" ] } in main.ts have included: /// <reference path="../typings/index.d.ts" /> /// <reference path="../typings/tsd.d.

swift - How to get search bar background transparant?(see image) -

Image
i using searchcontroller in view, can not rid of annoying background of searchbar. the code using: import uikit class systemtable: uitableviewcontroller, uisearchbardelegate , uisearchresultsupdating{ @iboutlet var systemtable: uitableview! var searchcontroller = uisearchcontroller() override func viewdidload() { super.viewdidload() self.searchcontroller = ({ let controller = uisearchcontroller(searchresultscontroller: nil) controller.searchresultsupdater = self controller.searchbar.sizetofit() controller.searchbar.delegate = self controller.searchbar.bartintcolor = uicolor.lightgraycolor() controller.searchbar.translucent = true controller.searchbar.alpha = 1 controller.searchbar.backgroundcolor = uicolor.clearcolor() controller.searchbar.layer.opacity = 1 self.tableview.tableheaderview = controller.searchbar return controller })() } image: to clear: want rid of back

Shiny server.R failed to uploaded libraries -

i'm trying fix amazing error. here`s header of server.r: library(shiny) library(plotly library(dt) library(rcpp) library(rsqlite) library(org.mm.eg.db) library(shinybs) library(igraph) library(reshape2) library(ggplot2) library(org.hs.eg.db) library(visnetwork) i expect these libraries uploaded when running ythe application, instead in 3 cases : visnetowrk, plotly , shinybs i`m getting several errors: error : not find function "visnetworkoutput" error : not find function "plotlyoutput" error : not find function "bstooltip" so need include these libraries manually using console: library(plotly);library(visnetwork);library(shinybs) how overcome this? in advance!

angularjs - Checkbox binding in ng-repeat angular js -

https://jsfiddle.net/bngk/7urrobaa/ <div ng-repeat="item in items" ng-init="item.showcb = item.value == 'true' || item.value == 'false'"> <input type="checkbox" ng-if="item.showcb" ng-true-value="true" ng-false-value="false" ng-model="item.value" ng-checked="item.value == 'true'">{{items[$index].value}}</input> <input type="text" ng-if="!item.showcb" ng-model="item.value"/> </div> i have problem in binding checkboxes in ng-repeat if have few checked values default values not updated in model , if non-checked default, works value updated in model, holds boolean value though mentioned ng-true-value="true" , ng-false-value="false" string. want string value present in model. please check in fiddle. support. if have @ documentation: https://docs.angularjs.org/api/ng/input/input%5bchec

sql - Split a column into two or more in Oracle -

lets table looks : ------------------------- | id | prop | ------------------------- | 1 | jhon_dhoe_21 | ------------------------- | 2 | tom_dohn_23_male | ------------------------- | 3 | scot | ------------------------- the properties devided "_". after select table should this: -------------------------------------- | id | prop1 | prop2 | prop3 | prop4 | -------------------------------------- | 1 | jhon | dhoe | 21 | null | -------------------------------------- | 2 | tom | dohn | 23 | male | -------------------------------------- | 3 | scot | null | null | null | -------------------------------------- now if know maximum number of properties ( n ) have suppose can create n number of regex expresions on prop column or something. if not know maybe have first find row properties ? edit: i can't accept multiple rows. it interesting question, i've solved way: with tbl ( select 1 i

api - org.mule.module.launcher.DeploymentInitException: SAXParseException: Premature end of file -

i using mule api gateway , have deployed package in it. in api gateway org.mule.module.launcher.deploymentinitexception: saxparseexception: premature end of file. i have tried in version 1.3.0 , 3.8.0. in both got same error. please me. file : <http:connector name="httpconnector" /> <esper:config name="espermodule" configuration="esper-config.xml" /> <mxml:dom-to-xml-transformer name="domtoxmltransformer" /> <flow name="websocket-esper-bridge"> <http:inbound-endpoint address="niohttp://localhost:8080/websocket/events" exchange-pattern="one-way"> <http:websocket path="events" /> </http:inbound-endpoint> <custom-processor class="com.mulesoft.demo.mule.websocket.esperwebsocketupdatelistener"> <spring:property name="espermodule" ref="espermodule" /> <spring:p

javascript - "this" reference is not working in nodeJs -

i have 2 methods in nodejs code function method1(id,callback){ var data = method2(); callback(null,data); } function method2(){ return xxx; } module.exports.method1 = method1; module.exports.method2 = method2; for testing function method1 using sinon , mocha had stub method method2. required call method method2 function method1(id,callback){ var data = this.method2(); callback(null,data); } test code this describe('test method method2', function (id) { var id = 10; it('should xxxx xxxx ',sinon.test(function(done){ var stubmethod2 = this.stub(filex,"method2").returns(data); filex.method1(id,function(err,response){ done(); }) }) }) using test cases passed, code stopped working error this.method2 not function. is there way can rid of this or module.exports seems buggy. please let me know if missed other info.. you not using module.exports correctly. change code to:

java - retriving and accessing identical elements in Selenium -

Image
i automating tests webapp selenium in java. 1 of test cases has use slider 2 points on (for choosing age range) in html-code both points represented the style-attribute left: changes accordingly position of point on slider bar. now problem facing: i cannot hold on both of slider-elements @ same time. have tried: pagefactory @findall , both css selectors , xpath: @findall({ @findby(xpath = "//slider/span") }) private list<webelement> agesliders; driver.findby(...) css , xpath selectors - globally , locally in method, in case there problems pagefactory element initialisation getting parent element , iterating through children slider points some other combinations of above whatever however, retrieves 1 element twice. example doing: system.out.println(driver.findelement(by.xpath("//slider/span[@class='pointer'][1]"))) system.out.println(driver.findelement(by.xpath("//slider/span[@class='pointer'][2]")))

javascript - Getting error when pass data between controllers using sample service -

as part of angular js learning, created small app pass data between 2 controllers using services..below code pass data between 2 controllers.. controller code <!doctype html> <html lang="en-us" ng-app="myapp"> <head> <title></title> <script src="https://code.angularjs.org/1.5.8/angular.min.js"></script> <script type="text/javascript"> var app = angular.module('myapp', []); app.service('sampleservice', [function () { this.user = [name = 'pra', empno ='1234'] this.designation = 'teamlead'; }]) app.controller('namectrl', ['$scope','$sampleservice', function ($scope,$sampleservice) { $scope.empname = $sampleservice.user.name; $scope.empnumber = $sampleservice.user.empno; $scope.empdesignation = $sampleservice.designation; $scope.changevals = function(){ $sampleservice.user.empno = '9876'; $sampleservi

android - My App Spinner is getting in last -

Image
hey guys want set spinner default text in top select category shown last when fetch data data base want set text on top of items my code is private void loadspinnerdata() { socialdatabase db = new socialdatabase(getapplicationcontext()); arraylist<string> lables = db.getalllabels(); lables.add("select category"); arrayadapter<string> dataadapter = new arrayadapter<string>(this, r.layout.spinner_text, lables); dataadapter .setdropdownviewresource(r.layout.spinner_text); txtspinner.setadapter(dataadapter); } this output [ want this please me try line of code replace lables.add("select category"); with lables.add(0, "select category");

polymer - Iroin-ajax response with html tags -

this question has answer here: how inject html template polymer 3 answers i'm getting json feed iron-ajax, in returned json come html tags this. [{ pk :1, body: "<p>ثم سكان بشرية الأبرياء عدد, كلّ يقوم الطرفين و. وبدأت انذار عل بحق, تكبّد إستيلاء الأثناء، دنو بـ, عالمية العالم، بالمطالبة قد الى. وزارة السبب التّحول فصل بل, كل والتي واشتدّت وايرلندا بعض. إحتار واندونيسيا، بلا لم, بوابة الفترة بين بل. </p> <p>ثم سكان بشرية الأبرياء عدد, كلّ يقوم الطرفين و. وبدأت انذار عل بحق, تكبّد إستيلاء الأثناء، دنو بـ, عالمية العالم، بالمطالبة قد الى. وزارة السبب التّحول فصل بل, كل والتي واشتدّت وايرلندا بعض. إحتار واندونيسيا، بلا لم, بوابة الفترة بين بل.".</p> <p>ثم سكان بشرية الأبرياء عدد, كلّ يقوم الطرفين و. وبدأت انذار عل بحق, تكبّد إستيلاء الأثناء، دنو بـ, عالمية العالم، بالمطالبة قد الى. وزارة السبب التّحول فصل بل, كل والتي واشتدّ

rspec - To click on all check box and match [Ruby Selenium-webdriver] -

when click on select checkbox right corner value shows "selected 4 " need write case match selected 4 how can that? using ruby selenium driver.find_element(:name, "xbox").click element :selectedcount, :css, 'span[id=systems_removal_count]' your question isn't clear looks you're using site_prism i'm assuming have sort of page object i'll name @home on selectedcount element defined. mathew check text like expect(@home.selectedcount).to have_text('selected 4') or expect(@home.selectedcount).to have_text('4') depending on you're expecting in element

ios - Xcode accidentally removed reference to a file -

i accidentally removed reference .h file in xcode. the file nuisance , needs deleted. tried finding physical location of file , deleting through finder caused build fail. have restored physical location. i need undo "remove reference" can delete file through xcode properly. thanks help

c# - Copy HSSFCellStyle to XSSFCellStyle in NPOI -

my input file .xls have read data, manipulate , write .xlsx file along styles. so, using npoi hssf read .xls , npoi xssf generate .xlsx file. done data. have copy cell formats .xls , apply output file. when write outputheaderstyle.clonestylefrom(inputheaderstyle); exception occurs inputheaderstyle of type hssfcellstyle , outputheaderstyle of type xssfcellstyle can clone 1 xssfcellstyle another, not between hssfcellstyle , xssfcellstyle outputheaderstyle.clonestylefrom((xssfcellstyle)inputheaderstyle); throws exception unable cast object of type 'npoi.hssf.usermodel.hssfcellstyle' type 'npoi.xssf.usermodel.xssfcellstyle' is there other way copy style? well, cell style of .xls file hssfcellstyle , .xlsx file xssfcellstyle. there no direct way convert hssfcellstyle xssfcellstyle in npoi. i managed program copying 1 one style individually. _xssfstyle .borderleft = _hssfstyle .borderleft; _xssfstyle .borderright = _hssfstyle .bor

javascript - how to open a new browser insatnce not tab with angualrjs -

i need open new window when clicking on button ,i used way $scope.openinnewwindow = function () { $window.open('/newwindow.html', '_blank'); } but opens new tab, need new browser instance try http://plnkr.co/edit/f50fwhnlbc3y43mx6iuo?p=preview $window.open('/newwindow.html',"_blank", "toolbar=yes,scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

Codenameone: Unable to find packages during build -

when build application following errors. can please let me know how resolve it. application needs supported on platforms (andriod, ios, windows) , don't want write native code platforms separately. java:4: error: package java.lang.reflect not exist import java.lang.reflect.undeclaredthrowableexception; java:6: error: package javax.crypto not exist import javax.crypto.mac; ^ 7: error: package javax.crypto.spec not exist import javax.crypto.spec.secretkeyspec; java:48: error: cannot find symbol mac hmac; 50: error: cannot find symbol [javac] hmac = mac.getinstance(crypto); ^ java:53: error: cannot find symbol [javac] secretkeyspec mackey = ^ [javac] symbol: class secretkeyspec [javac] location: class tokengenerator java:55: error: cannot find symbol [javac] new secretkeyspec(keybytes, "raw"); ^

javascript - Must not display more when I get data from database -

i number of news database, example when max limit of news such receive 24 news in total, tag "download more news"¨ everything plays should, must away such 1 can not "download more news" button. just show can not download more news index.html <div class="col-md-12" ng-app="newsload" ng-controller="listnews"> <ul class="team-list sort-destination"> <li class="col-md-4 col-sm-6 col-xs-12 isotope-item leadership" ng-repeat="new in newslist | limitto: totaldisplayed" style="max-height:380px; float:left;"> @*html here*@ </li> </ul> <div class="form-group col-md-12" style="margin-top:23px;"> <button class="btn-block btn btn-info" ng-click="change()">download more news</button> </div> </div> load.js var

ggplot2 - Conserve grouping in ggrepel (R) -

i label points "box points"-plot sub-grouped. problem current ggrepel code omits sub-grouping. here example df: phenotype <- c("healthy", "healthy","healthy", "sick1", "sick1","sick1", "sick2", "sick2", "sick2" ) individual <-c(1:9) genotype <- c("nothing", "nothing", "nothing", "muta", "unknown", "muta", "mutb", "unknown", "unknown") variable <- c("var1", "var1", "var1", "var1", "var1", "var1", "var1", "var1", "var1") value <- c("1.2", "1.3", "1.3", "2.5", "2.5", "2.4", "4.1", "4.2", "4.3") df <- data.frame(phenotype, individual, genotype, variable, value) and here code plot: library(ggplot2

c++ - Adding a string to a string pointer -

is possible add string string pointer in c++? not working example: string* temp; temp[0] = "string"; just it's possible in: string temp[3]; temp[0] = "string"; before suggesting use normal array or copy different fixed array, string pointer needs returned in function. eg. string* someclass::toarray(string str) i open other suggestions how can return array function. independing of string code snippet string* temp; temp[0] = "string"; if compiled results in undefined behaviour because pointer temp either has indeterminate value (if local variable) or null , may not derefence it. provided code snippet string temp[3]; temp[0] = "string"; is valid write example string* other_temp = temp; other_temp[0] = "string";

How to secure Apache Camel rest endpoint with Spring Security and OAuth2 -

i'm working on spring boot application configured sso/oauth2 security. authentication works fine rest controllers , need secure apache camel route rest endpoint. as understand there several ways how it: by adding auth processor route by adding policy (springsecurityauthorizationpolicy) route by handlers option jetty endpoint i'm trying adding new auth processor rest endpoint stuck on exception: org.springframework.security.oauth2.common.exceptions.oauth2exception: no authenticationprovider found org.springframework.security.web.authentication.preauth.preauthenticatedauthenticationtoken during debugging see org.springframework.security.authentication.providermanager.getproviders() contains 1 provider anonymousauthenticationprovider have register appropriate provider... can me find right way solve problem please? @configuration public class securityconfig extends websecurityconfigureradapter { protected void configure(httpsecurity http) throws

Can there be multiple instances of a dependency in Xamarin.Forms? -

i have mirrored code xlabs network state tracking on device here: xlabs inetwork android implementation i've pretty aligned coding standards here , changed method names - working fine, except reason on android implementation unable event handlers respond, same way on ios. this adaptation android: [assembly: dependency(typeof(stm.droid.dependencyinjection.network))] [assembly: usespermission("android.permission.access_network_state")] [assembly: usespermission("android.permission.access_wifi_state")] [assembly: usespermission("android.permission.change_network_state")] [assembly: usespermission("android.permission.change_wifi_state")] namespace namespace.droid { [broadcastreceiver(enabled = true)] [intentfilter(new [] { android.net.connectivitymanager.connectivityaction })] public class network : broadcastreceiver, inetwork { /// <summary> /// internets connection status. /// </summary