Posts

Showing posts from February, 2012

bookTest.java prints out author arrayList, but not isbn -

requirements: accommodate multiple authors using 1 of components java collection framework. requires 1 book isbn , collection of authors. junit: guidance testvalidate: test @ least 2 cases (one case book properties hold correct data types , not empty nor hold null value, 1 not). guidance testequals: test @ least 2 cases (one case authors , isbn match, 1 not). test @ least 2 authors. teacher told me: testequals need add isbn , 2 authors. create arraylist. add 2 authors it. create book object , add arraylist instance , isbn. think that's have done, authors printing, isbns not. total newbie , @ loss! can help? edit/addition got isbn print, printing second isbn have. need change both of them print? or matter? here output: testsuite: library.domain.booktest equals author list: [bob smith, jane doe] isbn: 67890 validate author list: [bob smith, jane doe] isbn: 67890 tests run: 2, failures: 0, errors: 0, skipped: 0, time elapsed: 0.23 sec ------------- standard output ------

java - Verification key for jose4j JwtConsumer -

Image
i using jose4j validate , process jwt. jwt looks following , passes validation in jwt homepage. however, can't same using jose4j java library. exception complains verification key set. there many types of keys defined in library , tried them no luck. code following: import java.util.map; import org.jose4j.jwt.jwtclaims; import org.jose4j.jwt.consumer.invalidjwtexception; import org.jose4j.jwt.consumer.jwtconsumer; import org.jose4j.jwt.consumer.jwtconsumerbuilder; import org.jose4j.keys.hmackey; public class ygjwt { public static void main(string args[]) throws invalidjwtexception { string jwt = "eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9.eyjzdwiioiixmjm0nty3odkwiiwibmftzsi6ikpvag4grg9liiwiywrtaw4ionrydwv9.tjva95orm7e2cbab30rmhrhdcefxjoyzgefonfh7hgq"; string secret = "secret"; jwtconsumer jwtconsumer = new jwtconsumerbuilder() .setverificationkey(new hmackey(secret.getbytes())) //what kind of key need use here?

node.js - Graphicsmagick for node not writing the jpg -

i using https://github.com/aheckmann/gm resize image. var gm = require('gm').subclass({ imagemagick: true }); var fs = require('fs'); var dir = __dirname+'/img'; var readstream = fs.createreadstream(dir + '/desert.jpg'); var writestream = fs.createwritestream(dir + '/resize.jpg'); gm(readstream) .size({bufferstream: true}, function(err, size) { this.resize(50, 50, '%') this.write(writestream, function (err) { if (!err) console.log('done'); }); }); i using above code resize image....the problem empty image getting generated , error message {[error: write epipe] code:'epipe',errno: 'epipe', syscall:'write'} write method takes string output filename. try stream method: gm(readstream) .size({bufferstream: true}, function(err, size) { this.resize(50, 50, '%') .stream() .o

javascript - JQuery enter event doesn't trigger form submission -

usually, when press enter on input inside form submit button triggers form submission, when tried same result calling jquery's trigger function doesn't work. idea why? var ev =$.event('keydown',{keycode:13}); $('#myinput').trigger(ev); the event called form doesn't submit. $('#id').on('change',function(){ document.getelementsbyname('formname').submit(); });

How do I control my callbacks in Node.js? -

so i'm working on application written in coffeescript , i'm using sequelize orm application. i'm @ stage i'm integrating passport.js. part i'm having issues getting user out of database when trying authenticate. know issue function returning before sequelize function have written has had chance return can't figure out how control flow properly. here code i've got far: user model exports.getuserbyusername = (username, callback) -> user.findone({ : { username : username }}, (err, user) -> console.log 'hello?' return callback(err) if err return callback(undefined, user) if user ) hello doesn't called that's step 1 of knowing it's returning soon. in verification callback inside passport strategy have this: (username, password, done) -> chatmodel.getuserbyusername username, (err, user) -> console.log 2 return done err if err return done null, false, message: 'inco

mysql - Add nonexistent ID to database -

i have database starts @ id = 1000. want add entry @ id = 1. using mysql. done once, , not care rest of 2 - 999 values. concerned adding @ id = 1, id not exist cannot update it. you can insert , define id rather allowing auto_increment normal job. insert table (id, another_column, ... ) values (1, 'some value', ... );

angularjs - Getting the current month by default in a dropdownlist -

i working in project user on first visit can see content of current month default. if want see contents of month need select month , year dropdown list. <div class="row" ng-show="firstvisit"> <div class="col"> <select ng-init="item1=m+1" ng-model="item1" ng-change="onchangemonth()" style="width:100%;text-align:center;"> <option style="text-indent:30%" ng-repeat="item1 in ideamonthlist" value="{{item1}}" >{{item1}}</option> </select> </div> </div> <div class="row" ng-hide="firstvisit"> <div class="col"> <select ng-model="item1" ng-change="onchangemonth()" style="width:100%;text-align:center;"> <option style="text-indent:30%" ng-repeat="

javascript - Access to iframe Object.prototype in IE8 -

i have iframe element on page , need create prototype methods object inside iframe. i got iframe window var win = iframe.contentwindow || iframe.contentdocument.defaultview; and tried create methods. in ff, chrome , ie9+ it's simple: win.object.prototype.func = myfunc; but doesn't work in ie8. got undefined in win.object. @ same time win.element works perfectly. how can iframe object in ie8 ? you can insert script element in iframe creates global variable in outer window points inner object : var doc = iframe.contentdocument, s = doc.createelement('script'); s.text = "parent.object2 = object;"; doc.appendchild(s); doc.removechild(s); then, can use object2.prototype .

SQL Server Concatenate Certain Subsquent Rows onto Parent Row Using Set-Based Solution -

i trying parse baiv2 banking file in t-sql after importing table. file composed of rows , each row has 2 leading numbers. if leading number row happens "88", it's "continuation row" , meant extension of previous row (to prevent rows getting wide in file). example file below: 01,123456,123456,123456,1419,1,80,,2/ 02,123456,123456,1,123456,,usd,2/ 03,123456,usd,010,0,,,015,0,,,020,0,,,025,0,,,030,0,,,040,0,,,045,0,,/ 88,050,0,,,055,0,,,057,0,,,060,0,,,072,0,,,074,0,,,100,123456,1,,270,123456,1,/ 88,400,123456,35,,470,123456,35,/ 16,275,123456,s,123456,0,0,,/ 88,zba xfer bank account 123456 16,475,123456,z,123456,123456/ 88,check-ird 16,475,123456,z,123456,123456/ 88,check-ird how used set-based sql query append rows leading "88" previous row? looks xml based query might work. able accomplish complicated loops , variables it's inefficient i'd set-based solution. appreciated. i need "88" recor

function - Solving the system of non-linear equations in MATLAB by fsolve -

i have code produces vector in matlab, example following 3 component vector ( n=3 ): a1_1 - sin((17*a1_1)/60 + a2_1/8 + a3_1/40 - 0.153233) (15*a1_1)/16 + a2_1/4 + a3_1/32 - sin((17*a1_1)/60 + a2_1/8 + a3_1/40 - 0.0282326) (3*a1_1)/4 + a2_1/2 + a3_1/8 - sin((17*a1_1)/60 + a2_1/8 + a3_1/40 + 0.846767) as can see each component non-linear equation. 3 component of vector forms system of 3 non-linear equations having it's variables named a1_1 , a1_2 and a1_3 . want solve system fsolve . how do arbitrary n ? to use fsolve , function must accept vector input , return vector of same size. in case can accomplish anonymous function : f = @(a)[a(1) - sin(17*a(1)/60 + a(2)/8 + a(3)/40 - 0.153233);... 15*a(1)/16 + a(2)/4 + a(3)/32 - sin(17*a(1)/60 + a(2)/8 + a(3)/40 - 0.0282326);... 3*a(1)/4 + a(2)/2 + a(3)/8 - sin(17*a(1)/60 + a(2)/8 + a(3)/40 + 0.846767)]; n = 3; a0 = zeros(n,1); % initial guess opts = optimoptions('fsolve','display',

Programmatically obtain the phone number of the Android phone -

how can programmatically phone number of device running android app? code: telephonymanager tmgr = (telephonymanager)mappcontext.getsystemservice(context.telephony_service); string mphonenumber = tmgr.getline1number(); required permission: <uses-permission android:name="android.permission.read_phone_state"/> caveats: according highly upvoted comments, there few caveats aware of. can return null or "" or "???????" , , can return stale phone number no longer valid. if want uniquely identifies device, should use getdeviceid() instead.

python - Django sqlite database is locked -

i've been struggling "sqlite3.operationalerror database locked" day.... searching around answers seems known problem i've found explained of time fact sqlite not work nice in multithreading thread potentially timeout waiting more 5 (default timeout) seconds write db because thread has db lock . so having more threads play db , 1 of them using transactions , writing i've began measuring time takes transactionns complete. i've found no transaction takes more 300 ms , rendering not plausible above explication. unless thread uses transactions makes ~21 (5000 ms / 300 ms) consecutive transactions while other thread desiring write gets ignored time so other hypothesis potentially explain behavior ? i have had lot of these problems sqlite before. basically, don't have multiple threads could, potentially, write db . if not acceptable, should switch postgres or else better @ concurrency. sqlite has simple implementation relies on file system

java.lang.NullPointerException for JSAPI Speech Recognizer in Java -

while tried simple speech recognizer jsapi (jsr 113) here (this link not work now) or here following examples of library, got java.lang.nullpointerexception. error caused line "rec.allocate();". why did occur since recognizer assigned line above ("rec = (recognizer) enginemanager.createengine(mode);")? the code below: import javax.speech.*; import javax.speech.recognition.*; ... static recognizer rec; ... public static void run(string[] args) { try { recognizermode mode = new recognizermode(new speechlocale("en", "gb")); rec = (recognizer) enginemanager.createengine(mode); // start recognizer rec.allocate(); // load grammar, , enable string grammarmarkup = "<grammar root='sentence' xml:lang='en' version='1.0' " + "xmlns='h

Why am I getting Unexpected token illegal in javascript? -

why getting error "unexpected token illegal" in script? script supposed retrieve cookies , display names , values in table. error occurs on line has opening table tag. document.getelementbyid("showcookies").onclick = function(){ var columnright = document.getelementbyid('columnright'); var cookies = document.cookie; var cookiescontent = '<h1>existing cookies</h1>'; console.log(cookies); cookies = cookies.split(";"); if(cookies.length > 0){ cookiescontent += '<table width="30%" cellspacing="1" cellpadding="10" border="0"> <thead> <tr> <th>name</th> <th>value</th> </tr> </thead> <tbody> '; for(var = 0; < cookies.l

Catching HTML5 media network error javascript -

is there anyway can catch network error in case try create new audio() object , src url not resolved? try/catch doesn't work here apparently. you have docs here: docs and info you: <p id="player">non existing media file - click play</p> <audio preload="none" controls> <source id="wav" src="http://yourpage.com/false.wav" /> <source id="mp3" src="http://yourpage.com/false.mp3" /> </audio> and simple use js: $("#player").on("click", function () { alert("trying play file."); try { $('audio')[0].play(); } catch (e) { alert("error playing file!"); } }); $("audio").on("error", function (eevent) { alert("error @ audio tag!"); }); $("#wav").on("error", function (event) { alert("no wav file!"); }); $("

Create graph legend inside loop in Stata -

i generate graphs different datasets, same variables, in years change. far can generate graphs, without legend, doing this: levelsof year, local(lyear) foreach l of local lyear { local fig `fig' scatter mpg time if year==`l', connect(l) || } graph twoway `fig' i want add legend showing each year. example, doing without loop, add option: graph twoway `fig', legend(lab(1 "2010") lab(2 "2011") lab(3 "2012")) is there way have years appear in legend part of loop? years, , number of years, change dataset dataset , helpful. my short answer not draw such graph loop @ all. here 1 way it: separate mpg, by(year) veryshortlabel twoway connected `r(varlist)' time, sort here way it: ssc inst sepscatter sepscatter mpg time, sep(year) recast(connected) sort you need install sepscatter once. detail: legend(lab(1 "2010") lab(2 "2011") lab(3 "2012")) is easier legend(order

apache spark - Trouble in understanding the LDA topic model in MLlib -

i have trouble understanding lda topic model result in spark mlib. to understanding result following: topic 1: term1, term2, term.... topic 2: term1, term2, term3... ... topic n: term1, ........ doc1 : topic1, topic2,... doc2 : topic1, topic2,... doc3 : topic1, topic2,... ... docn :topic1, topic2,... i apply lda sample data of spark mllib looks this: 1 2 6 0 2 3 1 1 0 0 3 1 3 0 1 3 0 0 2 0 0 1 1 4 1 0 0 4 9 0 1 2 0 2 1 0 3 0 0 5 0 2 3 9 3 1 1 9 3 0 2 0 0 1 3 4 2 0 3 4 5 1 1 1 4 0 2 1 0 3 0 0 5 0 2 2 9 1 1 1 9 2 1 2 0 0 1 3 4 4 0 3 4 2 1 3 0 0 0 2 8 2 0 3 0 2 0 2 7 2 1 1 1 9 0 2 2 0 0 3 3 4 1 0 0 4 5 1 3 0 1 0 afterwards following results: topics: org.apache.spark.mllib.linalg.matrix = 10.33743440804936 9.104197117225599 6.5583684747250395 6.342536927434482 12.486281081997593 10.171181990567925 2.1728012328444692 2.1939589470020042 7.633239820153526 17.858082227094904 9.405347532724434 12.736570240180663 13.226180094790433 3.957039592115

java - Uninstalling or disabling JRebel from NetBeans 8.0.2 on Ubuntu 15.04 -

Image
i'm working on netbeans 8.0.2 ide platform, ubuntu 15.0.4. how uninstall or disable jrebel? general case :- user wants uninstall few plugins ide. to it, user opens plugin manager , in installed tab checks check boxes plugins (s)he wants uninstall. plugin manager informs use restart required. (s)he clicks uninstall button , wizard pops informing user again ide restarted. in wizard user clicks uninstall button , ide restarted , plugins uninstalled. you can same individually jrebel plugin , restart netbeans ide. check this netbeans wiki page more info on plugin uninstallation.

java - Why is this code giving me a strange output -

the method below written make string version of number, know there methods this, such string.valueof() , double.tostring() , or "" + somenumber . private static string numtostring(double i) { string revnumber = ""; boolean isneg = false; if (i == 0) { //catch 0 case return "0"; } if (i < 0) { isneg = true; } = math.abs(i); while (i > 0) { //loop backwards through number, loop //finish, otherwise, not output in 'main()' revnumber += "" + % 10; //get end /= 10; //slice end } string number = ""; //reversed (int k = revnumber.length() - 1; k >= 0; k--) { number += revnumber.substring(k, k + 1); } revnumber = null; //let gc work return isneg ? "-" + number : numb

loops - count up + 1 in looping data in table -

i have loop gives me data in form of table, haven't figured out how loop + 1 there number on left side of each row of data in order, 1, 2, 3, 4. using mssql data , table works great in regards that. want numbers @ beginning of each row. here current code: <% if delivery_id<>"" each x in rs.fields response.write"<th><b>" & (ucase(x.name) & "</b></th>") next%> </tr> <%do until rs.eof%> <tr> <%for each x in rs.fields %> <td> <% response.write(x.value)%></td> <%next rs.movenext%> </tr> <%loop rs.close conn.close end if %> </table></font> can assist me? start setting intc int. dim intc assign start value. intc = 0 place value inside each statement. adding 1 within for each loop statement. intc = intc + 1 place results before response.write in if need add space use &nbsp; between <%=intc%>.

javascript: throw new error without displaying to user -

is there way can use throw new error in javascript , hide display or change display of console window? throwing error end program. put program's execution within try/catch. can handle error want to. however, seems pretty hack-ish way terminate execution. function run_my_program(){ //do here throw "i want break world!"; } try{ run_my_program(); } catch(err) { //do whatever want err } fiddle: http://jsfiddle.net/trex005/s2u67jrg/

Unix time to Human time in R -

my dataset follows such structure: author, thread, created, converted created in unix time, converted changed posixct format. have converted data subset using posixct` format: data$converted <- as.posixct(data$created/1000, origin="1970-01-01") however, returned output off. example, unix timestamp 1379017192658 , r returns human time 9/13/13 5:49:52 . while time in online converted (and using formula in excel) returns different conversion of 9/12/13 8:19 pm what missing here?

osx - java os-x watchservice deadlocks -

i'm wondering if others have seen java 8 watch service on os x hang (deadlock). i'm using watch service (obtained using filesystems.getdefault().newwatchservice()) monitoring create/delete/modify events associated files/sub-directories under directory. service appears work fine on windows, on os x appears hang when several new directories created in short time span. haven't had time precisely characterize conditions cause this, rapid directory creation , renaming of directories under folder being watched reproduces problem. to precise, thread in our code invokes path.register() function (for registering directory watch service) appears hang following stack trace: at sun.nio.fs.pollingwatchservice$pollingwatchkey.disable(pollingwatchservice.java:296) @ sun.nio.fs.pollingwatchservice.doprivilegedregister(pollingwatchservice.java:169) @ sun.nio.fs.pollingwatchservice.access$000(pollingwatchservice.java:45) @ sun.nio.fs.pollingwatchservice$2.run(pollingwatchservice.ja

PayPal integration in android app -

Image
i have integrated paypal service in android app wanna different. shown in below picture product of 10$ when user buy product 10$ added account wanna transfer 10$ 2 different accounts 5$ 1 , 5$ other account there anyway please me the new paypal msdk built on top of restful payments api, @ moment not supporting use cases of parallel /chained payments, added soon. util please continue using classic adaptive payments apis or mpl (noted mpl not being updated new msdk replacing it)

python - Matplotlib : Consistent Y-Axis across 4 Separate Line Plots -

i have 4 dictionaries dictionaries of lists. this being used plot volume per month of various entities multiple line plots. each dictionary key has value list of 12 values each representing volume of corresponding month have 4 dictionaries : d1, d2, d3 , d4. sample value of dictionary element - [239, 138, 271, 175, 29, 0, 0, 0, 0, 2, 24, 62] how ensure same y-axis value (sharey ?) across 4 ? rcparams.update({'figure.autolayout': true}) plt.figure(figsize=(16,9), dpi=600) plt.margins(0.075) labels = [] plt.ylabel('volume') plt.xlabel('months') plt.title('monthwise volume per queue', {'family' : 'arial black', 'weight' : 'bold', 'size' : 22}) in d2: plt.plot([1,2,3,4,5,6,7,8,9,10,11,12], d2[i]) labels.append(i) months = ["", "january", "february", "march", "april", "may", "june", "july", "august&

javascript - Kill Process in windows when the download speed drops -

i looking code in instance powershell/cmd kill process when download speed goes below 5 mbps. the situation using vlc mediaplayer live broadcasting. happens broadcast goes down or starts having hickups. the solution restart. restart when complains not being able connect. i looking script/code monitor process , automatically restart/kill when download speed goes below level or isn't consistent. implying vlc reads content disk , speed matches outbound network speed can use disk read speed process performance counter measured 1 second: @echo off setlocal enabledelayedexpansion set limit=500000 set process=vlc :loop set line=0 /f "delims=, tokens=2" %%a in ('typeperf -sc 1 "\process(%process%)\io read bytes/sec"') ( set /a line+=1 if !line!==2 ( set speed=%%a set speed=!speed:"=! /f "delims=. tokens=1" %%b in ("!speed!") set speed=%%b if !speed! lss %limit% (

Google Apps Script: Setting color of an event using Calendar API -

Image
i set specific colours events. believe have use calendar api. cannot figure out how this. the code trying is: var event = calendarapp.getownedcalendarbyid(calendarid).createevent(class, starttime, endtime, {description:lessonplandatacomplete [t], colorid: 11}); the colorid 11 should set red events coming out default colour. any helps/hints gratefully received, many thanks, simon it possible using advanced calendar service. ( this post helpful ) the code create new event goes : (inspired google's example ) function createevent() { var calendarid = 'primary'; var event = { summary: 'other test', location: 'right here', description:' chat... ;-)', start: { datetime: new date().toisostring() }, end: { datetime: new date(new date().gettime()+3600000).toisostring() }, attendees: [ {email: 'user@gmail.com'} ], // red background. use calendar.colors.get() full li

sql - insert column from one table into another -

i have 2 tables: set1 , searchinfo. this: set1 searchid | position 3 1 1 7 3 4 searchinfo searchid | searchdate 1 6 2 8 3 9 i want add column searchdate set1 , use searchid key. have tried: alter table set1 add column searchdate1 datetime; insert set1 (searchdate1) select b.searchdate set1 left outer join searchinfo b on a.searchid=b.searchid; however, set1 searchid | position | searchdate1 3 1 1 7 3 4 x x x as oppose : set1 searchid | position | searchdate1 3 1 9 1 7 6 3 4 9 what want : update column have made. not need insert anything update set1 set searchdate = si.searchdate set1 s inner join searchinfo si s.searchid = si.searchid

javascript - HTML form doesn't capture all the checkboxes from Bootstrap responsive table -

i have table displays results db. in last column have checkboxes , clicking submit button sending array of account_id's php file. works fine problem using bootstrap responsive table can show 10-100 results on each page , form captures results on current page. if check boxes on different pages , switch between them, still remain checked, though. here html: <form action="compare.php" method="post"> <table class="table table-hover" id="datatables-example"> <thead> <tr> <th style="text-align:center;">account name</th> <th style="text-align:center;">address</th> <th style="text-align:center;">phone number</th> <th style="text-align:center;">website</th> <th style="text-align:center;">compare</th> </tr> </thead>

set CKeditor config.stylesSet for specific editor -

i have added styles list config.styleset.add function , can add style list ckeditor config.stylset function, can't find in manual how implement specific editor. any ideas? thanks! sorry dumb question. simple answer is: add stylesset: 'stylesname' to editor configs. the reason didn't success mistakenly writing "styleset" instead of "stylesset" :~

hsqldb - jira hsql database have been corrupted -

my hsql database of jira has been corrupted due power-jerk, have been trying recover hsql database haven't found proper solution yet.is there way recover database? did use hsqldb production environment? because absolutely not recommended: https://confluence.atlassian.com/display/jira/connecting+jira+to+hsqldb if have xml backup service enabled, might have saved of data in jira_home/exports https://confluence.atlassian.com/display/jira/automating+jira+backups

if statement - Javascript - if/and/else not working -

first off ... i'm new javascript ... here's code i'm using, doesn't seem working properly. here's i'm trying accomplish ... if has 'typeset' value of "complete set" , it's 'main' value "a2 tandem", it's title variable should "line set w/ alinks: ". if has other 'typeset' value or it's 'main' value "a2 tandem", it's title variable should "line set: " what's happening: doesn't seem differentiating between 'main' value being "a2 tandem". still applying "w/ alinks: " title if 'main' value "a2 tandem". help? if (acccat == "line sets"){ document.getelementbyid('o1').value = document.getelementbyid('main').value; document.getelementbyid('o2').value = document.getelementbyid('mainsize').value; document.getelementbyid('o3').valu

Resources to learn to deploy Java EE applications -

i want learn application deployment, java ee apps. don't know start , learning path should have. i've been building java ee applications on 2 years @ enterprise companies. deployment layer of app has been hidden me , done other teams, give them our ear file , gets magically deployed. i feel java ee developer should know stuff, i'm looking recommended material or learning path guidelines. fyi experience in deployment 0, i've deployed webpage on hosting site once. for deploying j2ee application, can start creating war file , deploying on running tomcat server. getting started can have @ documentation of tomcat. https://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html

c# - I am not able to debug the code. Tooltip is showing that breakpoint will not be hit and no symbols have been loaded for this document -

how can debug code ? i have tried load symbol following below debug>windows?modules , dll name tit.shared.usrmgmt.dll before 1st step changed build path bin\ then tried load symbol pdb file showing a matching symbol file not found in folder what problem here , how resolve same. below error while loading symbols c:\program files (x86)\iis express\tit.shared.usermgmt.pdb: cannot find or open pdb file. c:\windows\microsoft.net\assembly\gac_msil\tit.shared.usermgmt\v4.0_1.0.0.0__eac83faa75e40932\tit.shared.usermgmt.pdb: pdb not match image. d:\perforce\build_scm_tit_ci\interface\applications\tit\main\shared\usermgmt\obj\release\tit.shared.usermgmt.pdb: cannot find or open pdb file. c:\windows\tit.shared.usermgmt.pdb: cannot find or open pdb file. c:\windows\symbols\dll\tit.shared.usermgmt.pdb: cannot find or open pdb file. c:\windows\dll\tit.shared.usermgmt.pdb: cannot find or open pdb file. c:\users\user~1.y\appdata\local\temp\symbolcache\tit.shared.usermgmt.pdb\

session - I keep log out every time I include php -

i'm using http://www.php-login.net/ minimal user management system. when use $_get include php page, logged out. doesn't happen when log in on development machine. when tried on different computer, logged out. how can find out what's causing this? im guessing session? some part of index.php require_once("db/configure.php"); require_once("classes/login.php"); include_once("analyticstracking.php"); if ($login->isuserloggedin() == true) { include("inc/user.php"); } else { include("inc/nonuser.php"); } my user.php <? $pagearray = [ 'home' => 'views/home.php', 'setting' => 'views/setting.php', 'article' => 'views/article.php' ]; if(isset($_get['page'])){ $page = $_get['page']; }else{ $page = null; } if($page && isset($pagearray[$page]) && $

Apache camel getting Oracle database generated ID -

i using camel jdbc component insert record oracle table. insert uses sequence populate primary key id column. insert my_table (id, data) values (my_seq.nextval, 'some data') the relevant part of route looks below: from("some end point here") .process(preinsertprocessor) .to("jdbc:mydatasource") .process(new processor() { public void process(exchange exchange) throws exception { logger.info("extracting database generated id"); // list null list<integer> ids = exchange.getin().getheader( jdbcconstants.jdbc_generated_keys_data, list.class); }); inside preinsertprocessir set message body insert statement , set 2 header values instruct camel want generated id back: message.setbody("insert my_table (id, data) values (my_seq.nextval, ?:data)"); message.setheader("data", "some data"); message.setheader(jdb

php - Concatenate All Rows From One Column With MYSQL -

this question has answer here: sql, how concatenate results? 7 answers i trying thought simple it's driving me crazy. i have following data: id --- name 1 --- joe 2 --- bob 3 --- jim 4 --- mike i want able show results of mysql as: "joe", "bob", "jim", "mike" i tried concatenate tutorials, seem merging id's. $sql = "select names, concat_ws('', 'names') namelist peoplenames"; $result = $conn->query($sql); echo $row["namelist"]; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $names = $row["nameslist"]; echo $names; } } if echo outside loop recent result. any ideas? the problem overwriting contents of $names each time ro

cin - C++ not taking all inputs -

i creating simple c++ program. users input string .my program running fine when enter name space console skip next input here code. #include <iostream> using namespace std; // program can see cout , endl class etradehouse { private: string cnic,name,fname, dob,qua, des,join_date , number , address; int sal; public: void getdata(){ cout<<"\nplease enter national identity card number : \n"; cin >>cnic ; cout<<"please enter name: \n"; cin >> name; cout<<"please enter father name : \n"; cin >> fname; cout<<"please enter date of birth : \n"; cin >> dob; cout<<"please enter qualification : \n"; cin >> qua; cout<<"please enter designation : \n"; cin >> des; } }; // class ends here int main() { etradehouse obj; obj.getdata(); } it not skipping, stops reading after enco

How to set MAKEFLAGS from Makefile, in order to remove default implicit-rules -

i try following makefile: makeflags += s makeflags += r configure: then, when run make, following errors, if wants compile 'configure', per default implicit-rule: /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13 /usr/bin/ld: /

Include dependency from Maven local repository on Android Studio Gradle -

i think i'm stupid or i'm missing -hope latter- can't import dependency. i have repository in ~/.m2/repository , inside directory can see deploy. the maven setting.xml has <localrepository>${user.home}/.m2/repository</localrepository> here gradle file: dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile project(':lib_facebook') compile project(':lib_dslrdashboard') apt "org.androidannotations:androidannotations:3.2" compile 'org.androidannotations:androidannotations-api:3.2' compile 'de.livereach:rpc-objects-android:1.0.0'//this local dependency compile 'com.android.support:appcompat-v7:22.0.0' compile 'org.slf4j:slf4j-android:1.6.1-rc1' compile 'org.springframework.android:spring-android-rest-template:1.0.1.release' compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2' compile 'de.keyboardsurfer.android.widget:crouton:1.8.5@aar&

xcode - Getting JSON from google spreadsheets -

i want json of google spreadsheet. published to app @ this url. after researching,i tried retrieving json using code nsstring *theurl = @"https://spreadsheets.google.com/feeds/list/1gnmdd6l0pcmo-zdulf8wy3xwcmrqbxmzrfi5l06j38u/od6/public/full?alt=json"; nsstring *thefile = [nsstring stringwithcontentsofurl:[nsurl urlwithstring:theurl] encoding:nsutf8stringencoding error:nil]; nslog(@" %@",thefile); however didn't work. getting null. not sure if wrong code or url. if there wrong code please correct me. if wrong url tell me how right url. edit this new link json. however, not getting values in sheet. getting other random stuff. how values sheet? ahh yes know how this! however, google apps script. app script can call code access spreadsheet remotely. using: var spreadsheet = spreadsheetapp.openspreadsheetbyid("your id"); then have ability edit , view data want on spreadsheet

sql - JOIN on column only if NOT NULL -

i'm in process of re-writing old sql query , have troubles making sense out of it. contains several conditions of form select ... a, b, c c.id = ... , ( a.x_id null or a.x_id = c.x_id ) , b.id = a.b_id (+) can query rewritten using proper join syntax? equivalent following or produce different results under circumstances? select ... b left join on b.id = a.b_id left join c on a.x_id = c.x_id c.id = ... the original query 100 lines long , spans 5 tables, plus several joins on "virtual tables" (i.e. conditions of form x.z_id = y.z_id ), makes hard break down more manageable bits or debug. if want same result have in first query - must make left join table a, : select ... b, c left join on b.id = a.b_id , b.id = a.b_id c.id = ... b.c_id or if want same style tables, can use inner join table b, : select ... c inner join b on b.c_id = c.id left join on b.id = a.b_id c.id = ... in both query select data table b column not null

C# instantiate generic type from method signature -

i've been fooling around generic methods lately , came across methods this: public static void requires<texception>(bool condition, string message) texception : exception to understanding, when using above method provide type inherits exception , if condition false provided exception type thrown. how work under hood? texception instantiated throw new texception(); ? , how can pass in message parameter if type unknown method (all knows inherits type exception )? according msdn : system.exception have constructor takes string argument. string represents message. with of activator-class can following pretty simple: using system; public class test { public static void requires<texception>(bool condition, string message) texception : exception { exception exception = (exception)activator.createinstance(typeof(texception),message); throw exception; } public static void main() { try { requires<argu

java - How do I avoid getting NullPointerException in my Matrix sum? -

i want check if sum of each row in matrix equal. how should rewrite avoid npe? i can make work "normal" matrices int[][] = {{1,2,3}, {4,5,6}} , want work when testing null , empty matrices. public static boolean allrowsumsequal(int[][] m) { boolean = false; int x = 0; int total = rowsum(m[0]); (int = 0; < m.length; i++) { (int j = 0; j < m[i].length; j++) { x += m[i][j]; } if (x != total) { = false; break; } else { x = 0; = true; } } return a; } public static int rowsum(int[] v) { int vsum = 0; (int = 0; < v.length; i++) { vsum += v[i]; } return vsum; } you need define result or exception if want check "null" parameter. can return true if null valid or false otherwise. if(m == null) return true; empty or 1 lined matrices can return true time , not require calculation: if(m.length < 2) return true; the line test more simple, think: // expect positiv r

collation - ISO 8859-15 or ISO 8859-1 in SQL Server? -

what collation should use iso 8859-15 or iso 8859-1 in sql server? have looked around , cannot find references anywhere this. appreciated. that entirely depends on language going store. e.g. if use sql_danish_pref_cp1_ci_as_ki_wi aarhus sorted after xylophone since aa spelling of å , after x in danish/norwegian alphabet.

asp.net - Can't find code behind files in Sitecore File Explorer -

when view ascx file sitecore file manager , displays codebehind="promo downloads.ascx.cs in header, doesn't seem exist. there asp:literal control i'm trying figure out it's coming from. .cs files compiled dll , will/shouldn't available in sitecore solution using code behind model. happens if use old code file model. if want see code you'll need view original source code or decompile dll. to decompile url: dll in /bin folder. find out dll, @ namespace in .ascx file - name of dll should first part of namespace. once you've found dll, use dotpeek https://www.jetbrains.com/decompiler/ examine code.

wpf - Exception in async method executing in UI-thread crashes application -

Image
when await on method throws exception, try/catch not save application crashing. there throwing method void currentstep.process(cancellationtoken cancellationtoken) { throw new exception(); } it called ui thread means of icommand.execute() processcurrentstepcommand = asynccommandfactory.create(async cancellationtoken => { try { await task.run(() => currentstep.process(cancellationtoken)); } catch {} currentstep = currentstep.nextstepviewmodel; }); processcurrentstepcommand bound button on ui. when click button, application breaks. feel there general problem throwing exception on ui thread, @ same time don't understand why catch block isn't saving me exception. i have found way works me now: await task.factory.startnew( action: () => currentstep.process(cancellationtoken), creationoptions: taskcreationoptions.longrunning); but looks ugly. if forget in future wanted code might think need clean , trouble excep