Posts

Showing posts from April, 2011

javascript - kendo ui dropdownlist binding to static datasource -

hi i'm trying bind kendo ui dropdownlist control fixed datsource so: <input data-role="dropdownlist" data-text-field="catname" data-value-field="value" data-bind="value: selectedcategory, source: [{'catname': 'weeks', 'value':'weeks'}, {'catname': 'days', 'value':'days'}, {'catname': 'hours', 'value':'hours'}], events: { change: axischange }" style="width: 300px" /> but throws error on line of internal script. 'catname' not in apostrophes, got error saying couldn't bind id attribute dropdownlist widget, tried change see, little luck. have created jsbin issue here ...h

javascript - CRUD operation using angularJS -

i creating application of simple crud operation using angularjs in asp.net c# . want know, should keep code of crud operations?in .js file? need small demo of 1 crud operation. please note using sql database . can me? you starts learn angularjs with: the documentation phonecat tutorial app build single page application (spa) asp.net web api , angular.js enjoy!

filtering - What is correct Sampling frequency value? -

what correct sampling frequency (sampling rate) in given code ? 8khz? i'm having trouble find it. this comment suggests 8khz .equ timeconst, #32000 ;use 32000 samples (4 seconds) constant find peak and section of code says "8ks/s" ;setup timer 1 sampling delay: tcy = 16mhz (64mhz clock) mov #0x8000,w1 ;8ks/s @ tcy=16mhz mov w1,t1con ;1:1, int clk, on mov #2000,w1 ;load pr1 delay, 8ks/s sample rate @16mhz internal mov w1,pr1

sequelize.js - custom serialisation of sequelize toJSON -

currently sequelize serialize instance this id: 2, title: 'bla bla', url: 'https://mail.google.com/mail/u/0/#inbox/14c6002a21ae0679', createdat: sat mar 28 2015 18:58:42 gmt+0800 (sgt), updatedat: sat mar 28 2015 18:58:42 gmt+0800 (sgt), userbookmarks: { createdat: sat mar 28 2015 18:59:16 gmt+0800 (sgt), updatedat: sat mar 28 2015 18:59:16 gmt+0800 (sgt), userid: 1, bookmarkid: 2 } } i want highlight way relationship serialized. bookmark model , want build or use lib generically modifies relationship form userbookmarks xxx user:[]; any ideas ? you can provide custom tojson function: var model = sequelize.define(name, attributes, { instancemethods: { tojson: function () { var values = this.constructor.prototype.tojson.call(this); // magic here } } });

c - Structure with array of function pointer -

#include <stdio.h> void getsum(); void getdifference(); typedef void (*functionptr)(); // assign function's address functionptr arrayfp[2] = {getsum, getdifference}; struct true { int a; int b; functionptr arrayfp[2]; //syntax may wrong } w = { 5, 6, arrayfp[0] }; int main() { w.arrayfp[0]; //syntax wrong return 0; } void getsum() { printf("i greatest"); } void getdifference() { printf("i not greatest"); } when initializing structure, initialize array first function pointer, not actual array. in fact, structure contains array need initialize actual members of array, either or change pointer. then when want call it, use function pointer normal function. so structure, either struct { int a; int b; functionptr arrayfp[2]; } w = { 5, 6, { getsum, getdifference } }; or do struct { int a; int b; functionptr *arrayfp; } w = { 5, 6, arrayfp }; note: don't use sy

Google Translate API invoked too many time in one day error message. Bypass this limitation? -

i published google add-on translates google spreadsheets cells (add-on link : https://chrome.google.com/webstore/detail/translate-my-sheet/ikbffjfknllcipddomhgdhcedikhiaga ) for each cell, request sent google translate api translate content. many users performing fuly sheet translation many thousands lines , encoured following error message : 'invoked many time in 1 day message'. (i think limitation 20,000 day) someone knows if it's possible bypass limitation please? thank's in advance, joey.

replace - geany find special substring -

i have lot of php files , want find every occurance of htmlentities(some var); in geany, , don't want htmlentites(some var, ent_quotes); got found, has like: htmlentities(...); because dots stand undefined character, able find specified lenght. correct syntax find undefined length substring? you can use regular expressions inside search , replace dialogs. little depends on system (e.g. grep etc.) , looking in detail, here deeplink manual.

SVG glow filter not working in Safari, alternatives? -

i have glow filter around text whereby glow makes text readable, wouldn't otherwise (being on dark background). filter not working in browser mean have go image instead of svg. can think of alternatives? the filter has eminate actual text, not rectangle around it. here code isn't rendering in safari <filter id="glow2" width="150%" height="150%" style="color-interpolation-filters:srgb;"> <feflood id="feflood4276" result="flood" flood-color="rgb(255,255,255)" flood-opacity="1" /> <fecomposite id="fecomposite4278" result="composite1" operator="in" in2="sourcegraphic" in="flood" /> <fegaussianblur id="fegaussianblur4280" result="blur" stddeviation="4"

node.js - node-mysql - return rows where column contains string -

i want create function returns objects db string contained in 1 of object's columns. this code: router.get('/search-news', function (req, res) { var input = req.query.title; // user input var dynamicinput = '%'.concat(title.concat('%')); connection.query('select * news title = ?', [dynamicinput], function (err, rows) { console.log(err); res.json(rows); }); }); html: <form action="search-news" class="form-inline right search-form" method="get"> <input type="text" name="title" class="form-control" placeholder="Поиск..."></input> <input type="submit" class="btn btn-success" value="Поиск"></input> </form> however, function returns 0 records db. problem? thank you your dynamic input seems appending percent signs beginning , end of string. var dynamicinput = '%'.c

python - ascii codec can't encode character -

i'm trying create string special characters portuguese-brazil (e.g. á, à, â, ç) push_message = 'á' push_message.decode().encode('utf-8') but i'm getting error: unicodeencodeerror: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128) i need send parse api, , parse api allows utf8 encoding. can solve this? edit when try push_message.decode('utf-8') i get unicodeencodeerror: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128) when try push_message.decode('latin-1') i get unicodeencodeerror: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128) it worked this: unicode(push_message.decode('utf-8'))

Restoring a raw PostgreSQL backup from an ancient server? -

all guides can find suggest migrating psql database easy. call pg_dump out @ 1 end , can suck @ other. simple if remembered pg_dump ! two years or ago, migrated server crusty old 32bit server newer, fresher 64bit install. backed essentials (/etc, /var, /home, etc...) being quite new @ time, ignored postgresql , didn't restore on new server. sound odd? client uses moodle site use once in moon , has never needed in time. it's full moon today. client savage database isn't available. i have /var/lib/postgresql/9.1/... files initial backup still. try supplant new /var/lib/postgresql/9.3/... files different arch, , i've read several things suggesting won't work. don't want things worse. is there way restore old database or somehow convert neutral plaintext sql can reimported? you correct 64-bit postgresql can't read 32-bit postgresql data directory. nor 9.3 read 9.1 data directory. you need 32-bit postgresql 9.1 access this. because x8

javascript - Using Twitter API to get images tweeted by a user (REST API) -

i'm using twitter rest api try , images specific user. if use statuses/user_timeline , mixture of of textual tweets , images, , results limited 200. means can end 10 images per 200 results, because of text tweets involved in returned data. what i'm trying instead, use tweets/search from:username filter:images keywords. have encountered issue: on twitter.com, search term from:gregory_onye filter:images returns few results, when using api receive 1 result... can me issue? see below search metadata: "search_metadata": { "completed_in": 0.03, "max_id": 579641668875452400, "max_id_str": "579641668875452416", "query": "from%3agregory_onye+filter%3aimages", "refresh_url": "?since_id=579641668875452416&q=from%3agregory_onye%20filter%3aimages&include_entities=1", "count": 100, "since_id": 0, "since_id_str": &quo

matlab - How to delete element from cell arrays after comparisons without causing cell arrays to get empty? -

i created 1d array shows words , in sentences occur. after took intersection show word occurs each of other remaining words in sentence: occurstogether = cell(length(out1)); ii=1:length(out1) jj=ii+1:length(out1) occurstogether{ii,jj} = intersect(out1{ii},out1{jj}); end end celldisp(occurstogether) the output of above code below: occurstogether{1,1} = 4 11 14 occurstogether{1,2} = 1 occurstogether{1,3} = [] occurstogether{1,4} = 1 4 8 14 15 19 20 22 occurstogether{1,5} = 4 11 i want check single element if deletion doesn't cause empty set should deleted if deletion give rise empty set should not deleted. for example: step1: delete 4 {1,1} and {1,5} not empty 4 should deleted. step2: delete 14 {1,1} and {1,4} not empty 14 should deleted. step3: if delete 11 {1,1} and {1,5} cause empty set because 4 , 14 deleted in step 1 , step 2 should not deleted. element deletion operations should carried out cells of arrays. occurstogether declared 1d

java - Build Sip Client using Sip Servlet as signalling -

i using mobicent sip servlet , have deployed in jboss as7 successfully. saw testing sip softphones. i have google search alot building our own sip client cannot find proper guide. what have using sip servlet signalling , have create android client(using jain-sip) , have create uac browser. i confuse how can use sip servlet application running on server? how send requests(register,invite , on) client sip servlet? for example this tutorial how create client? :) a little guide or small tutorial create uac or how use sip servlet can help android has built in simple sip client , apis here http://developer.android.com/reference/android/net/sip/package-summary.html . need own jain-sip in android if using more advanced features. there plenty of examples here https://svn.java.net/svn/jsip~svn/trunk/src/examples

Reload data tableview in swift -

when run tableview.reloaddata() in uitableviewcontroller, works, when call function update tableview controller not work. //this way works normally func reloadtableview() { let path = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true ).first string let db = database("\(path)/db.sqlite"); conversasarray.removeall(keepcapacity: true); let stmt = db.prepare("select znome,zultimamsg,zidmensagem,zimage zusuario,zchat ztelefone = zto") var objetoconversa : anyobject = []; row in stmt { objetoconversa = ["znome":"\(row[0]!)", "zultimamsg":"\(row[1]!)", "zidmensagem":"\(row[2]!)", "zimage":"\(row[3]!)"]; //adiciona o objeto dentro array de objetos. conversasarray.append(objetoconversa) } tableview.reloaddata(); } //but when file tableview.reloaddata() not work. var = tableviewcontroller();

python - Find occurrences of a value in a numpy array and assign it appropriate weights -

i have text file of close 1 million lines.it has 2 columns.column 1 has numbers 0-99 , column has 4 sizes ranging s,m,l,xl. numbers 0 99 keep repeating in 1 million lines different sizes follows: 11 s 19 s 19 m 19 m 63 l 14 s 11 l 63 xl 14 s 11 l 63 xl my objective find final size each number.the plan of action find occurrence of each number,find size each occurrence , assign final size number maximum occurrences of size. expected output : 11 l 14 s 19 m 63 xl because of size of dataset,i having @ numpy,not have prior experience it. have started creating basic numpy array follows: import numpy np data = np.loadtxt('size_data.txt') this create numpy array.however,from whatever documentation have read till now,it not there direct way of doing want accomplish.can 1 give me pointers on how move forward ? we can applying numpy.unique on reversed version of first column received file. reversing required because other wise it( return_index=true ) return i

gsm - AT COMMANDS - USSD returns only OK -

i have bought zte mf667 gsm modem , using hyper terminal send @ commands, have problem ussd e.g : at+cusd=1,"*111#",15 (to check balance) returns ok at+cusd=1,"*111#" returns ok i have tested @ commads work fine like at+cmgl="all" read sms (works) how resolve problem please ? first of ussd messages similar sms in message sent mobile device operator network. means when execute ussd command on mobile device not receive immediate response operator network's ussd service must answer message. explains why receive "ok" answer ussd command. "ok" telling ussd command syntax valid , ussd command sent mobile device operator network, nothing more. secondly ussd command responses returned unsolicited response , therefore not stored alongside sms's. quote wikipedia regarding this: ussd associated real-time or instant messaging services. there no store-and-forward capability, typical of other short-message proto

html - get index of input element in javascript -

if have 3 input boxes on web page , user clicks second input, need input index, position of input on page. need in pure javascript. have far doesn't work... document.queryselector('html').onclick = function (e) { log(e); } function log(obj) { var nodename = obj.target.nodename var idx = nodename.length console.log(nodename, idx); } any appreciated! pure javascript: function getindexfromset(set, elm){ var setarr = [].slice.call(set); for( var in setarr ) if( setarr[i] == elm ) return i; } the above function can used so: function checkinputfocus(e){ if(e.target && e.target.nodename == 'input' ) index = getindexfromset(inputs, e.target); } var inputs = document.queryselectorall('input'); document.addeventlistener("click", checkinputfocus); using jquery, if run on page (in console) var inputs = $('input'); // input elements on page inputs.index( $('

python - find position of string elements in pandas dataframe -

i have pandas data frame , suspect contains strings >>> d2 1 2 3 4 5 6 7 8 9 10 ... 1771 \ 0 0 0 0 0 0 0 0 0 0 0 ... 0 1 0 0 0 0 0 0 0 0 0 0 ... 0 2 0 0 0 0 0 0 0 0 0 0 ... 0 3 0 0 0 0 0 0 0 0 0 0 ... 0 4 0 0 0 0 0 0 0 0 0 0 ... 0 5 0 0 0 0 0 0 0 0 0 0 ... 0 6 0 0 0 0 0 0 0 0 0 0 ... 0 7 0 0 0 0 0 0 0 0 0 0 ... 0 8 0 0 0 0 0 0 0 0 0 0 ... 0 9 0 0 0 0 0 0 0 0 0 0 ... 0 1772 1773 1774 1775 1776 1777 1778 1779 1780 0 0 0 0

What is "==+!" in javascript? -

does can show me "==+!" meaning in below code: if(my_var.length==+!0) //do i try google don't result. think of this: if (my_var.length == (+(!0))) since !0 === true , +true === 1 , end sequence of evaluation: if (my_var.length == (+(!0))) if (my_var.length == (+true)) if (my_var.length == 1) fyi, can see ordered list of javascript operator precedence when deciding how process operators here . of relevance here, precendence of ! operator highest, unary + operator , == operator. see results of !0 , +true here: http://jsfiddle.net/jfriend00/wh840n3q/

naming conventions - Are names in the C++ Standard Library meant to be in British English or American English? -

after quick search in draft n4296 , not find example of name in c++ standard library 2 possible spellings exists (bre vs. ame). while may intentional, can imagine @ point, if graphics library standardized (and there seems effort going in direction), choice between "colour" , "color" have made. are there normative regulations or perhaps informal criteria being used decide spelling pick names in c++ standard library? i'd expect that, if there official guideline, should able find in standard library guidelines on committee's web site. since there number of items regarding naming conventions , none of them mentions american versus british english, can conclude such decision has not been made yet. as others have commented, there prose , @ least 1 function name in standard uses american spelling bet would preferred in case of doubt. can tell, other libraries do. boost library requirements , guidelines , way, don't have issue either.

git - What should RESETING detached HEAD to BRANCH do? -

if understand right, when have detached head(head->commit), git checkout branch solves issue(head->branch[->somecommit]) but resetting branch do? supposed set pointer of object(often branch) head points branch. since dont have middle-man (branch) - then? , why? it moves head: mentioned in " practical uses of git reset --soft ? ": git reset moving head. if move head commit, head remains detached . after a discussion difference between git reset , git checkout vs detached or attached nature of symbolic reference head , here found together: if head points on branch, git reset move branch <something> : resetting doesn't make un-detached, changes branch head if head points on commit (was detached), remain detached: op puts it: so when detached , call git reset <branch> finds commit behind branch , change commit in .git/head commit <branch> refers to. let's consider head attached branch1 ( cat .git/he

android - How to search Amazon Cognito Identity? -

in android application, setting cognito identity follows: dataset dataset = ....syncclient.openorcreatedataset("whatever"); dataset.put("name", name); dataset.put("email", email); as result identity id created in format: us-east-1:1xxxxxx-999d-999x-nnnx-fxxxxxxxxxxx the identity browser on aws web console allows 1 search identity id. now want search identity email (because that's know user). how can search identity email in amazon web-console? alternatively, can set email id identity id - if yes, how? as of now, way search identity on console identity id. have heard request other customers make easier search factor , consider in future updates service.

SQL Server select column while inserting -

this question part of insert statement in trying select value value can inserted column. for example in table onlineservers, have columns: id, serverid, onlinesince in second table importservers, have columns data (the lines after newyork , paris empty): importservername newyork london paris tokyo this question related sql server. in third table, look-up table called serverlookup, have these columns data: id, servername 0 not specified 1 newyork 2 london 3 tokyo 4 munich 5 salzburg question: want have sql statement can select id '0' serverlookup table if value of column importservername empty. what have far is: insert onlineservers (serverid, onlinesince) select ( select id serverlookup serverlookup.servername = importservers.servername or serverlookup.servername = '' ), getdate() importservers the problem facing if server name matched, returns row empty server name. how can fix problem. thanks ps: forgive

ruby on rails - Cucumber feature failing when rendering template with confusing error -

i'm trying make tests pass, cucumber failing confusing error, template related, i'm not able understand , fix. here gemfile , gemfile.lock: https://gist.github.com/ngw/dada0c0658a9ef8b5573 you can assume on latest version of today, 28 march 2015, including rails, cucumber, ruby (2.2.0p0), database_cleaner, , on. the view fails render devise view renders fine on browser. here exception raised: background: # features/users/sign_up.feature:6 given not logged in # features/step_definitions/user_steps.rb:9 scenario: user signs valid data # features/users/sign_up.feature:9 when sign valid user data # features/step_definitions/user_steps.rb:13 undefined method `[]' nil:nilclass (in /users/ngw/petswantpats/app/assets/stylesheets/application.css) (actionview::template::error) ./app/views/layouts/application.html.haml:6:in `_app_views_layouts_application_html_haml___302582815389802583_70306431437360' ./features/ste

rstudio - R: Filling the NULLs in a data column -

the data i'm working on looks this: timestamp switchonoff speed speedlimit 2015-03-26 20:00:00 null null 35 2015-03-26 20:15:00 null 41 35 2015-03-26 20:30:00 0 49 35 2015-03-26 20:45:00 1 null 35 2015-03-26 21:00:00 yes null null 2015-03-26 21:15:00 null null 35 2015-03-26 21:30:00 no null null 2015-03-26 21:45:00 5 51 40 for variable: switchonoff: 0, 1 ; -but has many other levels i'm trying covert 0, 1 only. tried following for-loop, not work because of nulls (empty, length = 0) : for (i in 1:length(timestamp)) { if (is.null(switchonoff[i]) | switchonoff[i] == "yes") { switchonoff[i] = 1 } else if (switchonoff[i] == "no") { switchonoff[i] = 0 } else if (switchonoff[i] >= 1){ switchonoff[i] = 1 } else {switchonoff[i] = switchonoff[i]} } so wondering if knows better wa

multithreading - Is there another thread (apart from the main thread) which keeps on polling on the async operation in Javascript? -

i understand javascript single threaded , event queue maintained in order handle events in fifo order. if main thread fires async operation , callback added event queue, there other background thread keeps polling on async operation , notifies event queue execute callback?

wordpress - PHP uncheck option after set time -

i'm hoping can tell me function i'd use uncheck option after set amount of time. basically wordpress/buddypress user have "out of office" status displayed checkbox. set when status should clear time out of office displayed along status. thanks in advance.

c# - Deploy a WPF program and update the database if required -

i'm creating wpf application uses localdb instance (which provided clickonce installer). the program uses database store userdata. when application deployed first time, want create localdb data inserted upon initialization. when later provide update program (which may include schema changes), not want lose any userdata. i'm using ef code-first , dbcontext: public class mycontext : dbcontext { public dbset<stuff> premises { get; set; } public dbset<person> persons { get; set; } private static mycontext _current; public static mycontext current { { if (_current == null) { _current = new mycontext(); } return _current; } } protected mycontext() { //some data insert on first time } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.entity<stuff>().hasmany(p => p.per

How can i replace "this" in android studio? -

how can not overlap 2 uses of this, in same java file. trying make work replacing "this" else no working. well, i'm pretty sure can't , don't understand why want do so. you can change yourclassname.this

scala - Running Spark Application from Eclipse -

i trying develop spark application on eclipse, , debug stepping through it. i downloaded spark source code , have added of spark sub projects(such spark-core) eclipse. now, trying develop spark application using eclipse. have installed scalaide on eclipse. created simple application based on example given in spark website. import org.apache.spark.sparkcontext import org.apache.spark.sparkcontext._ import org.apache.spark.sparkconf object simpleapp { def main(args: array[string]) { val logfile = "your_spark_home/readme.md" // should file on system val conf = new sparkconf().setappname("simple application") val sc = new sparkcontext(conf) val logdata = sc.textfile(logfile, 2).cache() val numas = logdata.filter(line => line.contains("a")).count() val numbs = logdata.filter(line => line.contains("b")).count() println("lines a: %s, lines b: %s".format(numas, numbs)) } } to project, added spark

xcode - IBOutlet is nil, but it is connected in storyboard, Swift -

Image
using swift 1.1 , xcode 6.2. i have uistoryboard containing singular, custom uiviewcontroller subclass. on it, have @iboutlet connection of type uiview controller uiview subclass on storyboard. have similar outlets subviews of view. see figure a. but @ run time, these properties nil (figure b). though have assured i've connected outlets in interface builder. thoughts : is possible because using subclass of subclass messes initialization? not overriding initializers awakefromnib: not getting called reason maybe doesn't connecting subviews on subviews things have tried: matching @iboutlet , storyboard item types (instead of uiview ) deleting property , outlet , re-added them figure a* figure b *the obscured code in figure a is: @iboutlet private var annotationoptionsview: uiview! @iboutlet private var arrivingleavingswitch: uisegmentedcontrol! thank you. typically happens because view controller hasn't loaded view hierarch

android - 415 Unsupported Media Type for XML Post Rest API -

i trying request rest post api xml string getting following error response. <?xml version="1.0" encoding="utf-8" standalone="yes"?> <apierrors> <apierror> <errormessage>415 unsupported media type - null</errormessage> </apierror> </apierrors> i don't understand why happening. set content-type , header also. please take @ code. string xmlstring = "<contact>" +"<name>sandeep</name>" +"<title>mr.</title>" +"<address>india</address>" +"</contact>"; try { stringentity se = new stringentity(xmlstring); httppost httprequest = new httppost("http://abc:xyz123@000.000.0

mysql - PHP destruct function show an error? -

i have error shown in destruct function in class connects data base, tried remove variable in destruct function shows error. here code: class db_connect { function __construct() { $this->connect(); echo "connected succesfully"; } function __destruct() { $this->close(); } function connect() { require_once __dir__ . '/db_config.php'; $con = mysqli_connect(db_server, db_user, db_password, db_database) or die(mysqli_error()); if($con){ echo "connected succesfully"; } return $con; } function close() { mysqli_close($con); } } and there error message: mysqli_close() expects parameter 1 mysqli in connect method not assigning mysqli object instance variable. in __destruct $con undefined/null explains error message. require_once __dir__ . '/db_config.php'; class db_connect { private $co

c# - rank records according to vendors having most sales(Quantity*Price) -

Image
mine event management related website.. on admin side need following : vendorname , vendorphoto , vendorphone , vendoremail , servicetype(serviceid) based on rankin of sales( quantity * price ) displayed in eventitem table , i.e. : a vendor a(serviceid : 1 , service.name:florist) has couple of vendoritems in table vendoritem (i.e. product table) , other vendors have entries in table vendoritem . when user registers event choose quantity , product(i.e. vendoritem ) of vendor. then query should check amongst vendors of particular type(e.g. : florist,etc) , has sales(top 3)/ this query have tried far, not able required results , confused in how calculate value quantity*product ? select top (3) tblvendor.vendorid, tblvendor.name, tblvendor.email, tblvendor.phone, tblvendor.address, tblvendor.username, tblvendor.password, tblvendor.serviceid, tblvendor.isactive, tblvendor.photo, tbleventitem.quantity, tbleventitem.price t

php - Test website performance -

i have php , mysql website using xampp server. i wondering there software, online websites etc can test (network performance, load balance, stress tests etc) websites running on localhost (local environment)? thanks you can't test network speed of site on localhost, since it's going instant since it's local. thing can test how fast php can execute , there great extension php called php_xdebug . tell how long each function call takes execute. you can view results using tools such wincachegrind , view function taking time. for network stuff, need first deploy website , run tests load balancing, stress testing, etc. from experience, of delay websites php , not web server (unless on shared host).

c - MPI_Send to single variable destination -

i want send mpi_send message single variable host. mean dont know rank of host want send message to, @ compile time. so naturally, wrote following: mpi_send(&myintdata, 1, mpi_int, target_host, my_msgtag, mpi_comm_world); where target_host integer, containing rank of destination. when execute this, mpi ends timeout. if put printf before , after send, printf happens before displayed, means program stuck in mpi_send statement. if change target_host 1, example, second printf displays , works fine. so.. doesnt mpi support variable in destintation rank identifier? what problem here? mpi allow variable in rank argument. consider following example #include <stdio.h> #include <stdlib.h> #include <mpi.h> #include <unistd.h> #include <string.h> int main(int argc, char** argv){ int rank = 0; int comm_size = 0; mpi_init(&argc, &argv); mpi_comm_size(mpi_comm_world, &comm_size); mpi_comm_rank(mpi_comm_

php - using stored procedures with wordpress -

i have huge wordpress plugin uses stored procedures extensively. entire site based off plugin. therefore, haven't been able upgrade our version of worpdress since 3.0. looking bring wordpress date, question is, there way can current version of wordpress allow plugin use stored procedures? perhaps there line can put wp-config or wp-settings file allow them?

Legend Horizontal Graph Spacing in R -

Image
ok asked before, although have made more progress now, wasn't sure how add code comment of old post. anyways here new problem. using legend command creat horizontal leged , hoping there way reduce space between legend item list # initial variables, fine t = 0:50 int_seq = seq(0,0.1,by=0.025) int_seq100 = 100 * int_seq colors = c("black","red","blue","green","orange") index = 1:length(int_seq) #av simple interest, fine avsimple = function(i,t){ av = (1 + (i * t)) return(av)} # plot range y-axis, fine yrange = c(avsimple(min(int_seq),min(t)) * 0.95, avsimple(max(int_seq),max(t)) * 1.15) # plots simple interest different interest rates, fine plot(t,avsimple(int_seq[1],t), type="l", main = "av simple interest", xlab = "time", ylab = "av", ylim = yrange) (i in index) lines(t,avsimple(int_seq[i],t), col = colors[i]) # adds legend plot different interest rates # troubl

android - How is OnCreate() called SQLiteOpenHelper -

i have been searching on internet ı have found these informations: oncreate() method called when database opened or created... okey how method called ?by whom? activity class has oncreate method also, these 2 oncreate methods similar ?if makes them similar? activities oncreate method called os? how? papers should ı read? know when these methods called ı want know how. thank you. okey how method called ?by whom? it called sqliteopenhelper itself, in response call getreadabledatabase() and/or getwriteabledatabase() . can see in the source code sqliteopenhelper . activity class has oncreate method also, these 2 oncreate methods similar ? not really. activities oncreate method called os? how? it called activity itself, part of startup process. starting activity rather complicated, welcome review the ~6000 lines of activity source code if like .

Find a string in a string - Python -

i trying implement function find text in string recursively. i tried this, don't know why it's not working. please note new coding. def find(text, substring): if len(text) == 0: return 0 while substring[0] in text: return find(text, substring[1:]) thanks! :) example : find("mississippi", "sip") true find("to or not be", "be") true find("mississippi", "sup") false you need base case recursive function return without recursing. base case len(text)==0 never executed unless text=='' first time through.

c# - Listview on Windows Phone: Items not listing correctly -

Image
my requirement implement list of countries user select , phone number. in desperate attempts, this article followed. have listview setup way: the country names trial, not make sense. viewmodel: i've hard-coded list of countries //contructor class public countrylist_test() { //creating static data memberrs (hardcoded logic) var list_countrylist = new list { new countrylist_countrynames{countryname = "ffsdfndf"}, new countrylist_countrynames{countryname = "hfhjf"}, new countrylist_countrynames{countryname = "vcxbv"}, new countrylist_countrynames{countryname = "ujhfg"}, new countrylist_countrynames{countryname = "vbcvb"}, new countrylist_countrynames{countryname = "fdfgd"}, new countrylist_countrynames{countryname = "dfdhgfjjyhg"}, n

java - Why do these strings evaluate to false even when i enter them exactly right? -

this question has answer here: how compare strings in java? 23 answers i writing simple program grips using scanner in java. program has stored value user_1 , asks user provide string variable username checked against user_1 using == operator, when username matches user_1 still evaluates false. i'm sure must missing simple, appreciated. added line printing both variable double check same!! import java.util.scanner; public class helloworld { public static void main(string[] args) { string user_1 = ("lucasrhcp"); scanner input = new scanner(system.in); system.out.println("enter username: "); string username = input.nextline(); system.out.println(user_1 + " " + username); if (username == user_1){ system.out.println("true"); } else { system.out.println("false");

ruby - Why does Hash.try_convert not convert a two-dimensional array into a Hash? -

the docs following hash.try_convert(obj): try convert obj hash, using #to_hash method. returns converted hash or nil if obj cannot converted reason. however, when try with: [[:a,"a"],[:b,"b"]] i this: hash.try_convert([[:a,2],[:b, 3]]) => nil but if use #to_h method on array, consider correct behaviour: [[:a,"a"],[:b,"b"]].to_h => {:a=>"a", :b=>"b"} does mean understanding of docs incorrect (i.e. 2 approaches above should not considered analogous), else going on, or being dumb in way have not considered yet? thanks arie shaw in comments drew attention precise way being dumb. i've subsequently discovered related bug report : the class hash has method try_convert, documented "try convert obj hash, using #to_hash method." surpisingly, array class doesn't have method to_hash, have method to_h converts hash. looks there 2 possible methods different names, same expected

date - How to count occurrences of each year in Excel? -

i want count cells have specific year in date/string. have problem formula works if it's valid date, cells have month or day missing or totally blank. here examples of values want able count: 2002-07-? 2010-11-27 2009-10-21 2009-10-21 2004-12-20 2004-11-07 2010-11-? 2004-09-17 2000-?-? 2005-04-26 this how want output be: unknown 2 2000 1 2001 0 2002 1 2003 0 2004 3 2005 1 2006 0 2007 0 2008 0 2009 2 2010 2 if use =countif(a1:a12;"2000*") cells strings. there way count both dates , strings? use helper column , use following formula extract year: =if(istext(a1);left(a1;4);text(a1;"yyyy")) then use existing =countif() formula without wildcard * argument: =countif(a1:a12;"2000")

mysql - Searching a database for a string and taking relevant information VB -

i want able search database product name or product id number , load relevant information regarding product text boxes. my current code has no build errors doesn't seem return information. small , i'm being idiot cant fathom problem. private sub btnsearchproducts_click(byval sender system.object, byval e system.eventargs) handles btnsearchproducts.click ds.clear() if txtproductname.text = "" , txtproductid.text = "" messagebox.show("please enter either product id or product name..", "authentication error", messageboxbuttons.ok, messageboxicon.error) else if txtproductid.text <> "" each ch char in txtproductid.text if not char.isdigit(ch) txtproductid.clear() msgbox("please enter valid product id. integers valid input", messageboxbuttons.ok, messageboxicon.error) exit sub e

How do I run a long block of ruby code in a HAML file, including an array? -

i have bit of ruby outputs correctly .rb file. however, want include equivalent code in haml file, , can't output correctly. i've tried reformat in various ways, haven't been able figure out, nor find i'm looking in question. i'm generating repeated div blocks, using elements stored in array of arrays. there groups of 3 .class objects want group under .row. i've got make bunch of these, want automate if possible. right can run ruby code in sublime text, , copy+paste formatted haml haml page... seems should able in-line! here's ruby code: gfys = [ [ #row 1 {"title"=>"move", "id"=>"#gfy0a", "desc"=>"use either analog stick or directional buttons."}, {"title"=>"shoot", "id"=>"#gfy0b", "desc"=>"press button; pull trigger."}, {"title"=>"push", "id"=>"#gfy0c",

c - Return statement in function never prints to screen -

i'm trying pass in parameters 1 function, store values set of elements in struct. print values within struct, calling function. here's i'm trying do: #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct temp { int num; char * name; struct temp * nextptr; }temp; temp * test(); char * printtest(temp * print); int main (void) { test("tv",200); struct temp * t; printtest(t); return 0; } temp * test(char * name, int num) { struct temp * mem = malloc(sizeof(struct temp)); mem->name = malloc(sizeof(strlen(name) + 1)); mem->name = name; mem->num = num; mem->nextptr = null; return mem; } char * printtest(temp * print) { char * output; output = malloc(sizeof(struct temp)); print = malloc(sizeof(struct temp)); sprintf(output,"it's name %s, , costs %d",print->name,print->num); return output; //should print "tv"

ruby on rails - How to validate the state of a join model before creation -

as got downvoted first time, time try clear possible goals. if they're not clear, please let me know what's missing. i have course , students have has_many through: relationship. when create record newcourseparticipation, check if course full (via full? method). what best way that? first impulse introduce conditional check in create action of controller, i'm doing validation in course model. think best "before_create" validation in courseparticipation model. not sure how though. my course model class course < activerecord::base has_many :students, through: course_participations has_many :course_participations end and student model class student < activerecord::base has_many :courses, through: course_participations end the join model class courseparticipation < activerecord::base belongs_to :student belongs_to :course end in userscontroller: def create @course = course.find(params[:course_id]) @student = student.find

c# - Saving data to cache and retrieving it -

Image
i have been using following cache class cache class i have following in code, first sql statement select id, ambitiousdescription [user].[ambitious_description] next part when read in list var ambition = sqlcon.read().tolist(); i save cache, saves me doing multiple trips database. cache.cacheextension.savetocache("ambition", ambition, new datetime(1)); at top of method check see if in cache shown here if (cache.cacheextension.isincache("ambition")) { var listambition = new selectlist(cache.cacheextension.getfromcache("ambition"), "1", "ambitiousdescription"); } else { // otherwise database } i red error under word getfromcache reads i'm not 100% syntax retrieve cache if can i'd appreciate it. update after comments stephen decided create class called ambitiondetails shown here: public class ambitiondetails { public int id { get; set; } public string description { get; set;

access vba - Run-Time error '3075' when using sql UPDATE SET FROM WHERE -

i did simple syntax error. couldn't find similar on web i'm asking guys here. i'm trying update field 'true' if there match between 2 columns in 2 different tables, example table1: cat selected table2: cat 1 false 2 2 false 3 then "selected" field "2" changed true: table1: cat selected table2: cat 1 false 2 2 true 3 i'm using following sql code: docmd.runsql "update table1 set table1.selected=-1 " & _ "from table2, table1 " & _ "where table1.cat=table2.cat" and i'm getting error '3075' say: syntax error (missing operator) in query expression '-1 table2'. when i'm removing from statement, problem disappear, i'm writing values table2 manually. hope can help, thank in advance. i think solved doing: docmd.runsq

java - Convert string array to strings with a whitespace separating them -

this question has answer here: a quick , easy way join array elements separator (the opposite of split) in java [duplicate] 15 answers i have string array (not arraylist), best way print new string whitespace separating them, lets say string array = {"a", "b", "c"}; i want print "a b c", how can that? you can use code string whitespace. string[] array = {"a", "b", "c"}; string output = ""; (int = 0; < array.length; i++) { output += array[i] + " "; }

html - How do I change the source of the images in this table? -

code http://jsbin.com/ratohaxiya/1/edit?html,css,output for instance want use single png file hawks logo instead of taking them here img src not work , have keep background colors same it not recommended use many image files large set of small icons since effect page load time negatively. each individual file requested server , times waiting reply takes longer actual download. however, if opt replace current code locates position of each icon in css file. replace this: a[href$="/r/atlantahawks#s"]:before { background-position: 2px 1px!important } with using own filepaths: a[href$="/r/atlantahawks#s"]:before { background-image: url("hawks-filepath.png"); } this change shouldn't affect background color since wasn't part of image sprite sheet.

Android Studio Protocol family unavailable error -

Image
when launch android studio first time, see error.how can solve problem ? hi faced same issue, added application gradle manually application(i.e,select right side gradle option in studio , click plus button in top left corner choose gradle file).now error remain same can able run project.

android - Add title and subtitle to Chromecast loading screen with cwac-mediarouter? -

i working android chromecast app , since want have default actionbar rather using android support v7 actionbar used cwac-mediarouter . the problem i'm facing right unable add title , subtitle chromecast default loading screen. when trying mediarouter-v7 able add title using mediametadata , mediainfo classes. mediametadata mediametadata = new mediametadata(mediametadata.media_type_movie); mediametadata.putstring(mediametadata.key_title, getstring(r.string.loading)); mediametadata.putstring(mediametadata.key_album_title, getstring(r.string.app_name)); mediainfo mediainfo = new mediainfo.builder(getstring(r.string.video_url)) .setcontenttype(getstring(r.string.content_type_mp4)) .setstreamtype(mediainfo.stream_type_buffered) .setmetadata(mediametadata) .build(); try { mremotemediaplayer.load(mapiclient, mediainfo, true) .setresultcallback(new resultcallback<remotemediaplayer.mediach

bluetooth - How to use gatttool non-interactive mode -

i want write gatttool in non-interactive mode. $ sudo gatttool -i hci0 -b 78:a5:04:44:0a:57 -i [78:a5:04:44:0a:57][le]> connect attempting connect 78:a5:04:44:0a:57 connection successful [78:a5:04:44:0a:57][le]> char-write-cmd 0x0025 ff i'm changing color of light using bluetooth. what equivalent using non-interactive mode? tried this, doesn't change color of light , stop must use ctrl+c . there no message @ all. sudo gatttool -i hci0 -b 78:a5:04:44:0a:57 --char-write -a 0x0025 -n ff how can write command? environment: i'm using raspberry pi , rasbian . the option not --char-write --char-write-req . total command must be: sudo gatttool -i hci0 -b 78:a5:04:44:0a:57 --char-write-req -a 0x0025 -n ff

AngularJS with Laravel 5 using NPM -

i want use angularjs laravel 5 . since laravel uses npm gulp , laravel-elixir , first step edit packages.json : { "private": true, "devdependencies": { "gulp": "^3.8.8", "laravel-elixir": "*", "angular": "*" // import angular } } after executing npm install angularjs downloaded node_modules/angular folder. now how use angular.js in html? note: host settings pointing public folder. edit: i'm using piece of code in gulp.js file: elixir(function(mix) { mix.copy('node_modules/angular/*.min.js', 'public/js/'); mix.copy('node_modules/angular-aria/*.min.js', 'public/js/'); mix.copy('node_modules/angular-animate/*.min.js', 'public/js/'); }); so did, should've done before asking question. documentation. as example try use lumx css framework bower package laravel 5. step 1. install lumx , requi

git - Unfork a Github fork without deleting -

i "unfork" github fork without deleting + recreating it. possible? my reason project has different use source of fork, , makes no sense showing number of commits ahead, or pull request button (or @ least, such prominence). hindsight, think have git clone d original, rather made fork. i not delete fork in order keep issues + history of pull requests made. i happy keep history of commits, it's removal of fork status i'm after. i remember reading year ago in 1 of github's pages. mentioned contact github staff explaining situation. staff needful. edit after browsing through github pages list, see bit off actual task. page remembered transferring repository ; in particular: if transferred repository has forks , forks associated new repository after transfer complete. keep in mind users have forked repository need update remote urls point new git repository in order continue opening pull requests. it still worth contact staff par

android - Check programmatically if open WLAN network is really open -

there 2 kinds of open (unencrypted) wlan networks: 1 open , provides ip , network access after connecting it, , 1 additional authentication necessary after connection (typically via webpage special credentials have entered belong provider of service). is possible find out kind of "open" network available before connecting it? possibly somehow via scanresult objects returned result wifimanager.startscan()? thanks! is possible find out kind of "open" network available before connecting it? in short, no. android wifimanager (and, indeed, computers' networking drivers / stack) concerned low level communications. looking @ osi model, physical level, data link level , network level. wlan hardware, drivers etc have concerns include scanning available aps , verifying whether offer 'open' access or require authentication although in latter case concerned wep/wpa style authentication , doesn't consider higher level of control / secur

Laravel Server file path Error -

i downloading file google drive , saving locally , later submit url. after fetching file google drive, can access locally. when hosted file path changes in laravel (on pagodabox). this except of code: $path_to_save_file = public_path('myuploads/sample.txt'); $xlsfile = file_put_contents($path_to_save_file, file_get_contents($url)); $real_path = realpath($path_to_save_file); echo $real_path; nb: locally, expected file path. when hosted pagoda, url says /data/public/myuploads/sample.txt doesn't give me access file posting.

css3 - jQuery selector for element with numeric id using CSS escapes -

i'm trying give red color div id='1' class='std' using jquery (i equals 1): $("#" + i).css("background-color", "red"); code snippet: for(var i=0 ; i< info.length ; i++ ){ var div_std ='<div id="'+i+'" class="std"> <p> name :<b> '+info[i].nom_etud + ' </b></p> <hr><p> abs hours : '+info[i].hr_cours +'</p>' ; div_std+='<p> tps hours : '+info[i].hr_tp+'</p><section id="footstd"><button type="button" name="">mark absent</button><img src="images/abs.png"></section>'+'</div>'; if(info[i].col == 1) { $(function() { $("#\\" + i.tostring().charcodeat(0).tostring(16)).css("backgroun

c# - Updating chat whenever it updates -

i scripted live chat updates asynchronously asp:timer every 5000 m/s (5s). i'd instead make update in everyone's computer whenever updates instead of waiting 5 seconds every time. skype , facebook do. how can this? realtime updates server client achieved using web sockets. new transport available realtime updates. earlier methods long polling run problems or lot of handling in code run stable environment. you use third party library called signalr uses web sockets in background , provides backward compatibility earlier methods long polling. can read more on technology here http://www.asp.net/signalr/overview/getting-started/introduction-to-signalr