Posts

Showing posts from May, 2015

java - confused about String vs Integer -

this question has answer here: weird integer boxing in java 9 answers i have question comparing string , integer objects... a. comparing string references: string string1 = "hi"; system.out.printf("%s \n", string1); string originalstring = string1; system.out.printf("%-9s %-9s %b \n", string1, originalstring, originalstring == string1); system.out.println(); string1 += " there"; originalstring += " there"; system.out.printf("%-9s %-9s %b \n", string1, originalstring, originalstring.equals(string1)); system.out.printf("%-9s %-9s %b \n", string1, originalstring, originalstring == string1); produced output: hi hi hi true hi there hi there true hi there hi there false here, last line compares addresses , expecte...

SQL How UPDATE command works -

how update command in sql work? have table 3 columns a,b,c primary key. values in table (1,2,3),(2,4,5). suppose want update tuple , set value of column c 4 values of 1. tuple (1,2,3) deleted , new tuple inserted ? or values 1,2 kept constant 3 deleted , 4 inserted ? this should edit table entry not adding new tuple table update tablename set c='4' a='1'

c++ - Invalid free() / delete / delete[] / realloc() error in assignment operator -

i new programming , when trying run program using valgrind getting error this. googled hours solve problem. please can tell me going wrong. hope there mistake near assignment operator. error: ==5130== invalid read of size 8 ==5130== @ 0x400cfd: std::passwd::~passwd() (passwd.c++:18) ==5130== 0x400c06: main (p1.c++:21) ==5130== address 0x5a1c040 0 bytes inside block of size 8 free'd ==5130== @ 0x4c2bdec: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5130== 0x400d16: std::passwd::~passwd() (passwd.c++:19) ==5130== 0x400bfa: main (p1.c++:17) ==5130== ==5130== invalid free() / delete / delete[] / realloc() ==5130== @ 0x4c2bdec: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5130== 0x400d07: std::passwd::~passwd() (passwd.c++:18) ==5130== 0x400c06: main (p1.c++:21) ==5130== address 0x5a1c420 0 bytes inside block of size 8 free'd ==5130== @ 0x4c2bdec: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)...

ios - Why am I getting this error when uploading app to device? -

i changed name of app, , error when trying put on iphone. working fine before changing name. linker command failed exit code 1 (use -v see invocation) https://www.dropbox.com/s/m6wk6rkwk4n0jcw/screenshot%202015-06-19%2023.43.00.png?dl=0 try clean build doing this: cmd + shift + k , cmd + b . should solve problem. hope helps :)

jsp - How to exclude one textbox from the others that are using isNumeric validation with jQuery? -

i'm using jquery 1.11x in jsp page textboxes. i'm working 5 text boxes , need make sure have numeric entries, however, want exclude first 1 has string representation of date in , validate 1 it's id or other way if guarantee uniqueness. the code below checks of textboxes , fails on 1 string date value, if other textboxes have numbers. date format dd/mm/yyyy. if(!$.isnumeric($('input:text').val())) { alert("all text boxes must have numeric values!"); return false; } i couldn't above code work :not, tried selector, failed work. if(!$.isnumeric($('input[type=checkbox]:not("#specialtextbox")').val())) { alert("all text boxes must have numeric values!"); return false; } how exclude particular textbox string date,but still validate others have numbers? you need loop textboxes take of jquery each function here. $('input[type="text"]').each(funct...

reactjs - Best practice for organizing hundreds of components? -

when have big application have hundreds components, of heavily shared others, , of layout or simple view. there advises organizing components? module? or usage? or other policies? i create directory per page, stick 1 component per file (ie addbutton in add_button.js.jsx ). have top-level component page suffixed app. user user_list.js.jsx user_app.js.jsx dashboard dashboard_app.js.jsx histogram.js.jsx analytics shared buttons add_button.js.jsx reset_button.js.jsx list.js.jsx table.js.jsx this has become default go-to approach while now, curious see how others proceed.

vb.net - 2 text box with validation of custom format and input, and comparing both data VB2010 -

i kinda stuck scenario! need create 2 text box same format of data "3xyz-02-01-abc-001" , need compare "3xyz-02-01-abc" popup text when not matches. i using vb2010 , creating in winform, unable use regex, don't know why? solution that? masked textbox solution , , appreciate. bit of challenge! thanks to validate (boolean) without returning string, check both conditions. public function validatecode(code string) boolean dim test string = "" ' longer code check test = "\d[a-z]{3}-\d{2}-\d{2}-[a-z]{3}-\d{3}" ' regex or operator test = test & "|" ' shorter code check test = test & "\d[a-z]{3}-\d{2}-\d{2}-[a-z]{3}" ' perform regex test , return boolean return regex.ismatch( code, test ) end function

c++ - ld: 2 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) -

either pebkac or mac dumb. have following code. main.cpp #include <iostream> #include "parser.h" using namespace std; const char *filename = "main.c"; int main() { cout<<"parser"<<endl; parser *p = new parser(filename); p->parse(); return 0; } parser.h #ifndef parser_h #define parser_h struct parser { parser(const char* filename_); bool parse(); private: const char* filename; }; parser::parser(const char* filename_):filename(filename_){} #endif parser.cpp #include "parser.h" #include <iostream> bool parser::parse() { std::cout<<"the file name "<<filename<<std::endl; return false; } i following error when try compile using command g++ parser.cpp main.cpp duplicate symbol __zn6parserc2epkc in: /var/folders/sh/3w74dm6n05jbtbv6hzx9f3_00000gn/t/parser-7ddc8e.o /var/folders/sh/3w74dm6n05jbtbv6hzx9f3_00000gn/t/main-90a53f...

javascript - add more form element logic with radio input -

i wrote code user can click add more duplicate form elements , add values. it's working fine except radio inputs. stuck. how can solve problem in easy way? below code. <div id="dup"> <p> athlete name:<br> <select name="athlete_name" id="athlete_name[]"> <option value="" selected="selected">choose user</option> <option value="2">candice falzon</option> <option value="5">athlete example</option> </select> </p> <p> sex: <input type="radio" name="athlete_sex" value="male">male <input type="radio" name="athlete_sex" value="female">female </p> </div> i can not take athlete_sex array . sometimes jquery can stickler closing tags. fixed them ,...

scala - How to define class method with partially applied function? -

i want define class's method partially applied method. possible without applying method? this best shot: def getfile1(arg1: string) (implicit execution: executioncontextexecutor): future[file] = getfile("file 1")_ def getfile2(arg1: string) (implicit execution: executioncontextexecutor): future[file] = getfile("file 2")_ def getfile(filename: string)(arg1: string)(implicit execution: executioncontextexecutor): future[file] = //... what happens though instead of making getfile1(arg1) , getfile('file 1', arg1) equivalent, scala tries evaluate getfile("file 2")_ , sees error because type of getfile("file 2")_ function, not file. the error correct. getfile("..")_ expression inside method (that evaluates partial function) , not 'a method definition'. writing out following should make more clear: def getfile2(arg1: string) (implicit execution: executioncontextexecutor): future[file] = { ...

c++ - OpenCV 2.4.3 Download -

looking learn opencv c++, tutorials i've found on youtube cv 2.4.3. on opencv's website, there no 2.4.3 download link. know why, or can find alternative? thanks downloaded 2.4.11 version couple weeks ago, guess that's latest stable 2x version. should fine learning stuff whole 2.4 version, of them same, this newspost tells 2.4.3 version more bug , performance update. offtopic, learning via youtube videos isn't idea, of time turns out more c/p learning doing, suggest learn how read on-site api documentation.

android - Escaping reserved url parameters in Java -

i building android app , there part of app need post url form data. 1 of form fields pass along email address. i noticed issue email addresses have '+' sign in them reserved character in urls means ' '. wanted know, how can sanitize/escape characters , others in code before convert post byte[]. don't want replaceall. there specific encoder built java this? here code use: stringbuilder builder = new stringbuilder(); builder.append(id + "=" + params.id + "&"); builder.append(locale + "=" + params.locale + "&"); builder.append(email + "=" + params.getemail()); string encodedparams = builder.tostring(); mwebview.posturl(url, encodingutils.getasciibytes(encodedparams)); try using java.net.urlencoder.encode(valuetoencode, "utf-8"); it's been while since i've looked @ details, believe have call encode() on individual parts of string before concatenate them. the utility meth...

python - ValueError when converting string to integer in Dataframe -

i trying replace strings in years column of dataframe below numbers in string. example, change zc025yr 025 . code follows: import urllib, urllib2 import csv stringio import stringio import pandas pd import os zipfile import zipfile pprint import pprint, pformat my_url = 'http://www.bankofcanada.ca/stats/results/csv' data = urllib.urlencode({"lookuppage": "lookup_yield_curve.php", "startrange": "1986-01-01", "searchrange": "all"}) request = urllib2.request(my_url, data) result = urllib2.urlopen(request) zipdata = result.read() zipfile = zipfile(stringio(zipdata)) df = pd.read_csv(zipfile.open(zipfile.namelist()[0])) df = pd.melt(df, id_vars=['date']) df.rename(columns={'variable': 'years'}, inplace=true) the dataframe have looks this: date years value 0 1986-01-01 zc025yr na 1 19...

android - 2 days ago XML Layout ran perfectly, now (with no structural change) it gives me errors? -

two days ago, posted the following question . while there issues, still ran - test code on phone still. however, no major changes code (and no structural changes), program refuse run when second activity , crashes. luckily, had posted of xml code activity in linked question. error (warnings actually) element fragment not allowed here element imageview not allowed here how can be?? working code ran on phone, , giving me long list of error messages , cannot run second activity, can run first activity. detail this inspection highlights unallowed xml tags in android resource files , androidmanifest.xml extra information i updated ide android studio 1.3 preview 4 preview 5 since posting linked question code ran 2 days ago <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" ...

amazon ec2 - ansible ec2 running list needs to be a list of instances -

i'm trying deploy ec2 instances ansible. i keep getting error says: failed! => {"msg": "running list needs list of instances run: none", site.yml --- - hosts: hornet user: root sudo: false gather_facts: false serial: 1 roles: - role: ec2 roles/ec2/tasks/main.yml --- - include_vars: "env.yml" - name: create ec2 instance local_action: module: ec2 key_name: "{{ key_name }}" region: "{{ region }}" instance_type: "{{ instance_type }}" image: "{{ image }}" group_id: "{{ security_group }}" wait: yes private_ip: "{{ privip }}" assign_public_ip: true state: running instance_tags: { "{{ ectags }}","name: {{ inventory_hostname }}"} count: 1 register: basic_ec2 i have 2 hosts in hosts file. [hornet] awo-p01-hm02 privip=`uniqueip` ectags="{purpose:hornetmq}" awo-p01-hm03 privip=`uniquei...

ios - Apple Mach-0 linker error when adding Parse to existing FB SDK -

my first question here, pardon mistakes. i've created app , managed integrate both google plus login(sdk 1.7.1) , fb login(sdk 4.2.0). worked fine till here. later, let people manually sign up, i've added parse(sdk version 1.7.4). now when -objc linker flag not present in build settings, builds fine , i'm able sign , things parse. both fb , g+ throw errors like: "unknown class fbsdkloginbutton in interface builder file, unknown class gppsigninbutton in interface builder file, unknown class fbsdkprofilepictureview in interface builder file", etc. however, can login in facebook using custom button. google doesn't respond. both buttons views have custom classes. if remove -objc linker flag, 42 errors below: undefined symbols architecture x86_64: "_fbtokeninformationexpirationdatekey", referenced from: -[pffacebooktokencachingstrategy cachetokeninformation:] in parsefacebookutils(pffacebooktokencachingstrategy.o) -[pffaceboo...

ruby on rails - NoMethodError in Contacts#new -

i following tutorial "coder manual" , trying create contact form. seems have in place not work. contacts_controller class contactscontroller < applicationcontroller def new @contact = contact.new end def create end end class createcontacts < activerecord::migration def change create_table :contacts |t| t.string :name t.string :email t.text :comments t.timestamps end end end this new.html.erb <div class="row"> <div class="col-md-4 col-md-offset-4"> <div class="well"> <%= form_for @contact |f| %> <div class="form-group"> <%= f.label :name %> <%= f.text_field :name, class: 'form-control' %> </div> <div class="form-group"> <%= f.label :email %> <%= f.email_field :email, class: 'form-control' %> </...

how to send message between activities in android -

my app works follow: user hits compose button , types message sends main activity date , time in recycler view swipe refresh facebook or other type of social media. problem i'm having i'm new android development , haven't seen on google site. you have 2 options: send data in intent: use "put" file... intent = new intent(firstscreen.this, secondscreen.class); string keyidentifer = null; i.putextra("string_i_need", strname); then, retrieve value try like: string newstring; if (savedinstancestate == null) { bundle extras = getintent().getextras(); if(extras == null) { newstring= null; } else { newstring= extras.getstring("string_i_need"); } } else { newstring= (string) savedinstancestate.getserializable("string_i_need"); } use event bus register , handle events more advanced data , callbacks: example of use https://github.com/greenrobot/eventbus/blob/master/howto.md ...

android - Dagger2 Component as Static Global Variable -

my android app has multiple activities. mainactivity constructs dagger2 component in oncreate() method , assigns static variable class can call static method mainactivity.getdaggercomponent() inject dependencies. the problem i'm discovering when start videoplayeractivity, mainactivity object gets onpause() invoked. if happens, static component variable gets set null. @ later point, videoplayeractivity needs inject dependencies, there no component things blow up. how 1 ensure dagger2 component available @ times activities? initialize dagger component in application class or statically. might you're doing wrong thing trying use dependencies of 1 activity in activity. might create memory leaks , in particular sounds design problem. if first activity destroyed? free dagger instance? why graph belongs first activity , not second one? if user enter app second activity - first 1 won't initialized. , on, , on. if still need activity instance, should use acti...

php - Wordpress add javascript in footer -

i need add script in site footer. i'm referencing footer.php: <script src="wp-content/file/script.js"></ script> at home functions normally, when access page child not find because search directory: site/page-child/wp-content/file/script.js . i saw have use:   wp_enqueue_script () but should put code? thank's you need add "/" before url in order start root : <script src="/wp-content/file/script.js"></ script> indeed @ home page looks yoursite.com/wp-content on other pages searches yoursite.com/current-page/wp-content , results in 404. adding / make yoursite.com/wp-content

php - imagepng, set quality without writing to file, how? -

i want export png memory: imagepng ($img, ?, 9); i want compress, need set filename too. dont want it, how then? you this: <?php ob_start(); imagepng($img, null, 9, png_all_filters); $image_data = ob_get_contents(); ob_end_clean(); from manual : filename: path save file to. if not set or null, raw image stream outputted directly.

html - How to draw scalable rectangles Ruby on Rails -

i learning ruby on rails create website, , looking way (preferably conventional one) create white rectangles cover of texts (to make easier read). i have previous knowledge of java, c , python languages unfamiliar ror, html, css. i finished following blog tutorial , added background. http://guides.rubyonrails.org/getting_started.html therefore don't have relevant code share, basic stuff. i appreciate further tips on how have better control on figures draw (how make corners rounded, how make rectangle size larger text size etc.) it feels want draw poster if using adobe illustrator or that. for web design, shouldn't reason this. think of webpages collection of containers squeeze , adapt content. create white rectangles cover of texts this going background of containers. if want covering letters, try like html : <span class="white-shadow">your text</span> css .white-shadow{ background: white; } make corners rounded ...

java - Javabean Introspector - what is in my List? -

i use code find out java list in given class: beaninfo beaninfo = introspector.getbeaninfo(classx); propertydescriptor[] propertydescriptors = beaninfo .getpropertydescriptors(); (propertydescriptor pd : propertydescriptors) { class<?> ptype = pd.getpropertytype(); if ((ptype+"").contains("java.util.list")) { system.out.println("list class property: " + pd.getname() + ", type=" + ptype); } } this output: class property: value, type=interface java.util.list the question how find out type in list? example list defined in classx as: @jsonproperty("value") private list<value> value = new arraylist<value>(); how can know list list of value objects? thanks. you can not via property introspection, due type erasure. type class has no generic type parameter information (directly @ least; super-type relationships do). generic type declarations need able access java.lang.reflect.ty...

swift - XCode 7 auto-completion doesn't work properly -

it seems xcode 7 (beta) doesn't auto-completion well. in case doesn't auto-complete parse objects @ all... pfquery(classname:"user").getobje // doesn't propose completion, compilation works someone solved ? i faced problem in xcode 7 beta 2. solution specify xcode directory in framework located. can clicking on project, choosing build settings , search "framework search path" after double click on right side of row , click plus sign , add path directory. note: don't choose recursive way. not work. specify in directory parse framework used in project located.

process - Synchronization of parent and child with SIGUSR signal in C. Make parent and child read one after the other -

i have created 2 way communication between parent , child processes using 2 pipes. parent , child write data , able make them read data each other. parent writes numbers 1 5, , child writes numbers 6 10. want parent start reading data first, , reading continues in order switching parent child until data read: 6,1,7,2,8,3,9,4,10,5. have tried synchronize reading sigusr1 when parent reading second time program stops. have searched lot find problem can be, , tried tips , alike working examples, nothing seems help. here code: #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <signal.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> void paction(int dummy) { printf("p*************************************************\n"); } void caction(int dummy) { printf("c*************************************************\n"); } int main() { ...

Create MySQLdb database using Python script -

i'm having troubles creating database , tables. database needs created within python script. #connect method has 4 parameters: #localhost (where mysql db located), #database user name, #account password, #database name db1 = ms.connect(host="localhost",user="root",passwd="****",db="test") returns _mysql_exceptions.operationalerror: (1049, "unknown database 'test'") so clearly, db1 needs created first, how? i've tried create before connect() statement errors. once database created, how create tables? thanks, tom here syntax, works, @ least first time around. second time naturally returns db exists. figure out how use drop command properly. db = ms.connect(host="localhost",user="root",passwd="****") db1 = db.cursor() db1.execute('create database test1') so works great first time through. second time through provides warning "db exists". ho...

laravel 5 - What to put in down() function if up() drops table? -

just starting learn laravel, go easy. made couple migration files try out. first creates table, second adds column, , third drops table. i'm curious know should put in down() function of third migration, since can't "undrop" table. how handle rolling migration drops table? the point of down function restore database same state in before ran function. if up() drops table, down() should recreate table. it important note lose data if this. migrations intended manage scheme of database, not contents . if want preserve data, that's backup .

Which yum repositories for Oracle Linux 7 can I use to install Kubernetes? -

i've been able install kubernetes in centos 7 testing environment using "virt7-testing" repo described in centos " getting started guide " in kubernetes github repo. production environment running on oracle linux 7, , far enabling "virt7-testing" on ol7 hasn't been working. are there other yum repositories out there compatible ol7 , include kubernetes? it's not best solution pull outside of oel, couldn't find oel repository these packages, used this: []# cat /etc/yum.repos.d/virt7-common.repo [virt7-common] name=extra packages enterprise linux 7 - $basearch baseurl=http://mirror.centos.org/centos/7/extras/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

python - IndexError obstructing code from working with larger csv file -

i have data sorts csv using groupby , plots information. used small sample of information create code. ran smoothly , tried running huge file of data. i pretty new @ python , problem has been quite frustrating suggestions on how troubleshoot problem helpful. my code stopping in section: import pandas pd df =pd.dataframe.from_csv('mydata.csv') mode = lambda ts: ts.value_counts(sort=true).index[0] i tried selecting parts of huge data file , ran, entire thing getting error: indexerror: index 0 out of bounds axis 0 size 0 but i've looked @ 2 data set side-by-side , columns same! noticed big file has utf8 issues accents , working on combing out, indexerror perplexing me. here traceback runfile('c:/users/jbyrusb/documents/python scripts/tests/tests/topsixcustomersexecute.py', wdir='c:/users/jbyrusb/documents/python scripts/tests/tests') traceback (most recent call last): file "<ipython-input-45-53a2a006076e>", line 1, in ...

javascript - Array of Radio buttons directly related to array of Checkboxes -

specifically have range of 3 radio buttons, before range of 5 checkboxes, calculator field attached give different values depending on how many checkboxes selected. example: radio button: 1 radio button: 2 radio button: 3 checkbox: a checkbox: b checkbox: c checkbox: d checkbox: e if 1-2 checkboxes selected, value 50 each checkbox if 3 checkboxes selected, value 125 if 4 checkboxes selected, value 155 if 5(all) checkboxes selected, value 170 i have functionality working script: <script type="text/javascript"> jquery(document).ready(function($){$('input[type="checkbox"]').on('change', function() { if($('input[type="checkbox"]:lt(5):checked').length == 1) { greeting = "50"; } else if ($('input[type="checkbox"]:lt(5):checked').length == 2) { greeting = "100"; } else if ($('input[type="checkbox"]:lt...

Php include with multidimensional array -

hello having trouble accessing multidimensional array on separate php page. example on index.php: include 'scripts/test.php'; echo $test[1][1]; on test.php: $test = array ( array("one", "two"), array("three", "four") ); wanted result: four this works fine when have array on same page echo, route correct because works fine when i'm using normal array on same test.php file. did turn error reporting on? include work? code should work guess problem include make sure path correct make sure don't mix absolute , relative paths you use $_server['document_root'] absolutely sure include right file: <?php include($_server['document_root']."/scripts/test.php"); doit(); ?> with code folder structure should this: /scripts/test.php /index.php but first of put @ top of index.php error_reporting(e_all); ini_set('display_errors', '1');