Posts

Showing posts from July, 2013

php - Laravel 5 routes of Modules can't working correct when use authentication middleware -

i'm create folder modules in folder app. i'm config complete. module directory structure: module directory structure module.php return [ 'modules' => [ 'product', ] ]; routes.php route::group(['middleware' => 'auth', 'prefix' => 'products', 'namespace' => 'app\modules\product\controllers'], function() { // route::get('/categories', ['as' => 'categories.index', 'uses' => 'categorycontroller@index']); route::get('/', ['as' => 'products.index', 'uses' => 'productcontroller@index']); }); produccontroller.php namespace app\modules\product\controllers; use illuminate\http\request; use app\http\requests; use app\http\controllers\controller; class productcontroller extends controller { /** * display listing of resource. * * @return \illuminate\http\response...

g++ - compiling c++ with external library : lpsolve -

i trying compile program written in c++ using lpsolve external library. have written following line in .cpp : #include</var/lib/lpsolve/lp_lib.h> however, when i'm trying compile using g++, weird message : /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/liblpsolve55.so when searching -llpsolve55 /usr/bin/ld: skipping incompatible /usr/lib/../lib/liblpsolve55.so when searching -llpsolve55 /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/../../../liblpsolve55.so when searching -llpsolve55 /usr/bin/ld: skipping incompatible //usr/local/lib/liblpsolve55.so when searching -llpsolve55 /usr/bin/ld: skipping incompatible //usr/local/lib/liblpsolve55.a when searching -llpsolve55 /usr/bin/ld: skipping incompatible //usr/lib/liblpsolve55.so when searching -llpsolve55 /usr/bin/ld: cannot find -llpsolve55 /usr/bin/ld: cannot find -lcolamd collect2: error: ld returned 1 exit status i tried many different things... tried ins...

java - Is there such thing as not less than? -

in code, i'm trying make not less operator. can't a !< b ... can do? there package / method can use? the opposite of a<b a>=b , not a>b . edit: syntax looking !(a<b)

Voice chat over bluetooth between Android & Python (pybluez) -

i need stream live audio between android , python (pybluez). at first, i've thought sip, i've understood works on android internet , not bluetooth. so - solution i'm thinking on send voice data on sockets, in project: https://github.com/deanthomson/android-udp-audio-chat my big issue solution bluetooth sockets has no "udp mechanism". rfcomm bluetooth sockets connection oriented, tcp sockets, , i'm worrying can lead bad audio transfer speeds.. should use method transfer 2-way live audio on bluetooth?

language agnostic - Is floating point math broken? -

0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 why happen? binary floating point math this. in programming languages, based on ieee 754 standard . javascript uses 64-bit floating point representation, same java's double . crux of problem numbers represented in format whole number times power of two; rational numbers (such 0.1 , 1/10 ) denominator not power of 2 cannot represented. for 0.1 in standard binary64 format, representation can written as 0.1000000000000000055511151231257827021181583404541015625 in decimal, or 0x1.999999999999ap-4 in c99 hexfloat notation . in contrast, rational number 0.1 , 1/10 , can written as 0.1 in decimal, or 0x1.99999999999999...p-4 in analogue of c99 hexfloat notation, ... represents unending sequence of 9's. the constants 0.2 , 0.3 in program approximations true values. happens closest double 0.2 larger rational number 0.2 closest double 0.3 smaller rational number 0.3 . sum ...

c++ - difference between string size() function and strlen in this particular case -

i did question specification: input format first line contains number of test cases, t. next, t lines follow each containing long string s. output format each long string s, display number of times suvo , suvojit appears in it. i wrote following code : #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int suvo = 0; int suvojit = 0; string s; cin >> s; (int = 0; <= s.size() - 7; i++) { if (s.substr(i, 7) == "suvojit") suvojit++; } (int = 0; <= s.size() - 4; i++) { if (s.substr(i, 4) == "suvo") suvo++; } cout << "suvo = " << suvo - suvojit << ", suvojit = " << suvojit << "\n"; } return 0; } the code gave out of bounds exception substr() function test case: 15 rsuvo...

javascript - What is "dsh" parameter in create google account form? -

i want know, "dsh" parameter in below form? can param? <form novalidate="" id="gaia_loginform" action="https://accounts.google.com/serviceloginauth" method="post"> <input type="hidden" name="service" id="service" value="blogger"> <input type="hidden" name="dsh" id="dsh" value="-2655181513770911851"> <input type="hidden" name="galx" value="obuz5i4i_48"> </form> the name="dsh" attribute used in conjunction post array in php. which pulled from: <?php $var = $_post['dsh']; echo $var; the value (automatically) pulled hidden value it, being value="-2655181513770911851" since there preset value it. an id attribute used either in conjunction javascript/jquery and/or css. more on this: https://developer.mozilla.org/en/docs/web/html...

jackson - JSON copy same property to child nodes -

i have pojo structure similar below, public class { private int val1; private string createdby; private b bobj; . . // getters , setters plus more fields } public class b { private int val2; private string val3; private string createdby; . . // getters , setters plus more fields } input json this { "createdby": "user_1", "val1" : 1, "bobj" : { "val2" : 2, "val3" : "3", "createdby" : "user_1" } } i want reuse createdby root class a inside bobj without having have client send same value in child nodes. extend beandeserializer call super in deserialize , maniplations need there. register deserialzer using simplemodule. i not sure if there other direct way so.

JavaFX. GUI and model for read-only observable collection of observable collections -

i prepare gui in javafx , model ( data provider ) provides observable collection of observable collections of trading cards. it nice if mentioned observable "parent" collection , every "child" collection outside model unmodifiable/read-only . every changes made inside model private methods. let's trading card class looks this: package cards; import javafx.scene.paint.color; public class tradingcard { private string title; private string subtitle; private color background; private color border; public tradingcard(string title, string subtitle, color background, color border) { this.title = title; this.subtitle = subtitle; this.background = background; this.border = border; } public string gettitle() { return title; } public string getsubtitle() { return subtitle; } public color getbackground() { return background; } public color ge...

How do I create a foreign key in SQL Server? -

i have never "hand-coded" object creation code sql server , foreign key decleration seemingly different between sql server , postgres. here sql far: drop table exams; drop table question_bank; drop table anwser_bank; create table exams ( exam_id uniqueidentifier primary key, exam_name varchar(50), ); create table question_bank ( question_id uniqueidentifier primary key, question_exam_id uniqueidentifier not null, question_text varchar(1024) not null, question_point_value decimal, constraint question_exam_id foreign key references exams(exam_id) ); create table anwser_bank ( anwser_id uniqueidentifier primary key, anwser_question_id uniqueidentifier, anwser_text varchar(1024), anwser_is_correct bit ); when run query error: msg 8139, level 16, state 0, line 9 number of referencing columns in foreign key differs number of referenced columns, table 'question_bank'. can spot error? ...

scala - Cannot compile example -

i have class: class rational(n:int, d:int) { require(d!=0) private val g = gcd(n.abs, d.abs) val numer = n/g val denom = d/g def this(n: int) = this(n, 1); def add(that:rational): rational = new rational(numer * that.denom + that.numer * denom, denom * that.denom) override def tostring = numer+"/"+denom; private def gcd(a: int, b: int): int = if(b==0) else gcd(b, % b) } and test class: import rational object test extends app { val x = new rational(1/2) println("hello"); } i'm trying compile them using scalac test.scala rational.scala but following error: test.scala:3: error: '.' expected ';' found. object test extends app { ^ 1 error found can guide me why not compiling. basic error import rational not valid syntax (because it's class) as in default package, don't need import anyway

php - Github authentication failed with user www-data -

i'm setting hook between github , server, can auto pull new commits when script triggered github requests. it's setting finished, ssh-keys, git origin. can pull new commit private repo hosted on github running git pull origin master . it's works fine shell. but when write command deploy.php file, can triggered github, error message. host key verification failed. fatal: not read remote repository. please make sure have correct access rights , repository exists. after that, run command whoami through php file, returns user www-data . actually, generate key www-data user, , put them in /var/www/.ssh , copied id_rsa.pub , pasted github, still have authentication failure. nginx all files set belong www-data:www-data i have add www-data 's public key repo's deploy keys. deploy.php command shell_exec("cd /var/www/html/tinfo/; git pull origin master 2>&1;"); my question how create key www-data ? is www-data 's .ssh di...

html - How to make a div and a link inline? -

i want div , a elementes below appear inline: the result should like: here is: link 1 but didn't work. appreciate hints. .inline { float: right; display: block; } a.inline { float: right; } <ul> <li> <div class="inline">here is:</div> <a href="/someurl" class="inline">link 1</a> </li> </ul> p.s. i'm using twitter bootstrap css framework remove a.inline styling , change css this: .inline { display: inline-block; }

c# - Adding Columns and ListView items -

Image
this first foray c# winforms, , i'm trying create listview grid. my code looks this: listview1.columns.add("name", 100); listview1.columns.add("col2", 200); listview1.columns.add("col3", 300); string[] arr = new string[3]; arr[0] = "product_1"; arr[1] = "100"; arr[2] = "10"; string[] arr2 = new string[3]; arr[0] = "product_2"; arr[1] = "200"; arr[2] = "20"; listviewitem itm = new listviewitem(arr); listviewitem itm2 = new listviewitem(arr2); listview1.items.add(itm); istview1.items.add(itm2); but output looks this: so few questions here: why not see column names? why not see grid lines? why last entry being displayed (product2)? why there no information other string "product2" displayed, rather other column entries? any appreciated! the default viewstyle of listview largeicon. in view, no columns or details displayed. if want columns visible, should ...

android - how do i randomize without repetitions questions in a quiz app? -

between these 2 functions 1 should implement randomize questions database more efficiently. getquestion # 1 public void getquestion() { random r = new random(); int n = r.nextint(2); dbase = this.getreadabledatabase(); ctr++; //cursor cursor = dbase.rawquery("select * " + table_quest + " `qid` = " + n + ";", null); cursor cursor = dbase.rawquery("select * "+table_quest+" order random()"+""+ ";", null); if (cursor.movetofirst()) { if(cursor.getint(6) == 1) { ta.txtquestion.setvisibility(view.visible); ta.txtquestion.settext(cursor.getstring(1).tostring()); /* log.e("image", "i here"); ta.img.setvisibility(view.visible); int imageresource = draw.getresources().getidentifier("@drawable/"+cursor.getstring(1), null, package); drawable res = draw.getresources().getdrawable(imag...

Merge contents of two lists alternately into one list in groovy -

i want merge contents of 2 lists alternately new list. length of lists undefined. using below code achieve this. want know, if there groovy way achieve without using conditions , loop. objective shorten code as possible using groovy features. def combinelist(arraylist list1, arraylist list2){ def list = []; int j = k = 0; def size = (list1.size() + list2.size()); (int = 0; < size; i++) { if(j < list1.size()) list.add(list1.get(j++)); if(k < list2.size()) list.add(list2.get(k++)); } println list; } input: case 1: combinelist([1,2,3,4,5,6,7,8,9,0], ['a','b','c','d','e','f']) case 2: combinelist([1,2,3,4], ['a','b','c','d','e','f']) output: case 1: [1, a, 2, b, 3, c, 4, d, 5, e, 6, f, 7, 8, 9, 0] case 2: [1, a, 2, b, 3, c, 4, d, e, f] one of many ways: list combinelist(list one, list tw...

html - undefined by json array file using javascript -

i have display images browser , want image json response , display browser using javascript. json response looks like: var champion = [ { "name":"aatrox", "img" : "aatrox.png" }, { "name":"ahri", "img" : "ahri" }, { "name":"akali", "img" : "akali.png" }, { "name":"alistar", "img" : "alistar.png" }, { "name":"amumu", "img" : "amumu.png" } ] the json external file, called data.json . beginner. wrote code: var champ = json.stringify(champion); //var mydata = json.parse(champion); var images = 'mylink/'; var counter; var name; for(counter=0; counter<5 ; counter++ ){ var litag = document.createelement("li"); //create li tag litag.setattribute("class","champ-list...

c - Pointers to pointers - linked list mess -

i'm writing simple c program manage linked list defined follow: typedef struct node { int value; struct node *next; } *list; i reviewed code , seems okay when printing results not working well. my main, problems on comments: int main(void) { list n = list_create(1); insert(n, 2); insert(n, 3); insert(n, 5); insert(n, 4); //something here not work properly. produces following output: //value: 1 //value: 2 //value: 3 //value: 4 //where value 5? print_list(n); delete(n, 3); print_list(n); return 0; } i don't know destroying list structure. these functions, debug, if kind. list list_create(int value) { list new = malloc(sizeof(struct node)); new->value = value; new->next = null; return new; } list new_node(int value, list next_node) { list new = malloc(sizeof(struct node)); new->value = value; new->next = next_node; return new; } void print_list(list l) ...

python 3.x - Error installing pymc on debian sid -

i have installed gfortran sudo pip3 install pymc fails: ioerror: [errno 2] no such file or directory: 'lapack/double/dpotrs.f'. skipping file "lapack/double/dpotrs. ioerror: [errno 2] no such file or directory: 'lapack/double/dpotrf.f'. skipping file "lapack/double/dpotrf. ioerror: [errno 2] no such file or directory: 'lapack/double/dpotf2.f'. skipping file "lapack/double/dpotf2. ioerror: [errno 2] no such file or directory: 'lapack/double/ilaenv.f'. skipping file "lapack/double/ilaenv. ioerror: [errno 2] no such file or directory: 'lapack/double/dlamch.f'. skipping file "lapack/double/dlamch. ioerror: [errno 2] no such file or directory: 'lapack/double/ilaver.f'. skipping file "lapack/double/ilaver. ioerror: [errno 2] no such file or directory: 'lapack/double/ieeeck.f'. skipping file "lapack/double/ieeeck. ioerror: [errno 2] no such file or directory: 'lapack/double/iparmq.f'. ski...

How can I improve the performance of this MySQL Query in Perl, the same Query directly executed in MySQL Workbench is 1600 times faster -

my mysql query in perl takes longer same query in mysql workbench. trying improve performance of perl query same workbench query. running on microsoft windows 10 pro 64-bit, activeperl 5.24.0 build 2400 64-bit, using dbi v1.636, dbd-mysql 4.033 , mysql v5.7 64-bit. there not resource constraint can find. innodb buffer pool – 40% utilized. table open cache efficiency of 99%. 64gb of ram, 16 processors running @ 3.4ghz. of queries run through environment acceptably fast. there 1 class of queries runs in perl, reasonably in workbench. here example of query. select t1.csi_id, t2.signal_date, t2.nextgain equity t1 inner join (equity_signal t2, market_boundary t3) on (t2.equity_csi_id = t1.csi_id , yearweek(t3.signal_date)= yearweek(t2.signal_date)) yearweek(t2.signal_date) = 201643 , t2.currency_idcurrency = 'usd' , t1.useequity = 1 , t1.nodata = 0 , t2.spike =...

Is it possible to have per-user persistent data with AirConsole? -

i'm thinking of developing game airconsole. i'm not sure if it's right platform, though, since need way save data object unique each player, can save player's data across game sessions. here's want do: while playing on 1 airconsole player b, player unlocks ability player disconnects airconsole session, , later joins game player c player still has ability unlocked previous time played game, while player c not since haven't played before. what best way securely , reliably? also, great see way long-distance multiplayer come airconsole. let put in connect code in desktop browser have console's screen mirrored play friends aren't nearby. and way run airconsole laptop great - @ college wifi bad play airconsole on, , way host locally on separate router without internet connection great persistent storage available in latest api, have @ methods airconsole.requestpersistentdata airconsole.onpersistentdataloaded airconsole.onpersistentda...

sql - Best way to tie data to multiple users? -

what's best way relate pieces of data multiple users in sqlite? say have table of users, table stocks they've purchased. preferred solution multiple users share same data? example: user1 , user2 own stock in goog , appl. user3 owns goog, etc. how best represent these relations? based on answer comment (i.e. no link between users purchased same stock) , since tables (their records) rather small , hence no specific allocation issues expected, simple have 2 tables, 1 users (with id) , 1 3 columns: user_id, stock name, , amount.

asp.net membership comparing current logged on user password change and creation dates -

protected void login2_loggedin(object sender, eventargs e) { if (membership.getuser().lastpasswordchangeddate == membership.getuser().creationdate) { response.redirect("changepassword.aspx"); } } as can see im wanting force password changes on first login. not doing correctly. examples tried use appear have built own login controls. using built in login control i'm not sure how handle text boxes uses. the error getting on if statement "object reference not set instance of object. " thank help.

ios - Not able to hit the endpoint when making a GET request in swift -

Image
hello trying make request server failing hit endpoints checked logs , im not hitting final endpoint. endpoint needs authorization has been added request field. attempting json values , display them table cell. when attempt retrieve values return nil. never attempts hit endpoint. attempted put print statement print("session)" check if calls datawithrequest if fails so. please doing wrong here? func getlocaldata() -> [[string:anyobject]] { var json:[[string:anyobject]]? let endpoint = "http://******************" let url:nsurl? = nsurl(string: endpoint) let session = nsurlsession.sharedsession() let request:nsmutableurlrequest = nsmutableurlrequest(url: url!) request.httpmethod = "get" request.setvalue("application/json", forhttpheaderfield: "content-type") request.addvalue(token!, forhttpheaderfield: "authorization-header") let task = session...

fwrite - Python - TypeError: expected a character buffer object -

i'm trying write data: playlist = {'playlist': {u'up in flames': 0, u'oceans': 0, u'no surprises': 0}} to file so: open('playlist.txt', 'a') f: f.write(playlist) but looks writing integers file generator error: typeerror: expected character buffer object how correct this? there better file format data structure? you're trying write dictionary object text file, function expecting characters write. if want object stored in text format can read, need way structure data, such json. import json open('playlist.json', 'w') f: json.dump(playlist, f) there other options such xml or maybe csv. if don't care data being in plain text readable format, @ pickling dictionary object. as noted in comments, question appended data file, rather writing new file. issue json hierarchical structure doesn't work when appended too. if need add existing file may need come different struct...

java - javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher -

i'm working on project i'm doing encryption, picked key , cryptographer aes , step base64. problem happens @ time of decrypting base64 aes , aes , return string. below error , code import java.io.unsupportedencodingexception; import java.security.invalidkeyexception; import java.security.nosuchalgorithmexception; import java.util.base64; import javax.crypto.*; import javax.crypto.spec.*; public class criptografia { byte[] chave = "chave de 16bytes".getbytes(); public string encriptaaes(string chavecriptografada) throws invalidkeyexception, illegalblocksizeexception, badpaddingexception, unsupportedencodingexception { try { cipher cipher = cipher.getinstance("aes"); byte[] mensagem = chavecriptografada.getbytes(); cipher.init(cipher.encrypt_mode, new secretkeyspec(chave, "aes")); chavecriptografada = cipher.dofinal(mensagem).tostring(); chavecriptogr...

Regular Expression in Finite Automata -

i need explanation of regular expression of : all strings of {a,b} not contain 2 or more consecutive a's. the regex described should not generate string has "aa" substring. if have finite automata can convert regex using algorithm state elimination: (here youtube link) fa regular expression if want direct regex following work: left part covers ends b along empty string. right 1 covers ends a. ( (ab + b)* + ((ab + b)* a) )

Removing Duplicates From a Dataframe in R -

my situation trying clean data set of student results processing , i'm having issues removing duplicates wanting @ "first attempts" students have taken course multiple times. example of data using 1 of duplicates is: id period desc 632 1507 1101 90714 research contemporary biological issue 633 1507 1101 6317 explain process of speciation 634 1507 1101 8931 describe gene expression 14448 1507 1201 8931 describe gene expression 14449 1507 1201 6317 explain process of speciation 14450 1507 1201 90714 research contemporary biological issue 25884 1507 1301 6317 explain process of speciation 25885 1507 1301 8931 describe gene expression 25886 1507 1301 90714 research contemporary biological issue the first 2 digits of reg_period year sat paper. can seen, want keeping id 1507 , reg_p...

IBM Bluemix Services -

i have 1 question according bluemix services. please me out if me. - want use third party service cognitive graph project. couldn't access it. guide me how can that? please ask questions bluemix offerings @ ibm developerworks answers . stack overflow programming how-to questions. the bluemix cognitive graph service in closed beta , therefore not available general public. learn more, can submit email address explained on service's bluemix catalog page .

c# - why subtract 0.5 and then *2 in that code......by JAKEDREW(http://www.jakemdrew.com/blog/RgbProjector.htm -

http://www.jakemdrew.com/blog/rgbprojector.htm private static double calculateprojectionsimilarity(double[] source, double[] compare) { if (source.length != compare.length) { throw new argumentexception(); } var frequencies = new dictionary(); ////calculate frequencies (var = 0; < source.length; i++) { var difference = source[i] - compare[i]; difference = math.round(difference, 2); difference = math.abs(difference); if (frequencies.containskey(difference)) { frequencies[difference] = frequencies[difference] + 1; } else { frequencies.add(difference, 1); } } var deviation = frequencies.sum(value => (value.key * value.value)); ////calculate "weighted mean" ////http://en.wikipedia.org/wiki/weighted_mean deviation /= source.length; ////maximize scale deviation = (0.5 - deviation) * 2; return deviation;...

android - getPurchase returns the first subscription not the last one -

i using subscription model in android. when query inventory,the listener follows iabhelper.queryinventoryfinishedlistener mgotinventorylistener = new iabhelper.queryinventoryfinishedlistener() { public void onqueryinventoryfinished(iabresult result, inventory inventory) { log.d(tag, "query inventory finished."); if (result.isfailure()) { mact.alert("failed query inventory: " + result, true); return; } log.d(tag, "query inventory successful."); // have premium upgrade? purchase premiumpurchase = inventory.getpurchase(sku_premium); here getpurchase returns initial date of subscription, namely gpa.232423423423423.0 how can purchase information of latest subscription (ie gpa.232423423423423.7) i need know latest subscription date not first thank you

Why onSurfaceTextureAvailable cannot continue on Android 4.4? -

i remove textureview root layout , add windowmanager, mviewwidth = mtextureview.getwidth(); mviewheight = mtextureview.getheight(); rootview.removeview(mtextureview); windowmanager mwm = (windowmanager)getapplicationcontext().getsystemservice(context.window_service); windowmanager.layoutparams lp = new windowmanager.layoutparams(windowmanager.layoutparams.type_system_error); lp.width = windowmanager.layoutparams.wrap_content; lp.height = windowmanager.layoutparams.wrap_content; // lp.width = windowmanager.layoutparams.match_parent; // lp.height = windowmanager.layoutparams.match_parent; lp.flags = windowmanager.layoutparams.flag_not_focusable;// |windowmanager.layoutparams.flag_not_touch_modal;//| lp.format = pixelformat.translucent; //pixelformat.rgba_8888; // lp.gravity = gravity.bottom | gravity.right; mwm.addview(mtextureview, lp); on android 4.4, textureview cannot displa...