Posts

Showing posts from January, 2010

c# - Executing function based on pointer location -

Image
i working arcgis sdk dot net. programming using vc#. want execute piece of code mouse pointer enters particular longitude/latitude on map or if mouse clicked on location. there many event handlers don't know how retrieve location mouse pointer at. e.g want display picture mouse pointer @ longitude 25 , lat 33. add mousemove listener mapview . your listener method have parameter of type mouseeventargs . call getposition(null) on parameter screen point. use mapview.screentolocation(point) mappoint in map coordinates. if map isn't in longitude/latitude, use geometryengine.project(geometry, spatialreference.create(4326)) convert longitude/latitude. check longitude , latitude see if they're in range want. i tried posting source code here stack overflow gave me error, here screenshot:

php - (AuthComponent::user('role') in cakephp not returning data correctly in cakephp -

login: public function login(){ if($this->request->is('post')){ if($this->auth->login($this->request->data)){ return $this->redirect($this->auth->redirecturl()); }else{ $this->session->setflash('invalid username or password'); } } } this return value: if(authcomponent::user() but when use this: if((authcomponent::user('role'))==1) it does't return value @ all i can login-logout normally when authenticating users, attached authentication objects checked in order attached. once 1 of objects can identify user, no other objects checked. sample login function working login form like: public function login() { if ($this->request->is('post')) { // important: use login() without arguments! see warning below. if ($this->auth->login()) { return $this->redirect($this->auth->redirecturl())

newInstance() is not displayed for XML file creation in java -

i had imported javax.xml.parsers.documentbuilder , javax.xml.parsers.documentbuilderfactory xml manipulation. while creating reference document builderfactory, newinstance() not displayed. me fix it? syntax: documentbuilderfactory factory = documentbuilderfactory .newinstance();

android - In GCM: Does API Project account have to be the same as Google Play Store account? -

i have backend sending gcm push notifications uses api-project (sender_id) created under google-account. works great app published under google play store account (same google-account api-project). now have publish app friend under google play store account, , use same sender_id use in own app (that way not need changes on backend). is possible? can app under google play store account use sender_id (api-project) created different google-account google play store google-account? if answer positive: there possibility google requires in future api-project , google play store have in same google-account? (for security reasons, example) thanks! i believe thing requires same api project account , play store account if have link application google play services. using same senderid welcomed (see this question ). if application not yours, there obvious downsides of being harder maintain , debug, if you're fine that, having different accounts should work fine.

javascript - angular ui bootstrap: promise resolved/rejected when modal closed -

i'm working on angular , bootstap, using angular-ui-bootstrap bridge library. thing want achieve reuse modal component , wrap in promise resolved when modal closed (when pressing ok button) or rejected ( cancel button pressed or clicked outside of modal). as far can see, there $modal service comes bridge library, has 1 method available: open(options) . there built-in angular promise implementation : $q . i'm looking way on how combine two. i want have custom component (a service, factory?) provide startflow method return promise. calling startflow open bootstrap modal. when modal closed (positively or negatively), promisewould resolved or rejected. can give hint on how implement that? ddin't manage find existing solution far... the result property on object returned open promise behaves describe. in fact example in documentation @ https://angular-ui.github.io/bootstrap/#/modal uses it: var modalinstance = $modal.open({ templateurl: 'mymod

Android Studio Gradle - JavaExec classpath configuration - Java Reflection - class access -

im working on android project have process .java-files possibly generate .java-files should compiled , packed .apk-file. lets assume have 2 files processed library, file_a.java , file_b.java. now need access these files within library via reflection, e.g. with: class.forname("com.test.entities.file_a"); class.forname("com.test.entities.file_b"); the problem i'm not able access class files, think because of missing classpath configuration. use task call .jar-file: task (mytask, type: org.gradle.api.tasks.javaexec) { classpath(files('libs/myjar.jar')) main('com.test.testmain') } prebuild.dependson mytask i found ressources on web, don't work. i tried add following classpath: sourcesets.main.runtimeclasspath (main unknown) android.sourcesets.main.runtimeclasspath (runtimeclasspath unkown). so how can access class files in library? try task execute(dependson: ['compilereleasejavawithjavac'],

memory - Are non-static fields static until they're changed in Java? -

let's consider following code: public class testing { static int = 47; public static void main(string[] args) { testing t1 = new testing(); testing t2 = new testing(); system.out.println(t1.i == t2.i); i'm creating static field belonging testing class , field shared among 2 instances of class t1 , t2 well. test if reference same value in memory , indeed, do, result true. , that's clear me. however, if delete static keyword declaration of int i , unexpected happen. public class testing { int = 47; public static void main(string[] args) { testing t1 = new testing(); testing t2 = new testing(); system.out.println(t1.i == t2.i); i expect 2 instances t1 , t2 both have 47 value of field fields in different memory addresses. surprisingly, when test t1.i == t2.i true in case - why? field int = 47; not static anymore expect in different memory addresses every instance of class equality yields true.

Formatting strings in python with variables -

so code returns error "unknown format code 'e' object of type 'str'". why?? c="*"*i e=input01 d="{:>e}" print(d.format(c)) pass e format variable, using string "e" hence error: d = "{:>{e}}" print(d.format(c, e=e)) you can see passing variable right adjusts string correctly: in [3]: c = "*" * 4 in [4]: e = "10" in [5]: d = "{:>{e}}" in [6]: d.format(c, e=e) out[6]: ' ****' you remove e format , pass second arg format: d = "{:>{}}" print(d.format(c, e)) either way {} after > essential.

java - Using Action Listeners for buttons -

code: java sphere class import javax.swing.*; import java.awt.*; import java.awt.geom.ellipse2d; public class sphere extends jpanel { private boolean flashinglights = false; private int x = 168; private int y = 75; public void paintcomponent(graphics g) { super.paintcomponent(g); graphics2d g2 = (graphics2d) g; if (flashinglights) { //this flash option. here should change between grey , orange g2.setcolor(color.orange); ellipse2d.double ball = new ellipse2d.double(x, y, 50, 50); g2.draw(ball); g2.fill(ball); } else { g2.setcolor(color.gray); //this should stay grey now. ellipse2d.double ball = new ellipse2d.double(x, y, 50, 50); g2.draw(ball); g2.fill(ball); } } public void chooseflashinglights(){ //ignore these methods flashinglights = false; } public void choosesteady(){ flashinglights = true; } public void flickerorange(int d) { y = y + d; } public void flickergrey(int d) {

android - implementing app in purchase using ionic framework -

n above blog post, have debug using real device. in code if((window.device && device.platform == "android") && typeof inappbilling !== "undefined") { inappbilling.init(function(resultinit) { console.log("iab initialized"); }, function(errorinit) { console.log("error -> " + errorinit); }, {showlog: true}, ["productid1", "productid2", "productid3"]); } how can see console.log in device? this post contains answer question. basically, need have latest ionicframework release installed ( npm install -g ionic or npm update -g ionic fo update) not can run livereload, you can access console logs device , server logs showing files device requesting. lets build app in browser, debug on actual device or emulator (genymotion works, too). how start it? can pass few flags, in combination, in run/emulate commands: examples: $ ionic emulate ios --livereload --consolelogs --serverlog

algorithm - Why the probability of an empty slot preceded by i full slots getting filled next is (i + 1)/m in context of Primary clustering in Hashing? -

why probability of empty slot preceded full slots getting filled next (i + 1)/m in context of primary clustering in hashing open addressing collision resolution technique , linear probing? excerpt introduction algorithms clrs "long runs of occupied slots build up, increasing average search time. clusters arise because empty slot preceded full slots gets filled next probability (i + 1)/m. long runs of occupied slots tend longer,and average search time increases." please help. i think got answer it. for empty slot (say j) preceded full slots filled next element should hash of slots or slot j. book says: we shall assume given element equally hash of m slots, independently of other element has hashed to. i.e. probability element hashes slot k 1/m. so, required probability ( 1/m + 1/m + ... times ) + 1/m {for slot j} = (i+1)/m

r - how can I plot one heatmap using two data sets -

all existed answers not working me! these questions making heat maps side side, to display 2 heatmaps in same pdf side side in r or side-by-side plots ggplot2 or others i have 2 dfs want plot 10 highest rows (based on average) of df1 , 10 lowest rows (based on average) how force ggplot order x-axis or y axis want in plot? df1 taken previous post, , df2 follows. df2<- structure(list(phenelzine = c(-0.0665, -0.077, -0.0168, -0.1448, 0.0571, 0.0032, 0.5728, -0.0322, -0.4072, 0.2572, 0.1139, 0.0462, -0.0317, 0.1378, -0.1963, 0.5325, 0.0716, 0.522, -0.027, 0.3913 ), denatonium.benzoate = c(0.0386, -0.1908, -0.1477, 0.0331, -0.0628, 0.0012, -0.0107, 0.0382, -0.2829, -0.1123, 0.3734, 0.094, -0.0433, 0.1303, -0.0427, 0.0232, 0.0366, 0.0858, 0.0066, -0.2011 ), triamterene = c(-0.0486, 0.3781, -0.0366, 0.2605, -0.1519, 0.5596, 0.0218, -0.2791, 0.3106, 0.0682, -0.0829, 0.1277, -0.1318, -0.2668, -0.2608, 0.3003, 0.0567, 0.0204, 0.1276, 0.0999), talampicillin = c(0.0064,

php - combining output of a query -

i fetching data 3 tables of join. output in json format. output in json format:- {"order_id":"2","location_address":"testing location delhi","emp_first_name":" ranjeet ","order_status":"0","from_date":"0000-00-00 00:00:00","actions":"\r\n </i> edit </a>\r\n \r\n </i> delete </a>"}, {"order_id":"2","location_address":"testing location delhi","emp_first_name":" abhijeet ","order_status":"0","from_date":"0000-00-00 00:00:00","actions":"\r\n </i> edit </a>\r\n \r\n </i> delete </a>"}, the problem is, in above output, data same emp_first_name different because both having seperate id's. want combine data of both emp_first_name , display single output like the output want :- {"order_i

c - Dynamic memory allocation and sizeof() -

for allocating memory 2 dimensional array dynamically, write this int **ar = (int **)malloc(row*sizeof(int*)); for(i = 0; < row; i++) ar[i] = (int*)malloc(col*sizeof(int)); i came across code same cannot understand declaration. double (*buf)[2] = (double (*)[2])malloc(count*sizeof(double [2]));// explain printf("%d, %d, %d, %d \n",sizeof(double)); printf(" %d",sizeof(buf[0])); printf(" %d", sizeof(buf)); //prints 8, 16, 16, 4 when count 3 the output of first printf() trivial. please me next two. double (*buf)[2] = (double (*)[2])malloc(count*sizeof(double [2]));// explain this double (*buf)[2] defines buf pointer array of 2 double s. this (double (*)[2])malloc(count*sizeof(double [2])); can (and shall) rewritten malloc(count * sizeof(double [2])); the above line allocates memory size of count times "size array of 2 double s". this = assigns latter former. it ends buf pointing array of

jquery - find selected child with .on method -

how can property (i.e "id"), of child selector element? im using .on() method because elemenets created ajax call. $(this).attr('id'); returns id of selector, how 1 of child selector? tried: $(this).find(':selected').attr('id'); not helps. code: $(document).ready(function () { var userbtn = $(".userbutton"); $(".listbox").on("click", userbtn, function () { var userid = $(this).attr('id'); console.log(userid); }); }); the second parameter click handler child selector you're passing jquery wrapped object. $(".listbox").on("click",".userbutton",function(){ var userid=$(this).attr('id'); alert(userid); }); <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.2.min.js"></script> <ul class="listbox"> <li class="userbutto

Return JSON data in response in ColdFusion -

i'm working in icims api. need return json data , specific data in header in cfm page call icims server. here response should be: response work flow status change push event platform: http/1.1 303 see other location: http://xx.xx.xx.xx:8085/selectpackage?systemhash=101 content-type: application/json { "usermessage":"confirm or modify package.", } thanks in advance. answer: > <cfset contentstring = '{"usermessage": "confirm or modify package."}' > /> > > <cfheader name="location" > value="http://xx.xx.xx.xx:8085/selectpackage?systemhash=101" /> > <cfcontent type="application/json" variable="#tobinary( tobase64( contentstring ) )#" /> <cfheader statuscode = "303" statustext = "see other"> <cfheader name="location" value="http://xx.xx.xx.xx:8085/selectpackage?systemhash=

How to correctly update system ruby version to latest version (2.2.1) on OSX -

just trying update latest version of ruby. on ruby-lang.org/en/documentation/installation/#homebrew, found should able via homebrew: brew install ruby however, when listed ruby version (ruby -v) after 'updated' still @ old version 2.0.0. hermes:~ sancho$ ruby -v ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13] i happened list contents of /usr/local/bin/ , see symbolic link: ruby -> ../cellar/ruby/2.2.1/bin/ruby so, don't know what's happening , why version still lists old number , not 2.2.1, looks should. there sym links various other ruby tools (erb, gem, irb, rake, rdoc, ri) version 2.2.1 also. so happening here , how correctly install version 2.2.1? i have rvm installed also, want update system version of ruby latest. use homebrew make sure /usr/local/bin in path. ex: .bashrc export path=/usr/local/bin:$path this not update system ruby version. instead install version of ruby , line tells bash new versi

how to which person has all the things ? mysql -

below table person things tv car mobile house b tv c tv c car c mobile c house d tv e tv f tv above can see , c has things. as per book example able find thing every person has ? using below query , select things tbl_happiness x not exists ( select person tbl_happiness y not exists ( select 1 tbl_happiness z z.person = y.person , z.things = x.things ) ); is possible use same query change in alias name , find which person has things ? i approach these "set-within-sets" queries using group by , having : select person table t group person having count(distinct thing) = (select count(distinct thing) table t); if there no duplicates, can use: having count(*) = (select count(distinct thing) table t);

markdown - Stackedit doesn't accept custom CSS -

i'm trying follow guide: http://pacinispace.blogspot.it/2013/07/write-in-markdown-stackedit-with-custom.html in order improve markdown rendering. now, copied , pasted default template proposed guy. stackedit should refer custom css shown in blog post (via google drive), instead, in live preview, cannot observe change in way renders markdown. seems still refer "base.css". why? another (related) question: great customise alternative themes provided stackedit (solarized, night, etc..). it's possible? thanks. in order use template, should paste "default template". use "export disk -> using template" stackedit changed bit since wrote blog post. stackedit opensource project (and should still be); try find repository , non-minified css. able download , edit. other option open theme html source , download css.

python - How to remove a substring from a string based on list of strings -

i have list of strings(colors), l = ['chocolate brown','brown','chocolate'] i have string: sentence = "the jeans chocolate brown in color , has brown colored pockets" i have remove chocolate brown , brown string. example. whenever encounter color in string have remove if exists in list of colors. efficient way it? one approach thought split string trigrams, bigrams , unigrams. joining these n-grams , consistently between n-grams problem. my original list huge , string short. need efficient solution since have loop on elements of list. possible if check string color , check if color in list. wouldn't efficient solution? you use re : >>> import re >>> l = ['chocolate brown','brown','chocolate'] >>> s = "the jeans chocolate brown in color , has brown colored pockets" >>> >>> re.sub('|'.join(re.escape(r) r in l), '', s) 'the j

Are there examples of deprecated HTML elements that lost support in current browsers? -

Image
most of know , tags deprecated status, means has been outdated. either followed newer html construct, or can done in css (take example <center> ). question i'm wondering about, though, is: when tag or element gets deprecated removed browser support in future? in other words, browsers know of support <center> , can imagine might not efficient browsers keep supporting deprecated content. therefore, support must drop after time. is browsers drop support tag or element once quite common? provide question that's better suited question-answer template, i'll rephrase of above: are cases known browsers have dropped support property or element once common? the thing find in the docs , stating: deprecated deprecated element or attribute 1 has been outdated newer constructs. deprecated elements defined in reference manual in appropriate locations, marked deprecated. deprecated elements may become obsolete in future versions of html. user agents sh

angularjs - Getting unique id in firebase -

i using firebase project , trying of objects database, running piece of code them: var ref = new firebase("https://<fire-base-database>.firebaseio.com/games"); $scope.games = $firebasearray(ref); i getting objects correctly when try access id's .$id not getting data back... is there way of getting object unique id (which looks jltq-w2rtwpoukb2_gp )? need show detail view of item when clicks on it. thank in advance! i managed solve getting key in ng-repeat (key, games) in games , gave me access key.

html - Code to Start and Stop a broadcasting script on a schedule -

i new coding. i work sports complex , have set live streaming. currently have manually go streaming platform , click "start broadcasting" , "stop broadcasting" when want things happen. i wondering if can add code html these functions automatically on scheduled timer specify? thanks, jade your code not specific, going assume have javascript functions defined somewhere can start , stop broadcasting. this: function startbroadcasting() { // whatever takes start broadcasting } function stopbroadcasting() { // whatever takes stop broadcasting } what need then, call, in script tag @ bottom of body, this: var running = false; function myscheduler() { var = new date(); var dow = now.getday(); var hr = now.gethours(); var min = now.getminutes(); var sec = now.getseconds(); if (dow === 6 && hr === 7 && min === 0 && !running) { settimeout(startbroadcasting, 0); } if (dow === 9 &

smalltalk - Subclassing Stream -

i interested in creating own stream subclass , i'm wondering methods should override (deploying on pharo , gemstone). have collection various types of things in , want able stream on subset of it, containing elements of class. don't want copy collection or use collect: block because collection may large. first use case this: stream := self mailbox streamof: qturnmessage. stream size > 1 iftrue: [ ^ stream at: 2 ] iffalse: [ ^ nil ] any pointers on methods override? in smalltalk, when stream refer objects respond basic protocol given few methods such #next, #nextput:, #contents, etc. so, before going further detail stream at: 2 , put in example, not appropriate expression. more appropriate expressions stream be stream position: 2. ^stream next so, first thing have consider whether looking stream or collection . basic decision depends on behavior objects have implement. use subclass of stream in case decide want enumerate elements using #next

php - Laravel 5 Cached Routes not updating -

i've cached laravel 5 routes doing php artisan route:cache . went succesfull quite while , when changed route cache them again , work should. the problem i've moved routes route group , seems won't cached reason. i've tried cache them again didn't work. i've tried php artisan cache:clear still not working. routes.php changes: route::group(['prefix' => 'api', 'middleware' => 'auth'], function () { route::get('invites', 'invitationcontroller@get'); route::get('invites/check', 'invitationcontroller@check'); }); changed to: route::group(['prefix' => 'api'], function () { route::post('auth', 'auth\authcontroller@authenticate'); route::get('invites', 'invitationcontroller@get'); route::get('invites/check', 'invitationcontroller@check'); }); as can see i've moved invitation routes route group wit

algorithm - What is time-complexity of T(N)=4T(N/2)+(N^2)/logN -

this question given in mit video on analysis of algorithms, following question can not done using master method , can solved using recurrence tree. can please tell me solution? why claim can not done masters theorem ?. theorem has constraints a , b constants , a >= 1 , b > 1 . hold f(n) , therefore can apply here. if apply see a=4, b=2 , therefore c = 2 . n^c grows faster f(n) , therefore complexity o(n^2) .

Jquery Dropdown Menu: The Dropdown works fine but animation doesn't work, help and Thanks -

http://jsfiddle.net/jerrypeng0112/ahm7q1bq/ i've spent while on problem, way make work set specific width tag, cause long links word wrap. if don't set it, won't word wrap animation not working. html `<body> <header id="header"> <nav> <ul id="main"> <li><a href="#">home</a> </li> <li> <a href="#">about</a> <ul class="hidden"> <li><a href="#">about 1</a> </li> <li><a href="#">about 2</a> </li> <li><a href="#">about 3</a> </li> </ul> </li> <li>

gradle - How to set android target level 21 -

i finished developing app. , want change target api level of app 21. should change 21 or leave @ 19? changes have make gradle file make target set 21? thanks go module's build.gradle file (not 1 project) , replace 19 21. should similar below compilesdkversion 21 buildtoolsversion '21.1.2' defaultconfig { minsdkversion 8 targetsdkversion 21 versioncode 1 versionname "1.0" } also change in manifest <uses-sdk android:targetsdkversion="21"></uses-sdk>

android - 2.3.3 app not working in higher versions -

i made small app displays text , move in between pages made 2.3.3 sdk 10 version when install in 4.4.1 phones having compatibility issues saying incompatible version package com.top20e1; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.view.window; import android.widget.button; public class topactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.main); // requestwindowfeature(window.feature_no_title); final button switchact =(button)findviewbyid(r.id.button1); switchact.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent act2 = new intent(view.getcontext(),secondactivity.class); startactivity(a

HTTP Error 500 when using curl in PHP -

<?php ini_set('display_errors', 1); set_time_limit(0); $word = "product"; $ch = curl_init(); curl_setopt($ch, curlopt_url, "http://words.bighugelabs.com/api/2/ad63536b2f8108efe8c07295746c5a09/$word/json"); curl_setopt($ch, curlopt_returntransfer, 1); $data = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); $bigarray = array(); if ($info['http_code'] == 200) { $result = json_decode($data, true); $final = json_encode($result,json_pretty_print); file_put_contents("results.json", $final); $bigarray = $result["noun"]["syn"]; } else echo "http error: ".$info['http_code']; foreach ($bigarray $value) { echo $value."<br>"; } ?> this code displays synonyms of $word variable.when executing on xampp gives http error 500, worked fine before error emerged the http status code 500 means in case, api key no longer valid or inactive key. use

mysql - Doctrine on PHP FastCGI IIS 8 error -

this kind of strange problem. i have website hosted on server apache, php 5.4 , mysql 5.0.95 on redhat 5. for reason long discussed, web site had migrated windows server 2012. i'm using php 5.4 fastcgi , mysql 5.5 on iis 8. finally, got website work except 1 problem. when user trying register , new record inserted users table, error: fatal error: uncaught exception 'doctrine_connection_mysql_exception' message 'sqlstate[hy000]: general error: 1364 field 'district' doesn't have default value' in c:\websites\www.mysite.com\system\database\doctrine\doctrine\connection.php:1082 stack trace: #0 c:\websites\www.mysite.com\system\database\doctrine\doctrine\connection\statement.php(269): doctrine_connection->rethrowexception(object(pdoexception), object(doctrine_connection_statement)) #1 c:\websites\www.mysite.com\system\database\doctrine\doctrine\connection.php(1042): doctrine_connection_statement->execute(array) #2 c:\websites\www.mysite.

javascript - Node.js exec call never calls callback -

i have node.js script makes call exec never calls callback. code: var exec = require('child_process').exec; exec("{command} > results.log", function (error, stdout, stderr) { console.log('callback called!'); // never gets called. }); i'm using async lib , i'm relying on exec callback called can in turn call async callback continue execution flow. command indeed executed, see output results.log file. doing wrong here? you're piping returned result file, never returns node. exec("{command}", function (error, stdout, stderr) { console.log('callback called!'); // never gets called. });

zeroClipboard copy to click not working -

i have searched question related zeroclipborad, can not done. having wordpress site, running on bootstrap based theme. want have copy option. made button named copy , after copy, want changed name copied. have following code, not work. <div id="code_id">mycode</div> <button class="btn btn-default" id="copy-button">copy</button> <script language='javascript' type='text/javascript'> jquery(document).ready(function(){ jquery('#copy-button').zclip({ path:'js/zeroclipboard.swf', copy:'jquery('#code_id').text()' aftercopy:function(){ jquery("#copy-button").text("copied"); } }); }); </script>

scheme - Replicate Function -

i'm trying rewrite code function replicate repeats first item of list n times , returns list repeated first item , rest of list. here original function: (check-expect (replicateone 1 '(stays same)) '(stays same)) (check-expect (replicateone 0 '(hello bye)) '(bye)) (check-expect (replicateone 3 '(repeat second third )) '(repeat repeat repeat second third)) (define (replicateone n nonemptylist) (cond [(zero? n) (rest nonemptylist)] [else (cons (first nonemptylist) (replicateone (sub1 n) nonemptylist))])) this have right now, it's not working. (define (iterate f n x) (cond [(zero? n) x] [else (iterate f (sub1 n) (f x))])) (define (replicateone n nonemptylist) (iterate (λ (x) (list x x)) n nonemptylist)) i'm trying in isl+ without recursion, i'm unsure how write iterate function using new techniques. feel use foldr, i'm not sure. any great since i'm still learning. thank you

regex - R: how to convert part of a string to variable name and return its value in the same string? -

suppose have string marco <- 'polo' . there way can embed marco in middle of string, e.g. x <- 'john plays water marco.' , have x return 'john plays water polo.' ? edit the solution david kindly offered work hypothetical problem posted above, trying this: data <- c('kek','koki','ukak','ikka') v <- c('a|e|i|o|u') rather deleting vowels, solution can manage ( gsub(v,'',data) ), how specify, say, vowels between 2 k's? gsub('kvk','',data) doesn't work. appreciated. if want all vowels between 2 "k" letters removed, propose following: v <- '[aeiou]' data <- c('kek', 'koki', 'ukak', 'ikka', 'keeuiokaeioukaeiousk') gsub(paste0('(?:\\g(?!^)|[^k]*k(?=[^k]+k))\\k', v), '', data, perl=t) # [1] "kk" "kki" "ukk" "ikka" "kkksk"

c - Pass a two dimensional array to a function of constant parameter -

i learned c primer plus if want protect array being accidentally modified function, should add const modifier before pointer declaration in header of function definition. following sensible advice, in following minimal example, i'm trying pass non-constant two-dimensional array array function sum2d , 1 parameter of pointer-to-const-int[2] . #include <stdio.h> #define rows 2 #define cols 2 int sum2d(const int ar[][cols], int rows); //use `const` protect input array int main(void) { int array[rows][cols]={{1,2},{3,4}}; //the non-constant array printf( "%d\n", sum2d(array,rows) ); return 0; } int sum2d(const int ar[][cols], int rows) { int total=0; int i,j; for( i=0 ; i<rows ; i++ ) { for( j=0 ; j<cols ; j++ ) { total+=ar[i][j]; } } return total; } however, gcc cannot compile code without issuing following warnings: $gcc -ggdb3 -wall -wextra -o test test.c test.c: in funct

dynamic - Delete[] array breaks my C++ program -

i have had issue while now. every time grow function calls delete line, program breaks. doesn't give me error besides has reached break point. have not found solution online during google searches. can help? update after hitting continue on error screen few times if came different error. states crtisvalidheappointer(puserdata) driver.cpp #include <iostream> #include "myvector.h" using namespace std; // printv function // used test copy constructor // parameter: myvector object void printv(myvector); int main() { cout << "\ncreating vector sam of size 4."; myvector sam(4); cout << "\npush 12 values vector."; (int = 0; < 12; i++) sam.push_back(i); cout << "\nhere sam: "; cout << sam; cout << "\n---------------\n"; cout << "\ncreating vector joe of size 4."; myvector joe(4); cout << "\npush 6 values vect

php - MySQL error on inserting row into 2 separate tables -

i'm trying insert data 2 separate tables @ same time - getting following error: you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'insert storetable (name, price, description, imagename, colors, sizes, sku,' @ line 1 here's code: // insert new store item & image database: $query = "begin; insert storetable(name, price, description, imagename, colors, sizes, sku, category, dateadded) values ('". $newstoreitemname ."', '". $newstoreitemprice ."', '". $newstoreitemdescription ."', '". $newstoreitemimagename ."', '". $newstoreitemcolors ."', '". $newstoreitemsizes ."', '".$storenewitemsku."', '".$newstoreitemcategory."', '".$storeitemdateadded."'); insert storecategoriestable (categoryname, datemodified) values('".$newstoreitemcategor

ios - How to make NSArray an acceptable value for cell.textLabel.text? -

simple recipebook application in recipebook application have 2 uitableviewcontrollers. first uitableviewcontroller contains uitableview list of recipe names. if select cell segue second uitableviewcontroller. second uitableviewcontroller contains uitableview list of ingredients. in application use recipeobject class contains 2 properties (name (type: nsstring) , ingredients (type: nsarray). recipeobject objects declared in recipedata class, this: recipeobject *recipe1 = [[recipeobject alloc]init]; recipe1.name = @"fresh coconut cake"; recipe1.ingredients = [nsarray arraywithobjects:@"coconut cups", @"milk", @"baking powder", @"butter", @"sugar", @"eggs", nil]; in first uitableviewcontroller managed print out recipe names each cell. see following code: -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ static nsstring *cellidentifier = @"recipecel

android - Retrieve email address from Parse User class -

i trying email address of user parse database using objectid . parsequery query = parseuser.getquery(); query.whereequalto("objectid", "emqw4toq0c"); query.getinbackground("email",new getcallback() { @override public void done(parseobject parseobject, parseexception e) { email= parseobject.getstring("email"); } }); } }); i trying use getinbackground() method gives error. 03-29 02:13:33.600 19659-19659/com.parse.starter e/androidruntime﹕ fatal exception: main java.lang.runtimeexception: unable start activity componentinfo{com.parse.starter/com.parse.starter.mainactivity}: java.lang.nullpointerexception: println needs message @ android.app.activitythread.performlaunchactivity(activitythread.java:2295) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2349) @ android.app.activitythread.access$700(activitythread

javascript - How To Remove Awesomium.net Scroll Bars? & Auto Scroll? -

i want remove scroll bars awesomium.net web control. in visual studio defualt web browser can remove scroll bars this. public sub loadvideo(plink string) webbrowser1.scrollbarsenabled = false end sub but dont know how on awesomium.net web control. if there isn't way on awesomium.net web control, there javascript or css code can put webpage achieve 2 things? thanks. i haven't used awesomium, it's best remove scrollbars in css. if whole outer web control/page has no scrollbars, page can have element in takes or of view area , have scrollbars. it depends if want hide graphical scrollbar or disable scrolling. usual way stop element scrolling use css overflow property, so: /* disable scrolling on body */ body { overflow:hidden; } /* optionally, disable scrolling on (not recommended because it's strong) */ * { overflow:hidden; } there's more information searching "css remove scrollbars" or in this previous

parsing - PHP Simple HTML DOM Parser - error -

i have code: <?php header('content-type: text/plain; charset=utf-8'); include('simple_html_dom.php'); $html = file_get_html('http://test.com/'); $class = $html->find("thisisatest", 0)->innertext; echo $class; ?> error page: <br /> <b>notice</b>: trying property of non-object in <b>c:\xamp\htdocs\test\test.php</b> on line <b>6</b><br /> why works fine , getting error? it useful print html see u getting. url getting redirected. helpful use curl more consistent results , error check

php - RewriteEngine to hide extension ?lang="xx" -

how can rewrite url using .htaccess ? or hide ?lang=es . http://website/services?lang=es to: http://website/services/es try in .htaccess file: <ifmodule mod_rewrite.c> rewriteengine on rewriterule ^services/([a-za-z]{2})/?$ /services?lang=$1 [qsa,l] </ifmodule>

javascript - How do I get an image to stop moving when it hits the edge of a webpage? -

i want image stop if hits edge of screen, instead going indefinitely (or until crashes) , making scroll bar appear. i've tried setting stop having image's right side have lower client's width reason isn't registering viable command. in other words, how make image recognize when has hit edge of browser? html : <!doctype html> <html> <head> <h1> ----'s door prize </h1> </head> <body> <script src="doorprize.js"></script> <div id="d1" style ="display:inline"> <h3 style= "font-size:24px;" ><b> enter names </b></h3></br> <textarea style="margin: 0px; height: 347px; width: 327px;" id="contestantfield"></textarea></br> <button id="choosenames">choose participants</button> </div> <div id="d2" style="display:none"> <h3 id="