Posts

Showing posts from February, 2013

c++ - How properly connect libcurl to Visual Studio 2012? -

i want use in project libcurl library. here steps did connect libcurl library msvs 2012: 1. downloaded package official site libcurl-7.19.3-win32-ssl-msvc.zip 2. dll , lib files placed in c:\program files\microsoft visual studio 11.0\vc\lib 3. curl folder header files copied c:\program files\microsoft visual studio 11.0\vc\include 4. in vs 2012 in project's options added curllib.lib string 5. dll files copied project's debug folder but when run example: int main(void) { curl *curl; curlcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, curlopt_url, "https://api.copy.com/oauth/request"); /* example.com redirected, tell libcurl follow redirection */ curl_easy_setopt(curl, curlopt_followlocation, 1l); /* perform request, res return code */ res = curl_easy_perform(curl); /* check errors */ if(res != curle_ok) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerro

android - how can I add a spinner in a category preference -

i need add spinner in preferencecategory text on right there way that? plus when create checkboxpreference text on left how can make text appear on right? thanks. if want use these built in controls have use them way designed. because fits android design users expect. if need different, make own preference screen. list view click handlers, not hard make on own. styling want.

Hover over help in Bootstrap -

what easiest method in bootstrap showing small amount of text when hover on piece of text ?? ive found solutions using jquery, css wondered simpliest method is. thanks, a simple example have <span class="has-hover" data-toggle="tooltip" title="first tooltip">hover on me</span> in html , $(".has-hover").tooltip({placement: "bottom"}); in js ( example in jsfiddle ) bootstrap tooltips explained in detail @ http://twbs.github.io/bootstrap/javascript/#tooltips

mysql - PHP: Can't Get Oracle Table to Display on Page -

this obvious error. anyway, details: i have oracle database need extract data populate table on php page. table called flowers , has name, price , stock columns. the part of php code i'm having trouble this: $titlevalue = trim($_request['search']); $query = "select * flowers name = '$titlevalue'"; $stmt = ociparse($connect, $query); if(!$stmt) { echo "an error occurred in parsing sql string.\n"; exit; } ociexecute($stmt); the rest of php works -perfectly- when using different table on database, did test. in case, code prints query results (it's part of html table, can ignore that): while(ocifetch($stmt)) { echo "<tr valign=top bgcolor=#f7d4a3>"; $fg1 = ociresult($stmt,"name"); echo "<td width=75>"; echo $fg1; echo "</td>"; // display values in column two. $fg2 = ociresult($stmt,"price"); echo "<td width=75>"

Get error java.io.IOException: The parameter is incorrect -

i use hidapi-jni.dll/hidapi-jni.so , write program in java read , write data device. device defined hid device. code run on linux (debian 7.1) , can read , write data from/to device. on windows (windows 7 , xp) can read data , when try write error: java.io.ioexception: parameter incorrect. one part of write method is: try { hidmanager hid_mgr = hidmanager.getinstance(); dev = hid_mgr.openbyid(vendor_id, product_id, null); byte[] = new byte[4]; by[0] = (byte) 1; by[1] = (byte) 2; by[2] = (byte) 3; by[3] = (byte) 4; dev.write(by); } catch (ioexception | nullpointerexception ne) { system.err.println(ne); } how can fix error? i found solution error. in windows first byte 0. code is: by[0] = 0; and if write via dev.write(by); work correctly.

google app engine - How to cause a "back button' from a java servlet? -

i have form on page a. submits data java servlet on servlet b. servlet b error checking. if checking shows errors i'd send user page via button type action (which keeps data in form). there way in java servlet response? in case matters, in google appengine's java platform. no, can't that. can though, send html markup of page containing form, , prepopulate form values submitted user: <input type="text" value="hello" /> displays text field populated hello . basically mvc frameworks allow doing quite easily.

ruby - Rails 4: Modify eager load query when using .includes(:association) -

i have 2 models: class user < activerecord::base has_many :purchases # perform joins , attach calculations user object scope :add_stats, -> { group("users.id").joins(:purchases).select("users.*, sum(purchases.price) total_purchases") } end class purchase < activerecord::base belongs_to :user end the add_stats scope represents heavy calculations attached user objects. if want user objects stats, write user.all.add_stats . so far good. want fetch purchase objects , eager load user s with stats well. i've tried this: belongs_to :user, -> { add_stats } but when rails eager load users, seems remove .group("user.id").joins(:purchases) , complain on purchases.price - "purchases table unknown". .select() thing preserved scope. how apply scope (with working .group().joins() ) eager load query of included belongs_to :user objects? i tried in rails4 app , works class user < activerecord::base

eclipse - Java RMI server probleme -

i'm doing tutorial : http://www.youtube.com/watch?v=vkw275pti3e it's java rmi tutorial (client, server) try on local , dosen't work on computer when try activate server in local got message : java.rmi.serverexception: remoteexception occurred in server thread; nested exception is: java.rmi.unmarshalexception: error unmarshalling arguments; nested exception is: java.lang.classnotfoundexception: simple.rmi.server.myserver_stub @ sun.rmi.server.unicastserverref.olddispatch(unicastserverref.java:400) @ sun.rmi.server.unicastserverref.dispatch(unicastserverref.java:248) @ sun.rmi.transport.transport$1.run(transport.java:159) @ java.security.accesscontroller.doprivileged(native method) @ sun.rmi.transport.transport.servicecall(transport.java:155) @ sun.rmi.transport.tcp.tcptransport.handlemessages(tcptransport.java:535) @ sun.rmi.transport.tcp.tcptransport$connectionhandler.run0(tcptransport.java:790) @ sun.rmi.transport.tcp.tcpt

java - Processing with JBox2d Hellow World issue -

using eclipse, i'm trying write simple hello world program in processing draws rectangle on screen has gravity drop seen in this tutorial . the problem when try import p5 package, it's not resolving can't declare physics object. tried 2 things. download zip, unzip it, import 3 jars (library, serialization, & testbed) a. import org.jbox2d.p5.*; doesn't resolve others do b. physics physics; doesn't resolve download older standalone testbed jar import it a. physics physics; doesn't resolve; here i'm starting import org.jbox2d.util.nonconvex.*; import org.jbox2d.dynamics.contacts.*; import org.jbox2d.testbed.*; import org.jbox2d.collision.*; import org.jbox2d.common.*; import org.jbox2d.dynamics.joints.*; import org.jbox2d.p5.*; import org.jbox2d.dynamics.*; import processing.core.papplet; public class myfirstjbox2d extends papplet { physics physics; public void setup() { size(640,480); framerate(60); ini

c# - StorageFile store = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"~\Assets\KuchBhi.pdf"); -

before trying run following code metro app storagefile store = await windows.applicationmodel.package.current.installedlocation.getfileasync(@"~\assets\kuchbhi.pdf"); anticipated compiler throw exception since there no file named kuchbhi.pdf in assets folder, not happens, instead machine jams black screen , no further execution happens... can tell me problem , how resolve it. thank you

javascript - Run code for a period of time -

tried search , not find im after sorry if has been answered somewhere. i need run bit of code for period of time, not after period of time. want display random value array fast on page , want keep showing 1 minute , stop. the code below start after 3 seconds, , not stop , im not sure how can achieve this, appreciated. var messages = ["good!", "great!", "awesome!", "super!", "nice!"]; function getmessage() { return messages[math.floor(math.random() * messages.length)]; } settimeout(function () { onesecondfunction(); }, 3000); function onesecondfunction() { $('#test').html(getmessage()); settimeout('onesecondfunction()', 100); } thanks try var messages = ["good!", "great!", "awesome!", "super!", "nice!"]; function getmessage() { return messages[math.floor(math.random() * messages.length)]; } var inter

stop already playing sound with javascript -

i have following function play sound when div hovered function playsound() { var snd = new audio(); snd.src = 'snd/ring.mp3'; snd.play(); } // play sound on mouseover $('.navigation a').hover(function () { playsound(); $(this).find('img').animaterotate(-360, 1000); }); the problem when mouseleaves link, replays sound again. want play once , when mouse leaves sounds should stopped. how can done ? the hover() function addds handlers mouseenter , mouseleave. you want handle mouseenter only.

cocoa touch - MKAnnotationView not drawing transparent PNGs properly -

Image
i having trouble getting custom mkannotationview render proper alpha blending on edges. can see following screenshot, red , green dots have ugly black edge not blend background, system-supplied user location (the blue dot, barely visible) not. the image transparent png , have confirmed it's not image's fault renders elsewhere. i have set opaque = no on mkannotationview had no effect. am missing something? ha, went away on own. i'm not sure did wasn't worrying it, changing other stuff around , of sudden renders now. * shrug *

string - Moving Columns/Text in VIM -

i wondering how might go moving around columns/text around in vim using string. have short list of names have reorder, need placed in last name first middle first middle last. so here example list: plant, robert a. page, jimmy bonhham, john h. jones, john paul i thinking string should this: :s/\([a-z]\{2}\)\(\[a-z]\{2}\)/2\1/ thanks first, recommend using \v "very magic" flag avoid other internal escaping of metacharacters. work replacement like: :s/\v([a-z]+),\s+([a-z]+)(\s+[a-z.]+)?/\2\3 \1 breaking down: ([a-z]+) capture last name \1 ,\s+ literal comma , 1 or more spaces ([a-z]+) capture first name \2 (\s+[a-z.]+)? capture middle name with leading spaces, since may not exist. permit . , , end ? make whole construct optional, \3 \2\3 \1 replace second group (first name) followed middle name \3 no space in between because space captured along middle name. append \1 last name. if names possibly more [a-z]+ , may alterna

javascript - Change element properties of different HTML document -

in index.html file, have 2 div objects: <head> <meta charset = "utf-8"> <link href = "elv.css" rel="stylesheet" type="text/css"> </head> <body> <div id="goat">blue</div> <div id="puthtml"><object id = "hmehtml" type="text/html" data="test.html"></object></div> </body> css: #goat { color:blue; } in div#puthtml page (text.html) loaded after click. want know if change css property of #goat on click? jquery or whatsoever? tried using document.getelementbyid try #goat element no avail. here jquery function handle needs $(document).ready(function(){ $('#hmehtml').click(function(){ // can use '#hmetml button' selec //descendant button element, if there actual button in html // load $('#goat').css('color','red'); }

c# - Separate functions without duplicating code -

i working on program traverse through list of numbers 2 different functions find sum , specific value. here code have implemented class program { static int i, sum; static list<int> store = new list<int>(); static void main(string[] args) { (i = 0; < 100; i++) { store.add(i); } = 0; traverselist(); console.readline(); } static void traverselist() { while (i < store.count) { findvalue(); findsum(); i++; } console.writeline("the sum {0}", sum); } static void findvalue() { if (store[i] == 40) { console.writeline("value 40"); } } static void findsum() { sum = sum + store[i]; } } i thinking of separating findsum , findvalue 2 different functions , not calling them in traverselist. there

python - How to html input to Flask? -

i have html bit: <form action='quiz_answers'> <p> question1? </p> <input type="radio" name="q1" value="2">answer1</input> <input type="radio" name="q1" value="1">answer2</input> <input type="radio" name="q1" value="0">answer3</input> <input type="radio" name="q1" value="0">answer4</input> <p> question2? </p> <input type="radio" name="q2" value="2">answer1</input> <input type="radio" name="q2" value="1">answer2</input> <input type="radio" name="q2" value="0">answer3</input> <input type="radio" name="q2" value="0">answer4</input> </form> and python code: from flask

c# - How do I know what to put in my interfaces? -

i've come across recurring problem when trying design logic programs. let's have idriveable interface. interface idriveable { public void drive(); } then car class implements (c#) syntax: class car : idriveable { public void drive(){ //do movement here. } } here's problem occurs. if designing game, car doesn't drive itself, player should drive car, surely makes sense? class player { public void drive(idriveable vehicle){ vehicle.drive(); } } it feels 'ping-ponging' logic around doesn't seem right. a better way structure code might this: class player // start class names capital letter { car thisplayerscar; // initialize constructor or somewhere appropriate public void somefunction() { thisplayerscar.drive(); } } basically, purpose of interface wherever call thisplayerscar.drive(); (or drive() on idriveable ), you're guaranteed object have drive() function ready go.

facebook An access token is required to request this resource -

i using facebook app upload videos user walls. note: have user permission publish. script fine , works small videos success. have user extended token validity 60 days , debugged token , fine validity , have posting permissions. my script posting working fine small videos. issue when try upload more 100 mb video 5 or 6 min length receive following api errors. an access token required request resource. an active access token must used query information current user. note when apply small videos works successfully. test i added same video same length 2 different sizes 1 720p ~121mb , other 480p ~42mb both same video. but 480p ~42mb uploaded , 720p ~121mb failed , api throws error in error log an access token required request resource. $facebook->setaccesstoken($access_token); $facebook->setfileuploadsupport(true); $data = $facebook->api('/'.$user_id.'/videos', 'post', $args); the

Heroku routing errors in Rails app -

on local machine, when authenticate @ http://subdomain.myapp.dev (using pow server), redirected index page. when logging production domain http://subdomain.myapp.com (hosted on heroku), able authenticate; however, heroku not redirecting index page. after submitting necessary credentials, receive 'signed in successfully' notification remain on sign in page. rake routes , heroku run rake routes return identical routing schemes. i've listed contents of routes.rb file below example::application.routes.draw devise_scope :user authenticated :user root :to => 'admin/servers#index' end unauthenticated :user root :to => 'devise/sessions#new' end end resources :server_imports resources :servers devise_for :users activeadmin.routes(self) end below logs after entering credentials signing in: 2013-10-12t01:59:32.110046+00:00 app[web.1]: started post "/users/sign_in" 2013-10-12t01:59:32.5298

javascript - Storing XMLHttpRequest.responseText into variable -

this question has answer here: how return response asynchronous call? 21 answers not familiar xmlhttprequest s, using cross-origin function in google chrome extensions. works great (i can confirm appropriate data need), can't seem store within 'response' variable. i'd appreciate help. function getsource() { var response; var xmlhttp; xmlhttp=new xmlhttprequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { response = xmlhttp.responsetext; //im correctly set here } //i'm still set here } //all of sudden i'm undefined. xmlhttp.open("get","http://www.google.com",true); xmlhttp.send(); return response; } the onreadystatechange function asynchronous, not stop la

javascript - AngularJS - Passing nested variable with ng-click -

this answer helped me understand how bound variable via ng-click: how can pass bound variable ng-click function? however, if variable needs passed nested variable? for example: the nested variable: {{item['id']['attributes']['im:id']}} how called inside of ng-click? <a ng-click="open('item['id']['attributes']['im:id']')"> definitely not work because of multliple use of single quote. thanks! __ edit ___ attached jsfiddle of trying achieve: http://jsfiddle.net/runae/4/ basically in $scope.test, value trying pass within ng-click contoller {{ item['id']['attributes']['im:id']}} for reference, believe correct solution question asked above: here jsfiddle future reference: http://jsfiddle.net/runae/6/ ng-click="open(item.id.attributes['im:id'])" the non-proper variable placed within enclosing brackets. hope future searchers.

ruby on rails - Using git repo as gems, noMethodError -

i'm trying use repo https://github.com/kayinrage/weekly_vertical_calendar gem, since i'm working rails 4. the repo installed gem, found on c:\ruby200-x64\lib\ruby\gems\2.0.0\bundler\gems\weekly_vertical_calendar-071ea89ee1f0 but when try use it, receive nomethoderror on view: undefined method `weekly_vertical_calendar_links' #<#<class:0x000000089d38b8> but method exists... anyone me on ? hard find gem works vertical calendar... tought close solve problems... thanks in advance

android - Custom Adapter - Listview setBackground current row -

first of all, i'm trying achieve is: whenever person clicks specific button (this button on every line of listview rows), the row according button should change color. this i've tried far without success, because gives me errors. public view getview(int position, view convertview, viewgroup parent) { layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); view rowview = inflater.inflate(rowresourceid, parent, false); imagebutton add_to_cart = (imagebutton) rowview.findviewbyid(r.id.add_to_cart_butt); final listview lv = (listview) rowview.findviewbyid(r.id.product_listview); final int theposition = position; add_to_cart.setclickable(true); add_to_cart.setid(position); add_to_cart.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { lv.setfocusable(true); // line error begins lv.setbackgroundcolor(color.green);

firefox - How to mobilize all links, in a browsed page, using Google Mobilizer? -

i'm trying make links on of pages "mobilized" great service google mobilizer . eg: change urls like: http://imgur.com/ to: http://www.google.com/gwt/x?u=imgur.com google mobilizer reduces size of whatever url passed greatly. images reduced in size. first frame of animated gifs rendered, , resource heavily reduced in size. decreases download time on low-bandwidth , high latency connections. could done in firefox add-on or userscript? links on webpage prefixed www.google.com/gwt/x?u= ? there's a chrome extension gives context-menu item it. yes, firefox add-on can , firefox greasemonkey script should able it. here's outline of how might done firefox-only greasemonkey script: set script run @ document-start , use mutationobserver s watch creation of new <a> , <img> , , possibly <iframe> elements. when new <a> , <iframe> , etc. element found, rewrite src or href property use mobilizer service. w

python - returned objects by read_csv in Pandas -

i using read_csv method in pandas input multiple .csv files. print out objects returned read_csv , , curious differences in output: for example, 1 printout is: <class 'pandas.core.frame.dataframe'> int64index: 10 entries, 0 9 data columns (total 5 columns): col_1 10 non-null values col_2 10 non-null values col_3 10 non-null values col_4 10 non-null values col_5 10 non-null values dtypes: int64(5) while 1 simply: col_a col_b col_c col_d col_e col_f 0 1 1 1 183227 1 181913 1 2 1 1 183234 1 183003 ... how should interpret differences in these outputs? why second file not result in dataframe object? they both dataframes. if output longer few rows, pandas displays summary information in first format won't fill screen. if want full display, can use .to_string() method on dataframe. is, if df , dataframe, can print df.to_string() see data, if

Python socket server : Reject connection from address -

i have python socket server listens on port, , accepts incoming connections using: (conn, address) = socket.accept() however, wish accept connections ip address. currently, close connection if address isn't registered, accomplish this. but there better way this, directly rejecting connections unregistered addresses, instead of accepting connections , closing them? it's not possible indicate connection refused clients ip addresses, , establish connection clients other ip addresses. not python limitation, lower-level, bsd socket layer limitation. can't c. the closest behavior in general can in python closing connection after has been accepted: sock, addr = server_socket.accept() if addr[0] != '12.34.56.78': sock.close() return ... then client see connection being accepted, , shortly after client see eof when reading it, , wouldn't able write it. however it's possible limit interface (i.e. network card) @ bind time, using 1 of

java - Testing an internal fluent API -

i have designed fluent interface retrieve list elements. one call can like: repo.actives().sortedbycode().values(); the main avantage readability of code. the call values() returns list<ofwhatiexpect> . previous calls (actives(), sortedbycode(), ...) return listresult managing fluent api. i'm working on how test api call. depending on use case, must sure caller used actives() api example. any ideas on how manage that?

delphi - How do you set the color of a pixel under the cursor on a FMX.Canvas? -

with vcl used this: procedure movingdots(x, y: integer; acanvas: tcanvas); stdcall; begin {$r-} inc(alooper); acounter := acounter shl 1; // shift bit left 1 if acounter = 0 acounter := 1; // if shifts off left, reset if (acounter , 224) > 0 // of left 3 bits set? // fmx.canvas not have pixels acanvas.pixels[x, y] := aselectioncolor1 // erase pixel else acanvas.pixels[x, y] := aselectioncolor2; // draw pixel {$r+} end; how can set color @ x,y fmx canvas? according example , should work: var vbitmapdata : tbitmapdata; aselectioncolor : talphacolor; ... // define aselectioncolor somewhere // write access bitmap if acanvas.bitmap.map (tmapaccess.mawrite, vbitmapdata) begin try vbitmapdata.setpixel (x, y, aselectioncolor); // set pixel color @ x, y acanvas.bitmap.unmap(vbitmapdata); end; end; note mapping strategy locking/unlocking bitmap introduced in fm2, i.e. delphi-xe3.

git - How do you get an existing Web2py app deployed on OpenShift? -

i'm trying existing web2py app deployed on openshift. i'm doing following - 1) create , setup openshift app - https://github.com/prelegalwonder/openshift_web2py i followed instructions given , got welcome app running on openshift. created new repo on openshift , app works. 2) merge existing repo openshift repo - https://www.openshift.com/kb/kb-e1006-sync-new-git-repo-with-your-own-existing-git-repo i merged openshift repo existing repo (which has web2py app). resolved conflicts. works locally. but when push openshift following the git command never terminates - when git status shows it's gone through. don't see openshift build info saw when deployed first time the app shows no change - still behaves welcome controller first set of instructions. after while 503 , see openshift dashboard app building. the status hasn't changed in while - happening / doing wrong? so took different approach. i setup app first link.then used administrat

java - MySQL database in GitHub folder -

i'm new github , have java application in local github folder. works charm commit , push etc. add mysql database folder well. is wise, or should keep in default workbench folder use. figured make sense have version controlled projects , data in github folder, java application depends on mysql datasource , need updated schema developed incrementally along app. workbench doesn't give me location options when creating new schema. is approach keep on github in github folder reasonable? how accomplish when comes relational data , have other suggestions keep local data github project? storing actual database in git not work @ all. however, should store sql / ddl code used generate database in git. should able recreate base state of database git repo.

database - Creating After Trigger -

i trying build simple database on own time before sql business course starts better understand few concepts since struggling beginner. want create after trigger on hotel table deletes records rooms table match (:old.hotel_id). i've been reading on triggers online, still having trouble understanding how code body of trigger. using oracle since feels more comfortable me in inexperience. hoping community here give me insight on this. i tried create trigger tblhotel_t1 after delete on tblhotel each row and had delete tblrooms hothotel_id=:old.hothotel_id; i unsure how enter trigger oracle, since first began using sql studio manager. though oracle seems lot simpler, not use user interface. then oracle supplies "when" field, , "trigger body" field. become confused because i'm not sure how enter in. if post you've tried already, showing you're going wrong. it sounds trigger want like create or replace trigger trg_hotel_

network programming - Exception when trying to read packets with jpcap (java.lang.InstantiationException) -

i trying send udp packets multicast , receive them jpcap. multicast code works , when sniff wireshark receive packets want have. jpcap code not work, exception: exception in thread "main" java.lang.instantiationexception: jpcap.packet.datalinkpacket @ jpcap.jpcapcaptor.getpacket(native method) @ receiver.receiver.main(receiver.java:54) this code: networkinterface[] devices = jpcapcaptor.getdevicelist(); int index = 0; jpcapcaptor captor=jpcapcaptor.opendevice(devices[index], 60000, true, 20); //captor.setfilter("udp", true); for(int i=0;i<1000;i++){ //capture single packet , print out packet pac = captor.getpacket(); system.out.println(pac); } the network interface works in wireshark. when run code without captor.setfilter() exception . 1-2 times "null" before exception, seems there several packets let program crash (e.g beacons). when set filter, "udp"

windows - Faster alternative to the command type? -

recently i've been looking command can display text file on terminal, , fast. can open file in less 1 second in notepad + + type takes 25 seconds reading. have better alternative? the problem have not in opening , reading file, it's time taken output terminal screem. if you're interested in last few lines of file (and assume that's case unless can read million times faster regular mortals), can use tail either cygwin or gnuwin32 (in coreutils). assuming don't need full awesome power of unix-like environment, i'd opt latter since provides tools can run standalone. the command: tail -50l input.txt (for last 50 lines) should work substantially faster full file output. gives other nifty features "following" file that's being updated periodically.

sql - Inserting SQLite rows via Ruby iteration -

Image
inserting 5 rows of 4-column data existing sqlite db, , these errors... /users/sam/.rvm/gems/ruby-2.0.0-p247/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:in `initialize': near "tagline": syntax error (sqlite3::sqlexception) /users/sam/.rvm/gems/ruby-2.0.0-p247/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:in `new' /users/sam/.rvm/gems/ruby-2.0.0-p247/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:in `prepare' /users/sam/.rvm/gems/ruby-2.0.0-p247/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:134:in `execute' insert_code_sam.rb:60:in `block in <main>' insert_code_sam.rb:59:in `times' insert_code_sam.rb:59:in `<main>' here last lines (59-61) .rb file: 5.times db.execute('insert index1 (name tagline blurb photo_url) values (?, ?, ?, ?)', ["name", "tagline", "blurb", "photo"]) end any suggestions? you have

php - Phpmailer using smtp with Gmail not working - connection timing out -

i've looked following links: phpmailer send gmail smtp timeout send email using gmail smtp server through php mailer http://uly.me/phpmailer-and-gmail-smtp/ ...and tried implement myself combination of however...most of time sends message... message not sent. mailer error: smtp connect() failed. however there 1 time sent when experimented between "tls" , "ssl"... smtp error: failed connect server: connection timed out (110) smtp connect() failed. message not sent. mailer error: smtp connect() failed. my code attached...did somehow miss something? asked web hosting service if they're blocking , gave them template of code - said server allows connections gmail's smtp. require_once("class.phpmailer.php"); $mail = new phpmailer(); $mail -> issmtp(); $mail -> smtpdebug = 2; $mail -> smtpauth = 'true'; $mail -> smtpsecure = 'tls'; $mail -> smtpkeep

I have a background image that is loading only partially -

i have background image loads mostly, half of time there pice missing image , have refresh page entire image show. image i'm using corrupt or broken? or problem somewhere else. using mac , google chrome. here link: http://wlsnook.staging.wpengine.com/

c++ - Misusing istream& get -

i'm trying make method extracting email info external file , store in string. i'm using .get extract characters, debugger saying: no instance of overloaded function matches argument list. it's saying can't convert third parameter const char[2] char. seems quick fix, i've been playing around parameters , can't seem figure out what's wrong. current->email_data.sent pointer character array. also, i'm not sure why code won't indent when paste here. int classify::load_email(char filename[]) { email_node * current; current = email_head; ifstream source_file(filename); if(email_head) { while(current->next) { current = current->next; } } else { email_head = new email_node; } while(!source_file.eof()) { source_file.get(current->email_data.sent, 200, "|"); } }; in three-parameter overload of basic_istream::get , last parameter single character, not string. replace "|" '|' .

how to update like this? (SQL) -

i have 3 databases: service1, businessrecord, , teamastaffno 1)i want identify the service type in 2 type "play" , "mainbusiness" , "error" -if businessrecord.type "play" "play" -if businessrecord.other match service1.servicetype "mainbusiness" -if fulfill 2 option should show "error" 2) want business record match teamastaffno.staffno only, because want team record. 3) finally, want table have cloumn order_type show "play", "mainbusiness", "error" , "duplicate" than, sql code? and type select businessrecord.type, businessrecord.other, businessrecord.staffno; service1; join businessrecord; on businessrecord.other = service1.servicetype; inner join teamastaffno; on businessrecord.staffno = teamastaffno.staffno and record copy table proc1 alter table proc1 add order_type char(50) update order_type "mainbusiness" bus

java - Sending GPS Coordinates via sms -

i new android. trying develop app fetch users current gps coordinates , send them via sms hardcoded number. using 2 activities, first 1 has progress bar , text( processing, please wait),it fetching gps coordinates in background. second 1 receiving coordinates first activity , sending sms. problem m facing in mainactivity.java file condition if(latitude>0) never satisfied since gps take time coordinates , cant go second activity. m attaching code, please me on this. can edit code if u like. in advance. package com.shaji.smartcab; import com.shaji.smartcab.mainactivity; import com.shaji.smartcab.mylocationlistener; import com.shaji.smartcab.r; import android.os.bundle; import android.app.activity; import android.view.menu; import android.widget.textview; import android.widget.toast; import android.location.locationlistener; import android.content.context; import android.content.intent; import android.location.locationmanager; public class mainactivity extends activiy{ dou

java - RESTful thru JAX-RS, what is the common usage for @QueryParam and @Consume? -

i new comer in terms of web services. tasked convert existing software component web service. did research , decided use jax-rs. having difficulty decide when use @queryparam , when use @consume because seems able achieve same goal. for example, let have method named read() , takes book argument. public class areader { public void read(book book){...} } public class book { public string author; public string name; } when translating using jax-rs annotation, either use @post , @queryparam accept author , name parameter or use @post , @consumes consume text representation of book in xml or json format in body. my question common usage @queryparam , @consume. personal preference or there common practice? i found lot information usage of @pathparam , @queryparam not @queryparam , @consumes. thanks in advance... query parameters ideally best suited representing aspects of requests have nothing resource representation. for example, if designing restful web

python - How can I reference a dictionary with boolean terms as values in a while-loop statement? -

i have dictionary: flips_left = {'front flip': true, 'side flip': true, 'back flip': true } all values true and have while loop: while flips_left[flip_choice] == true: flip_choice = raw_input("do flip ") if flip_choice in flips_left: if flips_left[flip_choice]: print flip_lines[flip_choice] flips_left[flip_choice] = false else: print "you did %s" % flip_choice else: print "that not type of flip" print "great! completed wod!" i want way while loop exit when values in dict false. any() tests each of elements of passed iterable trueness. while any(flips_left.itervalues()):

Windows 8 phone app design in photoshop -

i'm working on design windows 8 app, team of developers.we have finalized of screens app, developer informed me mockup of entire app in photoshop presented him , screen size should 480 x 800. ( right sitting @ 480 x 1800 due scroll in page) i have been informed optimize mockup other 2 remaining screen sizes 768 x 1280 , 720 x 1280 required? wouldnt covered in development stage. from present html5 , css knowledge building small static websites, width 100% in container width wouldnt fix this? as design following guidelines grids made guidlines pdf had set 480 x 800 2 new screen size how can go this? can change canvas size in photoshop , resize elements?. please let me know if there anyway possible hands on - splashscreenimage.screen-wxga.jpg , splashscreenimage.screen-720p.jpg can overlay jpg in photoshop , create grid have windows 7 not able install sdk these 2 images. mockups other resolutions (almost) same. there automatic scaling. difference 720p resolu

android - Link to obtain Google Map Key is not available -

i have extracted md5 fingerprint .now want obtain google map key link not working. found http://code.google.com/android/maps-api-signup.html in wei-meng lee book beginnining android 4 application development latest publication google map key .can update new link google map key . googled not able find it. use link... and go services turn on service named google maps android api v2 , then go api access now click on create new android key after paste sha1 key ; , project's package name for ex: your_sha1_key;com.example.xyz and lastly click on create .it generate google map key you.

html5 - How to get element from a DIV container by points in javascript? -

i have created 5 number of div's in ".container" div element bellow; <div class="container"> <div class="elem1">no 1</div> <div class="elem2">no 2</div> <div class="elem3">no 3</div> <div class="elem4">no 4</div> <div class="elem5">no 5</div> </div> touchstart , touchmove , touchend event has assigned .container element. on touch start of container in .elem1 , touchstart event handler receive "elem1" in event.target . on touch end of container in '.elem4' touchend event handler receive "elem1" in event.target release touch in elem4 . problem. need elem4 here. how exact element on touchend event handler? solution / suggestion on using touch points? are using jquery listen touch events? similar this: jsfiddle . essentially, i'm listening touch events on touch class i

java - Using Apache Commons Codec decodeBase64 from Clojure -

i trying decode base64 string in clojure using apache commons codec library. i able use these methods in library: (ns decode.core (:import (org.apache.commons.codec.binary base64 hex)) (:gen-class)) (.encode (hex.) "s") (.decode (hex.) "0a") (.decode (base64.) "s") but when try use decodebase64 (.decodebase64 (base64.) "s") get illegalargumentexception no matching method found: decodebase64 class org.apache.commons.codec.binary.base64 clojure.lang.reflector.invokematchingmethod (reflector.java:53) what doing wrong? seems should able call decodebase64 can call decode ? decodebase64 static java method. here how call in clojure: (import '[org.apache.commons.codec.binary base64 hex]) (base64/decodebase64 "s")

c# - Getting Values from Cloned Elements -

this code http://jsfiddle.net/euyb8/ <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title> - jsfiddle demo</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script> <link rel="stylesheet" type="text/css" href="/css/normalize.css"> <link rel="stylesheet" type="text/css" href="/css/result-light.css"> <style type="text/css"> #templaterow { display:none; } table, tr, td, th { border: solid thin black; padding: 5px; } </style> <script type="text/javascript">//<![cdata[ $(function() { //attach function click event of "add box attribute button add new row $('#addattr').click(function() { //clone template row, , events attached row , in var $newrow = $('#templaterow'

excel - increment a value in a cell if they are the same -

this may little difficult me explain. have 1 column in excel has duplicate entries i.e. more 1 red , more 1 blue. need compare column against , increment each cell same word 1. for example if there list of 3 reds in column , 2 blues in same column need incremented red1, red2, red3 , blue1, blue 2. i've been searching far have not found works how need to. i have sorted column , need add number increments 1 same cell entry. the column have 5000 products (with many random duplicates) , if products have same name need incremented 1. any appreciated. thank , hope makes sense. you can use countif using little trick range. =countif($a$1:a1, a1) and if want directly concatenate... =a1&countif($a$1:a1, a1) and drag formula down. adjust range accordingly.

execution of the consecutive commands through unix script when the previous one is done -

i have unix script in command needs executed repeatedly command can run next time when previous 1 have completed successfully. searched command can tell script has finished execution couldnt find it. new in unix scripting , started love unix scripting. in order command execute after previous 1 has succeeded, need write 2 as: command1 && command2 to have in loop single command, need check return status of each invocation , exit loop if it's not successful; shortest form should like: while your_command; :; done you insert sleep instead of noop : .

javascript - d3 line.defined doesn't draw zero value -

fi've made multiline chart , want manage empty values. have 2 kinds of empty value '' , ' ' use map csv var column = color.domain().map(function(name) { return { name: name, values: data.map(function(d) { if(d[name] === '' || d[name] === ' '){ //if data empty store in d.vale string return {name: name, id: d.id, value: d[name]}; } else{ //if value not empty store in d.value number , replacing coma dot (replacedot function) return {name: name, id: d.id, value: +replace(replacedot(d[name]))}; } }) }; }); than inside line.defined check if d.vale not string , if not return it: var line = d3.svg.line() .defined(function(d) { if(typeof d.value !== 'string'){ return d.value;}}) this work fine escape empty value, if there 0.0 value in dataset escaped to... how can fix it? thanks daniele the .defined function supposed return true/false depending on whethe

jQgrid editrules custom_func showing cell value of "select column" in its beginning of error message -

i using editrules custom_func preventing user enter same record in jqgrid. have define custom_func on column colmodel defination follows : { name: 'bo', index: 'bo', width: 40, editable: true, edittype: 'select', /*formatter: 'select',*/ editrules: { custom: true, custom_func: function (value, colname) { return customfunction.call(this, value, colname, ogrid); } }, i populating select column of jqgrid id(uid) : name(text) code doing work , showing error message, problem error message showing uid value such b66a2719-b88a-427e-8904-816fe8e60fde creating duplicate record . please give role selected bo type. , don't want id value in error message. how should remove value???? suggestions??? you have update jqgrid new version fix problem. reason easy. inline editing module used in jqgrid 4.4.4 follow

twitter - iOS retweet with SLRequest returns bad URL error -

i'm implementing retweet functionality keep getting bad url error after post. here's code: slrequest *twitterrequest = [slrequest requestforservicetype:slservicetypetwitter requestmethod:slrequestmethodpost url:[nsurl urlwithstring:@"https://api.twitter.com/1.1/statuses/retweet/%@.json"] parameters:[nsdictionary dictionarywithobject:tweetid forkey:@"id"]]; [twitterrequest performrequestwithhandler:^(nsdata *responsedata, nshttpurlresponse *urlresponse, nserror *error) { dispatch_async(dispatch_get_main_queue(), ^{ if ([urlresponse statuscode] == 429) { nslog(@"rate limit reached"); return; } if (error) { nslog(@"error: %@", error.localizeddescription); return; } }); }]; any ideas? missing anything? thanks! my bad. forgot pass string when creating request "...%@.json". i.e. slrequest *twitterrequest = [slrequest requestforservicetype:slservicetypetwitter

How to group multidimension array by key with php? -

i have array: array ( [0] => array ( [0] => 78 [mount] => 78 [1] => activation [type] => activation [2] => 2013-10-01 [insertdate] => 2013-10-01 ) [1] => array ( [0] => 130 [mount] => 130 [1] => activation [type] => activation [2] => 2013-10-02 [insertdate] => 2013-10-02 ) [2] => array ( [0] => 210 [mount] => 210 [1] => activation [type] => activation [2] => 2013-10-03 [insertdate] => 2013-10-03 ) [3] => array ( [0] => 190 [mount] => 190 [1] => activation [type] => activation [2] => 2013-10-04 [insertdate] => 2013-10-04 ) [4] =&

php - Why multidimensional array keeps return the key "0"? -

i have array this $test = array("sumber"=>array("f1","f2"),"ukraina"=>array("f3","f4"),"0"=>array("f5","f6")); foreach($test $key => $value){ if($key=="sumber"){ $a=''; for($i=0;$i<count($value);$i++){ $a.=$value[$i].", "; } echo $key." has ".$a."<br/>"; } } and want result only sumber has f1, f2, but result this sumber has f1, f2, 0 has f5, f6, please me how display key "sumber" only??? thanks. use triple conditional === in if($key=="sumber") condition: $test = array("sumber"=>array("f1","f2"),"ukraina"=>array("f3","f4"),"0"=>array("f5","f6")); foreach($test $key => $value){ if($key==="sumber"){ $a=''; f

css3 - Chrome CSS transition + text shadow issue -

a { transition: text-shadow, 0.5s, ease; display: block; padding: 20px 0px 20px 0px; color: #fff; text-shadow: #343434 1px 1px 1px; text-decoration: none; } a:hover { color: #fff; text-shadow: #343434 1px 1px 1px, 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff, 0 0 40px #ff00de, 0 0 70px #ff00de, 0 0 80px #ff00de, 0 0 100px #ff00de, 0 0 150px #ff00de; text-decoration: none; } transition + text shadow works flawless firefox, not working chrome, know how fix this? please open following link firefox chrome, see differences; http://jsfiddle.net/tfke8/ thanks help! ps: tried -webkit-transition, won't work there might mistake in syntax, try without commas: transition: text-shadow 0.5s ease; this gives smooth transition in chrome 30.0.1599.69.

Support of iOS 5.0 icons with XCode 5 -

i'm using new asset catalog appicon set right icons ios 5 (in theory), 6 , 7. unfortunately, when installing application on ipad 1 (with ios 5.1.1), displayed icon not right 1 (it's upscaled one, 57x57 one). i saw after creating asset catalog, 2 empty entries added in info.plist file: icon files (ios 5) cfbundleicons~ipad i've read lot of "solutions", nothing worked me :( one of solution add these entries in plist (and add corresponding icons in project): <key>cfbundleicons</key> <dict> <key>cfbundleprimaryicon</key> <dict> <key>cfbundleiconfiles</key> <array> <string>icon.png</string> <string>icon@2x.png</string> <string>icon-72.png</string> <string>icon-72@2x.png</string> </array> <key>uiprerenderedicon</key> <true/> </

visual studio 2010 - print result in windows form applications in c# -

suppose have 2 arrays a[] , b[], array a[25] , b[25] both have 25 values, see following code:- for(int i=0;i<25<i++) { for(int j=0;j<25;j++) { if(a[i]==a[j]) { count++; } else continue; } //print result of each comparison } in above code comparing each value of a[] values of b[] , counting occurrences . not getting how show(print) occurrrences of each comparison in windows form applications use textbox , set multiline , scrollable: textbox1.multiline = true; textbox1.width = 150; textbox1.height = 80; textbox1.scrollbars = scrollbars.vertical; textbox1.text = "occurrences: " + count.tostring(); // print count

matlab - How to loop through a cell array of functions, plotting each one on a different graph -

this attempt 2 functions i'd plot side side: numgraphs = 2; x = 1:5; y1 = x.^2; y2 = x.^3; funcs = cell(y1, y2); i=1:numgraphs subplot(1,2,i); plot(x,funcs(i)); end but got error: error using plot conversion double cell not possible. is i'm trying possible? there 2 problems in code: creation of cell: should use funcs = {y1, y2}; , not funcs = cell(y1, y2); plotting: should use plot(x,funcs{i}); , not plot(x,funcs(i)); . curly braces used access content of cell.

excel - Drop down wont select horizontal selection -

Image
i have created dropdown in excel spreadsheet , selected values across horizontal axis. issue on drop down menu first value shows. can round perhaps entering values macro when page loads? below selections: date incident problem end end outage service outage client service area business area fact cause action due date owner root cause code strategic client impact completed date pm owner region ifc # of strat clients impacted downtime minutes internal impact comments you need store values horizontal cells in string , use data validation. assumption: let's data looks shown below , want show list a1:m13 in cell d4 code: sub sample() dim ws worksheet dim acell range, rng range dim slist string '~~> set relevant sheet set ws = thisworkbook.sheets("sheet1") ws '~~> range has horz list set rng = .range("a1:m1") '~~> values of each cell , store in string each acel