Posts

Showing posts from March, 2012

c# - Server Explorer shows both dbContext and database.mdf active -

i may have confused implementation of database asp.net mvc project, have separate data layer connection string pointed .mdf file. i imported data models through ado.net entity data model code-first existing database. when go enable migrations, no problem. however, i'm trying add-migration , , get: unable generate explicit migration because following explicit migrations pending: [201504081848445_initialcreate]. i checked server explorer, , noticed have both "databasecontext" , database.mdf showing up. sorry if elementary question, suspicion has connection string? saw when first enable , create migrations, show in databasecontext . next day, see "databasecontext" missing _migrationhistory , , see error message explicit migrations pending. my connection string: <connectionstrings> <add name="databasecontext" connectionstring="data source=(localdb)\v11.0;attachdbfilename=|datadirectory|\database.mdf;int

arrays - Permutations in Ruby - unsure how to handle -

i trying output array of 10-element arrays containing permutations of 1 , 2, e.g.: [[1,1,1,1,1,1,1,1,1,1], [1,1,1,1,1,1,1,1,1,2], [1,2,1,2,1,2,1,2,1,2], ...etc... [2,2,2,2,2,2,2,2,2,2]] i have done smaller arrays, (10): = [1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2] = a.permutation(10).to_a print a.uniq ...this apparently big calculation- after hour running, hadn't completed , ruby process sitting on 12gb of memory. there way come @ this? first, check size of permutation a.permutation(10).size => 670442572800 it's huge. can instead use array#repeated_permutations on smaller array. check here: b = [1, 2] # unique elements b.repeated_permutation(10) # returns enumerable b.repeated_permutation(10).to_a # creates array of permutations those permutations unique (which u can check printing size , without array#uniq )

php - How to display all the columns inside a table once at least one similarity has been found between 2 database? -

database_name1(criteria) -> table_name(tenantcriteria) , inside have following columns -username -firsrent -occupation -age -tenantgender -income -history -address -tenantsmk -tenantpet database_name2(tenant) -> table_name(preference) , inside have following columns -username -firsrent -occupation -age -tenantgender -income -history -address -tenantsmk -tenantpet 3.database_name3(ad) -> each table has usernames name, hence table_name($username) , inside have following columns -adtype -roomtype -negotiable -price -include -title -address1 -address2 -postcode -city -province -image -description if user log in's tenant, , wants see property sell, click on rentalmatch button , button supposed check similarities between tenants preference table , go through tables in criteria database , return username criteria database have @ least on similarity tenants preference. once returns usernames want go database *(ad) tables have usernames name found before. go inside user

php - cakephp3 read session in component -

i have plugin developed cakephp3 inside component read value stored in sessions. in cakephp 2 used: $userid = cakesession::read('auth.user.id'); but if use cakephp 3 return me error: error: call undefined method userpermissions\controller\component\userpermissionscomponent::_hassession() file /users/info/sites/cakephp3/vendor/cakephp/cakephp/src/network/session.php line: 382 to include sessions inside component i'm using : use cake\network\session; how can read value in session? thanks i make happen in initialize() method such: use cake\controller\component; use cake\controller\componentregistry; class yourcomponent extends component{ public $controller = null; public $session = null; public function initialize(array $config) { parent::initialize($config); // .... /** * current controller */ $this->controller = $this->_registry->getcontroller(); $this->s

javascript - Java Script to find tag value with out ID, Tag Name -

i want value of 2nd <td> <tr> <td>devaraj</td> <td>shiva</td> </tr> result expected : 'shiva' how can search 1st <td> tag value , take value of 2nd <td> tag value? thanks you use document.queryselector() which: returns first element within document (using depth-first pre-order traversal of document's nodes) matches specified group of selectors. so target 2nd td : document.queryselector('table td:nth-child(2)') see jsfiddle or following snippet alert(document.queryselector('table td:nth-child(2)').innerhtml) <table> <tr> <td>devaraj</td> <td>shiva</td> </tr> <table>

css3 - How can I make a flexbox constrain image height? -

Image
css flexbox newbie here. i'm trying achieve layout with a fixed-height header a content area takes available space, , displays image. a fixed-height footer i got working following flexbox code: <html style="height: 100%;"> <body style="height: 100%;"> <div style="display: flex; flex-direction: column; height: 100%;"> <div style="background-color: rgba(255, 0, 0, .1)";> header </div> <div style="flex: 1; background-color: gray;"> content </div> <div style="background-color: rgba(0, 0, 255, .1)"> footer </div> </div> </body> </html> this works great. want display image inside of content area. small images, works fine: <!-- inside content div

c - How to find row indices of large row matrix with n common elements in matlab? -

i trying find pairs of rows index matrix 2 common elements. have triangulation of 3d object , want filter triangles angle of neighboring triangles. so, have find triangles share edge. in order this, must find rows of .tri file have 2 common points. i have 350ish .tri files each of them have 7000x3 in dim. have found resource: mathworks link accepted answer takes mac air 15 mins, , matt figs answer takes 8 mins per .tri file (i have 350!). how can complete process? have been told try , code part in c ( have never used c). have considered trying install matlab on linux server , run there ( have never done either). advice on how either write program in c or use aws server? 3d files located here: 3d files here code run: (any suggestions clean appreciated) addpath('/users/len/desktop/javaplex/nonrigid3d') files1 = dir('/users/len/desktop/javaplex/nonrigid3d/*.tri'); files2 = dir('/users/len/desktop/javaplex/nonrigid3d/*.vert'); time=cputime; k =1:l

delphi - Invalid Pointer Operation with Dynamic Array -

heloo guys... once try run code gettin 'invalid pointer operation' error, problem ? supposed sort names in textfile alphabetical order (school project). program project2; {$apptype console} uses sysutils, classes; var names : textfile; count : integer=0; array : array of string; : integer; procedure load; begin reset(names); setlength(array, count - 1); := 1 count readln(names, array[i]); end; begin assignfile(names, 'names.txt'); reset(names); while not eof(names) begin readln(names); inc(count); end; load; := 1 count writeln(array[i]); readln; closefile(names); erase(names); end. dynamic arrays zero-based. need set length count , iterate 0 count-1 . setlength(arr, count); := 0 count-1 readln(names, arr[i]); obviously indexing needs changed 0-based. i changed name of array arr because array keyword. do not attempt continue 1-based indexing. doing cause endless headaches.

recursion - Lua: Taking a Recursive Action into a Single One -

i'm using lua create "plug-in" linux-based operating system. program contains c function recursive 1 (not intended is). @ moment, each time function called provides result 4-5 times. i'd ask question concerning recursive function(s) , results. possible take multiple (same) results of recursive function , use 1 of set(s) of results? example: (i'm going state "os function" point out coded operating system i'm integrating lua into) function abc123() -- os function based in os local names = os_names() -- os function local index, var = os_rows() -- os function pull vars file k,v in pairs(names) index2, var2 = os_rows(k) -- os function pull vars file if var2 ~= var os_rows(k,var2,var) -- recursive os function cnt = 1 while cnt <= 4 data_tbl = file_info(x,y,z) -- personal function grab info , return table info_tbl[data_tbl.id]=data_tbl

scala - Assertion for overloaded equality operator fails for triple-equals but passes for double-equals -

i overloaded case class's equality operator: case class polygon(points: seq[(double, double)]) extends shape { def ==(that: polygon): boolean = { ... } } my unit tests pass when using double-equals in assertions: import org.scalatest.funspec class shapespec extends funspec { describe("polygon") { it("is equal rotations") { val p = polygon(seq( ... )) { ← 0 until p.points.size } { val q = polygon(p.points.drop(i) ++ p.points.take(i)) assert(p == q) } } } } but when using === instead of ==, same tests fail: [info] polygon [info] - equal rotations *** failed *** [info] polygon(list((-1.0,-1.0), (4.0,-1.0), (4.0,2.0), (1.0,2.0), (1.0,1.0), (-1.0,1.0))) did not equal polygonm(list((4.0,-1.0), (4.0,2.0), (1.0,2.0), (1.0,1.0), (-1.0,1.0), (-1.0,-1.0))) (shapespec.scala:28) why happen? you spelled wrong. ;) it should be: override def equals(x: any): boolean

lambda - Not Function And Function Composition in F# -

is possible f# have function composition between operators.not , standard .net function, instance string.isnullorempty ? in other words, why following lambda expression unacceptable: (fun x -> not >> string.isnullorempty) the >> function composition works other way round - passes result of function on left function on right - snippet passing bool isnullorempty , type error. following works: (fun x -> string.isnullorempty >> not) or can use reversed function composition (but think >> preferred in f#): (fun x -> not << string.isnullorempty) aside, snippet creating function of type 'a -> string -> bool , because ignoring argument x . suppose might want just: (string.isnullorempty >> not)

javascript - For loop error in Firefox and IE but not Chrome -

i have weird issue: have loop in javascript works absolutely expected in chrome not in firefox or ie. in firefox , ie adds undefined item array , have no clue why. angular.module('app', []) .controller('itemctrl', function($scope){ $scope.itemsa = [ { name: 'testa' }, { name: 'testb' } ]; $scope.itemsb = []; $scope.dosomething = function(idparam) { for(var = 0; < $scope.itemsb.length; i++){ if ($scope.itemsb[i].name === $scope.itemsa[idparam].name) { ... }; }; according developer tools in both browsers $scope.itemb has length 0 @ loop start line for(var = 0; < $scope.itemsb.length; i++) (for whatever reason) still starts loop (which shouldn't know) , in following line if ($scope.itemsb[i].name === $scope.itemsa[idparam].name) there appears undefined item 0 array position out of (and produces error of course). any ideas?

.net - C# LINQ Lambda multiple group of IEnumerable with Sum() -

i have collection of data = ienumerable<analyticsdata> , i'm trying group multiple properties , sum() on integer column. end result collection of analyticsreportrow<dynamic>() can see below, though isn't highly relevant. in final select() method, want pass object in, ideally original set , prefer not recreate 1 in middle of chained queries if possible. of examples seem create either new strongly-typed or dynamic object pass next link in chain. here's have spent few hours trying work with, , returns set in first code block below rows (i export csv, hence formatting): var pageviewsdata = analyticsdata.groupby(data => new { g1 = data.webproperty, pv = data.pageviews, d = data }) .groupby(data => new { gg1 = data.key.g1, dd = data.key.d }) .select(data => new analyticsreportrow<dynamic>(data.key.dd, "page_views", data.sum(datas => datas.key.pv))); result this: "customera","","","

ios - How do I initialize a table view in edit / re-ordering mode? -

Image
i want table view in view re-orderable. cannot figure out. have rows in table view can't re-ordering handles show up. for table view prototype cell, made sure there check in indentation > "shows re-order controls", didn't anything. this how whole class looks like: class viewcontroller: uiviewcontroller { ... @iboutlet var currenttable: uitableview! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. currenttable.editing = true } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return unitcategories.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = uitableviewcell(style: uitableviewcellstyle.default, reuseidentifier: "cell") cell.textlabel?.text = "\(unitcategories[indexpath.row])" r

javascript - indexedDB.deleteDatabase() does not delete? -

google chrome lists 2 indexed databases own website: ursprung: http://www.example.com/ größe auf datenträger: 5,5 kb zuletzt geändert am: donnerstag, 9. april 2015 22:23:53 ursprung: https://www.example.com/ größe auf datenträger: 1.048 b zuletzt geändert am: dienstag, 3. märz 2015 22:49:21 regarding research resulted through indexeddb . not know set databases , names have tried find names , after delete them follows: <script> indexeddb.webkitgetdatabasenames().onsuccess = function(sender, args) { console.log(sender.target.result); var req = indexeddb.deletedatabase(sender.target.result); req.onsuccess = function () { console.log("deleted database successfully"); }; req.onerror = function () { console.log("couldn't delete database"); }; req.onblocked = function () { console.log("couldn't delete database due operation being blocked"); }; }; </script> the c

winforms - Turn off 'Show window contents while dragging' setting while displaying my C# windows forms -

there window display setting called 'show window contents while dragging'. http://www.thewindowsclub.com/disable-show-windows-contents-while-dragging when setting turned on, if drag window window repaint @ new position. if resize window, repaint window each new window size immediately, if still holding down mouse button. when setting turned off, dragging or resizing window shows outline of new window position or size until release mouse button , paint window @ new position or size. i display forms in c# winforms application 'show window contents while dragging' setting turned off. operating setting, effective when forms displayed regardless of setting set in os. is there way achieve using winapi calls change behavior winforms? if not, there way can change setting programatically before form displayed , reset after form has closed? performing change require admin rights (because don't want that)? the following code below use system setting of

android - Pass list item id into a contextmenu Click method -

i have database , need change remove , add values , created such contextmenu have chance change , remove clicked item. need know id of list item , within contextmenu have ids of menu. i'm doing right thing or there easier way. public boolean oncontextitemselected(menuitem item) { //iniciação da base de dados final helperdb myhelper = new helperdb(this.getactivity()); sqlitedatabase db = myhelper.getwritabledatabase(); string[] projection = {contrato_db.cidadeentry._id, column_nome, }; // how want results sorted in resulting cursor string sortorder = column_nome + " asc "; string[] columns = new string[] { "_id", "nome" }; final cursor c = db.rawquery("select * cidade ", null); c.movetofirst(); final adapterview.adaptercontextmenuinfo info = (adapterview.adaptercontextmenuinfo) item.getmenuinfo(); switch (item.getitemid()) {

python - How to validate Google reCAPTCHA v2 in django -

i have been trying use google recaptcha on website i've been making. captcha loads on webpage i've been unable validate using several methods. i've tried recaptcha validation using method given @ how use python plugin recaptcha client validation? think it's outdated no longer works , referring challenges whereas 1 i'm trying use new 'checkbox' recaptcha v2 google or maybe need make changes in settings after installing recaptcha-client or django-recaptcha. please help! there third-party django app implement new recaptcha v2 here: https://github.com/imaginarylandscape/django-nocaptcha-recaptcha after installing it, add following lines following files: # settings.py norecaptcha_site_key = <the google provided site_key> norecaptcha_secret_key = <the google provided secret_key> installed_apps = ( .... 'nocaptcha_recaptcha' ) #forms.py nocaptcha_recaptcha.fields import norecaptchafield class yourform(forms.form

mysql - INSERT data into a table only if it matches a field in another table -

i have data want import mysql db if there matching email address in table two. insert table_1 value data_1, email email *exists in table_2* i not sure if explaining correctly if need more info let me know. thanks! insert table1(data_1, email) values (select data_1,email table_2 table_1.email=table2.email)

visualization - How to visualize simplex? -

let's have n-simplex , grid on it. every point of grid evaluate function. don't know how visalize data received evaluation. would me approach represent simplex in 3-d or 2-d, quite interpretation? of course it's allowed representation not quite accurate. try find number of each poly tonic faces n-simplex using pascal triangle. give colour each of face.combine them convex hull.

android - Jackson JSONArray nested in a JSONArray not parsing -

not sure if i'm using correct syntax or declaring classes right doesn't seem parse jsonarray inside jsonarray. what doing wrong? here's json file: { "response": { "status": 200 }, "items": [ { "item": [ { "body": "computing", "subject": "math", "attachment": false } ] }, { "item": { "body": "analytics", "subject": "quant", "attachment": true } } ], "score": 10, "uri": "http://localhost/v2.0.0/surveys/5511fa0b7ccabf820b08172a/5512d3de7ccabf820b081731/", "thesis": { "submitted": false, "title": "masters", "field": "sciences" } } here classes i'm

delphi - FireMonkey ComboBox assigning Selected. Text from query -

i need allow users view selected item combobox. query provides previous choice combobox. i hoping live bindings me through it, slow, can't use it. i able complete similar action using comboeditbox, can't seem sort out needs done combobox. for comboeditbox, following code works fine: comboinspector1.text := fdquerygetinspectioninspector_1.text; however, following code not work combobox: combostationlocated.selected.text := fdquerygetinspectionstation_found.text; any ideas? i believe trying select item based on text, below select item in combobox if exists text of yourobject (whatever may be) combostationlocated.itemindex:=combostationlocated.items.indexof(yourobject.text); if not trying edit answer.

unity3d - android SIGSEGV in mono_gc_collect -

we've got unity engine game in soft launch now. we're seeing ocassional crash callstack below - few day dau of on 150. crash doesn't seem common particular android version or device. there lots of samsungs affected, demographics. since gc, guess out-of-memory. callstack mentions cleanup, not allocating. we're shipping standard texture format, rather multiple apks; have no idea if that's related. has seen before? can decypher runes? error: signal 11 (sigsegv), code 1 (segv_maperr), fault addr 6d299ff0 build fingerprint: 'htc/v01_htc_telus/htc_v01_u:4.4.2/kot49h/1.02.661.6:user/release-keys' revision: '0' pid: 12019, tid: 12043, name: main >>> com.spryfox.alphabear <<< r0 6d299ff0 r1 6d29a000 r2 fffffe5c r3 6d29a000 r4 6d299ff0 r5 00000001 r6 6d299ffc r7 7340b774 r8 609e15e0 r9 61f60f60 sl 62061688 fp 6205e8fc ip 61216ed0 sp 6205e8d0 lr 6113201c pc 61131f8c cpsr 48393454 libmono.002c8f8c:-2 libmono.gc_push_all_stack in gc_pu

java - Does jdbc dataset store all rows in jvm memory -

i using java jdbc application fetch 500,000 records db. database being used oracle. write data file each row fetched. since takes hour complete fetching entire data, trying increase fetch size of result set. have seen in multiple links while increasing fetch size 1 should careful memory consumption. increasing fetch size increase heap memory used jvm? suppose if fetch size 10 , program query returns 100 rows in total. during first fetch resultset contains 10 record. once read first 10 records resultset fetches next 10. mean after 2nd fetch dataset contain 20 records? earlier 10 records still maintained in memory or removed while fetching newer batch? appreciated. it depends. different drivers may behave differently , different resultset settings may behave differently. if have concur_read_only , fetch_forward , type_forward_only resultset , driver actively store in memory number of rows corresponds fetch size (of course data earlier rows remain in memory period of t

radio button - c# Geting values of multiple group of radiobuttons -

i've c# windows form application contains multiple groups , each group contains of radio buttons. want insert values of each group access database table. i’am trying return every function doing private void get_gender(radiobutton genderbutton) { if (genderbutton.checked) { return genderbutton.text; } } private void get_age(radiobutton agebutton) { if (agebutton.checked) { return agebutton.text; } } private void get_interest(radiobutton interestbutton) { if (interestbutton.checked) { return interestbutton.text; } } then trying pick them functions like string gender = get_gender(i don’t know put here); string age= get_age(i don’t know put here); string interestr = get_interest(i don’t know put here); and create connection..(this no problem) oledbconnection con = new o

Unable to create a Java NetBeans project inside Dropbox folder -

since last year i've been using netbeans main ide college reasons, must code our exams using ide (unfortunately) using other not option. practical reasons create java projects inside dropbox folder of current subject couple of days ago when had run project prompted on output following: error: not find or load main class javaapplication44.javaapplication44 java result: 1 build successful (total time: 0 seconds) i aware common problem , have tried following: reinstalling netbeans & jdk relocating main class using preferences menu of current project. so here comes problem, after reinstalling again , having tried sort of possible solutions, created project (again) in dropbox folder know if issue disappeared didn't, created project in desktop , worked. after bit of trial , error problem dropbox folder because when create simple project hello world, 100% code correct, inside place works fine. any appreciated. regards. dropbox might creating hidden file

xmlhttprequest - Quickbooks PHP - qbXML mapping TransactionRet(Invoice) with ItemServiceRet -

i'm developing rountine store invoice local database based on quickbooks invoices. using qbxml request: $xml ='<?xml version="1.0" encoding="utf-8"?> <?qbxml version="8.0"?> <qbxml> <qbxmlmsgsrq onerror="stoponerror"> <invoicequeryrq requestid="'.$requestid.'"> </invoicequeryrq> </qbxmlmsgsrq> </qbxml>'; return $xml; and results want, example data: <invoiceret> <txnid>11-1428375941</txnid> <timecreated>2015-04-06t23:05:41-05:00</timecreated> <timemodified>2015-04-06t23:05:41-05:00</timemodified> <editsequence>1428375941</editsequence> <txnnumber>5</txnnumber> <customerref> <listid>8000005a-1424374192</listid> <fullname>fake</fullname> </customerref> <araccountref> <listi

symfony - Upload profile picture -

i want allow user change profile picture. followed symfony2 documentations, it's working. problem is, can't call form using {{ form_widget(form.file) }} must use {{ form_widget(form) }} . it's annoying because have other value in formbuilder , want able custom every fields in twig. this formtype. <?php namespace l3o1\userbundle\form\type; use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface; use symfony\component\optionsresolver\optionsresolverinterface; class profilepictureformtype extends abstracttype { public function buildform(formbuilderinterface $builder, array $options) { // add custom field $builder->add('file', 'file', array( 'required'=>false)) /*->add('aboutme', 'textarea', array( 'attr'=>array( 'rows'=>4, 'cols'=>

input in C programming language -

i want code receive user floating number store 2 digit after decimal point for example if user input a=123.123456789 a value equal 123.12 #include <stdio.h> int func(int x,int digit,int con,char* s) { int v; v=x/digit; v=v*digit; x-=v; if(con==1){ printf("%d %s(s) de r$ %.2f\n",(v/digit),s,(float)digit/100); return x; } printf("%d %s(s) de r$ %.2f\n",(v/digit),s,(float)digit); return x; } int main() { int x=0; float y;//if change double result true scanf("%f",&y); //y = ((int)(100.0 * y)) / 100.0; x=(int)y; y=y-x; printf("notas:\n"); char* arr="nota"; x=func(x,100,0,arr); x=func(x,50,0,arr); x=func(x,20,0,arr); x=func(x,10,0,arr); x=func(x,5,0,arr); x=func(x,2,0,arr); printf("moedas:\n"); arr="moeda"; x=func(x,1,0,arr); //mod x=y*10

java - How to add a MimeMultipart to another one? -

this possibly stupid question, i'm trying compose email message suggested here multipart/mixed multipart/alternative text/html text/plain attachment 1 attachment 2 so i'm having mimemultipart altpart = new mimemultipart("alternative"); bodypart textpart = new mimebodypart(); textpart.setcontent("sometext", "text/plain"); altpart.addbodypart(textpart); bodypart htmlpart = new mimebodypart(); htmlpart.setcontent("somehtml", "text/html"); altpart.addbodypart(htmlpart); mimemultipart mixedpart = new mimemultipart("multipart/mixed"); and need add altpart mixedpart , can't adding method accepts bodypart only. wtf? note unlike here , i'm not mixing packages. you need wrap mimemultipart in mimebodypart , using mimebodypart.setcontent(multipart mp) method. can add mimebodypart mixedpart object: mimemultipart alternativemultipart = new mimemultipart("alternative");

ios - MobileFirst ChallengerHandler not returning from submitLoginForm call when using ISAM authentication -

(update added @ end) i have native ios mobilefirst (7.0) client written in swift. mobilefirst server behind firewall , accessed though junction on ibm security access manager web (isam). isam being used adapter authentication. i've tested app without isam in middle (no authentication), , works fine. a custom challenge handler registered: let mych = mychallengehandler(vc: self) wlclient.sharedinstance().registerchallengehandler(mych) mychallengehandler sets realm in init() function: init(vc: loginviewcontroller){ self.vc = vc super.init(realm: "headerauthrealm") } the app first connects server using wlconnectwithdelegate: wlclient.sharedinstance().wlconnectwithdelegate(connectlistener(vc: self)) and once connection made, should call adapter method on server user info (using invokeprocedure): let invocationdata = wlprocedureinvocationdata(adaptername: "login", procedurename: "lookuprole") invocationdata.parameters

symfony - Twig variable from one loop in another doesn't work -

i have 2 loops in twig. 1 check stock level of product, other display product options. i'm trying create variable 1 loop can use inside other add class name list(s). i can't work. more welcome... what have this: {% set stocklevel = '' %} {% variant in product.variants %} {% set stocklevel = variant.stock.level %} {{ stocklevel }} // gives 1 0 1 1 (so sizes except second 1 available) {% endfor %} {% option in product.options %} <ul class="optionslist"> {% if option.values %} {% value in option.values %} <li class=" {% if stocklevel == 0 %}not_on_stock {% endif %}" > <a class="item">etc...</a> </li> {% endfor %} {% endif %} </ul> {% endfor %} i believe there wrong way handling

sockets - Ruby - Send message to multiple IP addresses -

how go sending 1 message multiple receivers? this do: require 'socket' ip = ['ip 1', 'ip 2'] port = 18000 loop { message = gets.chomp() conn = tcpsocket.open(ip, port) conn.write(message) conn.close_write } try iterate on ips array: ips = ['ip 1', 'ip 2'] port = 18000 loop message = gets.chomp() ips.each |ip| conn = tcpsocket.open(ip, port) conn.write(message) conn.close_write end end

php include() to generate an xml file not working -

help needed.. can't figure out.. i have php file (a.php) read xml data , store mysql. then, have php file (b.php) generates xml file (c.xml) database. currently, have 2 cron jobs run a.php , b.php separately (hostgator shared hosting). i tried include() execute b.php within a.php. seemed working c.xml did not refreshed (displaying old data). however, when ran b.php manually or using cron jobs, c.xml got refreshed (displaying updated data). here summary of codes. a.php $doc = new domdocument; $xpath = new domxpath($doc); ... $query = "insert .."; ... include 'b.php'; b.php $doc = new domdocument('1.0', "utf-8"); ... echo $doc->save('c.xml') . "\n"; thanks in advance! ================================================== when run b.php manually, displays number (i think number of elements??) on b.php page , c.xml displays updated data. when, run a.php b.php included, same number shown on a.php page c.xml

cloudfoundry - How can I see my VCAP_SERVICES environment variable with the cf program? -

when run cf env <app-name> shows environment variables i've set cf set-env , don't see vcap_services environment variable. how can see variable's value? as of version 6.10 of cf program, vcap_services environment displayed other environment variables, command cf env <app-name> . to upgrade cf program, download appropriate version on releases page: https://github.com/cloudfoundry/cli/releases

sql - Rails ordering with nil last - SQLite3 error -

currently, trying order class limit attribute. want values in ascending order, nil values last. i've tried couple different queries activerecord query along cross base sql query (it needs sql flexible). i've tried few: self.order('isnull(limit), limit asc') self.order('case when -limit desc') self.order('limit null, limit desc') but keep getting errors around limit , missing something? sqlite3::sqlexception: near "isnull": syntax error: select "table".* "table" "table"."deleted_at" null order isnull(limit), limit asc limit null it, limit reserved keywork in sqlite3, enclose in backticks or quotes: self.order('`limit` null')

How to access docker logs of another container -

suppose have 2 docker containers, , b. there way access "docker logs" output of container b within container a? yes, can mount docker socket container (like so: -v /var/run/docker.sock:/var/run/docker.sock ) , access docker logs output through that. you'll either need docker cli binary installed in container b, or use client library of choice interact socket.

r - extract alphanumeric strings from text -

background related question not required reading question i have string str_temp <- "{type: [{a: a1, timestamp: 1}, {a:a2, timestamp: 2}]}" from extract 7 alphanumeric substrings: type, a, a1, timestamp, a, a2, timestamp . however, can't regex work. i have tried both base r , library(stringr) using various combinations of [:word:], [:alnum:], [:alpha:] etc. one example: > pattern <- "[:word:]" > str_locate_all(str_temp, pattern) [[1]] start end [1,] 6 6 [2,] 11 11 [3,] 26 26 [4,] 34 34 [5,] 48 48 but gives me end points of strings type , a , timestamp , a , timestamp , not start points, or either of a1 or a2 . what's correct regex extracting 7 alphanumeric strings? here regex works. matches alphanumeric words not numbers. ((?![0-9]+)[a-za-z0-9]+) http://www.rubular.com/r/euf9afdtxw thanks richard showing how use in r: regmatches(str_temp, gregexpr("((?![0-9]+)[a-za-z0-

android - Best way to store uri in mysql database -

i have android app in user registers using his/her facebook account, , want user's profile picture, method sdk offers returns uri(i) profile picture, want send uri php server , store in mysqldata base, , because new have bunch of questions: best way (field) store uri in server database? ll doing in further steps http request download picture, , method implemented download picture web server uses urls, have issues in using uri? there other issues ll have aware of in using uris? thank u in advance. as has been commented, best way store in string form. you can store uri using tostring method , when database later, can use uri.parse(string) method uri object. to answer other questions... the method implemented download picture web server uses urls, have issues in using uri? this shouldn't problem it's simple task convert uri url. is there other issues ll have aware of in using uris? one thing note android has 2 types of uri available in

android - Sinch Client down? Getting unable to resolve host -

after setting sinch instant messaging on app , testing it, worked good. when try use get: 04-10 00:08:16.175 12082-12103/com.yupo.dominic.yupo e/sinch-android-rtc﹕ error(code: 1002, domain: network, message: unknownhostexception: unable resolve host "sandbox.sinch.com": no address associated hostname) . i'm assuming on sinch's side client working fine yesterday. can if error on side? have searched online cannot find information regarding it. this problem internet connection. either offline or flaky internet connection.

php - Mod rewrite and redirect solution -

we have hundreds of locations , build separate page each in wordpress (location-in-some-state...): ourdomian.com/location-in-some-state/ works great. seo guys want page different design seo: ourdomain.com/newpage/location-in-some-state don't want change template because still use old one. going build new page , pull data slug: 'categories'=> 'location-in-some-state', so need redirect ourdomain.com/location-in-some-state ourdomain.com/newpage/ something think there's infinite loop here rewriterule ^newpage/(.*)$ /newpage/ [r=301,nc,l] lastly, need 'location-in-some-state' slug somehow. can moved query string or visible in url rewritten? if can redirected /newpage/ , rewritten (visual only) /newpage/location-in-some-state , maybe can pull out of uri, or can uri sent query string????? do mean like: rewritecond $1 !^newpage/ rewriterule ^(.*)$ /newpage/$1 [l,r=301]

python - Erroneous PyDev Errors with Django 1.8 -

i'm working eclipse + pydev. switched machine django 1.6 1.8. under django 1.6, project had no errors. now, under django 1.8, references properties of .objects on database model, such databasemodel.objects.filter(...) give me error undefined variable import: filter these errors don't occur in models.py; if import databasemodel different module , call method of it's .objects property different module. how eclipse stop reporting these errors? more details: eclipse version: kepler service release 1 pydev version: 3.9.2 i experienced similar problem when upgrading django 1.7 (which why kept around version of django 1.6 in development environment). humm, let's django structure pretty difficult thing understand, so, pydev static analyzer has hard-coded tricks dealing django... changed on 1.8, so, static analysis not working on anymore (reference: https://github.com/fabioz/pydev/blob/development/plugins/org.python.pydev/src_completions/org

ios - UIAccessibilityAnnouncementNotification doesn't fire off in background mode -

i working on simple app need make post uiaccessibilityannouncementnotification when user near specific point. when app active, works fine. when press home key, stops working. to narrow down problem, started printing in didupdateheading (since can't sit @ place, , have didupdatelocations called). saw when locked screen, heading getting updated. further, placed breakpoint on line uiaccessibilityannouncementnotification supposed fired. control arrives on line , goes next line without posting announcement. my question : how make uiaccessibilityannouncementnotification work in lock screen? google maps app same thing. don't use voice-over announcement (such "turn left") heard in lock screen. have use speech synthesizer achieve same? sample code illustration great, beginner in ios development. app settings: ios 8.2, iphone 4s, xcode 6.2, objective-c, app registers location updates in background mode (in .plist file) as commented, google maps speak a

vb.net - Byte array percentage similarity -

i kinda new in vb.net; pretty have been looking way calculate similarity of byte array. have been able determine whether equal or not, haven't figured out how calculate how similar in percentage. idea appreciated. thanks! leo. the following function takes 2 byte arrays arguments. if arrays not same length, throws exception. otherwise, returns fraction of elements in 1 array equal element @ same position in other array. function percentalike(array1() byte, array2() byte) double if array1.length <> array2.length throw new argumentexception("arrays must have same length") dim same integer integer = 0 array1.length - 1 if array1(i) = array2(i) same += 1 next return same / array1.length end function [added in response comment arrays may not same length] if need calculate percentage if arrays of different lengths, can use following function. returns number of elements in 1 array equal element @ same position in other array (ign

c++ - why getenv() can get name resolved without a std::? -

this question has answer here: why , how rand() exist both in global , std namespace in cstdlib? 2 answers getenv() has c++ implementation can included in header file . member of namespace std. however, getenv() function can resolved correctly in code without std::getenv(), means follow program can compiled , run without error , warning. why getenv() name member of namespace std can resolved without std::? os , compiler ubuntu 12.04 i386 , g++ 4.8.1 respectively. #include <cstdlib> #include <iostream> int main() { char * path_env; path_env = getenv("path"); //without name resolve operation std::getenv() std::cout << path_env << std::endl; return 0; } try use search before asking questions. duplicate of why , how rand() exist both in global , std namespace in cstdlib? c++11 standard: d.5 c standard lib

ruby on rails - ReactJS with dynamic type objects -

i working on project convert of rails view layer reactjs. 1 of challenge have render list of dynamic type of objects (objects using sti). for example, trying render bag of fruits, , each fruit has specific partial views in rails. in rails, fruits.each |fruit| #fruit.type orange, apple, banana, etc. render 'fruits/' + fruit.type end how do in reactjs? possible? you can create object. var things = { foo: foocomponent, ... }; and component that. var key = 'foo'; var component = things[key]; return <component /> note variable must start uppercase letter if you're using jsx, otherwise assume mean html element <component></component> . or don't use jsx here. react.createlement(things[key], null);

java - Adding JPanels to JFrame? -

the while loop in code below not displaying jpanels in gui frame. correct way this? appreciate help. don't worry code does. import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; import javax.swing.*; public class green { public static int[] values = new int[100]; public final int color_range = 150; public static int count; jframe window = new jframe("green values"); static jpanel main_panel = new jpanel(); static jpanel green_panel; public green() { window.setsize(600, 600); window.setvisible(true); main_panel.setvisible(true); window.setdefaultcloseoperation(jframe.exit_on_close); window.pack(); } public static void main (string[] args) throws filenotfoundexception { green g = new green(); scanner sc = new scanner(new file("green.txt")); int = 0; while(sc.hasnextint()) { values[i++] = sc.nextint(); count++; jpanel green_panel = new jpanel(); // ma

java - Table not updating on update though returning the opposite -

i have problem sqlite table "views" doesn't update upon update query. the views table constructed follows, 2 foreign keys making identifying primary key: create table views (description text, modulesid integer not null references modules(modulesid), eventid integer not null references events(eventid), primary key (modulesid, eventid)); using following code attempt, , appear, succeed in updating table, returned integer takes result of 1. private sqlitedatabase database; public void updateviews(string description, int modulesid, int eventid) { contentvalues values = new contentvalues(); values.put(mydatabasemanager.views_description, description); string = "modulesid = " + modulesid + " , eventid = " + eventid; int = database.update(mydatabasemanager.table_views, values, where, null); } so. int returned 1, indicating row indeed updated. attempt retrieve rows find description of supposedly updated row still null.

jquery stopImmediatePropagation does not prevent event from executing function twice -

my problem code gets executed twice. have textarea pops jquery dialog(when dot typed). $('#mytext').keydown(function(e){handlekeys(e);}); function handlekeys(e){ if(e.keycode == 190){openintelli(e,null);}} when user keeps typing keys, listened widget of dialog with widget.unbind('keypress'); widget.on('keypress',function(event) {event.stopimmediatepropagation();rearrangeintelli(event);}); in rearrangeintelli, dialog closed, key typed inserted in teaxtarea, intelli dialog box opened again openintelli() function rearrangeintelli(event){ console.log('rearrangeintelli'); //event.stopimmediatepropagation(); tried put here, no effect //alert('key:'+event.which); var key=string.fromcharcode(event.which); closeintelli(); inserttextatcursor(key); openintelli(event,key); } it works fine, untill want close dialog: if(key=='k'){closeintelli();} then closes , inserts last key again, , that