Posts

Showing posts from 2011

vb.net - How would I use a for loop to edit multiple labels in Visual basic for visual studios -

here code: private sub button1_click(sender object, e eventargs) handles button1.click dim randval integer dim label string dim val integer dim stringval string integer = 1 256 step 1 val = stringval = cstr(val) label = "label" + stringval randval = cint(math.floor((20 - 1 + 1) * rnd())) + 1 label.backcolor = color.green next end sub i error string has no property backcolor. how able edit strings without calling them individually? the error message correct: there isn't property called backcolor on string. there backcolor property on button, however, , looks if you're perhaps trying set background color of button object when it's clicked. if so, need hold of button object before can set color. event handler has made (moderately) easy, passing object handler parameter "sender". problem it's sent object, not button, first have cast type want, this: dim button button

java - RxJava. Observable.delay work strange (lacks some items at the end) -

i'm trying understand rxjava. test code is: import rx.observable; import rx.subscriber; import rx.functions.action1; import java.util.concurrent.timeunit; public class hello { public static void main(string[] args) { observable<string> observable = observable.create(new observable.onsubscribe<string>() { @override public void call(subscriber<? super string> subscriber) { try { thread.sleep(1000); subscriber.onnext("a"); thread.sleep(1000); subscriber.onnext("b"); thread.sleep(1000); subscriber.onnext("c"); thread.sleep(1000); subscriber.onnext("d"); thread.sleep(1000); subscriber.onnext("e"); thread.sleep(1000); sub

ajax - CasperJS: capturing JSON sent response to javascript onClick() -

in casperjs, working site has button this: <a id="showbills" onclick="javascript:{showbills(); return false;}" href="#">show bills</a> clicking generates xmlhttprequest post message massive form full of magic numbers , state. server responds sending json data structure want capture. in case, can't call casper.getpagecontent() json data, since it's interpreted client , incorporated dom. nor can call casper.download(...) since can't manually reconstruct form data required post request. the question how can 'intercept' json data sent in response onclick()-backed click? half idea there may way subvert showbills() method on client, example send json response ordinary page (rather xmlhttprequest). that's beyond understanding of casperjs, phantomjs , http protocols.

arrays - PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" -

i running php script, , keep getting errors like: notice: undefined variable: my_variable_name in c:\wamp\www\mypath\index.php on line 10 notice: undefined index: my_index c:\wamp\www\mypath\index.php on line 11 line 10 , 11 looks this: echo "my variable value is: " . $my_variable_name; echo "my index value is: " . $my_array["my_index"]; what these errors mean? why appear of sudden? used use script years , i've never had problem. what need fix them? this general reference question people link duplicate, instead of having explain issue on , on again. feel necessary because real-world answers on issue specific. related meta discussion: what can done repetitive questions? do “reference questions” make sense? notice: undefined variable from vast wisdom of php manual : relying on default value of uninitialized variable problematic in case of including 1 file uses same variable name. majo

opengl - Will memory leak if do multiple glBindBuffers on same buffer object, before call glDeleteBuffers? -

update discovered question duplicate of if call glbufferdata after calling on buffer, there memory leak? hopefully question still useful someone, give code samples, rather merely mentioning gl function calls, in q&a. i don't understand relationship between glgenbuffers / glbindbuffer / glbufferdata , gldeletebuffers . consider drawing sequence of lines (a line strip). original sequence drawn on number of frames, new user input increases number of lines. my first thought re-use buffer object name assigned glgenbuffers , when size changes. since buffer size needs larger, can't use existing buffer as-is. note: @ time, rather not assume "maximum size", allocate that, , sub-data calls size need. consider code based on example: when should call gldeletebuffers()? if had done these lines in initialization function before drawing first frame (code may not compile -- i'm concerned call sequence, not exact parameters pass -- i'm working in c# u

mysql - Spark DataFrame InsertIntoJDBC - TableAlreadyExists Exception -

using spark 1.4.0, trying insert data spark dataframe memsql database (which should interacting mysql database) using insertintojdbc(). keep getting runtime tablealreadyexists exception. first create memsql table this: create table if not exists table1 (id int auto_increment primary key, val int); then create simple dataframe in spark , try insert memsql this: val df = sc.parallelize(array(123,234)).todf.todf("val") //df: org.apache.spark.sql.dataframe = [val: int] df.insertintojdbc("jdbc:mysql://172.17.01:3306/test?user=root", "table1", false) java.lang.runtimeexception: table table1 exists. this solution applies general jdbc connections, although answer @wayne better solution memsql specifically. insertintojdbc seems have been deprecated of 1.4.0, , using calls write.jdbc(). write() returns dataframewriter object. if want append data table have change save mode of object "append" . another issue example in ques

javascript - Is there any way to gain access to this JSON feed purely from a browser client? -

i'd create client last.fm. music "station" feed here, in json format: http://www.last.fm/player/station/user/skeftomai/mix . however, when try access via $.getjson() , get no 'access-control-allow-origin' header present on requested resource. origin ' http://my.exampledomain.com ' therefore not allowed access. so unfortunately have cors issue on last.fm's end. i'd work around this. here things i've tried: ajax . fails access-control-allow-origin error. an iframe document.domain set "www.last.fm" or "last.fm". fails sameorigin iframe error. jsonp . unfortunately jsonp doesn't seem supported feed. a <script> tag src pointing feed link . unfortunately $('#scripttagid').html() empty. flash. unfortunately suffers same cross-origin issue. java applet. heavy, might not have jvm installed, , might suffer same cross-origin issue. i'm sure away web proxy whereby client utilizes server

AngularJS Router and ui-view -

hi have having trouble getting router work. have created page called lookup.html , i've added router file, it's not loading in ui-view when go url i've specified in router. i've created plnkr , hope help. http://plnkr.co/edit/ii7mv7jnyenhjhkx1ht5?p=linter here's router: (function () { 'use strict'; angular .module('crm.ma') .config(config); config.$inject = ['$stateprovider', '$urlrouterprovider']; function config($stateprovider, $urlrouterprovider) { $stateprovider .state('login', { url: '/login?token', data: { skipauth: true }, resolve: { valid: function (authservice, $stateparams, sessionservice, $state) { if (!sessionservice.getsession()) { if ($stateparams.token) { sessionservice.setsession($stateparams.token);

Why doesn't JavaScript require semicolons after function declarations? -

this question has answer here: why should use semicolon after every function in javascript? 7 answers a student asked me why javascript requires semicolons after variable declarations not after function declarations , didn't have answer. for example, these variable declarations (including 1 holding function) followed semicolons... var x = 5; var test = function() { return null; }; but function declaration has no semicolon afterwards nor should it. why? logic behind differentiation? why variable assignment require semicolon function declaration not? function test { return null; } semicolons serve separate statements each other, , functiondeclaration not statement.

Parse yaml into a list in python -

i required use yaml project. have yaml file using populate list in python program interacts data. my data looks this: employees: custid: 200 user: ash - smith - cox i need python code iterate on yaml file , populate list this: list_of_employees = ['ash', 'smith' 'cox'] i know must open file , store data in variable, cannot figure out how enter each element separately in list. ideally use append function don't have determine 'user' size every time. with open("employees.yaml", 'r') stream: out = yaml.load(stream) print out['employees']['user'] should give list of users.also note yaml missing 1 dash after user node

angularjs - Why does my interceptor that is defined on two modules get run twice? -

why here logged out twice? how can avoid being logged out twice, while still using factory module? (i want because makes testing easier) code: angular .module('app', ['factory']) .controller('maincontroller', maincontroller) .factory('httpinterceptorfactory', httpinterceptorfactory) .config(config) ; angular .module('factory', []) .factory('factory', factory) .factory('httpinterceptorfactory', httpinterceptorfactory) .config(config) ; function maincontroller(factory) { var vm = this; vm.sendrequest = function() { factory.sendrequest(); }; } function factory($http) { return { sendrequest: function() { $http.get('http://jsonplaceholder.typicode.com/users') } }; } function httpinterceptorfactory() { return { request: function(config) { console.log('here'); return config; } }; } function config($httpprovider) { $httpprovider.intercep

swift - Difficulty retrieving Parse Object Field Values -

i able retrieve "project" objects parse core, , "projectname" values returned me , printed log. thought these values update productnames array displayed in tableview. prototype tableview cell defined in dealcell class image , label. when run app, tableview empty. did miss? my tableview's class: var productids = [string]() var productnames = [string]() override func viewdidload() { super.viewdidload() self.productids.removeall(keepcapacity: true) self.productnames.removeall(keepcapacity: true) // ask current user's personal list of saved pfobject ids. let ids = pfuser.currentuser()?.objectforkey("accepted") as! nsarray print(ids) // requesting project objects based on ids retrieved. let projectretrieval = pfquery(classname: "project") projectretrieval.wherekey("objectid", containedin: ids [anyobject]) projectretrieval.findobjectsinbackgroundwithblock({ (objects, error) -> voi

ios - Decrement Integer Spritekit -

i have project in sprite kit , trying make timer gradually decreases. example if timer float variable set @ 3.0, gradually decrease , @ 0, 3 seconds later. way updates work in sprite kit horrible mess trying integer gradually decrease. for example: time+=1; if put in update void, increment extremely , differently depending on frames , forth. there way can increment or decrement value @ steady rate no despite fps in sprite kit? you'd better off getting current time each update , comparing initial time determine when 3 seconds pass. declare ivar in skscene subclass: @implementation myscene { nsdate* _timestamp; } when timer starts: _timestamp = [nsdate timeintervalsincereferencedate]; check timer in update pass: - (void)update:(nstimeinterval)currenttime { if(_timestamp != nil && currenttime - _timestamp.timeintervalsincereferencedate >= 3.0) { // perform timer event } // other updates }

Gradle: Could not find property 'installDist' on task ':stage' -

i have build.gradle in root project looks this: apply plugin: 'application' apply plugin: 'java' sourcecompatibility = 1.8 repositories { mavencentral() } allprojects { repositories { mavencentral() } dependencies { //....etc } } mainclassname = "com.website.main" task stage { dependson installdist println "running stage" } task wrapper(type: wrapper) { gradleversion = '2.7' //version required } however when run gradle stage get: * went wrong: problem occurred evaluating root project 'root-module'. > not find property 'installdist' on task ':stage'. the weird thing if run .\gradlew stage works fine... why this?

BigQuery Row Limits -

google says bigquery can handle billions of rows. for application estimate usage of 200,000,000 * 1000 rows. on few billion. i can partition data 200,000,000 rows per partition support in bigquery seems different tables. (please correct me if wrong) the total data size around 2tb. i saw in examples large data sizes, rows under billion. can bigquery support number of rows dealing in single table? if not, can partition in way besides multiple tables? below should answer question i run agains 1 of our dataset can see tables size close 10tb around 1.3-1.6 billion rows select round(size_bytes/1024/1024/1024/1024) tb, row_count rows [mydataset.__tables__] order row_count desc limit 10 i think max table dealt far @ least 5-6 billion , worked expected row tb rows 1 10.0 1582903965 2 11.0 1552433513 3 10.0 1526783717 4 9.0 1415777124 5 10.0 1412000551 6 10.0 1410253780 7 11.0 1398147

arrays - Displaying a message when item not found in search input - JavaScript -

i'm new javascript , working on creating basic applications. trying "not found" message display if there no contact found matching name entered in search input user. app loops through contacts array still display "no contact found" message. understand due conditional statement's "else" statement when loops through object in array , user input not match particular object on. "not found" message ends displaying default because other object's "names" property in array not match user search input loops through objects. what want know is, how message display only after has looped through of object's names in contact array and did not find matches? feel i'm missing simple. there value can return if loop finds no matches in order display message if value returns? bonus question: also, how contact information display name if @ least few characters match user search input? ex: user enters in "dav" , 1 of

parse.com - Parse::UserCannotBeAlteredWithoutSessionError 206 iOS -

i realise there many questions none specific problem. using ios sdk parse, v1.8.5 (latest). every time try saveinbackground... on pfuser.currentuser() error occurring , when pause program , check po pfuser.currentuser() in console displays current user fine , logged in no problems. not understand why getting problem then..? thanks in advance

javascript - Dynamically inserting HTML row with jQuery not working -

i trying dynamically insert row html table jquery. below code, row appears , disappears. problem? $(document).ready(function(){ var html = '<tr><td id="employee">joey cavazos</td><td class="satbr">6:30</td><td class="satdin">off</td><td class="sunbr">9:00</td><td class="sundin">off</td><td class="monbr">off</td><td class="mondin">off</td><td class="tuebr">off</td><td class="tuedin">4:00</td><td class="wedbr">8:00</td><td class="weddin">off</td><td class="trbr">8:00</td><td class="trdin">off</td><td class="fribr">off</td><td class="fridin">4:00</td> </tr>' $('#namesubmit').click(function(){ $('#schedbody tr').

c - Segfault when a large parameter is passed -

my program supposed print out every nth character in string of text. first parameter defines "n" or increment between characters report on. second parameter optional, if specified, defines how many characters work on. #include <stdio.h> #include <stdlib.h> #define max_str_len 100 int main(int argc, char **argv) { char string[max_str_len]; char *testval="this test, test. next sixty seconds, test of emergency broadcasting system."; if (argc<2) { printf("expected @ least 1 argument.\n"); return 1; } int inc=atoi(argv[1]); if (inc <=0) { printf("expected first argument positive number.\n"); return 1; } int max=max_str_len; if (argc==3) { max=atoi(argv[2]); if (max<0) max=max_str_len; } int i=0; while(i < max) { string[i]=testval[i]; // gdb says seg fault occurs i++; }

c++ - invalid operands to binary expression ('std::__1::basic_ostream<char>' and 'ostream' (aka 'basic_ostream<char>')) std::cout<<check<<std::cout; -

i'm trying solve standard interview question. i've vector each element vector of ints. v[0] employee 0 , vector of ints in v[0] number of employees reporting him, 2,3,5. if v[2] has 7 indirectly 7 reports employee 0 through 2. question find function takes in 2 ints , b , vector of dependencies , if reports b, directly or indirectly. here's bfs logic bool dependencylist(int a, int b, std::vector<std::vector<int>>& v){ std::queue<int> q; std::vector<int> d; std::unordered_map<int, int> m; for(auto = v[b].begin(); it!= v[b].end(); it++){ q.push(*it); d.push_back(*it); m[*it] = 1; } while(!q.empty()){ int num = q.front(); for(auto = v[num].begin(); != v[num].end(); it++){ if(m.find(*it) == m.end()){ d.push_back(*it); m[*it] =1; q.push(*it); } } q.pop(); } for(auto it= d.begin

mysql - Which SQL command should I use to replace specific values? -

i have numeric values below: 0 2323 1003 i have replace only single zeros 100 . tried following code affects other values include 0. update table_name set field_name= replace(field_name,"0","100"); the values should below after transaction: 100 2323 1003 which sql command should use? thanks. you should use where clause instead of replace . update table_name set field_name = 100 field_name = 0

sql - How to output a warning message to the user in APEX -

i'm uploading csv file values during apex data load wizard below table. trigger runs before each update on table1 struggling display htp output user. know how in apex? table 1 (csv) mobile , address , product , comments 12312131,50 long street,product1,null 1231231,14 blah place,product2,comment4 trigger create or replace trigger "table1_t1" before update on "table1" each row begin if :old.comments not null htp.prn ('warning: ' || :new.comments || ' replace ' || :old.comments); end if; end; you can not print message trigger. can validation more error , not warning can't continue process. or can add dynamic action on before page submit popup confirm msg , if user presses ok process continue.

ios - Storing fetched json dictionaries in array resulting in nil -

i have database of files attributes such url, title, , timestamp. when load view controller, i'm fetching file data , loading tableview. because there multiple files each 3 attributes, i'm trying save data in array, go through each object in array , extract json data. of now, request , response successful, array remains nil. approach wrong? let task = session.datataskwithrequest(request, completionhandler: {data, response, error -> void in guard let data = data, response = response else { print("no data or response!") return } let strdata = nsstring(data: data, encoding: nsutf8stringencoding) print("body: \(strdata)", terminator: "") { self.fetchedarray = try nsjsonserialization.jsonobjectwithdata(data, options: .mutableleaves) as? nsarray print("fetched array count %i \(self.fetchedarray!.count)") if let jsonar

mysql - Error's With Signup & Login PHP with Hostinger -

so have been building forum friend & has challenged me lot of server side stuff tries designing & receive lot of these error's disclaimer: know alot of has been posted find hard understand me. disclaimer: intermediate not expert @ php , have debugged hours on this. here login.php <?php //this page let log in include('config.php'); if(isset($_session['username'])) { unset($_session['username'], $_session['userid']); setcookie('username', '', time()-100); setcookie('password', '', time()-100); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link href="<?php echo $design; ?>/style.cs

Matlab code to analyze data on a grid -

i have point set (x,y) coordinates , corresponding weights in matrix 1st, 2nd , 3rd columns x, y, , weight respectively. want divide point set grid cells, , count number of points in each grid , total weight of each grid. i tried small example below, did not work. here tried divide data set 2x2 small grid , tried count number of points , sum of weights. further, have big data set, can not extend approach further when need different step sizes grid. can please me develop easier approach? function datatree count=zeros(9,1); avg=zeros(9,1); data=[1 3 100; 2 1 120; 3 5 110; 4 2 100; 5 3 150; 6 2 100]; i=1:6 if data(i,1)<=2 j=1:6 if data(j,2)<=2 count(1) = count(1) + 1; avg(1) = avg(1) + data(j,3); elseif data(j,2)<=4 count(2) = count(2) + 1; avg(2) = avg(2) + data(j,3); elseif data(j,2)<=6 count(3) = count(3) + 1;

shell - How can I get pid and its executable path information through the file which is executed by this pid? -

based on information given file test.txt , hope pid , executable path process operating on file. for example, if command line has run this: $ cat test.txt ...then want have give output similar this: process 1123 bin/cat using /home/sam/test.txt if file still open, can use: fuser /home/sam/test.txt

java - how readUTF() method of DataInputStream finish form Keyboard? -

this test: datainputstream dis=new datainputstream(system.in); system.out.println("enter name: "); string name=dis.readutf(); system.out.println("ten vua nhap: "+name);// want print after input text keyboard, want finish , print text, programm still not finish.. how can deal this. you can scanner class scanner input = new scanner(system.in); system.out.println("enter name: "); string name= input.nextline(); system.out.println("ten vua nhap: "+name);// want print

link not working HTML/CSS -

i know stupid question, i've been trying find causes error i created site, however, links in content not working. know it's somewhere in css file can't find out what this draft, removed parts in main html, css ease var firstreel=new reelslideshow({ wrapperid: "myreel", //id of blank div on page house slideshow dimensions: [750, 550], //width/height of gallery in pixels. should reflect dimensions of largest image imagearray: [ ["images/a.jpg"], //["image_path", "optional_link", "optional_target"] ["images/b.jpg"], ["images/c.jpg"], ["images/d.jpg"], ["images/e.jpg"], ["images/f.jpg"], ["images/g.jpg"], ["images/h.jpg"] //<--no trailing comma after last image element! ], displaymode: {type:'auto', pause:2000, cycles:2, pauseonmouseover:true},

apache - create files.tar in debian PharData with PHP? -

define('__root__', dirname(__file__)); $phar = new phardata('proyecto.tar'); $phar->buildfromiterator( new arrayiterator( array( 'fichero/text.txt' => __root__ . '/text.txt', ))); don't create files.tar in debian in windows works perfectly(with xampp), issue of permit folders or apache server configuration? sorry, i'm noob in of unix. problem permissions in directory. solved conflict chmod 777 namecarpeta.

archlinux - How to disable vim mouse wheel? -

i want know how disable mouse wheel, found this , this question , have tried put them .vimrc : set mouse="" map <scrollwheelup> <nop> map <s-scrollwheelup> <nop> map <scrollwheeldown> <nop> map <s-scrollwheeldown> <nop> but none of them disable mouse wheel, still can use scrolling. and i'm on arch linux, using vim 7.4 gnome-terminal 3.16.2. it gnome-terminal problem , not vim one. .vimrc is, can turn on , off mouse wheel issuing these commands in terminal echo -e '\e[?1000h' echo -e '\e[?1000l' edit: previous answer doesn't work because gnome-terminal settings overridden settings of cinnamon (in case), , maybe because scrolling done using touchpad , not mouse. possible disable scrolling of synclient (command line utility configure , query synaptics driver settings) putting augroup scroll au! au vimenter * :silent !synclient vertedgescroll=0 au vimleave * :silent

python - Why aren't my arguments being passed to the parameters? -

project dealing functions , making main function. control rest of functions. wall = 112 paint = 1 work = 8 premier = 20.50 generic = 10.75 labor_c = 12.75 print('welcome a&pm painting co. how may today?''\n') def paint_job(): space = float(input('what measurement of area' +\ ' want painted? ')) gallon(space) labor() paint_cost() labor_chrg() tot_cost() all functions called def gallon(space): global final final = space / wall print('\n''the gallons of paint required ' +\ 'job is', format(final, '.1f'),'gallons''\n') def labor(): global job job = final * work print('the hours of labor required this' +\ ' job is', format(job, '.1f'),'hours''\n') def paint_cost(): ask = input('would use premier or generic paint? ') if ask == "premier":

Removing the "" in the matrix in R in order to work with rows with non empty elements for a list -

i have matrix called: combination_mat , looks this: combination_mat <- read.csv("data.csv") combination_mat <- as.matrix(na.omit(combination_mat)) combination_mat x1 x2 x3 x4 1 "ff" "wgs10yr" "wtb3ms" "stlfsi" 2 "ff" "wgs10yr" "stlfsi" "" 3 "wgs10yr" "wtb3ms" "stlfsi" "" 4 "ff" "wtb3ms" "stlfsi" "" 5 "ff" "wgs10yr" "wtb3ms" "" 6 "ff" "wtb3ms" "" "" 7 "ff" "stlfsi" "" "" 8 "wgs10yr" "stlfsi" "" "" 9 "wgs10yr" "wtb3ms" "" "" 10 "ff" "

import - Error while importing products in magento -

i trying import products in magento (csv import), gives me following error skip import row, value "default" invalid field "attribute_set" i have saved file utf-8 format, tried renaming "attribute_set" column "_attribute_set" nothing works. please me if have idea. check following: each product should in separate row it may complain on 1 field, problem might in other, make sure other required fields filled , correctly named, magento requires make sure have used correct delimiter symbol separate data re-save file utf-8 without bom encoding (this important, may use notepad++)

java - log4j not writing to file -

the log file has been created in specified location contents not entered in file. empty. import org.apache.log4j.logger; public class logfile { public static void log(string msg){ system.out.println("logfileee==="+msg); logger logger = logger.getlogger(logfile.class); logger.info(msg); } } log4j.rootlogger=info, r log4j.appender.a1=org.apache.log4j.consoleappender log4j.appender.a1.layout=org.apache.log4j.patternlayout log4j.appender.a1.layout.conversionpattern=%d{hh:mm:ss,sss} %-5p [%c] - %m%n log4j.appender.r = org.apache.log4j.dailyrollingfileappender log4j.appender.r.append = true log4j.appender.r.datepatter n = '.'yyy-mm-dd log4j.appender.r.file = d:/logs/testing.log log4j.appender.r.layout.conversionpattern = %d{yyyy-mm-dd hh:mm:ss} %c{1} [%p] %m%n log4j.category.datanucleus.jdo=warn, a1 log4j.category.datanucleus.persistence=warn, a1 log4j.category.datanucleus.connection=warn, a1 log4j.category.datanucleus.cache=warn, a1 l