Posts

Showing posts from March, 2013

How to know which button was clicked in winforms c#? -

Image
okay little bit tricky explain. i'm working on basic time table form. i have 7 buttons, named btnmontime , btntuetime , on till btnsuntime based on days of week. on each button click, pop window (winform) opens lets user select time through datetimepicker control. time parsed string , stored. there accept button on popup when pressed, popup closes , label beside particular day stating time posted. ` now know how 1 particular day, thing have 1 single function doing label creating. how know time button clicked place @ right place? this code come with: private void btnaccept_click(object sender, eventargs e) { formpopup.time = timepicker.value.toshorttimestring(); //label1.text = formpopup.time; label newlabel = new label(); newlabel.text = formpopup.time; newlabel.location = new system.drawing.point(205 + (100 * formtimetable.cmontime), 78); formtimetable.cmontime++; newlabel.size = new system.drawing.size

Android login and authenticate facebook user into a backendless mbaas application -

i have done upto code below , can succesfully authenticate , login facebook user. i have compile 'com.backendless:backendless:3.0.15.1' in build gradle. private facebookcallback<loginresult> mcallback = new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { // mdialog.dismiss(); graphrequest request = graphrequest.newmerequest( loginresult.getaccesstoken(), new graphrequest.graphjsonobjectcallback() { @override public void oncompleted(jsonobject object, graphresponse response) { log.e("response: ", response + ""); user = new user(); user.facebookid = object.optstring("id"); user.name = object.optstring("name"); user.email = object.optstring("email");

ios - Ionic App: Received memory warning. Message from debugger: Terminated due to memory issue -

i build app ionic framework, can download here https://itunes.apple.com/us/app/mdz-diario/id1087454519?ls=1&mt=8 when scroll bottom , navigate differents pages , tabs app terminated unexpectedly, , when debug app read on console next message: 2016-04-24 19:29:08.524 [683:210647] received memory warning. message debugger: terminated due memory issue the console not log thing more, , don't have more information share. someone, maybe have experience kind of problems can me solve this. thanks i think (if in hurry) disable ionic cache between tabs/pages. maybe give upper hand while think in way solve issue.

php - MySQL - Find points using spatial polygons (boundaries) -

i want select photo based on location (lat/lon) when else searches country or city. eg: photo's location 12.127, 42.127 -> request "san francisco" -> select points inside area (a example instagram photo linked both city + country) right looking use polygons find locations based on city/country. not sure how use , store polygons in database. here visual steps (not sure if that's right technically) get polygons/areas based on city/country table1 find points table2 inside polygon table1 if these steps correct, couldn't find resources polygons cities or countries please include examples + table structures , explanations on how implement this thanks :) mysql quite time has been supporting geospatial data types , functions. you can store city or other place polygon , can use 1 of within() or contains() functions (there 3 of each) test if point within city. mysql documentation contains great deal of examples on data types , funct

android - Convert base64 string to Image in Java -

i have image being sent me through json string. want convert string image in android app , display image. the json string looks this: "data:image\/png;base64,ivborw0kggoaaaansuheugaaavi..." note: truncated string ... i've got function (i think) converts string image. doing right? public bitmap converttoimage(string image){ try{ inputstream stream = new bytearrayinputstream(image.getbytes()); bitmap bitmap = bitmapfactory.decodestream(stream); return bitmap; } catch (exception e) { return null; } } then try display on android activity this string image = jsonobject.getstring("barcode_img"); bitmap mybitmap = this.converttoimage(image); imageview cimg = (imageview)findviewbyid(r.id.imageview1); //now try setting dynamic image cimg.setimagebitmap(mybitmap); however, when this, nothing shows up. don't errors in logcat. doing wrong? thanks i

python - Printing two values using Runge Kutta Method -

i trying print b , c code, not having luck. if correct, code should output several points step size of 0.05, not seeing it. know how print 2 values code? import math def rk3(a, b, c, fa, fb, fc, hs): a1 = fa(a, b, c)*hs b1 = fb(a, b, c)*hs c1 = fc(a, b, c)*hs ak = + a1*0.5 bk = b + b1*0.5 ck = c + c1*0.5 a2 = fa(ak, bk, ck)*hs b2 = fb(ak, bk, ck)*hs c2 = fc(ak, bk, ck)*hs ak = + a2*0.5 bk = b + b2*0.5 ck = c + c2*0.5 a3 = fa(ak, bk, ck)*hs b3 = fb(ak, bk, ck)*hs c3 = fc(ak, bk, ck)*hs ak = + a3 bk = b + b3 ck = c + c3 a4 = fa(ak, bk, ck)*hs b4 = fb(ak, bk, ck)*hs c4 = fc(ak, bk, ck)*hs = + (a1 + 2*(a2 + a3) + a4)/6 b = b + (b1 + 2*(b2 + b3) + b4)/6 c = c + (c1 + 2*(c2 + c3) + c4)/6 return a, b, c def fa2(a, b, c): return 0.9*(1 - b*b)*a - b + math.sin(c) def fb2(a, b, c): return def fc2(a, b, c): return 0.5 def vdp2(): a, b, c, hs = 1, 1, 0, 0.05 while (c&l

javascript - Errors while parsing invalid JSON passed from PHP to AJAX -

i'm trying parse json sent php. json: [{"id":"1","value":"1"},{"id":"4","value":"1"},{"id":"2","value":"1"},{"id":"3","value":"1"},{"id":"4","value":"1"}] i'm trying parse id , pass javascript function , i'm continuously calling php. when tried $.ajax , $.get , $.getjson , used json.parse , parsejson , error: uncaught syntaxerror: unexpected token < because json looks this: id: id: id: html> 1id: 4id: 1id: 2id: 3id: 4id: id: id: > i tried fix using json.stringify , caused error: cannot use 'in' operator search 'length' in , i'm stuck , have no idea how fix this. test.php: <?php $link = mysql_connect("localhost", "root", "password"); if (!$link) { die('could not conn

delphi - KBMMW master detail relationship -

i have kbmmwclient master-detail relationship using elevatedb on remote server. when posting data client after inserting new data entry, indexed field detail table won't save - saved null - if try force value in beforepost event. if manually insert field value (integer) on server, master -detail relationship works fine on client. why won't post indexed field? other fields post , resolve fine. check setting of updateinsertautoincfields:boolean on resolver. default false.

python - TensorFlow: simple recurrent neural network -

Image
i've built neural networks tensorflow, basic mlps , convolutional neural networks. want move on recurrent neural networks. however, i'm not experienced in natural language processing. therefore tensorflow nlp tutorials rnns not easy read me (and not interesting, too). basically want start off simple, not lstm. how 1 build simple recurrent neural network, elman network, in tensorflow? i able find gru- or lstm rnn examples tensorflow, nlp. know of simple recurrent neural network tutorials or examples tensorflow? this figure shows basic elman network, called srn (simple recurrent network): one option use built-in rnncell located in tensorflow/python/ops/rnn_cell.py . if don't want can make own rnn. rnn train using back-propagation through time. try unrolling network fixed number of steps, e.g. consider input sequences of length ten. can write loop in python of matrix multiplications each step of network. each time can take output previous step , concat

swing - Java Program says that sound file is not there -

i coding piano in java , used have entire class where, when note pressed specific method in class called specific note. in order shorten code (still working on part), used integers of boolean array made decide note. example, if boolean[1] set true , i'd call method integer , based on integer, string set name of sound file. problem having says file not there, , know fact is. can me out here? import java.awt.event.*; //imports import java.awt.color; import java.awt.graphics; import java.awt.font; import javax.swing.*; import java.io.file; import java.util.arrays; import javax.sound.sampled.*; public class pianogame extends jframe{ //jframe class public pianogame(){ super("pianogame"); setsize(1000,600); setlocation(400,50); setresizable(true); setdefaultcloseoperation(dispose_on_close); pianogamecontent pgb = new pianogamecontent(); setcontentpane(pgb); setvisible(true); } public static vo

java - How to create your own button and Use it with Scene Builder for javafx -

hello i've been curious know possible create own button, in example in photoshop. use "custom button" in place of default ones in scene builder. or there import function can use custom button? started using scene builder not familiar around can , cant do. thank you! being specific want mold imagine shape. use molded image button. not want use tradition button shape instead custom shape. im not sure if possible tips grateful! you can style button using css . if such styling insufficient purposes, can create custom button skin . if need additional properties button, can subclass button or buttonbase (this how javafx internally implements other button-like things additional properties such checkboxes, togglebuttons, radiobuttons, etc). either way scene builder doesn't care, there nothing special in scene builder , either option works scene builder. use scene builder place "normal" buttons in application's fxml files , set appropriate

xamarin.android - CoAP.NET for Xamarin -

my project need use coap.net. after adding coap.net in pcl, android or ios project report error when building. "xamarin.android.common.targets: error: exception while loading assemblies: system.io.filenotfoundexception: not load assembly 'common.logging, version=3.0.0.0, culture=neutral, publickeytoken=af08829b84f0328e'. perhaps doesn't exist in mono android profile?" it seems not support common.logging library, cause add in parts of solution, , cannot added. although, common.logging.core can added. in ios project choose linker behaviour "don't link", , can builded. in android project, won't work. does xamarin work coap.net? if not, how use coap? i assume mean library ? appears include ios version of library, not 1 android. can either try build source android (or pcl) library, fixing issues find, or contact author , ask them android support. if can find native android (java) implementation, created binding library allow u

javascript - 'Promise' is undefined in IE -

i'm getting 'promise' undefined error in ie. why , how can solve this? add like <script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.5/bluebird.min.js"></script> to <head>...</head> this pull in external bluebird promise library, able use promise on ie

PHP to Display JSON/HTML Return -

so i'm using php display data api outputs json. 1 of json data fields has output includes html used format text. problem how use php display json have returned data html in render html. here's php... echo "description:".$results['description']."</br>"; the ['description'] field, returns information such as.. <p>this example of returned description.<br> includes html.</p> so how break out of php display return data's html? decode html. read php html_entity_decode() then can echo "description:".html_entity_decode($results['description'])."</br>";

javascript - How to match space, newline in regexp -

this question has answer here: how use dotall flag regex.exec() 4 answers string content <head> <meta charset="utf-8"> <title></title> <!--@require a.css--> <!--@require bower/jquery--> <!--@require /build/bundle--> <!-- @require bootstrap @require bootstrap.css @require bootstrap.font --> </head> js var content = ...; var reg = /<!--[\s\t\n]*?@require (.+?)[\s\t\n]*?-->/g; var r; while((r = reg.exec(content)) != null) { console.log(r[1]); } output a.css bower/jquery /build/bundle it's not match last block, miss in reg expression. (dot). matches character except newline , that's why last string not matching. can use [\s\s]* or [^] matching character. ( ref : matching multiline patterns ) var content = `<hea

java - Solution to enum type with too many fields? [Improvement] -

as project gradually expanded, exited enum type need expand fields. example, there 1 enum class named ecityarea, used store city related informs, @ beginning city name necessary, need state informs, alias, image location , db alias etc. enum fields come little large, following codes : ecityarea(string name, string state, string alias, string imagelocation, string imagefolder, string imagealias, string dbalias) all developers can find there many fields, later there may more fields. predictably, ecityarea large , difficult read, there should solutions dilemma. just now, got 1 idea , share you. itegrate of fields enum class. following: ecityareaimagerelated(string imagelocation, string imagefolder, string imagealias) ecityarea(string name, string state, ecityareaimagerelated imagerelated, string dbalias) any other solutions provided? thanks.

c++ - exception thrown with sqlite select statement -

i willing access particular element present in coloumn in sqlite database in order achieve have used select statement char *query = {0}; strcat(query, "select ");//exception thrown here strcat(query, (char*)arr);//the value asscessed strcat(query, " cars"); but throwing exception in ucrtbased.dll why? update i have referred answer here , tried this, char* line1 = "select "; char* line2 = (char*)arr; char* line3 = " cars"; size_t len1 = strlen(line1); size_t len2 = strlen(line2); size_t len3 = strlen(line3); char *query = (char*)malloc(len1 + len2 + len3 + 1); if (!query) abort(); memcpy(query, line1, len1); memcpy(query + len1, line2, len2); query[len1 + len2 + len3] = '\0'; but found i've done wrong(because out put jumps else

VS CODE error S5057 cannot find a tsconfig.json file at the specified directory: '.' -

i having fits getting visual studio code going angular 2 starter project. i have set tsconfig.json ... { "compileroptions": { "target": "es5", "module": "system", "moduleresolution": "node", "sourcemap": true, "emitdecoratormetadata": true, "experimentaldecorators": true, "removecomments": false, "noimplicitany": false }, "exclude": [ "node_modules", "typings/main", "typings/main.d.ts" ] } immediately came across error [ts] experimental support decorators feature subject change in future release. set 'experimentaldecorators' option remove warning. class appcomponent i not identify going on ran build , got error. error ts5057: cannot find tsconfig.json file @ specified directory: '.' this error explains why getting errors component decor

How to get access to Julia function calling it from matlab engine using MATLAB.jl -

i have problem calling julia functions matlab engine using matlab.jl . in project have specific function must call outside of engine. in simpliest form problem can demonstrated this: using matlab function julia_func(arg::integer) return arg end @matlab begin ans = exp(julia_func(3)) end @mget ans @show ans after performing code get: undefined function or variable 'julia_func'. how make work?

java - Design and implement a class called Card that represents a standard playing card -

here issue, have created class incomplete because having issues on 2 levels. might tired...so bear me please. i having issue trying resolve having 5 random cards generate , not 1 more important no duplicates. i still new every time try add main says variables haven't been initialized. wtf...this biggest program/ first class have had write , stuck. help please import java.util.*; public class card { private int suit; // initializes 2 variables card private int value; public card() // constructor of card creates random suit , value card { random num = new random(); suit = num.nextint(4); value = num.nextint(13)+1; } public card(int card_suit, int card_value) // constructor of card takes int representing suit , value { suit = card_suit; value = card_value; } public int getvalue() // returns numeric value of card {

mysql - creating sessions and validation of data in php -

i created php script retrieving data table , storing data upon selection in table submitting form. have trouble in creating sessions storing values , validation of data. how can create session , validate data upon selection of items in drop down. <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "leave-form"; $dbh = new pdo("mysql:host=$servername; dbname=$dbname", $username, $password); $dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception); if (isset($_post["submit"])) { try { $sql = "insert authority (emp_name, repo_auth, contr_auth) values ('" . $_post["emp_name"] . "','" . $_post["repo_auth"] . "','" . $_post["contr_auth"] . "')"; if ($dbh->query($sql)) { echo "<script type= 'text/javascript'>alert('new record inserted

jquery - Javascript generate recursive JSON object from nested UL LI check box -

i have situation generate json object below structure nested ul li checkbox when checked/uncheck. <ul class="tree" id="tree"> <li><input type="checkbox" name="team1" value="team1" checked="checked">team1 <!-- , should check here --> <ul> <li><input type="checkbox" name="one" value="team1 child1" checked="checked">team1 child1</li> <li><input type="checkbox" name="two" value="team1 child2">team1 child2</li> <li><input type="checkbox" name="three" value="team1 child3" checked="checked">team1 child3 <!-- should check here --> <ul> <li><input type="checkbox" name="four" value="team1 child3 - child1&q

spring integration - int-jms:message-driven-channel-adapter and acknowledge="transacted" -

i have message driven channel adapter configured pick messages queue acknowledge set transacted. possible send different messages different queues down stream holding same transaction have database inserts between in flow?. if message delivery fails queue , transaction must roll (including database entries) message send other queues. example : queue(receive)--->insert db-->send to(queue1,queue2.. etc sending different message each queue) if send call fails queue1, queue2 etc transaction should roll back.. i able configuration single queue (ie queue1). how if multiple queues involved , holding transaction boundaries. thanks vaidya below configuration <int-jms:message-driven-channel-adapter id="messagedrivenadapter" channel="injmschannel" destination="testq" concurrent-consumers="5" max-concurrent-consumers="10" acknowledge="transacted"

excel - Search a term in one cell on a specific website then return resulting URL -

so have little experience web queuries in vba. currently, have column of gecodes require satellite image of location. i want use website : http://google-maps.pro/satellite , search in search bar, return resulting url. have " http://google-maps.pro/satellite# " in 1 cell , concatenate geocode, not work (although works other websites). i not sure if web queury, while learning see web queury scripts seem focus on returning html table, whereas want url. looking for? wasting time learning web queury(ing?) vba? edit: solved, read url wrong.

c# - is msdn wrong when it says ProcessWindowStyle.Hidden requires UseShellExecute=false? -

Image
is msdn wrong when says use processwindowstyle.hidden processstartinfo.useshellexecute property must false ? https://msdn.microsoft.com/en-us/library/system.diagnostics.processwindowstyle(v=vs.110).aspx firstly it's not processstartinfo.useshellexecute, it's instance of processstartinfo dot useshellexecute aside. secondly, , importantly. find opposite true if create e.g. winforms application, code cmd window appears processstartinfo psi = new processstartinfo(); psi.filename = "cmd.exe"; psi.useshellexecute = false; psi.windowstyle = processwindowstyle.hidden; process.start(psi); if do processstartinfo psi = new processstartinfo(); psi.filename = "cmd.exe"; psi.useshellexecute = true; //default psi.windowstyle = processwindowstyle.hidden; process.start(psi); then cmd window doesn't appear. so seems processwindowstyle.hidden requires useshellexecute true/default. not false. opposite of msdn says. is msdn wrong in documentation,

html - Move Angular Material Dropdown menu to the left -

Image
i using angular material. have created navigation bar , dropdown menu. it looks this: i move dropdown left-hand side. now, appears around centre. html code: <md-toolbar layout="row" class="md-whiteframe-z3" style="padding: 0px;margin:0px;float: left;"> <h2>material navbar</h2> <md-menu> <md-button md-menu-origin ng-click="$mdopenmenu()">dropdown</md-button> <md-menu-content width="2"> <md-menu-item> <md-button>help</md-button> </md-menu-item> <md-menu-item> <md-button>about</md-button> </md-menu-item> </md-menu-content> </md-menu> <md-button aria-label="go back"> go </md-button> <md-button>item 1</md-button> <md-button>item 2</md-button> &

server - How to check if SSAS service is responding -

Image
is there way check if analysis service installed on server not responding , requires restart ? been looking @ ssas dmvs : select * $system.discover_connectionsgo select * $system.discover_object_memory_usage select * $system.discover_locks but dont feel answer question. thanks in advance. try this: here mssqlserverolapservice name of sql analysis service , can found exec xp_servicecontrol n'querystate',n'mssqlserverolapservice' you can check status of service , take decision accordingly.

What is the ClojureScript analogue of typeof ... undefined from JavaScript? -

i'm seeing lots of code using pattern: if (typeof a.b === 'undefined') { ... now i'm translating to: (if (nil? (-.b a)) ... is appropriate - or losing crucial data? my question is: what clojurescript analogue of typeof ... undefined javascript? for checking possibly undefined references can use cljs.core/exists? : (when-not (exists? js/unknownreference) ...)

javascript - dojox/widget/Toaster to show latest one first -

i'm using dojox/widget/toaster show toaster message, have declared as, <div data-dojo-type="dojox/widget/toaster" id="toast2" data-dojo-props='positiondirection:"br-up", messagetopic:"/app/notif", duration:"8000"'> </div> and im calling javascript different places as, connect.publish('/app/notif', [ "<b><font color=\"red\">"+ "toaster message" +". </font></b>" ]); but im able see latest message on bottom of toaster, i need @ top, can suggest how it. try use tr-down instead of br-up property positiondirection . options positiondirection message slides screen are: ["br-up", "br-left", "bl-up", "bl-right", "tr-down", "tr-left", "tl-down", "tl-right"] if issue persists, please cons

python - Eventlet vs Greenlet vs gevent? -

i'm trying create gui framework have event-loop. threads handle ui , event handling. i've searched little bit , found these 3 libraries , i'm wondering 1 better use? pros , cons? i use 1 of these 3 library or create create myself using python threads , or concurrent library. i appreciate sharing kind of experience, benchmark , comparison. you don't want greenlet purpose, because it's low level library on top of can create light thread libraries (like eventlet , gevent). eventlet, gevent , more similar libraries provide excellent toolset io-bound tasks (waiting read/write on file, network). likely, of gui code wait other threads (at point green/light/os thread irrelevant) finish, perfect target above mentioned libraries. all green thread libraries same. try , decide 1 suits project best. but it's possible you'll need extract things separate os thread due requirements of os level gui layer. considering , better implementation of thread

postgresql - How is my Ruby on Rails app able to access the database without the password? -

i'm getting started ruby on rails. i'm building hello world app , i'm using postgresql. used following command create app: rails new rails-hw -d postgresql i created database user using createuser -s pguser , set password. i edited development section of config/database.yml, using username , password of user created. however, seems use password in database.yml file doesn't matter , app able access data in database. why ignoring password? because current postgres installation configured allow connections localhost. check pg_hba.conf you'll find this: # type database user ip-address ip-mask method host 127.0.0.1 255.255.255.255 trust which says "allow connections postgres users , databases 127.0.0.1." more specifics can found in docs: http://www.postgresql.org/docs/9.1/static/auth-pg-hba-conf.html (see example 20-1)

Ruby on Rails - Chartkick - Highcharts drilldown -

i have been playing around chartkick gem using highcharts.js , wondering if had been able drilldowns work. if options did pass in work? i think looking http://www.highcharts.com/demo/column-drilldown hope helps .

java - Spring data repository sends null as bytea to PostgreSQL database -

after switching mysql postgresql found out sql query (@query in spring data repository interface) not work anymore. issue caused null value being sent bytea , i'm getting following exception: caused by: org.postgresql.util.psqlexception: error: operator not exist: bigint = bytea hint: no operator matches given name , argument type(s). might need add explicit type casts. repository @query: public interface winerepository extends pagingandsortingrepository<wine, long> { @query(value = "select * wine w (?1 null or w.id = ?1)", nativequery = true) wine simpletest(long id); } simple test: logger.warn("test1: {}", winerepository.simpletest(1l)); //ok logger.warn("test2: {}", winerepository.simpletest(null)); //psqlexception in real case have multiple parameters can null , prefer not checking them in java code sending them sql query. have checked questions here on stackoverflow found none answer spring data repository @que

ajax cross domain not working in jquery -

error : response preflight request doesn't pass access control check: 'access-control-allow-origin' header contains multiple values ' http://localhost:8080 , *', 1 allowed. origin ' http://localhost:8080 ' therefore not allowed access. $("#selector3").autocomplete({ source: function(request, response) { $.ajax({ url: "http://example.com/"+$("#selector3").val(), type: "get", datatype: "json", data: request, processdata: true, data: {}, headers: { "access-control-allow-origin" : "*", "access-control-allow-headers": "origin, content-type, accept" },

Upgrading Rails 3.2 to Rails 4 and Params -

i upgrading project rails3 rails4 tutorial: railscasts i have model: class test < activerecord::base validates :content, :presence => true, :length => { :minimum => 2 } validates :name, :presence => true, :length => { :minimum => 2 } validates :value, :presence => true end after upgrading, in rails console tried create new test object test.create(name: "asd", content:"asd", value: 5) and got warning: can't mass-assign protected attributes achievement: name, content, value (0.2ms) begin (0.2ms) rollback => #<test id: nil, name: nil, content: nil, value: nil, created_at: nil, updated_at: nil> looks forgot upgrade something. tried re-create rails application overriding config , other rails files, nothing changed. i created new empty project , copied model files. working ok. if i'll add config.active_record.whitelist_attributes = false to config/application.rb, upgrad

Ruby splat and << operators -

i want this: a << *b but happens in irb: 1.9.3p327 :020 > => [1, 2, 3, 4] 1.9.3p327 :021 > b => [5, 6, 7] 1.9.3p327 :022 > << *b syntaxerror: (irb):22: syntax error, unexpected tstar << *b ^ am missing something? look reason here : = [1, 2, 3, 4] b = [5, 6, 7] p a.<<(*b) # ~> -:3:in `<<': wrong number of arguments (3 1) (argumenterror) # ~> -:3:in `<main>' << method expects 1 argument.so below splat( * ) operator,which create 5,6,7 ,which << method not expect,rather expects 1 object. design of ruby don't allowing * before b . = [1, 2, 3, 4] b = [5, 6, 7] p << * # ~> -:3: syntax error, unexpected * = [1, 2, 3, 4] b = [5, 6, 7] p << *b # ~> -:3: syntax error, unexpected * # ~> p << *b # ~> ^ that why 2 legitimate errors : wrong number of arguments (3 1) (argumenterror) syntax error, unexpected * pro

java - how to improve performance of application on spark cluster? -

i have 3 node cluster (1 master + 2 worker) assigned driver-memory = 12gb assigned executor-memory = 12gb input data size = total 12gb (15 files, each of 800 mb) two files of 400 mb , 70 mb store in 2 maps , broadcast workers. each record input data lookup in broadcast-ed maps match return pairrdd ,say , javapairrdd < object1, list< object2 > > r1 . from r1 need 2 outputs, first, r2 = r1.map(output1mapper()) for second, need output value list < object2 > in file named key object1 r1. hence collect keys in set < object1 > keys. and each object1 in keys lookup() in rdd r1 , output list < object2 > in output file. problem: if load 15 files in rdd process per above fails error: java heap space, increase spark.driver.maxresultsize 3gb again fails. i used way, perform above operations on each input files generate outputs , taking 35 mins approx. on cluster. need pointers on how increase performance , approach best.

php - How to talk between HTTP request & cli class objects -

i have application running that's listing http request. each request passed single page framework object $app instantiated , takes care of routing / controller / model etc. now have class object instantiated via. cli script lets call $cliapp problem how make both object talk each other. $app instantiate every-time there new request. but $cliapp instantiate once when script ran. scripts runs in loop via $loop object php react event loop . cli app running websockets. want http & sockets communicate via. http api. p.s. : right have 1 solution use message queueing e.g. 0mq etc. seems overkill since i'm not looking scale , keep simple. another solution i'm trying , feels right share sptstorageobject between threads created $http request , thread created $cli request. maybe question of dependency injection , i'm having troubles share $store object. if understand correctly, have (assumptions noted): a normal php web app communicates on h

javascript - Change the value of a checkbox inline using the onChange attribute -

am doing wrong or impossible? want set value of checkbox "0" if unchecked, , "1" if checked <input type="checkbox" onchange="function() {$(this).val(this.checked? '1': '0')};" /> note: know how outside of onchange event or doing onchange="takecareofthis()" , i'm looking inline you need set statement executed. <input type="checkbox" onchange="$(this).val(this.checked? '1': '0');" />

python 3.x - Pandas combines values from two columns and compare for uniqueness -

i want combine/concatenate values 2 columns of dataframe , compare uniqueness of these values, e.g. col1 col2 row1 val11 val12 row2 val21 val22 row3 val31 val32 i want concatenate val11 , val12 , val21 , val22 , val31 , val32 , compare val11+val12 , val21+val22 , val31+val32 uniqueness, i.e. check if 3 concatenated values equal. the dtype of col1 , col2 str . i wondering whats best way this. you can use duplicated checking uniqueness of concanecated columns col1 , col2 boolean indexing : print df col1 col2 row1 val11 val12 row2 val21 val22 row3 val31 val32 row3 val31 val32 ser = df.col1 + df.col2 print ser row1 val11val12 row2 val21val22 row3 val31val32 row3 val31val32 print ser.duplicated(keep=false) dtype: object row1 false row2 false row3 true row3 true print ~ser.duplicated(keep=false) row1 true row2 true row3 false row3 false dtype: bool print df[~ser.duplicated(keep=fa

javascript - How to return a value in the only non-blank column in a range for sendEmail function in Google App Scripts -

the issue is: can't find way return value 'course' because each form submission generates new row name of course spread on columns e m (column 4 through 12). in each row, there 1 'course' name in 1 of columns e m (e.g in f) , other columns blank. (users can select 1 course , other columns blank. have categorize courses 9 columns because of page breaks in order split sheer number of options users select course from.) how return value of non blank cell e m entered in email ? i advised insert entire findcourse function inside of sendemail function before of other code. did have still been receiving failure notifications of google app scripts: typeerror: cannot read property "values" undefined. (line 14, file "code") (referring var value = e.values[i]) the full code below: function sendemail(e) { function findcourse (e){ var coursetotake; //loop through values ( var = 4; <=12; ++){ //pull value variable

Ruby OOP correct concept? -

the exercise questions below answers. #create tree class rings attribute , getter method. #trees create ring every winter passes #it should have bear_fruit? method should return true if #has fruit year. tree produces fruit when has #more 7 rings less 15, false otherwise. #the class should have winter_season method increases #rings attr 1. can give me constructive criticism on code? class tree attr_accessor :winters, :rings, :bear_fruit? def initialize(winters, rings) @winters = winters @rings = rings end def rings_created @winters = 0 @rings = 0 while @winters == @rings @winters +=1 @rings +=1 break if @winters == 100 end end end def bear_fruit if @rings > 6 || < 16 @bear_fruit? = true else @bear_fruit? = false end end def winter_season @winters = 0 @rings = 0 while @winters < @rings @winters +=1 @rings +=2 break if @winters == 100 end

One to many/inverse relationship - Laravel -

this seems simple enough can't seem figure out. i have below models city -> hasmany locations locations -> hasmany restaurants restaurants -> belongsto locations this means restaurant linked city via locations now want find restaurants in particular city based location provided not restricted location rather city . the values provided city name , location name. can city_id , location_id // city locations $city = city::with('locations')->where('value', $c)->first(); $city_id = $city->id; // location id $location = location::where('value', $l)->first(); $location_id = $location->id; so $restaurants query should find restaurants location part of location of $city . how can achieve this? you can define hasmanythrough relationship - class city extends model { public function locations() { return $this->hasmany('app\location'); } public function restaur

angularjs - Keep menu open after selecting a item in angular -

my menu closing after click on toggleshare button. how can prevent this. use angularjs angular material here code: <md-menu> <md-button ng-click="$mdopenmenu()"> </md-button> <md-menu-content> <md-menu-item> <md-button ng-click="toggleshare()"> </md-button> </md-menu-item> </md-menu-content> </md-menu> you can use md-prevent-menu-close attribute stop menu closing suggested in offical doc . here how write code <md-menu> <md-button ng-click="$mdopenmenu()"> </md-button> <md-menu-content> <md-menu-item> <md-button ng-click="toggleshare()" md-prevent-menu-close="md-prevent-menu-close"> </md-button> </md-menu-item> </md-menu-content> </md-menu> here working exam

node.js - Cross compile nodejs modules to Windows with node-gyp -

due compiler problems on windows 7 x64 machine, have compile code on linux arm box. how can cross compile node modules node gyp? in advance. there 2 problems here. first, have cross-compiling set go arm box windows. this should help: http://wiki.wxwidgets.org/cross-compiling_under_linux then (assuming compilers , linker set up: cxx, etc.), need specify architecture when running node-gyp: node-gyp --arch x64 rebuild that should it.

apache - .htaccess forward 'www.w.' to 'www.' -

i have weird issue google indexing several of site's pages 'www.w.example.com' causing issues security certificate. while i'm looking solution, i'd redirect using .htaccess can't seem work. currently have: rewriterule ^(.*)www\.w\.(.*)$/$ https://www.$1/$2 [r=301,l] but doesn't seem work.. i have multiple domains site ideally needs redirect correct domain e.g. https://www.example1.com or https://www.example2.com you need use rewritecond matching host name: rewriteengine on rewritecond %{http_host} ^www\.w\.(.+) [nc] rewriterule ^ http://www.%1%{request_uri} [r=301,l,ne] however might still ssl cert warning because cert negotiation happens before mod_rewrite rules invoked.

busybox - how I choose between FTPclient in java vs linux binary ftpget to download file from ftpserver -

i want download file ftp server have 2 ways 1)using ftpclient in java using commons-net-3.0.1.jar 2)linux binary ftpget of busybox now want know utilities should use in application? mean parameter should have consider while selection right method download file ftp that depends on requirements; there can't "generic" answer here. if using java library, have more control on whole "process" (you can call methods using known types, stuff that). if calling binary host operating system, means have dependency towards element harder control 3rd party java library. in both situations, have different sets of dependencies, application has check in end (and might easier ship java application version of apache commons library; versus making sure got specific ftp binary on customer systems).