Posts

javascript - Create websocket without connecting -

is there way create websocket without connecting right away? far think var ws = new websocket("ws://ws.my.url.com"); creates , connects right away. i'd create socket, define callbacks, , connect once user clicks connect button. thanks no. creating websocket means you've created connection server (or started process of connecting). there no such thing creating websocket isn't connecting yet. you create object store configuration parameters , tell object connect when wanted to, though i'm not sure why that's better creating actual websocket when connect made. or create function setup work , call function later when user clicks connect button.

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

i learning perl. trying in debugger define variable, here-document. not know how enter same code in perl script, in debugger. due new lines present inside eot, makes hard in interactive debugger. here small example. have script: >cat ex1.perl #!/usr/bin/perl -w $s =<<'eot'; first line second line eot print $s now run , gives expected output: >perl ex1.perl first line second line now want same in debugger. tried this: >perl -de0 loading db routines perl5db.pl version 1.39_10 db<1> $s =<<'eot';\ cont: first line\ cont: second line\ cont: eot can't find string terminator "eot" anywhere before eof @ (eval 6) [/usr/share/perl/5.18/perl5db.pl:732] line 2. @ (eval 6)[/usr/share/perl/5.18/perl5db.pl:732] line 2. eval 'no strict; ($@, $!, $^e, $,, $/, $\\, $^w) = @db::saved;package main; $^d = $^d | $db::db_stop; $s =<<\'eot\'; first line second line eot; ' called @ /usr/share/perl...

Android SDK Manager freezes after installation of OSX 10.11 El Capitan public Beta -

i've installed public beta of el capitan os x (10.11). the issue i'm having after upgrade installation yosemite android sdk manager. when launch android sdk manager within android studio 1.2.2 checks , parses via network call. after clicking on of individual modules, sdk manager freezes , colourful wheel of death. way force close application. i've tried restarting macbook pro , force quitting , relaunching sdk manager , still issue persists. sdk manager working without issues prior upgrade of 10.11 edit: i've noticed none of emulators work el capitan cpu acceleration status: hax not installed on machine (/dev/hax missing). i've tried using genymotion , doesn't work either. i in trouble same thing, too. workaround fix, use no-ui option: $ android update sdk --no-ui other option available here: http://tools.android.com/recent/updatingsdkfromcommand-line

android - Linear layout children not scrolling -

i'm trying add image views linear layout @ runtime. <linearlayout android:id="@+id/llfolderlayout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight=".65" android:orientation="horizontal" android:scrollbars="horizontal" > </linearlayout> linearlayout llfoldertabs = (linearlayout) myfolder.findviewbyid(r.id.llfolderlayout); imageview imgtab = new imageview(activity); imgtab.setid(i); imgtab.settag(i); imgtab.setimagedrawable( mcontext.getresources().getdrawable(r.drawable.icon_folder_inactive)); if (i == 0) { imgtab.setimagedrawable( mcontext.getresources().getdrawable(r.drawable.icon_folder_active)); // imgtab.setpadding(10, 0, 4, 0); linearlayout.layoutparams lp = new linearlayout.layoutparams( 74, layoutparams.match_parent); lp.setmargins(15, 0, 0, 0); imgtab.setlayoutparams(lp); } else { // imgtab....

Image not being inserted into mysql database from php -

i trying insert image mysql database php. using following code so. $file= file_get_contents($_files['file']['tmp_name']); $id=$_session['id']; $sql="update mainadmin set photo='$file' id='$id'"; mysql_query($sql); $_session['photo']=$file; but image not being inserted mysql database. being stored in session variable , shown properly. when going image database saw previous image still stored , no update taken place in database. can me find mistake i found solution problem. here updated code. using addslashes() method solved problem $file= file_get_contents($_files['file']['tmp_name']); $filei=addslashes($file) ; $id=$_session['id']; $sql="update mainadmin set photo='$filei' id='$id'"; mysql_query($sql); $_session['photo']=$file;

sharepoint - Accessing files across a shared directory using a Windows service -

i trying access files on shared directory (sharepoint): \\sitename\sites\path_to_doc\doc.csv so have custom application looks @ files on shared drive , when launch application going folder it's installed - c:\myapp.exe, the application can access them . when corresponding service launched services.msc same user launched executable in previous step, doesn't find files on shared directory. i guess, question is: what general differences launching application interactively double clicking versus launching executable using service , of respect windows permissions , remote shared folders?

Quickblox API Session Creation With User & Signature Error -

quickblox rest api create session function running without user information not working when added user information. signature string:success string signaturestr=string.format("application_id={0}&auth_key={1}&nonce={2}&timestamp={3}", this.application_id, this.auth_key, this.nonce, this.timestamp); signature string:error string signaturestr=string.format("application_id={0}&auth_key={1}&nonce={2}&timestamp={3}&user[login]={4}&user[password]={5}", this.application_id, this.auth_key, this.nonce, this.timestamp,this.user.login,this.user.password); generate signature function public string generatehmacsha1(string key, string body) { system.text.encoding encoding = system.text.encoding.utf8; byte[] keybyte = encoding.getbytes(key); hmacsha1 hmacsha1 = new hmacsha1(keybyte); byte[] messagebytes = encoding.getbytes(body); byte[] hashmessage = hmacsha1.computehash(messagebytes...

ruby on rails - FactoryGirl build ignored when testing with Shoulda Matchers -

i've switched on shoulda matchers, can't seem validate factory builds. i've instantiated factory build in before callback, matcher doesn't seem acknowledge it. instance, intentionally set instance's name nil test returns no errors. doing wrong? require 'rails_helper' describe restaurant context 'validations' before { factorygirl.build(:restaurant, name: nil) } should validate_presence_of(:name) end end end for scenario, don't require instance match shoulda matchers; it's going test the usage of validate_presence_of against model definition itself. so, i'd rewrite test thus: require 'rails_helper' describe restaurant { should validate_presence_of(:name) } end

many to many - Updating extra fields pivot table laravel -

i have 3 tables, a pedido(order) table, product table , pedido_product table have field cantidad in pedido_product table i´m trying update each product orderd i'm able update fields hardcode values in update method, cantidad get's updated correctly $productid = 2; $cantidad = 1.1; pedido::find($pedidoid)->products()->updateexistingpivot($productid, [ "cantidad" => $cantidad ]); now have form try update cantidad on each product on same request {!! form::open(array('action' => ['pedidoscontroller@update', $pedido->id],'method' => 'patch')) !!} @foreach ($pedido->products $product) {!! form::text($product->pivot->product_id, $product->pivot->cantidad, ['class' => 'form-control' ,'id' => 'cantidad']) !!} i want, array key refrenced product_id , value of updated cantidad. how bind productid , cantidad in update method array recieve form ,...

javascript - Selecting Pseudo Element :focus and :active via JS -

i can't seem pseudo slement select workaround work on :focus styled form text box want change via js function. i know it's matter of adding class, , i've seen examples :after , :before not :focus , , not sure add class js: $(document).ready(function() { function night() { var currenttime = new date().gethours(); if (0 <= currenttime&&currenttime < 5) { $('.text_box').css('text-shadow', '0 0 0 #272727'); $('.text_box:focus').css('background-color', '0 0 0 #fff'); } if (10 <= currenttime&&currenttime <= 24) { $('.text_box').css('text-shadow', '0 0 0 #fff'); $('.text_box:focus').css('background-color', '0 0 0 #272727'); } } night(); }); ccs: .text_box { ...

android - Swipe Refresh Layout onRefresh working but not displaying refresh indicator -

i've implemented swipe refresh layout onto 1 of list views view not sliding down when swipe , icon not visible. though seems doesn't work, fire off onrefresh listener. also think worth mentioning i'm using listview on fragment i'm initializing listener in fragment activity displayed below. swipe refresh xml <android.support.v4.widget.swiperefreshlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <listview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listview" android:layout_gravity="center_horizontal" android:dividerheight="1sp" android:translationz="5dp" android:background="@color/background_gray"...

c# - How to create commands/utilities in a visual studio project -

i have solution in vs 2013 have few utility tasks need done once in while, example rebuild files embedded in output executable. right using test run these, because simple run code ide, don't – it's not test. my question how create utilities or commands can run ide? if can make utilities runnable commandline (for example, if they're in batch scripts or standalone helper executables), can use external tools functionality of visual studio. here's msdn page topic. i don't have vs 2013 handy, i've done previous versions of visual studio. little more natural running test invoke helper utility tasks, although works in pinch. you cobble pre/post-build event runs utility task. it's unclear doing periodically, if it's pretty lightweight operation, might not hurt there.

java - how many times is the println statement executed -

i kind of don't nested loops, can explain me why following code executed 45 times please? shouldn't i++ , j++ increment 1? first loop should (0 * 0), (1 * 1), (2 * 2) , on. for(int = 0; < 10; i++) for(int j = 0; j < i; j++) system.out.println(i * j); that not how nested loops work, - first enter outer loop, execute inner loop till inner loop exits (that j's value becomes equal i) , , after again increment i. so example , if i 5 , enter the outer loop, , j start 0 till 4 (as 5) , values calculated (5*0) , (5*1) , (5*2) , (5*3) , (5*4) , , after exiting inner loop, again increment i 1 , i become 6 , repeat (that j start 0 till 5).

What does 'generated box' in css mean? -

as question title, 'generated box' in css mean? article link: http://www.sitepoint.com/web-foundations/css-box-model/ a "generated box" box associated element in visual formatting structure. word "generate" refers act of creating box , drawing on screen according css properties of element. introduction section 9 of css2.1 spec summarizes nicely: in visual formatting model, each element in document tree generates 0 or more boxes according box model . layout of these boxes governed by: box dimensions , type. positioning scheme (normal flow, float, , absolute positioning). relationships between elements in document tree. external information (e.g., viewport size, intrinsic dimensions of images, etc.). most elements tend generate 1 box, can generate multiple boxes or none @ depending on situation. example, following generates single block box 100 pixels 100 pixels: <div style="width: 100px; height: 100px;...

python - Django models: how to handle conceptually similar ideas and somewhat repetitious elements -

i new django , databases. suppose trying create database filled information various nobility on time. so, there number of different countries might have "monarch" position, held various people, male , female, @ different times. several countries might call king/queen while perhaps 1 call tsar/tsarina. these fixed. initial impression modeling might class person(models.model): sex_choices = ( 'm': 'male', 'f': 'female' ) name = models.charfield(max_length=200) birthdate = models.datefield() sex = models.charfield(max_length = 2, choices = sex_choices) titles = models.manytomanyfield(title, through='titleoccupation') class country(models.model): #... class title(models.model): country = models.foreignkey(country) #... class titleoccupation(models.model): title = models.foreignkey(title) date_start = models.datefield() date_end = models.datefield(null = true, bla...

Is android-asynct-http library coupled with UI thread? -

i want use awesome library server request in application work on map. my need want make server request every 2 minutes without block user interaction on screen while server requesting process happening , in onsuccess call i'll work on map. how can use library need? , the library coupled android activity , fragment life cycle? please refer site library information. http://loopj.com/android-async-http/ actually that's page linked http://loopj.com/android-async-http/ . theses callbacks executed in ui thread actual request being processed in thread. asynchttpclient client = new asynchttpclient(); client.get("http://www.google.com", new asynchttpresponsehandler() { @override public void onstart() { // called before request started } @override public void onsuccess(int statuscode, header[] headers, byte[] response) { // called when response http status "200 ok" } @override public void onfailure(...

c - How to iterate over a char pointer array -

how iterate on files variable in efficient way ? should add null last value, or else ? char *files[] = { "c1.txt", "r1.txt", "t2.c", "d.cpp", }; there several possibilities. you can add null final entry, suggest yourself if array comes source (like file on disk), keep counter of number of lines you're reading but if array given in source, length constant , can check how many elements has (by subtracting line numbers) also, size of constant array sizeof(files) / sizeof(char*) .

c# - Getting interface implementations in referenced assemblies with Roslyn -

i'd bypass classical assembly scanning techniques in framework developing. so, i've defined following contract: public interface imodule { } this exists in contracts.dll . now, if want discover implementations of interface, similar following: public ienumerable<imodule> discovermodules() { var contracttype = typeof(imodule); var assemblies = appdomain.current.getassemblies() // bad var types = assemblies .selectmany(a => a.getexportedtypes) .where(t => contracttype.isassignablefrom(t)) .tolist(); return types.select(t => activator.createinstance(t)); } not great example, do. now, these sorts of assembly scanning techniques can quite under-performaning, , done @ runtime, typically impacting startup performance. in new dnx environment, can use icompilemodule instances metaprogramming tools, bundle implementation of icompilemodule compiler\preprocess folder in project , funky. what target be, use ico...

nscopying - Is it better to use -> instead of . in to implement `copyWithZone:` method in objective-c? -

say there's class property p1, , setter p1 has been overwritten. want implement nscopying protocol class a. in understanding since you're "copying" instance of class a, there's no need trigger setter methods in copywithzone: method. copyofinstance -> _p1 = _p1; better copyofinstance.p1 = _p1 . right? yes. forming new object if implementing initializer. rules same. must not use setter method in init... method, must not use setter in copywithzone: .

Unable to forecast linear model in R -

i'm able forecasts arima model, when try forecast linear model, not actual forecasts - stops @ end of data set (which isn't useful forecasting since know what's in data set). i've found countless examples online using same code works fine, haven't found else having same error. library("stats") library("forecast") y <- data$mfg.shipments.total..usa. model_a1 <- auto.arima(y) forecast_a1 <- forecast.arima(model_a1, h = 12) the above code works perfectly. however, when try linear model.... model1 <- lm(y ~ mfg.no.total..usa. + mfg.inv.total..usa., data = data ) f1 <- forecast.lm(model1, h = 12) i error message saying must provide new data set (which seems odd me, since documentation forecast package says optional argument). f1 <- forecast.lm(model1, newdata = x, h = 12) if this, able function work, forecast predicts values existing data - doesn't predict next 12 periods. have tried using append functi...