Posts

Showing posts from May, 2014

jquery - post data to new tab via ajax -

here try achieve: let's have 2 files, order.php , print.php. in order.php there button printing data. when user clicks button want post data order.php print.php. easy. how? this last attempt this. $.ajax({ type: 'post', url: '../event/print', async: false, data: {json:$("input[name=json]").val(),id:"2"}, success:function(data){ mywindow = window.open('../event/print', "_blank"); mywindow.focus(); }, error:function(data){ swal("oops...", "something went wrong.", "error"); } it shows me error alert everytime 500 internal server error. i'm doing wrong? edit i've changed things around web, , not show error. cant see $_post parameters. in way calling page ../event/print twice. the first time post request via ajax, second time request due fact opening new tab. what describing not ajax request, form target="_blan...

python 3.x - Regex: match "group3.*group1" if group2 is not between groups 3 and 1 -

i'm using python 3.4. have 3 groups: g1 = 'g11|g12' g2 = 'g21|g22' g3 = 'g31|g32' i want match instance of g3, followed except g2, followed g1. here strings on want find match: 'g31 or nothing g11' 'g31g11' edit: added: 'anything or nothing g31 g11 or nothing' edit: added: 'anything or nothing g21 g31 g11 or nothing' and here strings on not want find match: 'g31 or nothing g21 or nothing g11' 'g31g21g11' i tried: (g31|g32)(?=.*?(g11|g12))(?!.*?(g21|g22)) , works 'g31 g11' , 'g31 g21 g11' fails if there g21 or g22 after g11, in 'g31 g11 g21' . i've tried '(g31|g32).*?(g21|g22){0}.*?(g11|g22)' works 'g31 g11' , 'g31 g21 g11' not 'g31 g31 g21 g11' . the problem trivial if expect fixed width strings, e.g., 'g31 g11' or 'g31 g21 g11' , there many solutions such problem on stackoverflow already. also, hav...

c# - How to use dropdownlists in ASP.NET MVC with lookup values without ViewBag? -

this should easy, , can't life of me realize haven't found answers despite @ least hour of googling. anyway, here go: i want create simple asp.net mvc view dropdowns allow user select values, saved id:s database. i've been told viewbag/viewdata devils work i've tried solve adding selectlist (view)model like: public virtual selectlist accommodations { get; set; } and in controller fill like: loanapplication theloanapplication = new loanapplication(); theloanapplication.accommodations = new selectlist(db.accommodations.tolist(), "accommodationid", "name"); and in view use working: @html.dropdownlistfor(model => model.accommodationid, model.accommodations, "choose accommodation") this works should, when try save model, errors accommodations property (the list) null kind of expected. else in model should though. i've looked @ known "countoso university" code example on asp.net site , in seem use ...

Swift for-loop wont accept index as a variable multiplied with a size.widht value -

code: the issue: im not allowed operate index size.widht. know cg value allowed operate literals. however, when try use declared int instead doesnt allows either. size.widht/5 * (index + 1) says "cannot invoke '+' argument list of type '($t6,($t10))'. func addbricks(cgsize) { var index = 0; index < 4; index++ { var brick = skspritenode(imagenamed: "brick") brick.physicsbody = skphysiscsbody(rectangleofsize: brick.frame.size) var xpos = size.widht/5 * (index + 1) var ypos = size.height - 50 brick.position = cgpointmake(xpos, ypos) self.addchild(brick) } } what possible wrong?

windows - Starting selenium server from java in the background -

i want make easy-to-use selenium tests - run 1 file , starts server, connects it, run tests, close server , exit (on windows). i don't want user see selenium console want hide if possible (run in background , maybe log output). how can start selenium server directly java? well, wasn't hard (at least on windows). used start selenium server this: java -jar selenium-server-xxx.jar <options> to start without console use javaw : javaw -jar selenium-server-xxx.jar <options>

php - How do i multiply values of an array -

i error message "array_product() expects parameter 1 array, string given in..." when try multiply values in foreach statement below. kindly help. in advance here code. note values in $answer "1.50 real(yes)". need "1.50" many in loop multiply , total. foreach($_post['gm'] $key => $answer){ if($answer != ''){ $odd=explode(" ",$answer); $od=trim($odd[0]); } $total = array_product($od); echo $total; i try multiplication outside loop above $total. not repeat in loop. please? you not reconstructing array in foreach loop. $od variable overridden each time loop. your code should be foreach($_post['gm'] $key => $answer) { if($answer != '') { $odd = explode(" ",$answer); $od[] = trim($odd[0]); } } $total = array_product($od); echo $total;

osx - Packages installer (for Mac) script execution fails -

i have been unsuccessful in getting packages v1.1.2 (within osx 10.9.5) in either bundle or flat mode fire sort of script—-even simple test script beeps: #!/bin/sh osa "beep 1" exit 0 the package , script have been code-signed , verified, , script permissions set take correct permissions using chmod u+rwx. frustrating have older package installation file executes script fine. can overlooking? i advised @ install log , found following: executing script "./preinstall" in /private/tmp/pkinstallsandbox.dm4h07/scripts/com.mygreatcompany.pkg.test.fmbtok packagekit: *** couldn't posix_spawn: error 8 perhaps sandbox culprit? apparently there wrong shell script. remade new shell script, pasting original content except "she-bang" part. hand-typed. noted unlike original shell script, new 1 showed in desktop white icon--not black previous script file. had been playing around c programming , made change command line tool make compile c....

node.js - Implementing PeerJS Server with multiple dynos on Heroku -

Image
i've implemented peerjs express in node.js application using: app.use('/peer', peer.expresspeerserver(app, {proxied: true})); my concern when scale application onto multiple dynos accomodate traffic, won't able signal between peers have been connected different dynos through heroku's internal process model. my initial thought create database collection keep track of peer ids connected on of dynos, don't know of way database notify each of dynos when peer on 1 dyno attempting signal peer connected on different dyno. is there way exists or possibly implemented resolve issue scaling? edit i found reference doing wanted redis here: https://remysharp.com/2014/11/10/muddling-my-way-through-real-time#server-side my question now, there existing repositories implement webrtc using redis? there not appear existing signaling servers exist using node , redis.

c# - Reactive Extension : 3 Consecutive occurance of a Record -

i have hot observable - class tablerecord { string propertya; datetime dt; dictionary<string,int> checkthreshholdvalues; } i need check each value present in dictionary, if 3 consecutive values exceeding threshold or not. if yes, need generate new event property. (here each reacord come @ different of 15 minutes ie 4 records in 1 hour. class generatedrecord { string propertya; datetime lasttimeobserved; string dictionarypropertyname; int lastvalue } i know have use groupbyuntil buffer, somehow unable think , how split dictionary individual parts still keeping condition appreciated. example : lets have propertya value in {"towna","townb","townc"} lets properties in dictionary {"pollution","temperature","pressure"} lets say, recv values per 15 minutes, data - {"towna" ,"6/14/2015 10:00",{ {"pollution",61},{"temperature",48},{"pressure...

javascript - Getting textarea's to be next to each other in a div -

so have div, , have 2 <textarea> tags inside. how them go next each other instead of 1 on each row. jsfiddle: in case, can .input-field-div{ display:inline-block; } .thirdrow { background-color: blue; border: 10px solid red; border-radius: 10px; } .input-field-div{ display:inline-block; } } <div class="col-md-12 thirdrow"> <!-- input fields --> <!-- player 1 name input field --> <div class="input-field-div"> <textarea id="input-player1-name" rows="1" placeholder="player 1 name"></textarea> </div> <!-- player 2 name input field --> <div class="input-field-div"> <textarea id="input-player2-name" rows="1" placeholder="player 2 name"></textarea> </div> </div>

c# - simple form application throwing an exception -

this question has answer here: what nullreferenceexception, , how fix it? 29 answers this application shows total females, males , total number of students xml document when "count" button pressed. problem program throws error when "count" button pressed , im not sure why?. second, im not sure 3 totals correct. new programming , assistance if possible. namespace debugsession { /// <summary> /// summary description form1. /// </summary> public class form1 : system.windows.forms.form { private system.windows.forms.label label1; private system.windows.forms.label lbltotal; private system.windows.forms.label label4; private system.windows.forms.label lblmales; private system.windows.forms.label lbl; private system.windows.forms.button btncount; private system.wi...

gcc - When can/will a function be inlined in C++? Can inline behavior be forced? -

i trying expected behavior when use keyword inline . tried calling function in different files, templating function, using different implementation of inline function, whatever do, compiler never inlining function. so in case compiler chose inline function in c++ ? here code have tried : inline auto add(int i) -> int { return i+1; } int main() { add(1); return 0; } in case, get: add(int): pushq %rbp movq %rsp, %rbp movl %edi, -4(%rbp) movl -4(%rbp), %eax addl $1, %eax popq %rbp ret main: pushq %rbp movq %rsp, %rbp movl $1, %edi call add(int) movl $0, %eax popq %rbp ret or again, template<typename t> inline auto add(const t &i) -> decltype(i+1) { return i+1; } int main() { add(1); return 0; } and got: main: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $1, -4(%rbp) leaq -4(%rbp), %rax movq %rax, %r...

javascript - Upload properly encoded (base64?) image to SharePoint with AngularJS -

i able upload image file sharepoint, not being recognized image. have tried utilizing following directive based on research states images need base64 encoded when uploaded sharepoint, still uploads file appears corrupt: https://github.com/adonespitogo/angular-base64-upload i happy use directive, unsure of how pass need sharepoint's rest api. the original iteration had not use directive, more of straight upload attempt. what need achieve follows: 1) upload image without being "corrupted", , require base64 encoding/how achieve this? 2) upload images name (not "test.jpg") , have metadata (ex. upload image title or department name belongs to) iteration 1: no directive here html (please note controller tied page via ng-route): <div class="col-md-12"> <form> <input type="file" onchange="angular.element(this).scope().fileschanged(this)" data-ng-model="files" multiple> ...

android - Scroll to searched text and bringing it on top of the textview -

i have search option user can search word given textview. example of sample textview , if user searches "cupy cup n" text in blue box should scrolled top first line . i have tried answer here don't know how find line number of searched text. can more specific? cannot understand want. understand have either listview or recyclerview , want filter results based on typed text in inputtext (i.e.). in order achieve can do: add textchangelistener inputtext (reference http://www.mysamplecode.com/2012/06/android-edittext-text-change-listener.html ); at end of listener, filter list , pass filtered list adapter, call notifydatasetchanged();

save - Implementing both Serializable and Parcelable interfaces from an object in Android - conflict -

i have object must save file reuse. class of object implements parcelable use in intents. knowledge of saving object file says implement serializable , when do, error in class contains object @ putextra method of intent because both serializable , parcelable have method. is there way avoid this, or way can save object state , reload easily? i have looked @ few articles , feel no more informed how should saving object. in advance i believe parcelable , serializable both reaches same goal in different ways , different performances. given that, if class in object hierarchy alread implements parcelable interface, can override writetoparcel method, call super (so members of super classes written parcel if implement way) , then, should write attributes parcel, keeping in mind order use save them order use retrieve them latter (filo data structure) edit just cast object complains , tells conflict class want use described here: https://stackoverflow.com/a/13880819/...

git - gitlab: Windows: How to use chmod and fix "Get Permission denied (publickey). fatal: Could not read from remote repository" -

i have gone through many other posts above error, seem different os, or different reason. i running windows 8.1. have git installed (i new git), , have signed gitlab, create project there, created , added key (as per instructions), when try , push, pushing git@gitlab.com:myusername/test1.git permission denied (publickey). fatal: not read remote repository. please make sure have correct access rights , repository exists. now when created ssh key using ssh-keygen -t rsa -c "myemail@gmail.com it did create files in local project folder, , not under c:\users\peter (my home folder) so, copied single file (known_hosts) deleted existing .ssh folder, , created using bash, , copied in above created id_rsa.pub , idrsa.key files. from git gui, if go | show ssh key reports "found public key in ~/.ssh/id_ras.pub from bash, permissions on folder are. drwxr-xr-x 1 peter administ 0 jun 14 09:35 .ssh and permissions on files within are.. $ ls .ssh -l t...

c# - Creating custom partitioners for Parallel.ForEach -

question https://msdn.microsoft.com/en-us/library/dd997416(v=vs.110).aspx claims possible write custom partitioner parallel.foreach "provid[es multiple] elements @ time". how 1 this? justification i have collection of on 750,000 tasks i'm attempting execute in parallel parallel.for or parallel.foreach . (i'm using for , custom partitioner apparently requires foreach .) total processing time runs 30 processor minutes, should take 4 minutes on 8 cores. "should" operative term. workloads highly dissimilar, point first 5 require 20 minutes. fine if ran on 5 separate threads, seems default partitioner (quite sensibly) assumes tasks require same amount of time, , therefore runs first dozen or on same thread. since not case workload, write custom partitioner hands out first 32 tasks 1 @ time, next 64 2 @ time, next 128 4 @ time, , forth. https://msdn.microsoft.com/en-us/library/dd997416(v=vs.110).aspx claims provide example of how create custom p...

android - Synchronize testing thread, UI thread, and CursorLoader thread -

my understanding android instrumented junit tests run on own thread unless annotated @uithread or calling instrumentation.runonmainsync() or activity.runonuithread() . i'm trying use cursorloader access app's database , populate listview . have test verifies listview populated correctly. my problem need synchronize 3 threads: test thread should wait until cursorloader thread finishes , notifies ui thread populate listview . create cursorloader , register loadercallbacks support loadermanager , create instance in oncreateloader() . onloadfinished() changes cursor of listview 's adapter. now need ensure test waits until onloadfinish() has been called before attempting access child views of listview . current idea add waitfordata() method loadercallbacks implementation tests can call. however, i'm not sure how implement method. can use wait() , notifyall() in onloadfinished() ? or need use more sophisticated semaphore ? you're on right tra...

c++ - Why can't we always use the register storage class in C? -

i read in book that, whenever declare variable storage class register, stored in register, subject availability. if no register available, default storage type of 'auto' assigned it. whenever declare variable without explicitly mentioning storage class, default storage type assigned 'auto' itself. so, question is, why not declare every variable of 'register' storage class - if no register available, anyways treated default 'auto' class itself . , luckily, if registers available, stored in one. understand cannot use & operator longer, if i'm not going work pointers , addresses? can declare variables 'register' storage class then? because seems bad practise. edit: searched web, 'unavailability of address' point mentioned. why can't rest variables declared 'register' not mentioned. you cannot make variables register , because c (and (c++) language specification(s) explicitly forbids taking address of ...

Redis Cache .Net Client -

does know if amazon supports c# client libraries making calls redis server? know service stack , stack exchange 2 libraries right now, amazon makes no mention of them @ all. either .net, nodejs, ruby, c/c++ don't require server component work redis server. why they're clients . it required if amazon develop own branch of redis change standard communication protocol defined official redis implementation...

python - Initialising value within or before "For Loop" -

i not understand why putting initial value of patriots_wins in , before loop make such difference. output 0 wrong # nfl data loaded nfl variable. item in nfl: patriots_wins = 0 if item[2] == "new england patriots": patriots_wins = patriots_wins + 1 print(patriots_wins) correct answer # nfl data loaded nfl variable. patriots_wins = 0 item in nfl: if item[2] == "new england patriots": patriots_wins = patriots_wins + 1 print(patriots_wins) the reason not working correctly each time loop executes, reset value of wins 0, because statements in loop's body executed. however if declare , initialize outside of loop, not "reset" within loop, incremented @ each iteration of loop. end result being variable has total number of wins. to see how working, here example script supposed count number of 'a' in list: >>> items = ['a','a','b','c','d','a...

linux - Search A Variable in Specific Column in BASH with awk -

i have log_file below: log|server301|2015|05|12|00|58|35|572617|0|comp|002.01.003.00|dsohmsn2viewcallback.cpp|142|callback:dsohmsn2viewcallback::flipbypasson changed sn=2 old value =2 new value =1 log|client2|2015|05|12|00|58|35|593088|0|comp|002.01.003.00|amsn.cpp|12577|callback:ohmoam::ohmsn2viewchange, old flipbypassonmt log|server302|2015|05|12|00|58|35|593116|0|comp|002.01.003.00|amsn.cpp|12590|callback:ohmoam::ohmsn4viewchange, new flipbypassonmt log|server301|2015|05|12|00|58|35|593302|0|comp|002.01.003.00|amsn.cpp|12577|callback:ohmoam::ohmsn3viewchange, old disableflipbypassonmt log|client1|2015|05|12|00|58|35|593324|0|comp|002.01.003.00|amsn.cpp|12590|callback:ohmoam::ohmsn2viewchange, new disableflipbypassonmt i want print line no have word server @ 2nd column word callback @ 15th column variable $parameter_name @ 15th column i executed below command: parameter_name="flipbypassonmt" $(awk -v var="$parameter_name" -f'|' '$2...

image processing - ImageJ Fast filters plugin -

i've tried using fast filters plugin - http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:fast_filters:start - michael schmid. when integrated own java program, results different when used same parameters tried in imagej software. any ideas on other techniques should done before feeding plugin? as far know fast filters use square or rectangular kernel . the default imagej filters use aproximate circular kernels. you can view them under process -> filters -> show circular masks

sql - How to find if a function exists in PostgreSQL and where? -

my question similar headline of question posted here answer there different , more complex need. my problem simple... have function name func1 , know if , function implemented. it's location, it's arguments , it's code. i've tried build 1 using pg_proc : select proname,prosrc pg_proc proname 'func1'; how add schema name, function code (text) , , function argument list? another issue curious me... can make work if instead of func1 i'll search lower ? lower build in function not implemented user. the question not address whole problem . doesn't explain how in schema function defined nor if work on functions build in sql standard lower(string). everything there in pg_proc table . the source code function in prosrc field. pronamespace field schema identifier (if want name, need join pg_namespace table). reconstructing parameter list information in pg_proc not @ straightforward, select pg_get_function_arguments(oid) pg_p...

php - Sum values in multidimensional array (selecting multiple columns with multiple rows) -

let's have 5 different columns, a, b, c, d, e , , i'm selecting multiple rows: $result = mysqli_query($conn,"select a,b,c,d,e posts submitter='$user'"); while ($row = mysqli_fetch_assoc($result)){ $ratings[] = $row; } example: the user has 3 posts, it'll select 3 rows in query. i want sum of rows' values a (and rest of course). e.g. row 1 a value = 4 row 2 a value = 10 row 3 a value = 1 so need sum of 15. i know use array_sum($ratings) find sum of array if select 1 column ( a ) can have multiple rows, multi-dimensional right due multiple column values being selected? you can use sum in query: select sum(a) , sum(b) , sum(c) , sum(d) , sum(e) posts submitter = '$user'

java - A very simple stoper -

so 2 days ago i've started learning android technology. i've written simple program can count time using countdowntimer class. here xml code: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" tools:context=".mainactivity" android:id="@+id/raf"> <button android:id="@+id/btnstart" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_centervertical="true" android:layout_marginleft="28dp" android:textcolor="#76ee00" android:background="#2c3529" android:text="start" /> <button android:id="@+id/btnstop" andro...

algorithm - A new Bin-packing? -

i'm looking in kind-of bin-packing problem, not quite same. problem asks put n items minimum number of bins without total weight exceeding capacity of bins. (classical definition) the difference is: each item has weight , bound , , capacity of bin dynamically determined minimum bound of items in bin. e.g., have 4 items a[11,12], b[1,10], c[3,4], d[20,22] ( [weight,bound] ). now, if put item bin, call b1, capacity of b1 become 12. try put item b b1, failed because total weight 11+1 =12, , capacity of b1 become 10, smaller total weight. so, b put bin b2, capacity become 10. now, put item c b2, because total weight 1+3 =4, , capacity of b2 become 4. i don't know whether question has been solved in areas name. or variant of bin-packing has been discussed somewhere. don't know whether right place post question, helps appreciated! usually algorithm design np-hard problems, it's necessary reuse techniques rather whole algorithms. here, algorithms standard...

Generating a dice game - C Programming -

i'm following tutorial on youtube , doing dice generator. print out 3 dice result , sum out dice result. after which, user @ sum, , based on sum, user going guess whether next roll going higher,lower, or same. below code, suppose, when typed 'yes', should doing code inside if statement. however, went straight else statement. can please tell me what's wrong? int answer; int guess; int diceroll4 = 0; printf("would guess next dice? y/n \n"); scanf(" %c", &answer); if (answer == 'yes' ){ printf("what guess?\n"); printf("please key in number \n"); scanf(" %d", &guess); if (guess > diceroll4 ){ printf(" got wrong, high!"); } else if (guess < diceroll4){ printf(" got wrong, low!"); } else { printf("you got right"); } } else{ printf("thanks playing"); } first of all, answer should...

php - Symfony: Custom Session Save Handler Maximum Execution Time -

Image
i using symfony's custom session handler. works fine when set session first time when refresh page. page keep on loading , after 30 seconds max_execution_time defined in php.ini, errors shown. setup custom save handler, created table sessions in ratchet database. structure , data in table: now script, on top of page looks initialize custom save handler: <?php ini_set('session.auto_start', false); use symfony\component\httpfoundation\session\session; use symfony\component\httpfoundation\session\storage\nativesessionstorage; use symfony\component\httpfoundation\session\storage\handler\pdosessionhandler; require dirname(__dir__) . '/vendor/autoload.php'; $pdo = new \pdo('mysql:host=localhost;dbname=ratchet', 'root', ''); $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); $storage = new nativesessionstorage(array(), new pdosessionhandler($pdo)); // here when pdosessionhandler class initialized a...

Pass pointer as generic type c++ template -

i'm trying pass pointer (char*) generic function wrote. error " overloaded foo ambiguous in context ". why happen? template <class t> t foo(t a, t b) { return a+b; } int main() { char *c="hello",*d="world"; foo<char*>(c,d); return 0; } it have no reason add 2 pointers, result in non-sensical pointer. imagine e.g. first text @ address 0x7fffff00 , , second 1 in 0x80000100 . after addition on 32-bit machine going get… 0 . zero. null pointer! perhaps wanted use string's instead, like: #include <string> template <class t> t foo(t a, t b) { return a+b; } int main() { std::string c="hello", d="world"; foo(c,d); return 0; } also note: in many cases (like one) compiler can infer template type you, no reason write explicitly foo<std::string>(c,d) .

java - Reverse engineer database in spring data rest -

i want expose crud operations mysql via rest apis. have started exploring spring. have found spring rest data fit this. but there 1 problem, automating generation of java model, repository classes, etc,. tools available can this? want done without interface, preferably via maven.

ios - Xcode 7: exception breakpoint firing in `main.m`, but app runs normally -

Image
i've set "all exceptions" exception breakpoint project. in xcode 7, mysteriously fires on launch in main.m , there doesn't seem wrong. on continuing, app runs normally. even running project in xcode 6 causes breakpoint fire. i can't figure out causing this. threads don't indicate specific cause is. maybe it's sort of font issue in storyboard or something? know fix? note: it's c++ exception, not objective-c. perhaps due missing fonts. xcode throws exception in main() in ios 8 'all exceptions' breakpoint i have identical problem in xcode 7, of beta 3. workaround solved me. because it's c++ exception, can change "all exceptions" breakpoint catch objective-c exceptions. having done this, no longer hit mystery break on startup, , because i'm not writing c++, 99% of value of having "all exceptions" break point on. here's how: go breakpoints tab (view > navigators > show breakpoint ...

php - MySQL count unique rows based on multiple factors -

i need find unique rows based on unique ip , result sorted users in single query. i trying way $query="select count(distinct `userip`) `count`, `userid` `userid` `tablename` (`date` >= unix_timestamp(curdate())) group `userid`"; $result = mysqli_query($connection, $query) or trigger_error(mysqli_error($connection), e_user_error); $row = mysqli_fetch_assoc($result); print_r($row); this gives me result last user as array ( [count] => xxx [userid] => last_user); i need result every user in single query as array ( array ( [count] => xxx [userid] => first_user); . . array ( [count] => xxx[userid] => last_user); ) please see if can done, , suggest way it. thanks edit thanks answers, solution working checking query on row instead of result. i think should use group on both columns userip , userid columns. see if below query works you. select count( `userip`) `count`, `userid` `userid` `tablename` (`date` >...

r - Error: 'X' must be a numeric or complex matrix [in a binary spatial autoregressive model] -

i estimating binary spatial autoregressive model via gibbs sampler in r. when using neighborhood matrix, goes fine, when switch distance matrix, program stops immediately, , outputs infamous: "error in ginv(a) : 'x' must numeric or complex matrix" what strikes me odd when try compute generalized inverse myself, goes smoothly, , matrixes seem numeric. below find data , code replicable example. data link code (the error occurs after executing final line, toy model estimated through bsar function): code link any ideas?

java - Android BufferedReader does not read the whole response -

i have problem reading ulr response. on android reads around half of response. if use same code in normal java project works fine. try { string _output = null; url url = new url("http://example.com"); bufferedreader buffer = new bufferedreader(new inputstreamreader(url.openstream())); stringbuilder = new stringbuilder(); string line; while ((line = buffer.readline()) != null) { everything.append(line); } _output = everything.tostring(); buffer.close(); system.out.print(_output); } catch (ioexception e) { e.printstacktrace(); } how know it's half of response? if rely on printed system.out.println() should aware logcat has limitation prevents printing more 4,000 characters. after truncated. check how of response have, print everything.length() first, ot see if in situation. you can @ this existing question on reference, there many others. ...

Search multiple fields in two data Frames in R -

i have 2 data frames:dfa , dfb. data table: dfa dfb fields: name job check name job alice analist alice attendant bob attendant carl professor carl professor bob analist daril analist daril analist if 2 fields same in both data tables third field in dfa should receive 1 value: if (dfa$name==dfb$name , dfa$job == dfb$job) { dfa$check <- 1 } data table: dfa dfb fields: name job check name job alice analist 0 alice attendant bob attendant 0 carl professor carl professor 1 bob analist daril analist 0 daril analist i can loop found techniqu...

How would I refer to a specific html element that was just made in Javascript and get its value? -

my program takes in user input of string , checkbox , builds list displayed. (check-list basically) each list element consists of string variable , check-box input can't refer specific checkbox if third 1 ticked since id wouldn't unique in method. feel if there's better approach. i'm new stackoverflow apologize if code much, little, confusing, etc. relevant code (imo): var taskarr= []; //string of tasks array var comparr=[]; //comp = completed? task completion array, has bool var iscompleted = 0; document.getelementbyid('list').addeventlistener('click',alternatevalue); function alternatevalue(){ //recheck actual clicked boxes , updates array since list members not have unique id. way? alert("click works!"); var newchecks = document.getelementsbyclass(''); //2nd alert, no alert. alert(newchecks[0].checked); comparr = []; for(i = 0; i<newchecks.length;i++){ comparr.push(newchecks[i].checked); ...

php - Curl post username/password to login -

i using curl (or other method) send login details login page. here's code i'm using. <?php $username='mymail/usernamehere'; $password='mypasswordhere'; $postdata = 'username='.$username.'&password='.$password; // init curl $ch = curl_init(); // set url post form login curl_setopt($ch, curlopt_url, 'https://secure.runescape.com/m=weblogin/loginform.ws? mod=www&ssl=1&expired=0&dest=account_settings.ws?jptg=ia&jptv=navbar'); // enable http post curl_setopt ($ch, curlopt_post, 1); // set post parameters : form values each field curl_setopt ($ch, curlopt_postfields, $postdata); // imitate classic browser's behaviour : handle cookies curl_setopt ($ch, curlopt_cookiejar, 'cookie.txt'); # setting curlopt_returntransfer variable 1 force curl # not print out results of query. # instead, return results string return value # curl_exec() instead of usual true/false. curl_setopt ($ch, curlopt_...

html - Create a frame with angularjs -

i want create official page og angular https://docs.angularjs.org/api on left using kind of "frame". how can ? tried bg-splitter , angular ui layout note sure if it's right way ? short question, list of element on left (the frame) made in single view right ?

PHP - Compare a string to all in array and only echo once (unique) -

i'm trying make list of directories file. want list contain unique entries i.e. - echo once no duplicates. example: log file: inactive : [2007-04-01 08:42:21] "home/club/member" 210.00 "r-200" inactive : [2008-08-01 05:02:20] "home/club/staff" 25.00 "r-200" active : [2010-08-11 10:12:20] "home/club/member" 210.00 "r-500" inactive : [2010-01-02 11:12:33] "home/premier/member" 250.00 "r-200" active : [2013-03-04 10:02:30] "home/premier/member" 250.00 "r-800" active : [2011-09-14 15:02:55] "home/premier/member" 250.00 "r-100" i want echo list of directories no duplicates: home/club/staff home/club/member home/premier/member i used foreach loop iterate through array don't know how compare each value each item in array , output identical items once. foreach($listofdir $value) { echo "<p>" . $value . "</p>";...

continuous deployment - Named entity recognition with a small data set (corpus) -

i want develop named entity recognition system in persian language have small ner tagged corpus training ans test. maybe in future we'll have better , bigger corpus. way need solution incrementally better performance whenever new data added without merge new data old data , training scratch. there solution ? yes. help: work in progress. js , "no training ..." please see https://github.com/redaktor/nlp_compromise/ ! it fork worked on ner during last days , optimized usage different languages !!! it combination of dictionary words, dictionary rules + build tool. awesome work on persian support (i working on german) ... planned support ner of 'cardinal' -> [ready] 'date' -> calendar based [gregorian calendar ready] 'duration' -> see above [date ranges ready] 'measure' -> systems based [metric system , si units ready, 80+ categories] 'money' -> currencies based [ready in few days] 'person...

python - Issue creating .txt file with long name -

i trying create series of text files reasonably long names (but near 260 characters). example file name is: premier_league-tottenham v manchester city-saturday, aug 14 2010-12:45-0-0-410996-home-team-2010-2011-30-2015-06-14.txt the code using generate looks like: mylogprint = "premier_league" + '-' + str(the_home_name) + ' v ' + str(the_away_name) + '-' + str(the_match_date) + '-' + str(the_match_time) \ + '-' + str(the_ft_score) + '-' + str(matchid) + '-' + num_list2 + '-' + myseasonstart + '-' + myseasonend + '-' + str(slot_list2) + '.txt' however, file being created as: premier_league-tottenham v manchester city-saturday, aug 14 2010-12 here half file name missing, including '.txt' on end. can tell me issue here? thanks if working files in windows, colon (:) invalid character in filename.

c++ - Reading objects from a binary file -

i wrote program, lets enter information car, , writes object on binary file. car car_obj; std::ofstream entr; std::ifstream ex; void save_data() { entr.open("main.bin", std::ios::app | std::ios::binary); car_obj.setinfo(); entr.write((char*)&car_obj, sizeof (car_obj)); entr.close(); } after this, have function reading binary file in order display cars have fuel consumption less user enters (the number factr in function arguments). void vehicles_under_factr(float factr) { ex.open("main.bin", std::ios::app | std::ios::binary); while (ex.read((char*)&car_obj, sizeof (car_obj)) && !ex.eof()) { if (car_obj.fuel_cons < factr) { car_obj.displayinfo(); } } ex.close(); } it works fine, if have three, or less, objects in binary file. when there more three, displays rest empty fields. if there no access after third car. why so, , can it? i feel close solution, knowledge limited. thank in advance! no,...

oracle - Not sure how to write connect by clause -

i have following query find employees not managers in emp table of oracle select * emp e1 not exists (select null emp e2 e2.mgr=e1.empno) i need output using start connect clause , avoiding self join there function, connect_by_isleaf(), indicates whether given row in hierarchical query leaf node. in emp table, employees not managers leaf nodes. so, can use function in nested hierarchical query filter non-managers: select empno, mgr, ename ( select empno, mgr, ename, connect_by_isleaf cbi emp start mgr null connect prior empno = mgr ) cbi = 1 / oracle has several neat functions interrogating hierarchies. find out more .

php - Efficient way of exporting a bunch of PDF's from a user? -

i need give our users ability export bunch of pdf's (invoices). the problem is, pdf's generated everytime user opens them. so don't have them stored in filesystem. so, question is, efficient way of exporting user's pdf's, when want to? for example, user wants export 100 invoices previous quarter. i need call script generates pdf's , put them in .zip file. but , if multiple users request heavy export @ same time? i thinking of running cronjob every 10 minutes or so, doesn't solve possible heavyness of script. do need run multiple cronjobs, can each handle portion of exports? or can somehow create efficient script, , maybe separate pdf's in several batches? i'm using wkhtmltopdf generate pdf's. so fortunately, it's pretty fast render pdf's. although still depends on content, of course. on average, single pdf takes 3-5 seconds render. any or guidelines appreciated! thanks follow-up question: if save every invoice files...

python - LXML - parse td content within tr tag -

i want parse each individual statistic yahoo finance tables formatting purposes - when parsing entire table formatting terrible!! using code below , have repeat 4 lines of contenta code altered retrieve stats within each row of table. exemplified in contentb variables below. refuse believe efficient way so. suggestions? from lxml import html url = 'http://finance.yahoo.com/q/is?s=mmm+income+statement&annual' tree = html.parse(url) contenta = tree.xpath("//table[@class='yfnc_tabledata1']/tr[1]/td/table/tr[2]/td[1]")[0].text_content().strip() contenta1 = tree.xpath("//table[@class='yfnc_tabledata1']/tr[1]/td/table/tr[2]/td[2]")[0].text_content().strip() contenta2 = tree.xpath("//table[@class='yfnc_tabledata1']/tr[1]/td/table/tr[2]/td[3]")[0].text_content().strip() contenta3 = tree.xpath("//table[@class='yfnc_tabledata1']/tr[1]/td/table/tr[2]/td[4]")[0].text_content().strip() contentb = tr...

javascript - Using multiple instances of datetimepicker working with a Range between date -

i'm trying "range between date" work multiple instances. each instance couple has different id. datetimepicker added using class, same instances: var format = "d-m-y h:i"; var startselector = ".date_timepicker_start"; var endselector = ".date_timepicker_end"; now want id of field clicked, replace start end, have id of matching end field, , use result value: $(startselector).datetimepicker( { format : format, onshow : function(ct) { var selectedid = $(this).attr('id'); var selid = selectedid.replace("start", "end"); var val = $("#"+selid).val(); console.log('id: '+selectedid); var opts = { formatdate : "d-m-y", maxdate : val ? val.split(' ')[0] : false }; this.setoptions(opts); }, }); the var selectedid = $(this).attr('id');returns undefined however. tried this.id etc.. got idea? i'm overlooking something.. ...