Posts

Showing posts from January, 2010

c++ programming function error -

my full code (couldn't make smaller) : /*password admin*/ #include <iostream> #include <fstream> #include <algorithm> #include <string> using namespace std; //------------------------------- fstream d_base; char path[] = "library books.txt"; void output(){ //this function displaying choices cout << "***********************************" << endl; cout << "1. list books in library" << endl; cout << "2. list available books borrow " << endl; cout << "3. borrow book library" << endl; cout << "4. search book" << endl; cout << "5. add new books"<< endl; cout << "6. delete book" << endl; cout << "7. exit library"<< endl; cout << "***********************************" << endl; } //=======================================================================...

ruby on rails - Capybara "can't find" text field, yet fills it in -

in integration specs, log users in this: fill_in "session_email", :with => user.email fill_in "session_password", :with => password click_button "submit" capybara fails tests unable find field "session_email" . strange thing is, fills in fields , logs user in (i can see output sessions controller, , when use selenium can see working). tests fail. the log-in thing opens in bootstrap modal. i'm using capybara (2.1.0) , capybara-webkit (1.0.0). has else experienced this? what's solution? i had similar issue, , switching capybara-webkit fixed me. using bootstrap well, not sure if selenium doesn't bootstrap or what, webkit worked me

linux - Translating a vimrc to Windows -

i installed vim windows, , trying port vimrc linux. the bash script in vimrc need make work follows : set nocompatible source $vim behave mswin let icanhazvundle=1 let vundle_readme=expand('$vim/bundle/vundle/readme.md') if !filereadable(vundle_readme) echo "installing vundle..." echo "" silent !mkdir $vim/bundle silent !git clone https://github.com/gmarik/vundle $vim/bundle/vundle let icanhazvundle=0 endif " required vundle filetype off set rtp+=$vim/bundle/vundle/ call vundle#rc() " let vundle manage vundle " required! bundle 'rip-rip/clang_complete notice checks see if vundle packages have been installed or not(based on existence of readme), , installs them if not. included first bundle call give idea of how executes. difference in code below , original linux script replaced entries linux file system: ~/.vim $vim . when run :echo $vim in windows vim terminal gives me proper path. script runs, fails c...

unix - Regex & ls or find -

i need select directories between periods of 2014 0729 - 2014 0921 . the directories this. 20140729_154208 20140814_221350 20140829_215623 what best method this? thanks using find in order find files modified within range, if creation time of last file in directory matches directory name , easiest way create files @ boundaries of range , use -newer predicate. touch -t 201407290000 start touch -t 201409210000 stop find . -newer start \! -newer stop -type d (i know not how work dates within regex , hope have time learn) using awk yeah, why not using awk instead of building static regex match case? pass find or ls result awk little program checking result between stop , start (nb: find had substr(3,10) comparison): find . |awk -v start=20140729 -v stop=20140921 \ '{ curr=substr($0, 3, 10); if (curr <= stop && curr >= start) { print $0 } }' (it worked me on aix , linux )

Powershell - converting hex from the registry key -

i have following output mru list. how can convert string or ascii characters? 'gp "hkcu:\software\microsoft\windows\currentversion\explorer\comdlg32\lastvisitedpidlmru"' 18 : {80, 0, 120, 0...} 5 : {50, 0, 109, 0...} assuming gp "hkcu:\software\microsoft\windows\currentversion\explorer\comdlg32\lastvisitedpidlmru" gives : pspath : microsoft.powershell.core\registry::hkey_current_user\software\microsoft\windows\currentversion\explorer\comdlg32\lastvisitedpidlmru psparentpath : microsoft.powershell.core\registry::hkey_current_user\software\microsoft\windows\currentversion\explorer\comdlg32 pschildname : lastvisitedpidlmru psdrive : hkcu psprovider : microsoft.powershell.core\registry mrulistex : {14, 0, 0, 0...} 11 : {114, 0, 117, 0...} 9 : {69, 0, 120, 0...} 19 : {83, 0, 107, 0...} 10 : {78, 0, 79, 0...} 17 : {123, 0, 57, 0...} 15 : {115, 0...

(Excel-VBA) Specific data import (on the background) in the active sheet -

would please me (total beginner) prepare vba macro open sheet on background , import specific selection shown below: let's have downloaded wordcount analysis (xlsx) this downloaded cat tool testing. now need add macro main sheet read lines starting (column a) "all". if "all" i'd need record columns of line (specficilly columns - o) in array / hashtable?. please take @ this image summs (better explaining me :-) let me know in case need know more details. all tips / suggestions appreciated. many thanks! my suggestion (i'm beginner too) use macro recorder. great tool learn ( example ). start recording filter 'all' copy/past cells stop recording then have @ recorded code , adjust :)

python - Heroku refuses connection to postgres database -

i trying deploy flask app based on postgresql on heroku, when try create table db.create_all() keep getting error: (psycopg2.operationalerror) not connect t rver: connection refused server running on host "localhost" (127.0.0.1) , accepting tcp/ip connections on port 5432? here how code looks like: app=flask(__name__) app.config['sqlalchemy_database_uri']='postgres://kfgriimpfjecsv:bk1*****g@localhost:5432/dd71doth8gopgh' db=sqlalchemy(app) if __name__ == '__main__': app.debug=true app.run() i using heroku toolbelt communicate heroku servers. also, when try this: psql -p 5432 -h localhost i same error: psql: not connect server: connection refused server running on host "localhost" (127.0.0.1) , accepting tcp/ip connections on port 5432? i tried ec2-23-21-215-184.compute-1.amazonaws.com instead of localhost in uri, got same error. and here complete traceback when run db.create_all(): ...

html - Display separate text strings each day -

i want display text string, or bit of code each day of week 2 weeks, repeat. through days display monday 1, tuesday 1...friday 1, monday 2, tuesday 2...friday 2. revert monday 1. if there way without using i-frame (have spell let me post question) site please say. have tested out i-frame never seems work. maybe counter when reaching 14 revert 1 again. thank in advance! you should able achieve pure javascript using following: date.prototype.getweek = function() { var onejan = new date(this.getfullyear(),0,1); var today = new date(this.getfullyear(),this.getmonth(),this.getdate()); var dayofyear = ((today - onejan +1)/86400000); return math.ceil(dayofyear/7) }; var sentences = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelvth", "thirsteenth", "fourteenth...

bootstrapping code in R doesn't work? -

so ready jump off building because cannot figure out code life. everytime run it, standard error of 0 (bias=0 too) i'm doing wrong because it's using same sample when want 1000 iterations. i want aic of model these samples. i've created data frame , named "d." here code: bootaic<-function(d, idx){ d2<-d[idx,] fit<-coxph(surv(time,infection) ~ x48fl + x55fl, method="efron", data=d) return(aic(fit)) } bootf<-boot(data=d,statistic=bootaic,r=1000) what wrong. appreciate , help, novice bootstrapping , suck @ coding.

How to change some text in a form using jquery -

i need change text in form "search listings type:" (translation in spanish "buscar listado por categoria") <form action="" id="searchform" method="get" role="search"> <input type="hidden" name="s" value=""> <input type="hidden" name="post_type" value="listing"> <select style="float:left;" class="wp-listings-taxonomy custom_search" id="status" name="status"> <option selected="selected" value="">search listings type:</option> <option value="features">featured</option> <option value="new">new</option> <option value="for-sale">for sale</option> <option value="for-rent">for rent</option> </select> <div class="btn...

c - Multiple string concatenation -

this question has answer here: how concatenate const/literal strings in c? 17 answers i'm new c language , loadrunner. how do string concatenation in c. pseudo code: string second = "sec"; string fouth = "four"; system.out.println("first string" + second +"third" + fouth); if sure target string can accommodate, can use snprintf , #define size 1024 char target[ size ]; // .. .. snprintf( target, sizeof( target ), "%s%s%s", str1, str2, str3 ); for case, snprintf( target, sizeof( target ), "%s%s%s%s", "first string", second, "third", fourth ); of course, second , fourth should valid string (character array).

android - RxJava and facebook sdk threads trigger periodic cpu load in the background -

Image
i observed periodic cpu load after app closed home button. load caused threads part of facebook android sdk , rxjava. overview (trace period of 2 minutes after app closed home button): facebook sdk active: rxjava active: i know these threads active < 1ms. have feeling waking ever 15 seconds (facebook) / 70 seconds (rxjava) bad battery life. on average leads waking every 10 seconds. observed behavior continues till app killed system. is behavior problematic , reduce battery life of device or shouldn't cause problems? facebook: facebooksdk.sdkinitialize(this); // application.oncreate appeventslogger.activateapp(this, getstring(r.string.app_id)); // activity.onresume appeventslogger.deactivateapp(this, getstring(r.string.app_id)); // onpause rxjava: .subscribeon(schedulers.computation()) .observeon(androidschedulers.mainthread()) versions: facebook-android-sdk:4.9.0 rxjava:1.1.0 rxandroid:1.1.0

swift - Indicator activity not showing -

Image
i have code show activity indicator in swift, it's not working properly. the activity indicator doesn't appear, after code inside configuration func loaded correctly. what going wrong in code? here code , image: import uikit class selecionapaisviewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource, uisearchresultsupdating { //mark: - outlets @iboutlet weak var paisestableview: uitableview! //mark: - propriedades var paises = [paiscodigo]() var paisesfiltrado = [paiscodigo]() var controladordebusca: uisearchcontroller! var container: uiview = uiview() var loadingview: uiview = uiview() var indicadordeatividade: uiactivityindicatorview! //mark: - métodos reescritos da view override func viewdidload() { super.viewdidload() paisestableview.delegate = self paisestableview.datasource = self //carrega configuração searchcontroller configurarcontroladordebusc...

C# Get Time from Network Attached Storage on Small LAN -

i don't know if can done or not, please patient me. first describe environment. we have 8 laptops used offline work in stand-alone access database. have large wired router. nas drive connected router. when laptop users come in field, connect laptops router. front-end access database c# program. master copy of database exists on nas. lan not connected internet. when users connect laptops lan, want full sync occur. so, new records exist on nas database downloaded laptops. new records have created on laptops uploaded nas. all primary keys guid's. have added datetime field each table. anytime record in table added or changed, timestamp updated. no records ever deleted. each users laptop know datetime of last snc. download users laptop records timestamp newer last sync. upload nas based on time well. so, cannot guarantee users laptops time synced each other. these laptops never connected internet or server. not want use times users laptops record timestamps. want time ...

html - How do i make all the columns equally big? -

@import url(https://fonts.googleapis.com/css?family=open+sans:400,600|lato|montserrat&subset=greek); body { background-repeat: no-repeat; background-attachment: fixed; background-size: cover; } .desc { margin-top: 40px; text-align: center; font-size: 100px; color: darkred; } .cool { display: inline-block; width: 100%; } .topbar { position: fixed; top: 0px; width: 100%; right: 0px; background-color: tomato; text-align: right; height: 50px; z-index: 100; } .texti { margin-right: 15px; } .linkur { border: 1px solid black; padding: 8.5px; margin-right: 10px; text-decoration: none; border-color: transparent; font-size: 1.3em; color: darkred; } .linkur:hover { background-color: lightblue; opacity: 0.7; } label { position: fixed; top: -2000px; } .mynd { position: fixed; top: -50px; left:20px; } .navigation { height: 96%; width: 20%; background-color: tomato; ...

sublimetext3 - How do they make multiple columns to a single line with spaces between? -

https://www.sublimetext.com/ on "video" 2/6 how make multiple columns single line spaces between? thanks on sublime, can put every selected line on unique line pressing ctrl+j. other possibility: when @ end of line , press "delete" erase end of line. indeed, "delete", unlike "backspace" erase character on right of cursor, not on left example: qqqqq aaaaa if put cursor @ end of qqqqq , press "delete", obtain: qqqqqaaaaa now in subime, multiple cursor, same thing erase every cursor's right character. to have multiple cursor, press alt+shift , use or down array on keyboard. can middle button of mouse create multiple cursors. once cursors create, press "end" key on keyboard place cursors @ end of line. thus, can press "delete". column become line. then, feel free add spaces, comas or other punctuations.

java - The path to the driver executable must be set by the webdriver.gecko.driver system property -

i'm trying resolve problem described here: https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/4757 building selenium standalone server locally, after edits. , after release local version of selenium standalone server "selenium-server-standalone-3.0.0-beta1.jar", , runs. when i'm trying connect server protractor or selenium builder error: "webdrivererror: path driver executable must set webdriver.gecko.driver system property; more information, see https://github.com/jgraham " how integrate (or something) selenium standalone serer integrated firefox driver? the way worked me clone sources github using git. earlier downloaded zip , doesn't work, clone sources sunig git , steps described here: http://shengwangi.blogspot.ru/2014/08/how-to-build-selenium-from-source.html , except "download 3rd party library" step.

sql server - SQL: If field is empty, return empty string, otherwise cast as number -

i'm running sql server 2008 (otherwise use try_parse) , need cast field number in cases non-empty. if field empty, empty string or null should returned. prefer if field stored number in database, have no control on @ time. here have tried: select case when accountnumber='' '' else cast(accountnumber bigint) end accountnumber accounts or select case when cast(accountnumber bigint)=0 '' else cast(accountnumber bigint) end accountnumber accounts but both of these bring 0 empty account numbers. feel should possible going crazy trying figure out! thanks! you can't select both numbers , empty strings same column, because incompatible types. that's why empty strings converted automatically 0. null should work, however. select case when accountnumber='' or accountnumber null null else cast(accountnumber bigint) end accountnumber accounts

c++ - openGL - understanding colors changes due to lightning -

i writing software in c, render yellow , brown cube. once programmed light, colors changes light blue. explain me why colors changed? , how can prevent such extreme change? this code used light: glfloat color1 = {0.633, 0.237, 0.170}; \\ changed blue void initlight() { glfloat red[] = {1.0,0.0,0.0,1.0}; glfloat white[] = {1.0,1.0,1.0,1.0}; glfloat bluegreen[] = {0.0,0.4,1.0,1.0}; gllightmodelfv(gl_light_model_ambient, white); gllightfv(gl_light0,gl_ambient,white); gllightfv(gl_light0,gl_diffuse,bluegreen); glmaterialf(gl_front,gl_shininess,127.0); glenable(gl_light0); } based on fact you're using immediate mode, assume wrote looks setting vertices? glbegin(gl_triangles); glvertex3f(/*...*/); glcolor3f(/*...*/); /*...*/ glend(); when add lighting scene, renderer no longer considers color values proposed individual vertices, , instead substitutes in white or grey (causing light turn faces blueish-green). fix that, need t...

javascript - Can't set Dropzone options on window.onload -

i'm trying add dropzone.js website i'm having problem setting options when want. using jquery can run on $(document).ready() this: <body> <form action="/upload" class="dropzone" id="upload-dropzone"></form> <script src="app.js"></script> </body> //app.js var dropzone = require("../vendor/js/dropzone"); $(document).ready(function(){ dropzone.options.artworkuploaddropzone = { init: function () { console.log("init!"); } }; }); however, want use dropzone without jquery , instead set options on window.onload . i've tried following init function not executed. <body> <form action="/upload" class="dropzone" id="upload-dropzone"></form> <script src="app.js"></script> </body> //app.js var dropzone = require("../vendor/js/dropzone");...

android - Dependency configurations -

i know if make library uses product flavors, when use library in application, can in gradle: dependencies { flavor1compile(path: '{path}', configuration: 'flavor1config') flavor2compile(path: '{path}', configuration: 'flavor2config') } i know can this: dependencies { debugcompile(path: '{path}', configuration: 'debugconfig') releasecompile(path: '{path}', configuration: 'releaseconfig') } what want this: dependencies { flavor1debugcompile(path: '{path}', configuration: 'flavor1debugconfig') flavor1releasecompile(path: '{path}', configuration: 'flavor1releaseconfig') flavor2debugcompile(path: '{path}', configuration: 'flavor2debugconfig') flavor2releasecompile(path: '{path}', configuration: 'flavor2releaseconfig') } but code produces this: error:(30, 0) gradle dsl method not found: 'flavor1debugcompile()...

performance - php - efficiency of if conditions - nested or using the AND method? -

this question has answer here: what better ? multiple if statements, or 1 if multiple conditions 8 answers in php, can use nested if structure, or can combine conditions using && method ... there known differences in regards performance/efficiency? (is 1 known/established faster, or less resource intensive etc.?) nested: if ($x == $y) { if ($n >= $p) { if ($tt != true) { // } } } or combined and: if ($x == $y && $n >= $p && $tt != true) { // } i know appears duplicate of php nested ifs vs single if multiple conditions because wasn't answered (instead people linked things in java etc.). so please don't flag dupe, or link answers of non-php questions etc. talking of efficiency, don't think there difference in both. if 1 boolean decision false in 1 line stateme...

Isolate an email address from a string using MySQL -

i trying isolate email address block of free field text (column name text). there many different variations of preceding , succeeding characters in free text field, i.e.: email me! john@smith.com e:john@smith.com m:555-555-5555 john@smith.com--personal email i've tried variations of instr() , substring_index() first isolate "@" (probably 1 reliable constant in finding email...) , extracting characters left (up until space or non-qualifying character "-" or ":" ) , doing same thing text following @ . however - i've tried far hasn't filtered out noise level need. obviously 100% accuracy isn't possible mind taking crack @ how can structure select statement? there no easy solution within mysql. can after have retrieved using regular expressions. here example of how use in case: regex example if want select e-mail addresses 1 string: regex example you can use regex extract ones contain e-mail in mysql still doesn...

Are there any editors to help develop AIML (artificial intelligence markup language)? -

im starting work on chatbot , have decided use aiml sentence interpretation. please recommend editors or guis create aiml. the gaitobot aiml editor gets reviews community, simple aiml editor nice.

hibernate - Spring data jpa inheritance - table per class not working -

i have abstract entity. @entity @inheritance(strategy=inheritancetype.table_per_class) @entitylisteners(auditingentitylistener.class) public abstract class abstractentity { @id @generatedvalue(strategy = generationtype.auto) protected long id; @createdby protected string createdby; @createddate protected date creationdate; @lastmodifiedby protected string modifiedby; @lastmodifieddate protected date lastmodifieddate; } and 2 concrete implementations of class: class a: @entity @table(name = "a") public class extends abstractentity { @column(name = "name", nullable = false) private string name; @column(name = "priority", nullable = false) private int priority; } class b: @entity @table(name = "b") public class b extends abstractentity { @column(name = "place", nullable = false) private string place; @column(name = "distance", nullab...

eclipse - Undefined refference to sem_open despite the correct option being included -

i using thing sem_open, sem_post, sem_wait , on in program. i have included option -lpthread compiler still getting: undefined reference sem_open' undefined reference to sem_post' ........ and on when try build program. what else can make work? on ubuntu , i'm using eclipse.

Javascript JSON.parse function with Ajax request and "\\n" new line escaped char -

https://jsbin.com/zuhatujoqo/1/edit?js,console edit: json file has line: {"pd":"ciao \\n ste"} i'm requesting valid json file ajax call. json.parse result. i don't understand happening "\\n" escaped new line char coming json file. json.parse giving me different result if feed same values. var result = json.parse(data); console.log(result); var result2 = json.parse('{"pd":"ciao \\n ste"}'); console.log(result2); as understand may related fact javascript before , parse escaping ( or unescaping ?? ) string. the problem don't understand this: result = result.replace(/\\n/g, "<br />"); do have escape regex itself? sum: want use .json file loaded via ajax. want json.parse job , unescape "\\n" returning newline char. thanks answers bergi gave me, understand json.parse doing job. fault, providing json file "\\n" inside instead of "\n". here u...

spring - SpringFramework .NET - Rollback/Commit for NMS Messaging (ActiveMQ) Transactions -

i'm working on converting existing java/springboot/activemq console app (which consumes messages named activemq message queue , processes messages) analogous c# .net console app. i've got things running correctly success case, i'm having trouble replicating java app's behavior cases in message handler fails process message successfully. the failure case behavior i'm attempting replicate rollback & re-queueing of message (back named queue received) when message handling fails. in java/springboot, via adding transactional configuration appropriate classes/methods wherein message processing occurs. failure cases, throw runtimeexception (unchecked) , allow such thrown exceptions handled in spring transactional framework (using springboot defaults such exception handling) and, based on transaction rollback processing framework, message re-queued. i'm not explicitly doing rollback processing in java application code logic, but, rather, allowing framework d...

c# - MySQL - UPDATE query not effecting row -

i have update query not working doesn't show errors, no rows effected/ matched: update `budget` set `amount` = 500, `rest` = 500 `company_number` = 1 , `section_number` = 1 , `chapter_number` = 1 , `article_number` = 3 , `subarticle_number` = 0 , `ssubarticle_number` = 0 but when "select" database got row returned: select * budget `company_number` = 1 , `section_number` = 1 , `chapter_number` = 1 , `article_number` = 3 , `subarticle_number` = 0 , `ssubarticle_number` = 0 this "budget" table: create table `budget` ( `budget_id` int(11) not null auto_increment, `company_number` int(11) not null default '0', `section_number` int(11) not null default '0', `chapter_number` int(11) not null default '0', `article_number` int(11) not null default '0', `subarticle_number` int(11) not null default '0', `ssubarticle_number` int(11) not null default '0', `name` varchar(90) default null, `amount`...

c# - Retrieving the selected checkbox values from a ValidationGroup -

i have page dynamically populates listview checkboxes based on database. text checkboxes equal usernames of users in database. trying create control in usernames in selected checkboxes deleted. this, plan on using foreach loop run each selected checkbox within validationgroup. first, here asp .net code, displaying approach formatting page. <asp:listview id="lvusers" runat="server"> <itemtemplate> <asp:checkbox id="chkuser" runat="server" text='<%# eval("username") %>' validationgroup="usercheck" /><br /> </itemtemplate> </asp:listview> here current (broken) code, attempting run foreach loop each listview item, when should running foreach loop each selected checkbox. foreach (listviewitem item in lvusers.items) //trying replace "for each selected checkbox within usercheck validationgroup". { ...

multithreading - JAVA : factorise code -> runnable anonymous class -

i factorise code because have huge same block of code in 2 class. in anonymous runnable class , here description of situation class { a(){} do_a_function(){} } class b extends a{ b(){ runnable runb=new runnable() { public void run() { while (true) { super.do_a_function(); do_b_function(); } } }; new thread(runb).start(); } do_b_function(){} } class c extends a{ c(){ runnable runc=new runnable() { public void run() { while (true) { super.do_a_function(); do_c_function(); } } }; new thread(runc).start(); } do_c_function(){} } and can guess that class { a(){ runnable runc=new runnable() { public void run() { while (true) { ...

android - Calling a method from my MainActivity -

i've desperatly tried on internet able call thisisamethodjusttotryoutmybutton(view view) , when user click delete button mainactivity, nothing works. button gives no reaction. java.lang.nullpointerexception: attempt invoke virtual method 'android.content.res.resources android.content.context.getresources()' on null object reference adapter class public class adapter extends baseadapter{ private arraylist<item> items= new arraylist<>(); public void additemtolistview(item item){ this.items.add(item); } public void deleteitem(int position){ items.remove(position); } @override public item getitem(int position) { return items.get(position); } @override public long getidofitem(int position) { return position; } @override public int getcount() { return items.size(); } class viewholder { public textview title, content; public viewholder(view view){ title= (textview) view.findviewbyid(r.id.title); content= ...

c++ - Error when connecting qt and matlab -

after putting following in .pro file of qt project (follow tutorials) includepath +=/applications/matlab/matlab_r2016a.app/extern/include libs += -l/applications/matlab/matlab_r2016a.app/bin/maci64 i try create engine pointer compiler show :-1: error: symbol(s) not found architecture x86_64 :-1: error: linker command failed exit code 1 (use -v see invocation) can 1 me how solve problem or how connect qt matlab? you have defined directory in find necessary shared libraries haven't specified actual libraries using -l flag libs += -l/applications/matlab/matlab_r2016a.app/bin/maci64 -lmx -leng

python - Geopandas PostGIS connection -

i started using geopandas in python of spatial work , pleased - i'm trying read in postgis features , don't quite understand how parameterize database connection, , didn't seem clear in documentation: geodataframe.from_postgis(sql, con, geom_col='geom', crs=none, index_col=none, coerce_float=true, params=none) this simple question, wanted know needs go in 'con' - assume string database connection information? in format? setting 'sql' seems straightforward. appreciated - thanks! example: import geopandas gpd import psycopg2 /*(if postgres/postgis) con = psycopg2.connect(database="your database", user="user",password="password",host="your host") sql= "select geom, x,y,z your_table" df=gpd.geodataframe.from_postgis(sql,con,geom_col='geom' )

node.js - How to access environment variables from `npm start`? -

i have set environment variable (on osx): export npm_package_config_test_user=user42 and javascript file: -- index.js -- console.log(process.env.npm_package_config_test_user); which if run node index.js provides me expected answer. now, definition in package.json : "scripts": { "start": "node index.js" }, i can do: npm start when environment variable value comes undefined . so 2 questions: 1) why? , 2) need set can pick value correctly? thanks so found npm clears npm_package_* space before use, set variable , wipes out when runs. however, works: export test_user=user42

mongodb - Mongo 2.6.12 secondaries not using index -

we upgraded our mongo replica set 2.4 2.6.12 , having strange behavior primary uses indexes , secondaries not. for instance query: query fitly_metrics_production.rank_ledger_entries query: { $query: { user_id: objectid('56dd084df093a136580be18a'), category: "chest" }, $orderby: { _id: -1 } } plansummary: ixscan { _id: 1 } ntoskip:0 nscanned:1645536 nscannedobjects:1645536 keyupdates:0 numyields:12866 locks(micros) r:138352610 nreturned:1 reslen:316 481856ms when run explain() on on same box see { "cursor" : "btreecursor user_id_1_category_1", "ismultikey" : false, "n" : 9, "nscannedobjects" : 9, "nscanned" : 9, "nscannedobjectsallplans" : 30, "nscannedallplans" : 30, "scanandorder" : true, "indexonly" : false, "nyields" : 0, "nchunkskips" : 0, "millis" : 0, "indexbounds" : { "user_id" : [ [ ...

java - SQS ExpiredToken: The security token included in the request is expired status code: 403 -

i have long-running worker process running on ec2 consumes items sqs queue. after time (8-12 hours, reckon) begin getting expired security token errors. expect aws lib handle refresh of credentials automatically seems not case. in anyway handled within client? happens when use defaultcredentialsproviderchain generate access. error not occur when used key , secret. stacktrace below: com.amazonaws.amazonserviceexception: security token included in request expired (service: amazonsqs; status code: 403; error code: expiredtoken; request id: 6ff6e1a0-d668-5ac5-bcd7-ae30058f25c0) @ com.amazonaws.http.amazonhttpclient.handleerrorresponse(amazonhttpclient.java:1182) @ com.amazonaws.http.amazonhttpclient.executeonerequest(amazonhttpclient.java:770) @ com.amazonaws.http.amazonhttpclient.executehelper(amazonhttpclient.java:489) @ com.amazonaws.http.amazonhttpclient.execute(amazonhttpclient.java:310) @ com.amazonaws.services.sqs.amazonsqsclient.invoke(amazonsqsclient.jav...