Posts

Showing posts from June, 2014

stl - Find the minimum number +ve number in c++? -

i want find minimum number using stl in c++, know syntax should min(x,y). want find minimum +ve numbers in list. not inlcuding -ves. how do that? p.s numbers in array for finding minimum number, makes sense use std::min_element . fortunately, comes optional comparison parameter, can make use of: ( sample here ) auto pos = std::min_element(std::begin(arr), std::end(arr), [](const t &t1, const t &t2) {return t1 > 0 && (t2 <= 0 || t1 < t2);} ); you have careful take account if it's comparing positive t1 negative number, should true. if none of elements positive, give location of first number in array. if 0 should treated part of positives, change t1 > 0 t1 >= 0 , t2 <= 0 t2 < 0 .

java - Display data on JTable from Mysql db after click off button -

i've been trying insert data mysql database , @ same time display data in jtable. problem unable store data database able display in jtable. have placed db connection string in class follows public class databaseconnection { public static connection getdbconnection() { connection connection; try { class.forname("com.mysql.jdbc.driver").newinstance(); connection = drivermanager.getconnection("jdbc:mysql://localhost:3306/accounting","root","jinxed007"); return connection; } catch (exception ex) { return null; } } } and method implementing jtable follows table = new jtable(dtablemodel); try{ class.forname("com.mysql.jdbc.driver"); conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/accounting","root","jinxed007"); statement sqlstate = conn.createstatement (resultset.type_sc

Trying to print the lines after writing them to an ouput file (java) -

i have problem. i'm asked use method print output file. start off began filling output file lines..then when tried read them , print them on screen there slight problem. used 'debug' option , problem turned out within ' line = input.nextline()' line of code don't know why..i mean that's how read output file...help appreciated. here's work far: import java.util.*; import java.io.*; public class problem_3 { public static void main(string[] args) { printwriter outfile = null; file f1 = new file("try.txt"); try { outfile = new printwriter("try.txt"); outfile.println("first line!"); outfile.println("second line!"); outfile.println("third line!"); cat(f1); } catch (exception e) { outfile.print("(1) exception: " + e.getmessage()); // no such element exception } ou

html - Javascript button text change before processing -

i have button has value "submit". text change "submitting" @ clicked. @ moments, have this: <input type="button" id=btnsub name="submittoenicq" value="submit" onclick="do_submission()"> <div id="results"> no submission has been performed yet</> <script> function do_submission() { var elem = document.getelementbyid("btnsub"); elem.value="submitting"; var xhreq = new xmlhttprequest(); var request = "main.php?pid=21&submitenicq=yes " xhreq.open("get", request, false); // send request xhreq.send(null); document.getelementbyid("results").innerhtml=xhreq.responsetext; } </script> i text change before xmlhttprequest processed, change immediate user. above code seems change button text once whole request has been completed (normally 3 seconds after button press). does have solution this? don

windows phone 8 - drawing a number line in wp8 app -

i trying draw number line in wp8 app unable want create line , show numbers on it. have pointer on pointing on number on number line. how can so? i can point in approximate direction. use canvas , when drawing line use line. line s line no pointers. can places textblocks nearby. you add line, textblocks etc canvasvas children.

java - Access to variable in ActionEvent-Class -

btnbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { try { var1 = float.parsefloat(txtbox.gettext()); } catch(numberformatexception n) { } } }); i can't access variable 'var1' here, error: local variable var1 accessed within inner class; needs declared final how can access variables in actionperformed event? declaring final not usefull because changing final variables value not possible. var1 = float.parsefloat(txtbox.gettext()); make variable member variable. class outer { //declare variable here btnbutton.addactionlistener(new actionlistener() { // assign here } // can use later jls # chapter 8 any local variable, formal parameter, or exception parameter used not declared in inner class must declared final. any local variable used not declared in inner cl

c# - Store anonymous values in a list and extract each individually -

i'm trying store information in block of anonymous values //holds info var jobs = new { newjob, numbytes, requiredtime }; then take information , place list single element //puts above info list joblist.add(convert.tostring(jobs)); console.writeline(joblist[0]); //testing purposes now able call joblist , take value of example numbytes @ position 4. is possible? or alternate way of doing this? thanks! the "normal" thing in c# create class hold information want store. example: public class job { public string name { get; set; } public int numbytes { get; set; } public datetime requiredtime { get; set; } } then can add these list: var jobs = new list<job>(); var ajob = new job(); ajob.name = "job 1"; ajob.numbytes = 123; jobs.add(ajob); then can access jobs index in list: var jobnumbytes = jobs[3].numbytes; one thing note c#, when do: new { newjob, numbytes, requiredtime }; the compiler, @ build time, c

c# - How to obtain device's info from WM_DEVICECHANGE? -

i'm working on c# program retrieve information of device plugged in. i want ask there ways obtain device's info (name, id, ...) based on wm_devicechange event fired when device has been plugged in/out. i tried looking wm_devicechange 's parameters nothing in contain info device. thanks in advance. here complete solution using hardware helper library in c#. solve it.

python - TypeError: unhashable type: 'list' (a few frames into program) -

so first project in python outside of code academy, decided make basic molecular dynamics simulator on pygame. works fine while, electrons start move fast, , strip other electrons off atoms, typeerror in title. have no idea comes from, , appears after program has been running long enough me mess physics. now know error telling me i'm trying pass list somewhere shouldn't, i've looked on program , can't figure out where. error pops in bit tells electrons how orbit atom angle = finda(particles[el], particles[nuc]) + 0.001 , controlled block of code near end tells program in order physics, , list of each electron meant orbit controlled point, , on. so decided give code. import sys, pygame, math pygame.locals import * pygame.init() sizescreen = width, height = 1000, 700 sizemenu = width, height = 652, 700 e = 1.6 * 10 ** -19 particles = {} mx, = 0, 0 selected = [] def findorbital(el): in particles: if != el , particles[a][4] != 'el':

recursion - How to add a node at front of linked list recursively in java -

i need add node @ front of linked list using recursion. below add method i'm trying implement. figure out how add @ of linked list :( public void add(e element) { node<e> newnode = new node<e>(element, null); if (this.next == null) { this.next = newnode; } else { next.add(element); } } to add item front of single-linked list create new node , make point first node of list. this new node new first node of linked list.

c++ - Thoughts on different types of inheritance -

in looking @ following simple code make sense introduce virtual destructor if know not deleting base pointer? seems should try avoid vtable ups if possible performance reasons. understand premature optimization etc. question in general. wondering thoughts on following: using protected destructor if not deleting items through base pointer the overhead associated introducing single virtual method also, if class has destructor virtual method lookup overhead destructor method , other methods not incur penalty or once introduce vptr suffers? assuming each class have vptr inside of have perform vptr lookups on destructor. class cardplayer { public: typedef std::vector<cardplayer> collectiontype; explicit cardplayer()=default; explicit cardplayer(const card::collectiontype& cards); explicit cardplayer(card::collectiontype&& cards); void receivecard(const card& card); bool discardcard(card&& card); void foldcards();

python - Can not plot .fit file with PYFITS -

in fits file have 3 columns called j, h, , k , plot relation between j-h , h-k in x , y axes pyfits, respectively. how can make this? this general , basic question. first need open fits file , plot, here example program: import pyfits import matplotlib.pyplot plt # load fits file program hdulist = pyfits.open('your fits file name here') # load table data tbdata tbdata = hdulist[1].data fields = ['j','h','k'] #this contains column names var = dict((f, tbdata.field(f)) f in fields) #creating dictionary contains #variable names j,h,k #now call column j,h , k use j = var['j'] h = var['h'] k = var['k'] #to plot j vs h , h vs k , on plt.plot(j,h,'r') plt.title('your plot title here') plt.show()

Java How to destroy Singleton instance -

i have singleton created that private static class singletonholder { public static singleton instance = new singleton(); } public static singleton getinstance() { return singletonholder.instance; } i'd reset singleton instance @ time. (i'm sure @ time safe reset singleton instance). tried remove final specifier , set instance null when want reset problem how instance (it remain null) another question is safe remove final specifier inside singletonholder. thanks if really need reset singleton instance (which doesn't makes sense actually) wrap inner members in private object, , reinitialize via explicit initialize() , reset() methods. way, can preserve singleton istance , provide kind of "reset" functionality.

Visual studio 2008. Application won't run on another computer -

i read lot problem here, , on other websites well. tried already: .net framework 4.0 .net framework 3.5 (the actual version visual studio 2008) http://www.microsoft.com/en-us/download/details.aspx?id=29 http://www.microsoft.com/en-us/download/details.aspx?id=5582 "the simplest possible solution change dynamic linking of runtime libraries static linking. go project properties , under c/c++ > code generation find runtime library option. need change multi-threaded dll (/md) multi-threaded (/mt)." did not compile @ after changing there... i using visual studio 2008 9.0.21022.8 rtm microsoft .net framework 3.5 sp1. test machine windows xp sp3. the errors are: the application failed initialize (0xc0000135). or this application has failed start because application configuration incorrect. reinstalling application may fix problem. what wrong?

php - How to make a Facebook FQL query to select all friends -

i'm new php sdk facebook, sorry if quesiton stupid. so, have code select name user current_location.country = 'italy' , uid in ( select uid2 friend uid1 = me() ) that responses me: { "data": [ { "name": "matilde xxxx" }, { "name": "samson xxxxxxxx" }, { "name": "emanuela xxxxxxx" } ] } i'm using site analyze how manage json : http://chris.photobooks.com/json/default.htm i saw if want have request of name of friend have that: root.data[5].name so php code : $user_id = $facebook->getuser(); $all_friends = $facebook->api(array('method' => 'fql.query', 'query' => 'select name user current_location.country = "italy" , uid in ( select uid2 friend uid1 = 1068943079 ) ')); $val = 1; echo $all_friends['data'

winforms - Adding a record to access database from C# -

Image
i have form windows program in c# adds record database , can remove it. in database have id (which auto number), if delete record , if want add record instead, auto number increases , doesn't add missing numbers. i mean if have 9 records in access database , want remove record, 8, when add new record, 10 instead of 9. picture: is there solution that? if it's auto number, database generate number greater last 1 used - how relational databases supposed work. why there solution this? imagine deleting 5, want then, have auto number create next record 5? if displaying id in c# app - bad idea - change other value can control wish. however trying achieve not make sense.

c++ - Make interval using two set<int> -

we want use 2 set<int> s' create integer-intervals. some of works want remove interval in our intervals, set sorted! , interval_first[i] != set1[i] , interval_last[i] != set2[i] . as way, how can delete inteval using set<int> st1, nd2 , iterator it1, it2 ? sample input: a 2 5 a 3 4 d 2 5 p result: 1, 2 5, 5 i have code now, , delete not work (because set sorted), please me complete this: #include <iostream> #include <set> using namespace std; int main() { set<int> st1, nd2; while(true) { char order; cin >> order; int a, b; switch(order) { //add: case 'a': cin >> >> b; st1.insert(a); nd2.insert(b); break; //delete: case 'd': cin >> >> b; if(st1.find(a) != st1.end() && nd2.find(b) != n

asynchronous - understanding python twisted asynchronicity in terms of operating system -

i'm new twisted library , i'm trying understand how done operations in python/twisted performed asynchronously. far thought gui-alike (qt or javascript) platforms use event-driven architecture extensively. facts : twisted programs run in 1 thread = no multithreading reactor , deferred patterns used: callbacks/errbacks declared , execution of controlled reactor main loop a single cpu can never parallelly, because shares resources between processes, etc. parallel code execution mean programming platform (python, javascript, whatever) executes more 1 sequence of operations (which can done, example, using multithreading) question 1 python seen high-level wrapper operating system. os functions (or c functions) provide asynchronous operation handling? there any? question 2 q1 leads me idea, twisted's asynchronicity not true asynchronicity, have in javascript. in javascript, example, if provide 3 different buttons, attach callback functions them , click 3 butto

What is the proper way to use namespaces and reference models inheriting from other (mongoid/rails)? -

i have model handlingscenario inherits scenario . this: ## models/scenario.rb class scenario include mongoid::document end ## models/scenarios/handling_scenario.rb class scenarios::handlingscenario < scenario include mongoid::document belongs_to :user, :inverse_of => :handling_scenarios # in `user` model, reference `has_many :handling_scenarios` end but when try access handlingscenario class, trouble: ➜ rails c loading development environment (rails 3.2.12) 2.0.0-p247 :001 > user.first.handling_scenarios loaderror: expected /users/christoffer/projects/my_project/app/models/scenarios/handling_scenario.rb define handlingscenario also, when try visit through browser error: started "/scenarios/handling_scenarios" 127.0.0.1 @ 2013-10-06 19:41:29 +0200 processing scenarios::handlingscenarioscontroller#index html moped: 127.0.0.1:27017 query database=my_project_development collection=users selector={"$query"=>{"_id"=&

java - Using Document FIlter to filter multiple periods(.) -

lets user has input double value jtextfield gets calculated. if user used more 1 period trigger numberformatexception, assume solution using document filter filter out periods or catching exception , notifying user of invalid input currenty using documentfilter allow digits , periods, problem how filter out second period plaindocument filter = new plaindocument(); filter.setdocumentfilter(new documentfilter() { @override public void insertstring(filterbypass fb, int off, string str, attributeset attr) throws badlocationexception { fb.insertstring(off, str.replaceall("[^0-9.]", ""), attr); } @override public void replace(filterbypass fb, int off, int len, string str, attributeset attr) throws badlocationexception { fb.replace

ssh - execute a gtk python app over remote ssh? -

i'm writing gtk python app i'm testing on ubuntu laptop, i'm writing script on win7 desktop (sftp update script laptop). if try execute script via ssh such as: python /path/to/app.py it gives me errors since gtk won't render window in putty such as: /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: gtkwarning: not open display my question is, there way execute script via remote ssh open fine on laptop? kind of pain have save script, lean on , execute script on laptop. does have ideas how this? install x server on windows 7: http://sourceforge.net/projects/xming/ then, don't forget ssh -x when start remote script.

html - Strange behavior : display table + after pseudo-element -

i noticed strange phenomenon when apply :after pseudo-element on element display:table can see here : http://jsfiddle.net/rkznv/1/ the pseudo-element may behave table cell when should not. do have idea? bug? thanks! from mdn - ::after (:after) the css :after pseudo-element matches virtual last child of selected element. so .table:after matches virtual child of div.table , allowed behave table cell. the behaviour changes, when replace display: table-cell; display: table-row; http://jsfiddle.net/rkznv/2/

canvas - KineticJS: For a Bezier Curve that Widens as it Flows - How to Add Rounded Corners? -

i'm using kineticjs draw bezier curve widens flows. here's example: flat http://www.market-research-services.com/starpowermedia/for_distribution/bezier-curve-with-flat-end.png what possible approaches giving rounded corners @ wide end? example: rounded http://www.market-research-services.com/starpowermedia/for_distribution/bezier-curve-with-rounded-end.jpg thanks in advance info. for reference, here's code i'm using: //based on: http://stackoverflow.com/questions/8325680/how-to-draw-a-bezier-curve-with-variable-thickness-on-an-html-canvas //draw bezier curve gets larger flows function plotflow(centerleft, centerright, thicknessleft, thicknessright, color, desiredwidth) { var bezierlayer = mainlayer.getattrs().bezierlayer; var context = bezierlayer.getcontext(); var leftupper = {x: centerleft.x, y: centerleft.y - thicknessleft / 2}; var leftlower = {x: centerleft.x, y: leftupper.y + thicknessleft}; var rightupper = {x:

passwords - Hacked Wordpress account -

good evening everybody, i've found problems managing wordpress website has been hacked hours ago. i've changed password , created new users db , domain panel, wp admin panel too. however, if i've changed passwords i've seen md5 hash i've modified change password, password hash returns continuously the hash of people hacked website. it's "monitoring" website domain panel, recording changes , trying change again. anyway website online now. anyone can stop them , avoid other attacks of kind ? thank ! if you've been hacked, should consider whole machine compromised. re-install (including os if can) , restore data, , manually make sure don't restore compromised account or that.

c# - Binding.UpdateSourceTrigger giving XamlParseException/TargetInvocationException in WPF -

i'm trying apply trigger follows: using smartrouteplanner.models; ... map locationmap = new map(); locationtextbox.datacontext = locationmap; binding locationbinding = new binding("location"); locationtextbox.setbinding(textbox.textproperty, locationbinding); locationbinding.updatesourcetrigger = updatesourcetrigger.explicit; and xaml code this: ... xmlns:models="clr-namespace:smartrouteplanner.models" ... <grid.resources> <models:map x:key="mapdatasource"/> </grid.resources> <grid.datacontext> <binding source="{staticresource mapdatasource}" /> </grid.datacontext> <textbox x:name="locationtextbox" /> what causing exceptions? in xaml should this: <window x:class="teste.window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title=

lifetime of a lambda expression in rust -

if have function returns function: fn<'r, t> ( p : t ) -> (&'r fn(&'r str) -> ~[(t,int)]) { return |s| ~[(p, 0)] } however, doesn't seem work, following (somewhat tautological) error: playground.rs:10:8: 10:29 error: cannot infer appropriate lifetime due conflicting requirements playground.rs:10 return |s| ~[(p, 0i)] ^~~~~~~~~~~~~~~~~~~~~ playground.rs:9:70: 11:5 note: first, lifetime cannot outlive block @ 9:70... playground.rs:9 pub fn result<'r, t>( p : t ) -> (&'r fn(&'r str) -> ~[(t, int)] ){ playground.rs:10 return |s| ~[(p, 0i)] playground.rs:11 } playground.rs:10:8: 10:29 note: ...due following expression playground.rs:10 return |s| ~[(p, 0i)] ^~~~~~~~~~~~~~~~~~~~~ playground.rs:9:70: 11:5 note: but, lifetime must valid lifetime &'r defined on block @ 9:70... playground.rs:9 pub fn result<'r, t&g

ruby on rails - some of my images, my javascript and my bootstrap css won't work on heroku -

i have found bunch of solutions , tried implement them, none of them solved issue. java script code in : assets/javascripts/application.js css bootstrap in : assets/stylesheets/custom.css.scss , images in: assets/images of them png. i've included rails_12factor gem in gem file source 'https://rubygems.org' # bundle edge rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.0' # use sqlite3 database active record # use scss stylesheets gem 'sass-rails', '~> 4.0.0' # use uglifier compressor javascript assets gem 'uglifier', '>= 1.3.0' # use coffeescript .js.coffee assets , views gem 'coffee-rails', '~> 4.0.0' # see https://github.com/sstephenson/execjs#readme more supported runtimes # gem 'therubyracer', platforms: :ruby # use jquery javascript library gem 'jquery-rails' # turbolinks makes following links in web application faster. read more:

How substitute variable in Matlab? -

i have trouble set of equations. have: x' = f(t, x, u) - it's set of equations - dimension n x1' = .. x2' = .. x3' = .. and have u - it's vector (u1, u2, u3..) how can substitute u in set of equations? example : x1' = sin(t) * u1 + sin(u2) x2' = u2*x2 u1 = sin(1000t) u2 = cos(1000t) and need x1' = sin(t) * sin(1000t) + sin(cos(1000t)) x2' = cos(1000t) * x2 thank's. well, assuming using symbolic toolbox: syms t u1 u2 x2; x1prime = sin(t) * u1 + sin(u2); x2prime = u2 * x2; then can use method or b. method a: x1prime = subs(x1prime, [u1 u2], [sin(1000*t) cos(1000*t)]) x2prime = subs(x2prime, u2, cos(1000*t)) method b: u1 = sin(1000*t); u2 = cos(1000*t); x1prime = subs(x1prime) x2prime = subs(x2prime) i tested both methods on matlab r2011a. use works best you.

windows - create text file with all folders in directory in order by date created -

i have done .bat file opens notepad , fill folders in directory .bat file placed. now want change fill text file folders in order date of creation. this how .bat files looks now: dir /a /b /-p /o:gen >c:\windows\temp\file_list.txt start notepad c:\windows\temp\file_list.txt also option autosave text file in same directory. any higly appreciated. thanks this lists folders , files, , saves file in current folder. dir /ad /tc /od /b >file_list.txt dir /a-d /oen /b >>file_list.txt start "" notepad file_list.txt

c++ - Unix server - Windows client, connection failed -

is there more required in order communicate server unix process , client windows process? after compiling both, run server , run client. however, client fails @ connect() error: 10061. client (windows application): #ifndef unicode #define unicode #endif #define win32_lean_and_mean #include <winsock2.h> #include <ws2tcpip.h> #include <stdio.h> // need link ws2_32.lib. #pragma comment(lib, "ws2_32.lib") int wmain() { // initialize winsock. wsadata wsadata; int iresult = wsastartup(makeword(2, 2), &wsadata); if (iresult != no_error) { printf("wsastartup() failed error: %d\n", iresult); return 1; } // create socket connecting server. socket connectsocket; connectsocket = socket(af_inet, sock_stream, ipproto_tcp); if (connectsocket == invalid_socket) { printf("socket() failed error: %ld\n", wsagetlasterror()); wsacleanup(); return 1; } // soc

GitHub fork a repo from previous commit -

i've found repository on github fork - not current version. i want fork repo quite few commits - possible? repo has not marked releases, i'm not sure how this. copy code in commit, prefer fork, link original repo. you can fork current repository. you can reset forked repository's master branch earlier commit though, giving repository in same state if had forked @ point. see: how can rollback github repository specific commit?

java - How to store values as variables in iterator, for loop? -

i'm developing android app. i'm using jsoup retreive elements page. then, i'm iterating on collection each individual part of it. i'm not sure how save each instance of element different variable. think can use loop this, don't quite understand it. how determine length of how long select from? how use it? i'm retreiving elements here: http://lapi.transitchicago.com/api/1.0/ttarrivals.aspx?key=201412abc85d49b2b83f907f9e329eaa&mapid=40380 . code below: public class teststation extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.test_station); strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build(); strictmode.setthreadpolicy(policy); intent intent = getintent(); string value = intent.getextras().getstring("value"); uri = uri.parse("http://lapi.transitchicago.co

regex - How to convert a string with french accents to an URL (replacing accent letters)? -

i want create urls based on strings automatically convert string french accents url. (defn str->url [] ...) (defn str->url-case [] ...) (str->url "Élise noël") ;=> "/elise-noel" (str->url-case "Élise noël") ;=> "/elise-noel" here non accent letters equivalents : À,  -> Æ -> ae Ç -> c É, È, Ê, Ë -> e Î, Ï -> Ô -> o Œ -> oe Ù, Û, Ü -> u Ÿ -> y à, â -> æ -> ae ç -> c é, è, ê, ë -> e î, ï -> ô -> o œ -> oe ù, û, ü -> u ÿ -> y thank you! to use official url encoding format ( application/x-www-form-urlencoded ), different removing accents, can this: user> (java.net.urlencoder/encode "Élise noël" "utf-8") "%c3%89lise+no%c3%abl" to use replacements question, map clojure.string/replace each of replacement pairs on string. here's example necessary replacement pairs example string. follow same pattern rest: (re

c# - Xamarin Studio Monogame.Framework.dll Reference Error -

when create brand new ios monogame project references lidgren.network , monogame.framework can't found. delete them , in edit references go library/application support/xamarinstudio-4.0/localinstall/addins/monodevelop.monogame.3.0.1 , attempt select monogame.framework.dll , lindgren.network.dll , following error: system.reflection.targetinvocationexception: exception has been thrown target of invocation. ---> system.io.filenotfoundexception: not load file or assembly 'system.core, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e' or 1 of dependencies. system cannot find file specified. it seems "file not found" error files there because can select them in folder? have advice? overlooking easy? remove lingren.network , monogame.framework import /users/ username /library/application support/xamarinstudio-4.0/localinstall/addin/monodevelop.monogame.3.0.1/assemblies/ios/lingren.network.dll same location monogame.framework.dll

javascript - How do I select the first row on this site with jQuery? -

i trying select first row has channel, artist, song, etc. not sure how select it? this site: http://www.dogstarradio.com/search_playlist.php?artist=&title=&channel=51&month=&date=&shour=&sampm=&stz=&ehour=&eampm= and have tried $("td:contains('51')") not work. ultimately want able select rows follow. ---- here html trying grab there no real unique identifier such class or element , there more 1 table, row, , table data <center>this search includes data 12:00:00 9/30/2013 6:05:18 pm 10/6/2013<br> <table><tbody><tr><td colspan="5"><div id="light" class="white_content"></div></td></tr><tr><td> &nbsp;</td><td colspan="3">search results 1 50 of 2441 total matches</td><td><a href="search_playlist.php?artist=&amp;title=&amp;channel=51&amp;month=&amp;da

unix - CSV - remove rows in which any column is empty -

i'm playing titanic data set kaggle. i'd remove rows train.csv have empty column (i know isn't best way deal missing data, question interesting me regardless). i'd unix-type way (using awk, sed, or grep), because i'm trying better @ tools, i'm not sure start. example of data: passengerid,survived,pclass,name,sex,age,sibsp,parch,ticket,fare,cabin,embarked 1,0,3,"braund, mr. owen harris",male,22,1,0,a/5 21171,7.25,,s 2,1,1,"cumings, mrs. john bradley (florence briggs thayer)",female,38,1,0,pc 17599,71.2833,c85,c 3,1,3,"heikkinen, miss. laina",female,26,0,0,ston/o2. 3101282,7.925,,s in second row, cabin empty, want remove file. note fourth column contains commas, column contained in double quotes. aside: i'd know how specific columns, can ask separate question if answer question doesn't me answer one. i stick language has csv parser because commas inside double quotes can problematic. , easier extend

coldfusion - Data row limits on cfspreadsheet -

Image
i loading 20,000 rows <cfspreadsheet> . throws error: when limit number of rows 15,000, don't error. is there hard limit on number of rows <cfspreadsheet> supports? this sounds similiar issue had here: how fix spreadsheetaddrows function crashing when adding large query? . if have cf10 might in luck 'cause should fixed (as of update 10 @ least).

python - How would I make a condition that requires an odd number in a certain range? -

here pretty simple example of mean: def work(): x = input("give me number : ") if x in range(30000): print "hello" so long put in number in range print hello, if want accept odd number in range? tried defining separate function that's range odd numbers this: def work(): = input("give me number : ") if in range(30000): x = range(30001) y = (2*x)-1 if in range(y): print "hello" but doesn't work. if 0 <= x < 30000 , x % 2 == 1: print "hello"

c - How can I access arrays from different threads? -

i'm new c language. know how threads work think i'm still not getting idea how pointers works char arrays, how populate arrays loop... the errors on terminal follows... q2.c: in function ‘main’: q2.c:18:22: warning: multi-character character constant [-wmultichar] q2.c:23:57: warning: multi-character character constant [-wmultichar] q2.c:23:40: warning: passing argument 2 of ‘strcpy’ makes pointer integer without cast [enabled default] in file included q2.c:4:0: /usr/include/string.h:128:14: note: expected ‘const char * __restrict__’ argument of type ‘int’ q2.c: in function ‘myfunc1’: q2.c:61:23: error: invalid type argument of unary ‘*’ (have ‘int’) ubuntu@ubuntu-virtualbox:~/desktop$ gcc q2.c -lpthread -o hell q2.c: in function ‘main’: q2.c:18:22: warning: multi-character character constant [-wmultichar] q2.c:23:57: warning: multi-character character constant [-wmultichar] q2.c:23:40: warning: passing argument 2 of ‘strcpy’ makes pointer integer without cast [enabled

java - Using Final Fields in Anonymous Classes, Declaring Static Nested Class Inside a Method and Defining Static Members inside an Inner Class -

i have 3 questions. 1- how can non-final fields used in anonymous class class if value can change? class foo{ private int i; void bar(){ = 10 runnable runnable = new runnable (){ public void run (){ system.out.println(i); //works fine }//end method run }//end runnable }//end method bar }//end class foo 2- why static nested classes can't declared inside methods inner classes can uner name of (local classes)? class foo { void bar(){ class localclass{ //static nested classes not allowed here //define members }//end class localclass }//end method bar }//end class foo 3- why can't inner class define static members except static final fields? class foo { class bar{ static int x; //notallowed static final int y; //allowed static void dosomething(){} //not allowed }//end class bar }//end class foo for third question, know in

python - More elegant/Pythonic way of printing elements of tuple? -

i have function returns large set of integer values tuple. example: def solution(): return 1, 2, 3, 4 #etc. i want elegantly print solution without tuple representation. (i.e. parentheses around numbers). i tried following 2 pieces of code. print ' '.join(map(str, solution())) # prints 1 2 3 4 print ', '.join(map(str, solution())) # prints 1, 2, 3, 4 they both work ugly , i'm wondering if there's better way of doing this. there way "unpack" tuple arguments , pass them print statement in python 2.7.5? i love this: print(*solution()) # not valid syntax in python wish kind of tuple unpacking it's equivalent to: print sol[0], sol[1], sol[2], sol[3] # etc. except without ugly indexes. there way that? i know stupid question because i'm trying rid of parentheses wondering if there missing. print(*solution()) can be valid on python 2.7, put: from __future__ import print_function on top of file. you itera

swing - drawImage in Java applet -

i can't display image in applet. using drawimage() in paint() method. (graphics2d) cast part of tutorial program. image supposed change every few seconds , correspond title , http link. works images. tried oracle's tutorials , looked through other questions on stackoverflow. tried passing different arguments drawimage() method. think may have unnecessary 'import's. import java.applet.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.net.*; import java.net.url; // image libraries import java.awt.image.*; import java.io.*; import java.awt.image.*; // buffered image import javax.imageio.*; // read buffered image import java.awt.image.bufferedimage.*; public class ch_19_ex_01 extends japplet implements runnable, actionlistener { string[] pagetitle = new string[5]; string[] imagestring = new string[5]; url[] pagelink = new url[5]; bufferedimage[] images = new bufferedimage[5]; color butterscotch

java - How to reverse an ArrayList without the reverse method? -

hello trying reverse arraylist without reverse method. wanted make work without method. can't seem right. have far: for (int x = nums.size()-1; x>=0; x--) { for(int z =0; z<nums.size();z++) { nums.set(z, x); } } this output: run: 0 1 2 3 1 1 1 1 build successful (total time: 0 seconds) you can ascend bottom & simultaneously descend top ( size() - 1 ) swapping elements, , stop when meet in middle. int = 0; int j = nums.size()-1; while (i < j) { int temp = nums.get(i); nums.set( i, nums.get(j)); nums.set( j, temp); i++; j--; }

stubbing File.expand_path in rspec/rails 4 -

i have multiple calls file.expand_path(rails.root) in code for testing created following configuration in spec/support rspec.configure |config| config.before(:each) file.stub(:expand_path).and_return("spec/fs") end end so instead of "/home/user/" each request file.expand_path returns "spec/fs/" it worked while on rails 3 however after moving rails 4, tests started throwing following error: failure/error: let(:category) { build(:category) } loaderror: cannot load such file -- spec/fs why appear/how can fix that? ps. tests/models basic, strangely test case fails: #in class def first method(category) "#{file.expand_path(rails.root)}/public/collections/#{self.name}/_new/#{category.name.downcase}" end #in rspec describe "#first_method" { expect(collection.first_method(category)).to be_instance_of(string) } end but 1 doesn't! #in class def second_method "#{file.expand_path(rails.root)}/

php - Laravel Model lists method return all the value of the column -

a model defined this: class model extends eloquent { protected $table='model'; } then query like: $model=model::find(2); $model->id;//return 2; $model->lists('id');//return array contains ids in model table ['1','2','3',...]. not ['2']; so, though lists method should contains array has ids found. why has id of model table. and class api in laravel api doc should after? per the docs , lists function fetches list of column values table. calling in manner running brand new query.

uitableview - UICollectionView Data Source methods inside of UITabBarView not being called until tab is navigated to -

i have issue can reproduce. can see issue life of me cant figure out how correct it. first, let me explain view structure. the root view controller window tabbarcontroller. tabbarcontroller contains 2 views, navigationcontroller 1 (nav) root view contrller set uitableview , navigationcontroller 2(nav2) root view controller set uicollectionview. here how setup in appdelegate: wtatableview *tv = [[wtatableview alloc] initwithnibname:@"wtatableview" bundle:nil]; uinavigationcontroller *nav = [[uinavigationcontroller alloc] initwithrootviewcontroller:tv]; nav.tabbaritem.title = nslocalizedstring(@"birthday list", nil); nav.tabbaritem.image = [uiimage imagenamed:@"birthdaycake"]; wtacollectionviewcontroller *cv = [[wtacollectionviewcontroller alloc] initwithcollectionviewlayout:[[uicollectionviewflowlayout alloc] init]]; uinavigationcontroller *nav2 = [[uinavigationcontroller alloc] initwithrootviewcontroller:cv]; nav2.tabbaritem.tit

html - Issue accessing results with PHP from an SQL database which was working yesterday. Also, need advice for injection proofing -

this question has answer here: mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 33 answers this working second ago. can't life of me figure out went wrong. error: warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\phpproject1\results.php on line 25 <!doctype html> <html> <head> <link type="text/css" rel="stylesheet" href="stylesheet.css"/> <title>find me goods</title> </head> <body> <a href="form.php" id="help">help other people find goods</a> <div class="container"> <?php error:warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean gi