Posts

Showing posts from August, 2013

android - String null pointer exception -

i have strange nullpointerexception @ app. i run code: protected void onpostexecute(void result) { log.i("name1", userprofilepictures[positionforpicture][0]); if(movedtoanotheractivity) return; if(loadnewposts && loaded10more == false) { firstlooppicture = true; positionforpicture = 0; return; } if((positionforpicture == userprofilepictures.length) == false) { new getuserpicture().execute(); int loadlength = loadedpostssaverforpictures.length; string name = userprofilepictures[positionforpicture][0]; log.i("name", name); } } ... ... ... and null pointer exception @ line: string name = userprofilepictures[positionforpicture][0]; log.i("name", name); log cat: 08-28 17:39:28.140: e/androidruntime(26801): fatal exception: main 08-28 17:39:28.140: e/androidruntime(26801): java.lang.nullpointerexception:

c# - setting value's of a superclass (inheritence) -

i'm having trouble setting variables of superclass i have following classes: computer(superclass) laptop(subclass) desktop(subclass) in supperclass computer have variable string name; public class computer { protected string name; } when call method changename(string yourname) laptop class, should set variable name in superclass computer , this: public class laptop : computer { public void changename(string yourname) { name = yourname; } } when try name ,with properties, superclass computer , returns null . debugged see happend, , subclass laptop changed name in superclass, when method changename ended compiling, restored null . what may have caused this? i think setting variable laptop.changename(name); and trying name computer.name . you misunderstanding inheritance . obviously null . because computer , laptop 2 different objects. laptop inherited doe

java - ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView? -

i'm trying type cast data when write textview clickdata=(textview) view under onitemclick(...) logcat shows msg: java.lang.classcastexception: android.widget.relativelayout cannot cast android.widget.textview i don't know why. this belongs main activity: public class listviewforallcontact extends appcompatactivity { listview mylistview; protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.listviewforallcontact); contactdatabase onbofcontactdatabase=new contactdatabase(getbasecontext()); cursor mcursor= onbofcontactdatabase.phonename(); string[] fromfilename=new string[]{contactdatabase.name}; int[] toviewid=new int[]{r.id.textview5}; simplecursoradapter simplecursoradapter; simplecursoradapter=new simplecursoradapter(this,r.layout.forreading,mcursor,fromfilename,toviewid,0);

android - ImageView width not matching parent -

Image
i'm trying have 3 sections under each others using linearlayout : <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".imageediting"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:orientation="vertical"> <com.google.android.gms.ads.adview android:id="@+id/adviewofediting" android:layout_width="wrap_content" a

r - trying to compare POSIXct objects in if statements -

i have within function: x <- as.posixct((substr((dataframe[z, ])$variable, 1, 8)), tz = "gmt", format = "%h:%m:%s") print(x) if ( (x >= as.posixct("06:00:00", tz = "gmt", format = "%h:%m:%s")) & (x < as.posixct("12:00:00", tz = "gmt", format = "%h:%m:%s")) ){ position <- "first" } but output: character(0) error in if ((as.numeric(departure) - as.numeric(arrival)) < 0) { : argument of length zero how can fix comparison works , prints correct thing? some examples of dataframe$variable column: 16:33:00 15:34:00 14:51:00 07:26:00 05:48:00 11:10:00 17:48:00 06:17:00 08:22:00 11:31:00 welcome stack overflow! first, reason you've gotten down votes because haven't given in question go on. 1 thing, haven't shown (dataframe[z, ])$variable is, makes hard formulate complete answer. seem trying ext

Oracle Listener mess -

being newbie oracle 12c messed network setup while modifying memory_target setting, weird know happened somehow. the sid=oradb2 today listened on 1538 of host oracle12c.mydomain.com nicely. not. , don't know how port 1539 came picture. hope can me. here $oracle_home/network/admin/listener.ora file: listener1 = (description_list = (description = (address = (protocol = tcp)(host = oracle12c.mydomain.com)(port = 1538)) ) ) listener = (description_list = (description = (address = (protocol = tcp)(host = oracle12c.mydomain.com)(port = 1539)) (address = (protocol = ipc)(key = extproc1521)) ) ) here $oracle_home/network/admin/tnsnames.ora file oradb2 = (description = (address = (protocol = tcp)(host = oracle12c.omilia.com)(port = 1539)) (connect_data = (server = dedicated) (service_name = oradb2)) ) listener_oradb2 = (address = (protocol = tcp)(host = oracle12c.omilia.com)(port = 1538)) listener_oradb1 = (address = (pro

php - Can't print stdClass property -

in following example, i'm trying print file_already_exists inside string, query, error: catchable fatal error: object of class stdclass not converted string in ... $db_items = (object) [ "cover" => (object) [ "file_already_exists" => 0, // can't print ], "file_already_exists" => 0, // can print ]; $str = "insert albums (file_on_system) values ('$db_items->cover->file_already_exists')"; echo $str; using $db_items->file_already_exists works fine, not $db_items->cover->file_already_exists . why that? there way print 1 in cover ? in simpler way echo "$db_items->file_already_exists"; // works echo "$db_items->cover->file_already_exists"; // doesn't work $str = "insert [...] values ('$db_items->cover->file_already_exists')"; the parser not know variable name ends, tries insert $db_items string - , caus

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot

python 3.x - Discrepancy between rpy2 and standard R matrices -

my goal so i'm trying call normalize_quantiles function preprocesscore r package ( r-3.2.1 ) within python3 script using rpy2 package on enormous matrix (10 gb+ files). have virtually unlimited memory. when run through r following, able complete normalization , print output: require(preprocesscore); <- data.matrix(read.table("data_table.txt",sep="\t",header=true)); all[,6:57]=normalize.quantiles(all[,6:57]); write.table(all,"qn_data_table.txt",sep="\t",row.names=false); i'm trying build python script other things using rpy2 python package, i'm having trouble way builds matrices. example below: matrix = sample_list # 2-d python array containing data. v = robjects.floatvector([ element col in matrix element in col ]) m = robjects.r['matrix'](v, ncol = len(matrix), byrow=false) print("performing quantile normalization.") rnormalized_matrix = preprocesscore.normalize_quantiles(m) norm_matrix = np.arr

sql - Percentage calculation when size is same but weight is different -

i want weight percentage of total weight each person. here's data: tablea name | size | weight ------------------------------------ jamie | 0.25 | 48 jamie | 0.50 | 48 taylor | 0.25 | 55 taylor | 0.30 | 54 taylor | 0.45 | 48 taylor | 0.45 | 60 and here's output like: name | size | percentage | weight --------------------------------------------------------------- jamie | 0.25 | 50% | 48 jamie | 0.50 | 50% | 48 taylor | 0.25 | 35.03% | 55 taylor | 0.30 | 34.39% | 54 taylor | 0.45 | 49.76% | 108 eg : total weight jamie 96 (48+48), have calculate weight values percentage of 96 each row. and taylor there size 0.45 twice different weight in output should sum weight (48+60) , (108/217)*100=49.76 percentage i suggest need summariz

Why does Javascript (ES.next) force me to declare a function as async if I want to use await? -

it seems compiler / parser should smart enough detect if function uses await automatically becomes async function. why forced type async keyword? adds clutter , there many times forget add , error , have go , add it. would there disadvantage having compiler automatically promote function async when sees await , save hassle of dealing it? compare async functions es6 generator functions , pretty obvious: function* x() {} // generator function without 'yield' object.getprototypeof(x); // returns generatorfunction generator functions inherently different traditional functions, not need have yield expression in body. there a bug in es6 proposal stated syntax error if generator function not contain yield , fixed: one important use case prototyping dummy generator. or case comment out yield debugging. shouldn't render program illegal. the same holds async functions: according the draft , async function not required have awaits in body whil

Bootstrap Modal Overlay Another Modal -

Image
after searching web hours, found solutions regarding on how can open new modal inside modal. requirement kinda different. want use "universal" modal form serve message box in page (not whole application, current page only). message box overlay once being called/shown. for example, open modal form data entry, if want prompt message user, pop modal form on data entry form. i new web programming don't know code went wrong or missing something. here's code designer: <div class="modal fade" id="modaddbulletin" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true" style="top: 15%;" data-keyboard="false" data-backdrop="static"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h3 class="modal-title"

git - Plastic SCM - Ignore directory on repository on initial sync to new workspace -

i'm unsure if right place ask i'm working remotely , started new workspace , want sync repository. 1 of folders has few gigs of files in , want ignore folder save me downloading whole thing. possible? i can see can ignore files workspace end doesn't commit them there way on sync don't have download everything. thank you! you need add intems "cloaked list" . cloaked items items update operation won't download default repository workspace. convenient in scenarios, instance when there big files in repository updated often, don't work them, prefer skip downloading cloaked files every time switch workspace different branch or update of workspace. more info at: plasticscm documentation

javascript - fullpage.js - If 'scrolloverflow' is set to true can't scroll down to the next section -

i'm using fullpage.js scrolloverflow: true , autoscrolling: true . once reach bottom of section overflowing content won't jump next 1 unless click on next navigation dot. tried isolate bug in js bin, i'm not able reproduce it. no errors found in console, , i'm using plugin's 2.8.1 version. if head this bin you'll see reaching bottom of section 3 triggers jump section four. not happen on end. ideas on or how fix it? my current settings initialize fullpage.js these: $('#fullpage').fullpage({ easingcss3: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)', navigation: true, navigationposition: 'left', scrolloverflow: true }); seems issue recent bug encountered when fullpage.js made jump , started using iscroll. adding following project's css seems solve problem: .fp-scroller{ overflow:hidden; } more information here .

refactoring - How to refactor my php methods? -

i have question regarding simplify codes. i have public function gettext($text){ if(!empty($text)){ $dom = new domdocument(); $dom->loadhtml($text); $xpath=new domxpath($dom); $result = $xpath->query('//a'); if($result->length > 0){ $atags=$dom->getelementsbytagname('a'); foreach($atags $atag){ $style = $atag ->getattribute('style'); $atag->setattribute('style',$style.' text-decoration:none;color:black;'); } $returntext .= $dom->savehtml(); return $returntext; } $result = $xpath->query('//table'); if($result->length > 0){ $tables = $dom->getelementsbytagname('table'); $inputs = $dom->getelementsbytagname('input'); foreach ($inpu

c++ - Cryptarithmetic puzzle -

i trying solve cryptarithmetic puzzle 2 + 2 = 4 , used raw brute force, can't figure out making mistake. idea here tries possible combinations of numbers 0 10 , numbers assigned characters must distinct. definition a cryptarithmetic puzzle mathematical game digits of numbers represented letters (or symbols). each letter represents unique digit. goal find digits such given mathematical equation verified: in case: 2 + 2 ------ = 4 this code goes through possible combinations until finds solution satisfies problem. constraint given in else if statement. first if statement checks if numbers same, , if are, skips iteration. my desired output see all correct solutions displayed. int t, w, o, f, u, r; (t = 0; t < 10; t++) { (w = 0; w < 10; w++) { (o = 0; o < 10; o++) { (f = 0; f < 10; f++) { (u = 0; u < 10; u++) { (r = 0; r < 10; r++)

java - What are the factors affecting the speed in sending large amount of data in SocketChannel? -

can tell me specific factors affecting speed in sending large amount of data in socketchannel? example byte allocation affects speed? the main limiting factors, in order, are: network bandwidth, mean bandwidth of slowest part of path between peers. size of socket receive buffer @ receiver. if less bandwidth-delay product of path, won't able utilize full available bandwidth. the speed @ send. contrary suggestion in comments, should send as possible @ time, , repeat rapidly can, assuming blocking mode. in non-blocking mode considerably more complex, if bandwidth utilization goal you're better off using blocking mode. you're better off using java.net rather nio too.

javascript - MEAN Stack - Should I separate servers? -

i'm working on personal project mean stack , appreciate advice on route should take when setting server architecture. performance , scalibility important me since build enterprise level web apps in future. this project image hosting application include front-end, private api, , file storage system. option 1: on same server option 2: front-end , private api on same server. file storage on separate server. option 3: front-end, private api , file storage on own server. i'm thinking option 2 might best option, love learn have experience in building apps similar architecture. thanks! depending upon how scale expecting , how want spend on server infrastructure different cases suitable. try explain best of both world. for services api based, should on infrastructure can scale. reason, in form of servers behind load balancers. scaling takes places based upon traffic type , region. this, industry favorite docker based microservices. comparable solution google

vba - Macro combining multiple cells into one, with values separated by a comma -

in previous posted answer, combine multiple cells 1 in excel macro? , following macro provided..which works great way! however, need separate cell values comma. have tried inserting comma between quotes "," not working. can please guide me resulting cell separate values comma? thank you! sub joincells() set xjoinrange = application.inputbox(prompt:="highlight source cells merge", type:=8) xsource = 0 xsource = xjoinrange.rows.count xtype = "rows" if xsource = 1 xsource = xjoinrange.columns.count xtype = "columns" end if set xdestination = application.inputbox(prompt:="highlight destination cell", type:=8) if xtype = "rows" temp = xjoinrange.rows(1).value = 2 xsource temp = temp & " " & xjoinrange.rows(i).value next else temp = xjoinrange.columns(1).value = 2 xsource temp = temp & " " & xjoinrange.columns(i).value next end if xdestination.value = temp end sub h

haskell - How to write an instance of Control.Lens.AT -

i have data structure can understood analogous data.map in maps keys of 1 type values of another. write instance of control.lens.at type cannot ever seem satisfy requirements. given struct k v lookup , insert , update , , delete , must make instance @ (struct k v) work? the at method should return indexed lens given index gets input structure , behaves this: on getting, if key not present, return nothing , otherwise return value @ key in structure. on setting, if new value nothing , remove key structure, otherwise set (or create if it's not there) value in just . the index key given at . this leads following code requirements: instance @ (struct k v) @ key = ilens getter setter getter = (key, lookup key) setter s nothing = delete key s setter s (just newvalue) = insert key newvalue s i use lens construct lens ilens construct indexed lens getter , setter. assume functions have following types: lookup :: k -> struct k

android - Mutlilevel expandable listview -

how parse below json in multilevel expandable listview idea or suggesstion appreciated. { "company": { "hr dept.": [], "admin": [], "technology": [ { "t_name": "team1", "t_members": [ "xyz", "pqr" ] }, { "t_name": "team2", "t_members": [ "stu", "wxy" ] }, { "t_name": "team3", "t_members": [ "abc", "def", "ghi" ]

php - print $_COOKIE display nothing BUT firefox display the cookie -

i working on local project, here function create cookie: setcookie('remember-me', "large , complex key", time() + $une_semaine); even after reloading page nothing displayed... print_r display phpsessid , not cookie when watch coockies on firefox parameters can see him, created, whats wrong ?? im blocked, me guys please? use setcookie('remember-me', "large , complex key", time() + 60*60*24*365);

java - Why below program is printing Object of different Array? -

i not able understand internal working happening behind screen confused because printing different result in console expected to. resolve problem explanation? public class demo { public int [] sort(int h[]) { int temp; for(int i=0;i<h.length;i++) { (int j=i;j<h.length;j++) { if(h[i]>h[j]) { temp=h[i]; h[i]=h[j]; h[j]=temp; } } } return h; } public static void main(string args[]) { demo obj =new demo(); int a[]={9,2,3,5,32,1,5,3,7}; int[] sorted=obj.sort(a); /*code display array a*/ for(int s :a) { system.out.print(s+ " "); } system.out.println(""); /*code display array sorted*/ for(int k:sorted) { system.out.print(k+" "); } } /* expected output 9 2 3 5 32 1 5 3 7 1 2 3 3 5 5 7 9 32 a

bash - How to capture stdout/stderr/time into variables in Zsh -

suppose following function exists. action() { sleep 1 echo 'stdout' >&2 echo 'stderr' } i want capture each of following items shell variables. stdout stderr execution time the following code trick in bash. unset stdout stderr time eval "$( { time action >&3 2>&4; } \ 2> >(time=$(cat); typeset -p time) \ 3> >(stdout=$(cat); typeset -p stdout) \ 4> >(stderr=$(cat); typeset -p stderr) )" echo "stdout: $stdout" echo "stderr: $stderr" echo "time: $time" how can achieve in zsh?

java - Change tree-cell selected font color in JavaFX -

Image
i have javafx treeview , want change font color of selected cell black, make non-selected cell. (i tried setselectionmodel(null) throws errors.) cells have transparent background on background image, if matters. css: .tree-view, .tree-cell { -fx-font: 20px "segoe print"; -fx-background-color: transparent; } .tree-cell { -fx-background-color: transparent; -fx-padding: 0 0 0 0; -fx-text-fill: #000000; } .tree-cell:focused { -fx-text-fill: #000000; } .tree-cell:selected { -fx-text-fill: #000000; } .tree-cell .tree-disclosure-node { -fx-background-color: transparent; -fx-padding: 10 10 0 40; } .button { -fx-padding: 0 10 0 10; } result: ("test4" selected) this seems should set font color selected cells black, it's not happening. css file loaded , being used (the font correct, instance, , i've modified other things well), that's not issue. if want transparent backgrounds , selected cells ap

asp.net - jquery ajax call to WCF service passing data with a data type "long" value sends 0 -

i have service contract method follows: [operationcontract] [webinvoke(method = "post", requestformat = webmessageformat.json, responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.bare, uritemplate = "fibonaccinumber/")] long fibonaccinumber(long n); public long fibonaccinumber(long n) { var = 0; var b = 0; for(var = 0; <= n; i++) { if(i == n) { return a; } var c = a; = b; b = b + c; } return 0; } however, when try call above jquery ajax call, value of parameter "n" 0 when fibonaccinumber service gets hit, idea may wrong? did console log value of "$('#fibindex').val()" , shows correct value on client: $('#btnfib').on('

angular - How to initialize an array in angular2 and typescript -

why happen in angular2 , typescript? export class environment { constructor( id: string, name: string ) { } } environments = new environment('a','b'); app/environments/environment-form.component.ts(16,19): error ts2346: supplied parameters not match signature of call target. how on initialize array? class definitions should : export class environment { cid:string; cname:string; constructor( id: string, name: string ) { this.cid = id; this.cname = name; } getmyfields(){ return this.cid + " " + this.cname; } } var environments = new environment('a','b'); console.log(environments.getmyfields()); // print b source: https://www.typescriptlang.org/docs/handbook/classes.html

python - Syntax Error when using except ValueError? -

group = range(1, 1001) num in group: num_length = len(str(num)) in range(num_length): if str(num)[i] == '1' or str(num)[i] == '7': group.remove(num) except valueerror: pass else: pass i trying remove numbers contain 1 or 7 digits in them. avoid "valueerror: list.remove(x): x not in list" , added "except valueerror: pass" . however, have "syntaxerror: invalid syntax" . first, range objects immutable, means cannot remove element range object. moreover, possible remove elements sequence iterating over. second, except block must related try block containing code may generated error caught except . what suggest create new list elements want keep (that without 1 , 7 in it). can simplify check inclusion of 1 , 7 using in operator. group = range(1, 1001) data = [] num in group: s = str(num) if not ('1' in s or '7' in s):

ios - CAGradientLayer not draw the gradient correctly -

Image
i use cashapelayer draw circle , set mask of cagradientlayer, here code: cashapelayer *circleshapelayer = [cashapelayer new]; // draw circle path code here... cagradientlayer *gradientlayer = [cagradientlayer layer]; gradientlayer.colors = @[(__bridge id)[uicolor whitecolor].cgcolor, (__bridge id)[uicolor clearcolor].cgcolor]; // self here means uiview gradientlayer.mask = circleshapelayer; gradientlayer.frame = self.bounds; [self.layer addsublayer:gradientlayer]; when run app, display gradient circle, gradient strange. what want circle @ start point, color white , @ end point color clear color, should this: but color of circle in simulator screen is: the color symmetric. i think problem not set gradientlayer.colors correctly, how can fix it? cagradientlayer can not paint gradient along arc. on other hand, mask layer's frame small gradient layer's frame see clear color

math - draw arc from 0 to 360 degrees with d3.js -

you can see working example of here . my questions small inner blue arc. want show arc starting @ 0 , going hypotenuse 0 360. at moment m code looks adds arc: const hypotenusecoords = { x1: hypotenusecentre, y1: parsefloat(state.hypotenuse.attr('y1')), x2: xto, y2: dy }; const angle = math.atan2(hypotenusecoords.y2 - hypotenusecoords.y1, hypotenusecoords.x2 - hypotenusecoords.x1); const arc = d3.svg.arc() .innerradius(15) .outerradius(20) .startangle(math.pi/2) .endangle(angle + math.pi/2); state.innerangle .attr('d', arc) .attr('transform', `translate(${hypotenusecentre}, 0)`); the problem arc goes 0 pi or 180 , 180 360. think startangle in coordinates wrong. how can arc stretch right round 0 360? after calculate angle , try: if(angle>0) angle = -2*(math.pi) + angle; if trig right :) update: play fiddle see issue: http://jsfiddle.net/rcb94j8m/ atan2() behaving fine rays in q

javascript - jQuery - replacing div background image from URL -

i'm trying replace div background in several divs label element (typed url) , while code works, won't push through $('#urlimage') . jquery: $(document).ready(function(){ $('.first, .second, .third').append(""); $('#urlimage').change(function(){ $('.first, .second, .third').css('background-image', $('#urlimage').val()); }); }) html <input type="text" id="urlimage" placeholder="type image url"> <div class="first"> </div> <div class="second"> </div> <div class="third"> </div> basically need whatever typed loaded background image. thanks suggestions. let try $(document).ready(function(){ $('#urlimage>div').each(function(){ $(this).css('background-image', $('#urlimage').val()); }); })

c++ - Product inspection with Computer vision - edge detection with opencv -

i new user of opencv. doing project of performing product inspection opencv. planning extract edges of product , bad product compare edges maybe mean square difference. however, quite difficult extract edge first step. good sample: good product [![enter image description here][1]][1] when use canny edge detection, edge of product (the blue part of picture) includes part of product , follows: edge of product [![enter image description here][2]][2] i tried use adaptivethreshold make greyscale picture more clear , use edge detection. but, edge detected not expected because of many noise. therefore, ask solution of extracting edge or better way of comparing product , bad product opencv. sorry bad english above. this task can made simple if assumptions below valid. example: products move along same production line, , therefore lighting across product images stays same. the products lie on flat surface parallel focal plane of camera, rotation of objects around axis o

javascript - Can't redirect to new page Ajax beginform -

Image
i have ajax.beginform-code: <script> function createsuccess(data) { if (data.redirecturl) { window.location.href = data.redirecturl; } } </script> @using (ajax.beginform("new", "profile", null, new ajaxoptions() { httpmethod = "post", insertionmode = insertionmode.replace, onsuccess = "createsuccess" })) { @html.antiforgerytoken() @html.validationsummary(true, "", new { @class = "text-danger" }) //html-code } here new action in profile controller: [httppost] public actionresult new(profile model) { model.userid = userid; if (_profileservice.createprofile(model) > 0) { var encryptedprofileid = encryption.protect(model.profileid.tostring(), userid.tostring()); response.cookies["profileid&

vagrant - Stderr: VBoxManage.exe: error: Invalid NIC number 9 -

i installing vagrant / homestead on computers. on laptop, works good; on computer, with virtualbox 5 vagrant 1.8.3 windows 10 when run vagrant up , there errors c:\users\neon\homestead>vagrant bringing machine 'default' 'virtualbox' provider... ==> default: checking if box 'laravel/homestead' date... ==> default: clearing set network interfaces... there error while executing `vboxmanage`, cli used vagrant controlling virtualbox. command , stderr shown below. command: ["modifyvm", "6b26b32b-0b7e-4428-bc3a-bdc89fe735bb", "--nic2", "none", "--nic3", "none", "--nic4", "none", "--nic5", "none", "--nic6", "none", "--nic7", "none", "--nic8", "none", "--nic9", "none", "--nic10", "none", "--nic11", "none", "--nic12", &q

javascript - Get meta viewport tag to work on desktop -

i have created script enables meta viewport tag on desktop. not seem able specified width viewport tag. have this: var viewportcontent = $( "#myviewport" ).attr('content'); var viewportcontents = viewportcontent.split(","); //if starts 'width=' (var = 0; < viewportcontents.length; i++) { if(viewportcontents[i].lastindexof('width=', 0) === 0) { var wspec = viewportcontent[i].substring(6); } } the problem seems ok, not work. help! have been looking @ long! website: http://apps.usecue.com/viewport/viewport_tag.html (static width, working) codepen: http://codepen.io/anon/pen/azdmga (dynamic width, not working) sorry guys... turned out typo! var wspec = viewportcontent[i].substring(6); had var wspec = viewportcontents[i].substring(6); . have remember use better variable names!!! working version here: http://codepen.io/anon/pen/gqoeyj

python - Django store csv float items in database -

i have csv file data like: company,104.95,102.8,102.6,104.5,104.5,102.75...\n etc. i storing float values prices[1:len(prices)] in models.commaseparatedintegerfield(blank=true, null=true, max_length=10000) but after values stored, float values quotes '104.95','102.8','102.6','104.5','104.5','102.75' whereas want store values floats, not strings. how achieve that? you can convert them floats so: float_prices = [float(p) p in prices[1:len(prices)]] that said, commaseparatedintegerfield validate comma-separated list of integers . neither strings nor floats valid field - it's odd able save data posted.

Rails 4 ActiveRecord Exclusion Validation for Association -

i'm trying validate association in model , exclude object validation, can't seem work. here's code: validates :user, presence: true, exclusion: { in: [:lot_high_bidder] } i imagine it's trying direct comparison of :user symbol :lot_high_bidder fail, mean can't use method name in exclusion validator or syntax wrong? rails has validates_associated method used validate association on models http://apidock.com/rails/activerecord/validations/classmethods/validates_associated not sure if can validate user_id instead of user association. hope helps

elixir - How to pipe Enum output to another Enum function that takes multiple arguments? -

i'm learning elixir , i'm trying this: list = enum.with_index ~w[a n b e c r z b d] #=> [{"a", 0}, {"n", 1}, {"b", 2}, {"e", 3}, {"c", 4}, {"r", 5}, {"z", 6}, {"b", 7}, {"d", 8}] enum.into(list, %{}) #=> %{"a" => 0, "b" => 7, "c" => 4, "d" => 8, "e" => 3, "n" => 1, "r" => 5, "z" => 6} i'd pipe... like: enum.with_index ~w[a n b e c r z b d] |> enum.into(%{}) or enum.with_index ~w[a n b e c r z b d] |> enum.into(&1, %{}) but neither of work. possible? you missing parentheses: enum.with_index(~w[a n b e c r z b d]) |> enum.into(%{}) or more idiomatically: ~w[a n b e c r z b d] |> enum.with_index() |> enum.into(%{}) your original version executed as: enum.with_index(~w[a n b e c r z b d] |> enum.into(%{})) you can see

javascript - AngularJS 1.5.6 controller not working -

it's me again simple question. i'm running angular 1.5.6 , controller doesn't seem work in way expect to. in below, {{ control.helo }} doesn't give me , i'm not sure why. <html ng-app="simplifiedexample"> <head> </head> <body> <div class="container" ng-controller="appcontroller control"> {{ control.hello }} </div> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> <script src="controllers/controller.js"></script> </body> </html> and in controllers/controller.js have following: var app = angular.module('simplifiedexample', []); app.controller('appcontroller', function () { this.hello = "helloooo"; }); any appreciated. edit: controller link correct, put console.log("test") in file, , got logged properly. i moved controller declaration

javascript - What is this line of Js code exactly doing? -

i learning objects in javascript , i'm using function construct object , adding method it. there's method change firstname of object, line this.changename=changename; exactly do? if delete or alter changename function name else error occurs , nothing displayed. , deleting line of code leads error, seems it's essential code run can't figure out does. <script> function person(firstname, lastname, age){ this.firstname=firstname; this.lastname=lastname; this.age=age; this.changename=changename; function changename(name){ this.firstname=name; } } me = new person("hazem", "khadash", 18); me.changename("bashar"); document.write(me.firstname); as understand code, me created, changeme() function called method person.lastname rendered on screen. thanks. function person(firstname, lastname, age) { ... function changename(name){ this.firstname=name; } } creates funct

ios - Infinite scroll and duplicated data -

i work on mobile app shows stream of data fetched server. app fetches first page 10 items. when user scrolls down, app fetches second page next 10 items (in other words - infinite scroll). problem have when user fetches page number x possible, user b creates new content on server modifies resultset available user a. means if user tries fetch x+1 page, contain previous item(s) "pushed back" new content. how solve it? came out 2 solutions don't know better: the mobile app remembers ids of shown items , if in next page there item shown, not shown again. the app remembers date of creation of first item first page. when fetches next pages, additionaly sends date server adds date sql query in order maintain same resultset what think? better? there better solutions? update: imagine have table 'queries' columns 'queries_id' (integer, primary key), 'date_created' (timestamp). query looks this: select * queries order date_created desc. not tru

SQL server transactional replication, change distribution server -

i have sql 2005 database published dozens of (mostly) transactional publications , dozens of subscribers . have local distributor. i'm trying improve our ha setup , looking @ mirroring published database. best practices use remote distributor, in case have fail on mirror replication can continue. i've tested , works fine. but if remote distributor fails? how eliminate single point of failure, or better, how recover when fail? from testing , little find on web, need undo replication set (remove subscribers, articles & publications, distributor) , recreate new remote distributor specified. i'd fine if add subscribers without needing reinitialize them. i've used @subscriptionlsn input of sp_addsubscription similar situations, want resume replication without resnapshoting & reinitializing them . undoing replication, min_autosynch_lsn lost outstanding transactions go it. i must missing fundamental. know clustering distributor adds layer of safety,

javascript - Unable to get JSON from Ajax POST using PHP -

i sending json in post php script. i'm unable object values json. format of post follows: [{"name":"amount","value":"12"}] javascript ("#idform").submit(function(e) { var url = "post.php"; // script handle form input. var formdata = json.stringify($("#idform").serializearray()); alert(formdata); $.ajax({ type: "post", url: url, data: formdata, datatype: 'json', success: function(dataresponse) { document.getelementbyid("orderamount").innerhtml = dataresponse.orderamount; } }); php if(!empty($_server['http_x_requested_with']) && strtolower($_server['http_x_requested_with']) == 'xmlhttprequest') { $data = array(); $json = json_decode(file_get_contents('php://input'), true); $data['orderamount'] = $json['amount']; //this works

javascript - Array/String lastIndexOf inconsistent results -

code self describing [3, 1, 3].lastindexof(3) 2 [3, 1, 3].lastindexof(3, undefined) 0 // wtf? //ok, lets compare string '313'.lastindexof(3) 2 '313'.lastindexof(3, undefined) 2 //wow! different algorithms in spec. the array version performs tointeger() on second parameter if 1 provided, substitutes 0 nan . if argument fromindex passed let n tointeger(fromindex); else let n len-1. the string version uses tonumber() on second parameter irrespective of whether or not 1 provided, return nan without substitute, algorithm manually substitutes infinity nan . let numpos tonumber(position). (if position undefined, step produces value nan). returnifabrupt(numpos). if numpos nan, let pos +∞; otherwise, let pos tointeger(numpos). as why, can guess, array version newer of 2 (es5) , must have decided nan better off being replaced 0 , makes @ least little sense considering falsey evaluation (not it's relevant) .

Facebook Messenger API: Buttons Not Showing On Mobile -

Image
two pics all: mobile instances of chatbot show no buttons (regardless of template_type chosen -- button, generic, etc), desktop instances work fine. buttons show up. users naturally quite confused , annoyed if can't see button they're supposed clicking , instead start shouting @ bot. mobile versions of bot shows no buttons: desktop versions of bot show buttons: there bug listed on fb dev forums describes behavior, couple of them, not action taking place, makes me wonder if there isn't workaround don't know about. there?

css3 - CSS: background-image inside another image (or canvas) -

Image
is there way set background-image fit inside image? example explains all: this should it, assuming png has transparent section. if can make images correct size, first option work. second option ensures 1 aligns left , second aligns right. depending on requirements, may need add padding second image , possibly scale correct size. comment {background-image: url("bubble.png"), url("people.png");} or more control comment { background-image: url("bubble.png") left top no-repeat, url("people.png") right top no-repeat; } and offset , pixel size inserted image: comment { background-image: url("bubble.png") left top no-repeat, url("people.png") left 30px top 20px / 300px 200px no-repeat ; } for more details see css3.com

ruby on rails - jQuery function works in partial but not show -

Image
i have jquery code counts current rows in table (and arithmetic) , adds them column. i've used script in _form/_partial , works great. however, when use same script inside show.html.erb (to setup same table again) not work. here _form <table id="mytable"> <th>rownumber</th> <th>header2</th> <th>header3</th> <th>header4</th> <%= f.nested_fields_for :partial |f| render 'partial', f: f end -%> <caption align = "bottom"><%= link_to_add_fields "add field", f, :manual_iops %></caption> </table> _partial.html.erb <tr> <td> <!-- nothing goes here --> </td> <td> <%= f.text_field :data1 %> </td> <td> <%= f.text_field :data2 %> </td> <td> <%= f.text_field :data3 %> </td> </tr> <script>

Trouble with UpdatePanel in an ASP.NET WebForms solution -

so have mixed situation here , thought on right track doesn't seem working out. so here want..... i have webpage uses map plot point. not want interfere user doing, want periodically check database see if there need update points. no need = start timer over. have update = auto trigger click event of "refresh" button user can manually click on. here road was\am trying .... so have ui working want. have update panel contains javascript countdown timer. when timer up, triggers "click" event of hidden button. code-behind checks database. if no update in database, there nothing callback returns update panel , timer starts over. here not working.... if there update, code behind calls needed routine redoes on page (e.g. rebuilds map , such). problem though code runs, page doesn't reload. i'm assuming because whole updatepanel workflow designed ignore page updates effect objects not inside update panel. i post code, there isn't any. on