Posts

Showing posts from March, 2015

html - cshtml radiobuttons disable -

Image
i'm developing mvc project, have cshtml file has radiobuttons page. when disable 1 of them, other one's position changed. sliped little left (font decrease) how can prevent ? my radiobuttons: <td> @html.radiobuttonfor(model => model.geta, true, new {id = "9", onclick = "", data_bind = "value:geta" }) true @html.radiobuttonfor(model => model.getb, false, new {id = "10", onclick = "", data_bind = "value:getb" }) false </td> i solved this: in project f_disable function load disable.png disabled radiobutton , create new id. reached attributes new id , changed disable.png width , padding in javascript. document.getelementbyid("9_readonly").style.width = "15px"; document.getelementbyid("10_readonly").style.width = "15px"; document.getelementbyid("9_readonly").style.paddingleft = "3px"; document.getelementbyid("1

python - How can I properly copy nested dictionary objects? -

i'm working on project python 2.7 have "complex" dictionary structure, , trying this: generic_dict = { 'user': {'created': {}, 'modified': {}, 'errors': {}}, 'usermon': {'created': {}, 'modified': {}, 'ignored': {}, 'errors': {}} log_data = { 'esp': generic_dict, 'por': generic_dict, 'sui': generic_dict, 'ben': generic_dict, 'mex': generic_dict, 'arg': generic_dict, } i trying use generic dict avoid repeating code have problem if this, when modify of country dicts (esp, ben, por) modifying @ same time. let's assume dictionary empty , this log_data['esp']['user']['created']['today'] = 'asdasdasda' all other dicts have same value generic_dict same of them. print log_data['ben']['user']['created'] output: {'today': 'asdasdasda

Email attachments recorded in Excel -

the macro below designed take x amount of emails, count how many attachments there in each mail , locate file formats. record has found in excel spreadsheet. the macro works perfectly, wanting add in scenario. scenario want add in of if email has more 1 .csv file, shall recorded "multiple" rather "yes". has got ideas implement scenario? if .attachments.count = 0 csv_report = "no" pdf_report = "no" xls_report = "no" end if if .attachments.count > 0 i2 = 1 .attachments.count if lcase(right(.attachments(i2).filename, 4)) = ".csv" csv_report = "yes" goto csvyes 'if .csv file found, skips pdf attachment checker else csv_report = "no" end if next csvyes: i2 = 1 .attachments.count if lcase(right(.attachments(i2).filename, 4)) = ".pdf"

How to parse CSV file values into MatrixEntry in Java/Scala -

i've got code in scala , have change java: import au.com.bytecode.opencsv.csvparser import org.apache.spark.rdd.rdd import org.apache.spark.mllib.linalg.distributed.matrixentry import org.apache.spark.mllib.linalg.distributed.coordinatematrix import org.apache.spark.mllib.linalg.distributed.rowmatrix import org.apache.spark.mllib.linalg.matrix import org.apache.spark.mllib.linalg.singularvaluedecomposition import org.apache.spark.mllib.linalg.vector import scala.collection.immutable.list import java.io._ import java.nio.file.{paths, files} import java.nio.charset.standardcharsets import org.apache.spark.mllib.linalg.matrix import org.apache.spark.mllib.linalg.matrices import org.apache.spark.mllib.linalg.densematrix import org.apache.spark.mllib.linalg.distributed.indexedrowmatrix def exportmatrix(matrix:array[double], filename: string, numcols:int, numrows:int) = { val pw = new printwriter(filename) for(columnindex <- 0 until numcols) { pw.print("word"

python - Identifying a sklearn-model's classes -

the documentation on svms implies, attribute called 'classes_' exists, reveals how model represents classes internally. i information in order interpret output functions 'predict_proba', generates probabilities of classes number of samples. hopefully, knowing (values chosen @ random, illustration) model.classes_ >> [1, 2, 4] means, can assume that model.predict_proba([[1.2312, 0.23512, 6.01234], [3.7655, 8.2353, 0.86323]]) >> [[0.032, 0.143, 0.825], [0.325, 0.143, 0.532]] means, probabilities translate same order classes, i.e. first set of features: probability of class 1: 0.032 probability of class 2: 0.143 probability of class 4: 0.825 but calling 'classes_' on svm results in error. there way information? can't imagine it's not accessible more after model trained. edit: way build model more or less this: from sklearn.svm import svc sklearn.grid_search import gridsearchcv sklearn.pipeline import pipeline, featureunio

ios - Understanding iPhone 5/6 resolution on image.xcassets -

Image
as title says, i'm still confused understand how image.xcassets handles iphone 5/6 images. let me explain better: this menu_empty_list file in image.xcassets. i've been looking answer here in stackoverflow , found this: 1x images original iphone through 3gs - 'standard' resolution devices (3.5" screens) 2x images iphone 4, 4s (3.5" retina screens) , iphone 6. retina 4 2x iphone 5 , 5s (4" retina screens) 3x images new iphone 6+ (5.5" super-retina [3x] screen) this helped me lot question is: if image set background (in short, image covering screen)? how can handle different screen size? have put "2x" square? iphone 4/4s image or iphone 6? only 1 problem iphone 4 , iphone 6 taking same @2x images. so, if want set perfect image devices have try following code : if([[uiscreen mainscreen]bounds].size.height==480) { login_bg.image=[uiimage imagenamed:@"i4_login.png"]; } else if ([[uiscreen mainscreen]b

javascript - jQuery dialog is not working for element created dynamically -

i working jquery dialog. have 1 problem trying solve is: i have created dialog on click of of anchor class , working. after have created 1 more anchor tag same class , on click of new created tag dialog not working. here html: <div id="loader_ajax"></div> <a id="show_hide_window1" class="show_hide_window" href=""> dialog </a> <div class="next_tg"></div> here jquery code: $(function(){ $(".show_hide_window").click(function(){ showdialog(); }); $('.next_tg').html('<a class="show_hide_window" href=""> dialog created jquery </a>'); }); function showdialog() { $("#loader_ajax").dialog({ modal: true, height: 400,width:650,title: title }); return false; } i have tried delegation(event binding) not working. dynamically created anchor give error in console: typeerror: $(...).dialog not funct

selenium webdriver - Chrome extension that performs animation where the user clicks -

i'm coding test webdriver, , need chrome extension shows me making click test (i can't see mouse during test). i'm looking plugin show me (with kind of animation) clicking test inside chrome screen. this can surely out here.

algorithm - How to cluster large datasets -

i have large dataset (500 million) of documents , want cluster documents according content. what best way approach this? tried using k-means not seem suitable because needs documents @ once in order calculations. are there cluster algorithms suitable larger datasets? for reference: using elasticsearch store data. according prof. j. han, teaching cluster analysis in data mining class @ coursera, common methods clustering text data are: combination of k-means , agglomerative clustering (bottom-up) topic modeling co-clustering. but can't tell how apply these on dataset. it's big - luck. for k-means clustering, recommend read dissertation of ingo feinerer (2008). guy developer of tm package (used in r) text mining via document-term-matrices. the thesis contains case-studies (ch. 8.1.4 , 9) on applying k-means , support vector machine classifier on documents (mailing lists , law texts). case studies written in tutorial style, dataset not available.

ios - GCD serial queue with NSTimer, dispatch_sync doesn't wait for the NSTimer to complete -

i'm trying make queuehandler takes object array input executing drive commands on simple double robot. i'm trying use gcd in order serially execute functions, when i'm using dispatch_sync on queue in won't wait until nstimer has run course, continue try , execute commands next object in array. i have 3 functions, 1 initializes nsmutablearray (loadcommands) 2 objects , runs queuehandler , called when toggle switch. queuehandler reads variables objects(type, timing, queuenr) determine type of drive function executed , how long. thought done in switch statement, , figured great if app execute function on main thread(that ok!) should wait until nstimer has run course. thought encapsulating switch case dispatch_sync solve promptly skips next iteration in loop , tries execute next function instead, drive backwards 3 seconds. when test single object in array command executed without trouble. suppose i'm locking main thread somehow. perhaps waiting return value

jquery - Copy Table Cell To Clipboard javascript -

how copy cell clipboard? want user click in cell , cell copied clipboard. i've tried this: <td onclick="clipboard();">hi</td> <script language="javascript"> function clipboard() { holdtext.innertext = copytext.innertext; copied = holdtext.createtextrange(); copied.execcommand("copy"); } </script> <table id="table" class="responsive" style="width:1000px;"> <tbody> <tr> <th>field display-name</th> <th>html identifier</th> <th>is required</th> <th>data type</th> <th>html type</th> <th>html attribute</th> <th>field type</th> <th>event type</th> </tr> <tr> <td>punitprice_pp</td>

javascript - Using translation with jquery in prestashop -

i'm trying translate terms when i'm using jquery inside smarty file. jquery code: else { $("#message").val("{l s='please try clear.'}"); this phrase appears {l s='please try clear.'} in web page , doesn't take consideration translation mode. i know can use js=1 when i'm inside javascript code doesn't work me neither. have idea how use translation in jquery function? it's practice use {literal} tags around js blocks: {literal} <script> /... </script> {/literal} but when need insert smarty js block, won't work; make work have close , reopen tags (looks little bit of hack :) {literal} <script> var txt = '{/literal}{l s='some text'}{literal}' </script> {/literal} also in prestashop templates you'll find; {strip} {addjsdefl name=translation_6}{l s='not found' js=1}{/addjsdefl} {/strip} which create var translation_6 = 'not found&#

Java ternary operator logic explanation -

can please explain line of java code doing? public string gettitlenavcontainer(boolean isthislandingpage) { return isthislandingpage ? stringutils.empty : "title-nav-container"; } i can see doing wondering how modify if landing page 1 thing otherwise else. thanks help. the above line called ternary operator ternary operator takes 3 parameter , sudo code is condition ? statement1 : statement2 condition: part should have valid conditional statement , should return boolean value statement1: if condition true statement1 execute statement2: if condition false statement2 execute now @ code block public string gettitlenavcontainer(boolean isthislandingpage) { return isthislandingpage ? stringutils.empty : "title-nav-container"; } if isthislandingpage true stringutils.empty execute else title-nav-container execute for quick understanding, convert code if-else statement if (isthislandingpage) { return stringutils.

c# - Need help in modifying OWIN (Katana) for running VS2013's MVC WebApplication in Raspberry Pi -

i want run visual studio 2013's default mvc webapplication in raspberry pi 2. managed install mono 4.0.1 , lighttpd web server, , able default mvc webapplication (with no authentication) run on raspberry machine. however, when tried same mvc webapplication "individual authentication", gives following error: system.missingmethodexception: method 'httpapplication.registermodule' not found. after googling, found here method 'registermodule()' not implemented in mono's system.web.httpapplication. , solution rebuild owin. have never done before. used 'git bash' clone katana follow: git clone https://git01.codeplex.com/katanaproject then modified preapplicationstart.cs accordingly, , run 'build' in command prompt, , created microsoft.owin.host.systemweb.dll under project directory. tried replace original dll new 1 in visual studio 2013, , hit f5 try run it, , following errors: the type 'microsoft.owin.iowincontext'

pyqt4 - Detect method by self.sender() in Python -

is there way detect method has run other method detect object self.sender()? for example have method enables checkboxes. on 1 page have 10 on other 15. depending on method b or c call method a, can define 2 scenarios in method a, rather copy code. yes, there way. utilizes inspect module import inspect def echo(): """returns name of function called it""" return inspect.getouterframes(inspect.currentframe(), 2)[1][3] def caller(): return echo() print(caller(), caller.func_name) output: ('caller', 'caller')

Cannot update Stock Module in Odoo -

when use shell update modules, i'm getting these errors: 2015-05-11 21:06:26,987 9822 error db openerp.modules.graph: module purchase: unmet dependencies: stock_account 2015-05-11 21:06:26,987 9822 error db openerp.modules.graph: module portal_stock: unmet dependencies: sale_stock 2015-05-11 21:06:26,988 9822 error db openerp.modules.graph: module warning: unmet dependencies: sale_stock, purchase 2015-05-11 21:06:26,988 9822 error db openerp.modules.graph: module sale_stock: unmet dependencies: stock_account 2015-05-11 21:06:26,988 9822 error db openerp.modules.graph: module stock_account: unmet dependencies: stock the problem changing privileges. how can restore them? this message comes when modify _depends __openerp__.py file of base module in odoo. you should set depended module require stock module , update module via terminal database name. message disappeared automatically.

javascript - ChartJS Doughnut Charts Gradient Fill -

Image
so tried make gradient fill chartjs doughnut chart, works horizontal , not in circle. this code i'm using: var ctx = document.getelementbyid("chart-area").getcontext("2d"); var gradient1 = ctx.createlineargradient(0, 0, 0, 175); gradient1.addcolorstop(0.0, '#ace1db'); gradient1.addcolorstop(1.0, '#7fbdb9'); var gradient2 = ctx.createlineargradient(0, 0, 400, 400); gradient2.addcolorstop(0, '#b5d57b'); gradient2.addcolorstop(1, '#98af6e'); var gradient3 = ctx.createlineargradient(0, 0, 0, 175); gradient3.addcolorstop(0, '#e36392'); gradient3.addcolorstop(1, '#fe92bd'); var gradient4 = ctx.createlineargradient(0, 0, 0, 175); gradient4.addcolorstop(1, '#fad35e'); gradient4.addcolorstop(0, '#f4ad4f'); /* add data doughnut chart */ var doughnutdata = [ { value: 80, color: gradient1, highlight: "#e6e6e6", labe

css - Invert sites div position without changing HTML code -

i have example: https://jsfiddle.net/vz9cean1/ this code html: <div class="patrat1"></div> <div class="patrat2"></div> this code css: .patrat1 { width:100px; height:100px; background:blue; } .patrat2 { width:100px; height:100px; background:red; } @media screen , (max-width: 700px) { //some code reverse div } how can when window less 700px squares change position in between? red above , blue below. this done without changing html, css only. http://i60.tinypic.com/x5tg6v.jpg put picture understand better thanks in advance! afaik way switch position vertically use flex container. css : .container { display: flex; flex-direction: column; } .patrat1 { width:100px; height:100px; background:blue; order: 0; } .patrat2 { width:100px; height:100px; background:red; } @media screen , (max-width: 700px) { .patrat1 { order: 1; } } html :

Dynamic loading of java class for activiti Service Task -

i need dynamically load jar , extract classes classpath, there no need of restarting server. activi service task, java class available jar. tried out below, @ point service task deployed gives error "cannot instantiate packagename.classname. " guess means class cannot found. urlclassloader loader = (urlclassloader)classloader.getsystemclassloader(); log.info("loader" +loader.geturls()); myclassloader l = new myclassloader(loader.geturls()); l.addurl(new url("jar","","file:"+artifactlocation+"!/")); jarfile jarfile = new jarfile(artifactlocation); enumeration e = jarfile.entries(); while (e.hasmoreelements()) { jarentry je = (jarentry) e.nextelement(); if (je.isdirectory() || !je.getname().endswith(".class")) { continue; } // -6 because of .class string classname = je.getname().substring(0, je.getname().length() - 6);

python - Pip install won't install anything "No command by the name pip install" -

randomly seems pip has stopped working following error inside new virtualenv: $ pip install requests==2.6.0 usage: pip command [options] no command name pip install (maybe meant "pip install requests==2.6.0") i've tried following: creating new virtualenv reinstalling virtualenv reinstalling pip reinstalling python checking out repo again which doesn't seem change anything, has else ran issue before? note can pip install outside virtualenv.

parse Javascript json into php -

here json. ia dwr response ( webservice created in java) . { key1 : { date : "today" , items : [ { itemkey1 : "itemvalue1", itemkey2 : "itemvalue2", }, { itemkey1 : "itemvalue1", itemkey2 : "itemvalue2", }, ] } } json lint showing error. if can see key not have "" may that's why can not parse json in php directly. there way oi can parse json , array or directly array. but when transfor this type of json it. in json lint shows proper json. { "key1": { "date": "today", "items": [ { "itemkey1": "itemvalue1", "itemkey2": "itemvalue2" }, { "itemkey1": "itemvalue1", "itemkey2": "itemvalue2" }

sql - First query data is used in second query -

i have query get_product : select a.product_id, a.name, a.description, a.type_id, b.series_name product_data inner join series b on a.series_raw_id = b.series_raw_id a.product_id = 503061 , a.registration_type_id = 4 order b.series_name and second query select b.series_name, a.tempacc_status access_fact inner join **get_product** b on a.tempacc_product_id = b.product_id a.tempacc_date_id between 6717 , 6808 , a.reason_id_total = 0 group series_name, status in second query use data first query ( get_product first query). how table here? you use with clause. for example, with get_product (select a.product_id, a.name, a.description, a.type_id, b.series_name product_data inner join series b on a.series_raw_id = b.series_raw_id a.product_id = 503061 , a.registration_type_id = 4 order b.series_name ) select b.series_name, a.tempacc_status access_fact inner join get_product b on a.tempacc_product_id = b.product_

What is the proper way of doing partial matches in Scala? -

i have properties object, , want if configuration contains specific key. if key not exist, want ignore it. tried following way: myprops getproperty "foo" match { case v if v != null => dosomethingwith v } but causes matcherror if properties object not contain foo . i can think of 2 ways tackle this. approach 1 is: myprops getproperty "foo" match { case v if v != null => dosomethingwith v case _ => // ignore if foo not exist } approach 2 is: if(myprops containskey "foo") dosomethingwith(myprops getproperty "foo") personally, approach 1 better because queries properties once , comment tells non-match intentionally ignored, quite verbose. approach 2 has flaw that, besides querying properties twice, if in near future key changed, has changed @ 2 places here source of bugs. so, there better way approach 1, shorter, or way done? try wrapping function in option . option(myprops getproperty "foo"

javascript call a function of a plugin in instantiating it -

i want call function in plugin. i overloaded function want call function it. $("myselector").myplugin({ my_function : function (){ functioin_from_the_plugin(); } }); an error appears says "unknown function". either plugin allows hookup startup event (e.g. oninit in following, plugin-specific name), e.g. $("myselector").myplugin({ oninit: function (instance){ instance.function_from_the_plugin(); } }); or (if plugin retains correct this when calling method): $("myselector").myplugin({ oninit: function (){ this.function_from_the_plugin(); } }); or, have wait plugin created before calling method. depending on way created plugin, usual way (which uses string specify function name call): $("myselector").myplugin().myplugin("function_from_the_plugin"); this creates plugin, attaches element, calls method on plugin. note: without seeing code plugin,

java - Spring MVC project cannot use Hibernate -

Image
i want build spring mvc project hibernate. the ide used eclipse 4.4.2(luna) , installed plugin spring tool suite (sts) eclipse luna (4.4) . the project create spring project > spring mvc project . here external jars add : antlr-2.7.7.jar dom4j-1.6.1.jar hibernate-commons-annotations-4.0.5.final.jar hibernate-core-4.3.9.final.jar hibernate-jpa-2.1-api-1.0.0.final.jar jandex-1.1.0.final.jar javassist-3.18.1-ga.jar jboss-logging-3.1.3.ga.jar jboss-logging-annotations-1.2.0.beta1.jar jboss-transaction-api_1.2_spec-1.0.0.final.jar mysql-connector-java-5.0.8-bin.jar then, add detail of database /src/main/webapp/web-inf/spring/appservlet/servlet-context.xml : <beans:bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource"> <beans:property name="driverclassname" value="com.mysql.jdbc.driver" /> <beans:property name="url" value="jdbc:mysql://192.16

xaml - WPF:stretch to parent loop -

in wpf application trying connect sizes app size. main grid stretches main window, canvas - main grid etc. not work. example, scrollviewer inside of canvas, stretches main grid. solution? simple code example: <window height="400" width="200" ...> <grid horizontalalignment="stretch" verticalalignment="stretch"> <grid.rowdefinitions> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> </grid.columndefinitions> <canvas grid.row="0" grid.column="0" horizontalalignment="stretch" verticalalignment="stretch"> <scrollviewer horizontalalignment="stretch" verticalalignment="stretch"> </scrollviewer> </canvas> </grid> </window> just remove canvas , work. basically,

javascript - Angular modules and dependency injection -

let's say: use module called constants . angular.module("constants", []) .constant("a", 10); i want use constant a in module: angular.module("modulethatuseconstants", ["constants"]) .service("b", ["a", services.b]); // here use that works ! if have constant (or controller etc) called a ? angular.module("modulethatuseconstants", ["constants"]) .service("a", [services.a]); .service("b", ["a", services.b]); // ??? question: how specify a comes module constants ? tried: .service("b", ["constants.a", services.b]); but doesn't work $injector:unpr unknown provider "constants.a" you cannot achieve this. later 1 same name resolved. 1 of shortcomings of di in angular 1.x. expect see solution in angular 2 di.

android - Select multiple images from the sdcard and upload them to a server -

my code: protected string doinbackground(httpresponse... arg0) { string result = ""; file file = new file(selectimages); try { httpclient client = new defaulthttpclient(); string posturl = "http://192.168.1.11/api/review/add_image.php?"; post = new httppost(posturl); filebody bin = new filebody(file); totalsize = bin.getcontentlength(); multipartentity reqentity = new multipartentity(httpmultipartmode.browser_compatible, new progresslistener() { public void transferred(long num) { publishprogress((int) ((num / (float) totalsize) * 100)); } }); reqentity.addpart("userfile", bin); post.setentity(reqentity); httpresponse response = client.execute(post); httpentity resentity = response.getentity(); if (resentity != null) { result = entityutils.tostring(resenti

arrays - Reading 3 strings from keyboard in C but only get two strings when I print them? -

the problem have following: want read keyboard 3 strings(s1,s2,s3).what best way without problem , want print 3 strings.i give 3 strings in print section s2 , s3,but s1 blank! here's code guys!: #include <stdio.h> #include <stdlib.h> #include <string.h> #define m 4 int main(){ char buffer[255]; char s1[m],s2[m],s3[m+1]; printf("give first string: "); scanf("%s",buffer); while(strlen(buffer) > 4){ printf("lenght of string must <= 4\n"); printf("give first string again : "); scanf("%s",buffer); } strncpy(s1,buffer,5); printf("give second string: "); scanf("%s",buffer); while(strlen(buffer) > 4){ printf("lenght of string must <= 4\n"); printf("give second string again : "); scanf("%s",buffer); } strncpy(s2,buffer,5); printf("give third string: "); scanf("%s",buffer); while(strlen(buffer) > 5

Pros and cons of using an Excel file as a database -

i'm looking detailed answers question : pros , cons of using excel file database ? one of pros seems users familiar excel , can work tables without needing know databases. there many reasons not use excel database. - though can validation in excel no match database program. - when importing data excel file to, instance, sql database run problems because of misinterpretation of valuetypes - when importing dates interpretation may fail - strings 000234 read numbers , end 234 - stated before sharing of database limited - 1 of main concerns using excel database fact single file can copied various locations may cause end several versions of different data

php - Moodle development to support RTL (right to left) languages -

how can develop feature in moodle ensure support languages, including rtl languages such arabic , hebrew? moodle supports right left languages. you need careful styling. there guidelines here : https://docs.moodle.org/dev/css_coding_style#right-to-left

unity3d - How can I embed a Unity project into an existing activity in an Android Studio project? -

i have problem: need embed unity project inside existing activity of android studio project. unity project made of single scene. scene 3d ambient script. android's activity sample black activity. how can start unity scene when open activity?

Dynamodb table with ruby on rails -

i have "books" table in amazon-dynamodb, having 287 items , 97kb in size. tried load data books table through ruby on rails coding(controller). loading time slow. , shows nothing because of time out situation. please me improve knowledge in dynamo db table handling. amazon dynamodb it's key value store database, shouldn't pull out "all data" because it's designed pull 1 record or few records scan command. can describe problem , why need use dynamodb ?

javascript - how to use ember.js without server -

i following ember.js example on this site (http://todomvc.com/) . clone project computer , double click index.html , runs, expect. but in ember's guide , tells me install ember-cli, , create new project, build it. ember new myapp ember build i can find files in /dist , when double click index.html fails. this post said, "you have serve directory http server." why need server run project, instead of opening in browser? the example linked using old global ember. different ember-cli working with. http server required because of <base> tag in index.html file specifies base url use relative urls contained within document. when app trying serve assets/app.js or assets/vendor.js , trying relative base url, defined in config/environment.js . defaults / . need server respond resource requests assets. notice assets folder relative index.html file

postgresql - Add URL to aggregated variable SQL -

i join 2 sql tables (applications, areas_application1) , group area. in first table have columns url_title , url_link. want display eah area list of url_title 's , add href link each title. tried aggregate url_title space, don't know how aggregate url_link each url_title. version not work. select app.area, ar.cartodb_id, count(app.area), array_to_string(array_agg(app.url_title), '<a href="app.url"</a><br />'), ar.the_geom_webmercator applications app join areas_application1 ar on ar.name = app.area group app.area, ar.the_geom_webmercator, ar.cartodb_id following query should help: select app.area, ar.cartodb_id, count(app.area), array_to_string(array_agg('<a href="'||app.url_link||'">'||app.url_title||'</a>'), ' '), ar.the_geom_webmercator applications app join areas_application1 ar on ar.name = app.area group app.area, ar.the_geom_webmercator, ar.carto

arduino - Read serial input until control char indicates end of message -

i'm using knewter/erlang-serial elixir , try read json-string (e.g. {"temperature":20.40,"humidity":30.10} coming in arduino via serial input after receives control-signal: defmodule myapp.serialinput require logger def start_link serial_pid = :serial.start [{:open, "/dev/cu.usbmodem1431"}, {:speed, 115200}] control_signal = "1" :timer.send_interval 5000, serial_pid, {:send, control_signal} wait_for_new_values serial_pid end defp wait_for_new_values(serial_pid) receive {:data, jsonstring} when is_binary(jsonstring) -> logger.debug "received :data #{inspect jsonstring}" wait_for_new_values serial_pid end end my problem is, serial input split (sometimes passes through @ once): [debug] received :data "{\"t" [debug] received :data "emperature\":19.00,\"humidity\":42.00}\r\n" [debug] received :data "{\"temperature\&quo

asp.net mvc - Checkbox name can't pass to controller from view -

i have checkbox in view page using (html.beginrouteform("shoppingcart", formmethod.post, new { enctype = "multipart/form-data" })) { ... <input type="checkbox" name="removefromcart_@item.id" class="remove-@item.id" value="@(item.id)" style="display:none;" /> ... } <script> $("tr.cart-item-row > td > input[type=checkbox]").click(function () { if ($(this).is(":checked")) { $('input[type=checkbox].remove-' + this.value).prop('checked', true); } else { $('input[type=checkbox].remove-' + this.value).prop('checked', false); } }); </script> so want pass name(removefromcart_@item.id) of checkbox controller. but can't handle because when submit form, markup of checkbox delete(mean when submit form dont name of checkbox in controller) can't name of checkbox in controller. so ple

How do i make a android app that can be used as a default program for opening certain kind of link -

this question has answer here: how implement own uri scheme on android 4 answers okay,like title said, want make android app can used default application opening kind of link (like if click http://facebook.com show me suggested app open link, browser or facebook's app) these called implicit intents assume want open app on web link click link "myapp://someapp" then in app manifest <activity android:name="myactivity"> <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> <data android:scheme="myapp" android:host="path" /> </intent-filter> </activity> wheneve

javascript - How to filter by part of value using OData? -

i have table lies data , change shown data according conditions (using odata). example: "(lastdate eq null or lastdate ge datetime'" + date + "')" or "status eq 0" now need filer shown in table value textbox , there problem. have used second thing: "(order eq '" + search + "' or sellername eq '" + search + "' or itemtype eq '" + search + "' or itemdescription eq '" + search + "')" works fine except eq. need find item not full match. saw there used called contains , didn't how supposed if have many or . and... reveived an unknown function name 'contains' found error. how can accomplish this? the .net implementation of odata has support "substringof" works same expect contains work. eg: filter=substringof(sellername, ‘urn’) returns records sellernames containing string “urn”. you can or them togeather have eq. fi

javascript - d3 tooltip hovering issue -

i show , hide tooltip on hovering circle . have data in tooltip can have link user want click. problem attached hover function node when try click on tooltip link tooltip hide. try append tooltip inside g of hovering element did not work. suggestion fiddle nodeenter.append("circle") .attr("r", 10) .style("fill", function(d){ return d._children ? "lightsteelblue" : "white"; }).on('mouseover',function(){ div.style('left',d3.event.pagex+20+'px').style('top',d3.event.pagey+'px').style('visibility','visible') }).on('mouseout',function(){ div.style('visibility','hidden') }) try settimeout in mouseout event. fiddle on('mouseout',function(){ settimeout(function(){div.style('visibility','hidden');}, 2000) })

c++ - Segmentation fault issue -

i trying make system() command move mouse using xdotool. the following test program: int main() { int x = 10; int y = 50; char* str; sprintf(str, "xdotool mousemove %d, %d", x, y); system(str); } i getting segmentation fault (core dumped) error. there way know of allow such command work? i've tried root way. i'm new c++ , appreciated. the other answers correct however, can use better methods in c++ rather using sprintf int main() { int x = 10; int y = 50; std::stringstream ss; ss << "xdotool mousemove " << x << " " << y; system(ss.str().c_str()); }

php - $_POST better writing quality -

i have code : if(isset($_post['prenom2'])){ $t['prenom2'] = $_post['prenom2']; }else{ $t['prenom2'] = ''; } if(isset($_post['nom2'])){ $t['nom2'] = $_post['nom2']; }else{ $t['nom2'] = ''; } if(isset($_post['prenom3'])){ $t['prenom3'] = $_post['prenom3']; }else{ $t['prenom3'] = ''; } etc (there 5 or 6 fields need test). there must better way of doing this, if given index of post isn't set, index is... thanks based on real problem, may choose 1 of these: for($i=1; $i<6; $i++){ $t['prenom'.$i] = (isset($_post['prenom'.$i])) ? $_post['prenom'.$i] : ''; $t['nom'.$i] = (isset($_post['nom'.$i])) ? $_post['nom'.$i] : ''; } or $indexes = array('prenom2'=>'', 'nom2'=>'', ...); $t = array_merge($i

cannot return delphi array in C# array -

i want use delphi array function in c#. my delphi code: tintegerarray = array of integer; function testarray(): tintegerarray stdcall; export; var res: tintegerarray2; begin setlength(res, 10); res[5] := 55; result := res; end; exports testarray; c# code: [dllimport("gitatele.dll", callingconvention = callingconvention.stdcall)] public static extern int[] testarray(); show me error: cannot marshal 'return value': invalid managed/unmanaged type combination. delphi dynamic arrays not valid interop types. need have caller allocate array, , let callee populate it. procedure populatearray(arr: pinteger; var len: integer); stdcall; var i: integer; returnarray: tarray<integer>; begin returnarray := getarray; len := min(len, length(returnarray)); := 0 len - 1 begin arr^ := returnarray[i]; inc(arr); end; end; do note export has no meaning, ignored, , should removed sake of sim

PHP: Dynamically find how many variables aren't empty -

i have list of 14 variables may or may not empty. let's example have many individual variables holds select ingredient recipe. number of ingredients in recipe differ recipe, obviously. there way, using php, can see how many of 14 variables not empty (i.e. contain ingredient)? example (using 7 ingredients): $ing_1 = "carrots" $ing_2 = "apples" $ing_3 = "sugar" $ing_4 = "celery" $ing_5 = "" $ing_6 = "" $ing_7 = "" how awnser 4 ? further info: i using mysqli_fetch_array load variables. given current variable structure, loop on variable like- $count=0; for($i=1;$i<=7;$i++){ if(!empty(${"ing_$i"})) $count++; } echo $count; with $i<=7 increased $i<=14 if have 14 variable/ingredients.

c# - Etsy API says UnAuthorized(401) when fetching access_token -

i following this question connect etsy api , have written following code: class etsy { private const string access_token = "jagbkdwqii82lhiaj2pqcujd "; private const string secret = "is1bztdh2k"; private const string base_url = "https://openapi.etsy.com/v2"; private string token = ""; public etsy() { string f = ""; try { var request_token_url = base_url + "/oauth/request_token"; var oauth = new manager(); oauth["consumer_key"] = access_token; oauth["consumer_secret"] = secret; oauth.acquirerequesttoken(request_token_url, "post"); f = "required tokens = " + oauth["token"].tostring(); token = f; } catch (exception ex) { cons

Android : how to detect already connected usb device? -

i'm trying detect usb devices connected android. understand there actions detect when usb either attached or detached. don't how check devices after connecting usb device android. also, i've found each usb device has it's device class code, how figure out kind of device connected? instance, need detect both usb mouse , keyboard; how differentiate them? try this: first register broadcast usb connection. manifest permission: get list of usb device details using this public void getdetail(){ usbmanager manager = (usbmanager)getsystemservice(context.usb_service); hashmap<string, usbdevice> devicelist = manager.getdevicelist(); iterator<usbdevice> deviceiterator = devicelist.values().iterator(); while(deviceiterator.hasnext()){ usbdevice device = deviceiterator.next(); manager.requestpermission(device, mpermissionintent);

mathnet - How to convert an integer array to a matrix in c# -

i have integer array named resp want rewrite/convert as/to row matrix name resp . int[] resp= {1, 0, 1, 0}; i using mathnet.numerics library. how can that? in mathnet, not able initialize array of integers. is, there's in limited support available this. if tried, this: unhandled exception: system.typeinitializationexception: type initializer 'mathnet.numerics.linearalgebra.vector`1' threw exception. ---> system.notsupportedexception: matrices , vectors of type 'int32' not supported. double, single, complex or complex32 supported @ point. you can initialize vector similar values (with doubles) this: var resp = new [] {1.0, 0.0, 1.0, 0.0}; var v = vector<double>.build; var rowvector = v.denseofarray(resp); in order build matrix, need multi-dimensional array.

android - change the size of Fragment tabs using ViewPager -

i want change size of fragment tabs. there way?? can change size of fragment tabs created using view pager , fragments ?? solved. need implement material design classes resize it. material design tabs new , best solution tabs. classes provided google. material design tabs from given link download both following classes, slidingtablayout.java slidingtabstrip.java and have same viewpager. need implement following in mainactivity.xml can customize size of tabs. <com.example.android.tabs.slidingtablayout android:layout_width="match_parent" android:layout_height="35dp" //size of tabs. android:layout_margintop="1dp" android:id="@+id/tabs"/> and add tabs viewpager, mpager.setadapter(new myadapter(getsupportfragmentmanager())); mtabs.setviewpager(mpager); you can change size of tabs way want. hope helps :)

ios - NSDate is older than today -

i understand how compare 2 nsdate objects, e.g: if ([olderdate compare:[nsdate date]] == nsorderedascending) { // } however compare date components, not time since time can make comparison inaccurate in case. is possible compare day, month , year? since ios 8, nscalendar has number of convenience methods sort of comparison. for example, there's: - (nsdate *)startofdayfordate:(nsdate *)date ns_available(10_9, 8_0); you can start of given day date (such [nsdate date] "now") , compare against that. there's also: - (nscomparisonresult)comparedate:(nsdate *)date1 todate:(nsdate *)date2 tounitgranularity:(nscalendarunit)unit ns_available(10_9, 8_0); you can call granularity nscalendarunitday comparison want directly. there others, too. see nscalendar.h details, since these methods don't seem in class reference documentation, yet.

c# - To Create Action That Accepts a Parameter Of Any Type Derived From The Parameter Type (Polymorphic Parameter) -

i want build dynamic structure client ask server in web api. have tried use following code deal question, however, isn't working. how can send generic type <travel> service how can change server code (or need change client/server)? ps:thank patience if have read question end. client code var serializer = new javascriptserializer(); var product = new travel() { travel_desc = "select * travel" }; var jsontext = serializer.serialize(product); var client = new httpclient(); client.baseaddress = new uri("http://localhost:65370/"); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); stringcontent content = new stringcontent(jsontext, encoding.utf8, "application/json"); var z = client.postasync<travel>("api/bb", product, new jsonmediatypeformatter()).result; server code, not working public ihttpactionresult pos

android - WebViewClient shouldInterceptRequest Freezes the WebView -

i want cache images displayed in webview specific time, e.g. 7 days, needed both save image caches disk , load them disk , provide them webview. also needed resize images avoid webview; crash on high memory usage, implemented caching , resizing logic in blocking function named " fetchbitmap ". as android documentation states, " shouldinterceptrequest " runs on thread other ui thread, can networking in function, can see, blocking call causes webview freeze. the way function behaves forces me use blocking call, , can't pass runnable e.g. future completion. any workarounds? webview.setwebviewclient(new webviewclient() { private boolean isimage(string url) { if (url.contains(".jpg") || url.contains(".jpeg") || url.contains(".png")) { return true; } return false; } @override public webresourceresponse shouldinterceptrequest(webview view, string url

wcf - SOAP server 1.1 sending response using content type defined for 1.2? -

i tried sending soap1.2 request server , received following exception system.servicemodel.communicationexception: envelope version of incoming message (soap11 ( http://schemas.xmlsoap.org/soap/envelope/ )) not match of encoder (soap12 ( http://www.w3.org/2003/05/soap-envelope )). make sure binding configured same version expected messages. on analyzing traffic through wireshark, see response envelope http://schemas.xmlsoap.org/soap/envelope/ , request envelope http://www.w3.org/2003/05/soap-envelope again tried sending message same server using soap 1.1 , got following exception system.servicemodel.protocolexception: content type application/soap +xml of response message not match content type of binding (text/xml; charset=utf-8). if using custom encoder, sure iscontenttypesupported method implemented properly. based on above 2 logs, can conclude remote server using soap1.1 , sending response using content type defined soap1.2 application/soap+xml

ruby - replace every occurrence that is unquoted -

i'm trying write regex in vim replace every occurrence of true 't' , false 'f' in sql file. complicate this, shouldn't replace true or false when occur anywhere inside quotes. i'm using following regex works: %s/\v^(([^'"]*)|(.*('.*'|".*").*)*)\zs((t)rue|(f)alse)/'\6\7'/ # no qts or number of qts \6 \7 but 1 small problem: replaces 1 set of true s , false s per run. e.g. (matches highlighted in bold): insert pages values (42, null, 'string', true, '', null, true, false , 1); insert pages values (42, null, 'string', true, null, true, false , 1); insert pages values (42, null, true , '', null, true, false, 1); insert pages values (42, null, true, null, true, false , 1); i've tried sorts of stuff, , i've searched internet can't find anything, i'm stuck. there regex wizards here know how can fix this? a vim or ruby s