Posts

Showing posts from February, 2011

servlets - Accessing bean from Jsp -

i searched on forum haven't got appropriate solution. , if mistake 1 duplicate sorry. coming problem... i'm setting values 1 of html using servlet code index.html <form method="post" action="user"> what's name? <input type="text" name="username" size=20>` code servlet package test; ...... userbean ub = new userbean(); string name = request.getparameter("username"); ub.setfirstname(name); request.setattribute("user",ub); requestdispatcher rd=request.getrequestdispatcher("/getjsp.jsp"); rd.forward(request,response); both servlet , bean placed in package called test. code userbean: private string firstname; public string getfirstname() { return firstname; } public void setfirstname(string firstname) { this.firstname = firstname; system.out.println(firstname); } from bean i'm able print proper value name on server console. after setting values servlet i'...

.net micro framework - how to send a signal to run a machine using netduino? -

first, beginner in netduino , micro-framework , situation : have application (winforms app) in win pad application sleeping detection, , have netduino cart, want it's send signal(start/stop) netduino car window, mean if signal sent window coming down , if it's sent second time window coming up. see example of led : public static void main() { var led = new outputport(pins.gpio_pin_d0, false); while (true) { led.write(!led.read()); thread.sleep(1000); } } so please if has idea appreciative. update : code basic , wondered if it's correct. outputport carwindow = new outputport(pins.gpio_pin_a0, false); while (true) { carwindow.write(true);//open window thread.sleep(2000); }

php - searching strings in SQL -

i'm building simple shopping cart. need allow related products. initial thought have db field in product table called tags have comma delimited list of tags in it: tag1,tag2,tag3 when grab product db grab tags , explode string on comma. problem i'm having trouble thinking of way call db other products have matching tag. there way search string in sql? can think of way achieve this i not go down route of storing comma separated strings in fields, not scalable (or normalized ) . split 3 different tables: products: ------------- id | name ------------- 1 | product 1 2 | product 2 tags: --------------- id | tag --------------- 1 | tag 1 2 | tag 2 product_tags: ---------------------- product_id | tag_id ---------------------- 1 | 1 1 | 2 when want find products related tags do select product_id product_tags tag_id = tag_id you use more advanced joining statements return records products table (instead of product_id...

NSIS - onClick not working at all -

i have issue driving me crazy: cannot the onclick work, not simple example: i've read documentation of nsis, once , again before asking, seems stuck (yes i'm new in nsis). function button_click messagebox mb_ok "hi there!" functionend function fnc_usb_drive_create ... ${nsd_createbutton} 12 74 121 30 "button1" pop $hctl_usb_drive_button1 ${nsd_onclick} $hctl_usb_drive_button1 button_click ... functionend the button appears on screen, clicking nothing. it's days have been working on this. i have win7 sp1 64b, , nsis + nsis dialog designer (latest version of all). have idea? page custom fnc_usb_drive_create var hctl_usb_drive_button1 !include nsdialogs.nsh function fnc_usb_drive_create nsdialogs::create 1018 pop $0 ${nsd_createbutton} 12 74 121 30 "button1" pop $hctl_usb_drive_button1 ${nsd_onclick} $hctl_usb_drive_button1 button_click nsdialogs::show functionend function button_c...

java - Extracting certain text from html file -

i want extract texts html file placed between parapraph(p) , link(a href) tags.i want without java regex , html parsers.i thougth while ((word = reader.readline()) !=null) { //iterate end of file if(word.contains("<p>")) { //catching p tag while(!word.contains("</p>") { //iterate end of tag try { //start writing out.write(word); } catch (ioexception e) { } } } } but not working.the code seems pretty valid me.how reader can catch "p" , "a href" tags. the problems start when have <p>blah</p> in single line. 1 simple solution change < \n< - this: boolean insidepar = false; while ((line = reader.readline()) !=null) { for(string word in line.replaceall("<","\n<").split("\n")){ if(word.contains("<p>")){ insidepar = true; }else if(word.contains...

java - Custom object input for CXF-JaxRS WebClient -

i pretty new restful, , trying create sample services achieve post on void methods. able test method string class getting exception while testing custom object. serviceclass: @override @post @path("/sayhello") public void sayhello(person person) { system.out.println("hello there, " + person.getname()); } @override @post @path("/sayhi") public void sayhi(string name) { system.out.println("hey there, " + name); } test clients: public void testsayhellorest() throws exception { webclient client = webclient.create("http://localhost:8080/servicestutorial/sampleservice/sayhello"); person p = new person(); p.setname("my name"); client.post(p); } public void testsayhi() throws exception { webclient client = webclient.create("http://localhost:8080/servicestutorial/sampleservice/sayhi"); client.post("my name"); } second test simpl...

perl - Using DBIx::Class, how can I check if a table exists? -

my goal create function create mysql db table (using schema defined via dbix::class already) if hasn't been created yet. otherwise creates reference $schema. currently understand how create table if doesn't exist following code: my $schema = myapp::schema->connect( $dsn, $user, $password, ); $schema->deploy( { add_drop_table => 1 } ); i need add more logic not attempt add table if exists. you can use "drop table if exists" in create table statement if want create every time. if don't want mess data can "show tables" , parse results, like my $tables = $dbh->selectall_arrayref(qq|show tables|) or die "can't show tables " . $dbh->errstr(); if (@$tables) { foreach $table (@$tables) { if ($table->[0] eq 'sometablename') { # table sometablename exists } } }

for loop on R function -

i'm new r (and programming generally), , confused why following bits of code yield different results: x <- 100 for(i in 1:5){ x <- x + 1 print(x) } this incrementally prints sequence 101:105 expect. x <- 100 f <- function(){ x <- x + 1 print(x) } for(i in 1:5){ f() } but prints 101 5 times. why packaging logic function cause revert original value on each iteration rather incrementing? , can make work repeatedly-called function? the problem it because in function dealing local variable x on left side, , global variable x on right side. not updating global x in function, assigning value of 101 local x . each time call function, same thing happens, assign local x 101 5 times, , print out 5 times. to visualize: # "global" scope x <- 100 f <- function(){ # "global" x has value 100, # add 1 it, , store in new variable x. x <- x + 1 # new x has value of 101 print(x) } this similar fo...

playframework 2.0 - Deadbolt - Access failure redirect is not working -

i using deadbolt 2 playframework 2.1 i have public page user clicks on action button , controller method called, method has @subjectpresent on it. want redirect user login page if user not logged in , after user logs in execute method call. i call controller method through jsroutes below function launchdemo(demoid){ jsroutes.controllers.demolaunchapplication.launchdemo(demoid).ajax({ success: function(data, textstatus) { $("#result").html(data); }, error: function(data) { alert("error"); $("#result").html(data); } }) } i have setup deadbolt 2 based on project sample here.( https://github.com/joscha/play-authenticate/tree/master/samples/java/play-authenticate-usage ) i following errors in console. [error] application - access [/test/launch?testid=2] requires subject, no subject present. [warn] application - deadbolt: access failure on [/test/launch?testid=2] and in result div, l...

input string in python 3 -

i have string variable test, in python 2.7 works fine. test = raw_input("enter test") print test but in python 3.3. use test = input("enter test") print test with input string sdas , , error message traceback (most recent call last): file "/home/ananiev/pycharmprojects/piglatin/main.py", line 5, in test = input("enter test") file "", line 1, in nameerror: name 'sdas' not defined you're running python 3 code python 2 interpreter. if weren't, print statement throw syntaxerror before ever prompted input. the result you're using python 2's input , tries eval input (presumably sdas ), finds it's invalid python, , dies.

c++ - PC performance and stability issue in multithreaded simple benchmark. How to make each thread run on separate core? -

look @ code in post: https://stackoverflow.com/questions/16594768/how-to-write-simple-speed-test-app-with-cuda this time i'm not cuda, code of application in post. issue want face application pretty unstable in case of total score returns. after first time compiled it returning value between 12.2 - 12.5 mld test time equal 10 secons today after pc turn off , on keeps returning value approx. 15 mld same test time. thought moment happened pc, in other professional tests it's more stable - eg. mdcrackgui benchmark returns me approx. 132 million first value every time run it. after moment of clever thinking had fallowing questions: i have 8 logical cpu cores, i'm not sure each computing thread using 1 , same logical core while test running. how modify code ensure if it's possible ? there 8 computing threads have 4 not 8 physical core cpu(because of ht technology). guess means 8 threads won't run in parallel. if there positive answer first question wouldn...

moving object using slider openCV c++ -

i'm new opencv (c++), lecturer ask me make simple slider every position in slider have different place in window. code below can move object in window based on slider position when moved slider old position still there. looks duplicate not move. can me on problem?? there way solve problem or must change code completely?? #include "stdafx.h" #include "cv.h" #include "ml.h" #include "cxcore.h" #include "highgui.h" int g_switch_value = 0; int colorint = 0; void switch_callback( int position ){ if( position == 0 ){ colorint = 0; }else{ colorint = 1; } } int _tmain(int argc, _tchar* argv[]) { const char* name = "change color of circle in picture"; int radius = 30; int thickness = 12; int connectivity = 8; cvscalar red = cv_rgb(0,0,255); iplimage* src1 = cvloadimage( "e:/2.jpg" ); cvpoint pt1 = cvpoint(405,195); cvpoint pt2 = cvpoint(620,400); cvnamedwindow...

javascript - Undefined local variable or method when I use <%= home_index_path %> in application.js.erb, why? -

as title states, have application.js.erb file looks following: //= require jquery //= require jquery-ui //= require bootstrap //= require html5shiv //= require_tree . $(document).ready(function(){ $("#opening-first").fadein(1000, function() { $("#opening-second").fadein(1000, function() { $("#opening-container").delay(500).fadeout(1000, function() { $("#body-overlay").fadeout(1000); }); }); }); $(".me").on('click', function(){ fadeandreload('<%= me_home_index_path %>'); }); $(".home").on('click', function(){ fadeandreload('<%= root_path %>'); }); function fadeandreload(filename) { var body = $("#reload-me"); body.fadeout(500, function() { body.load(filename, function() { body.fadein(500); }); }); } }); my routes listed as: home_index /home/index(.:format) home#ind...

css - vertical align html form -

i'm looking center textbox , submit button on page both vertically , horizontally following code puts in top center. how can center page? it's it's ignoring vertical-align setting. <div style="text-align:center; vertical-align:middle"> <form action="save_thought.php" method="post"> <input type="text" name="thought"><br> <input type="submit" value="submit"> </form> </div> you can use position:absolute demo http://jsfiddle.net/kevinphpkevin/u8dzr/ div#form-wrapper { position:absolute; top:50%; right:0; left:0; }

Clonezilla custom-ocs bash script failing on ocs-onthefly command -

i'm doing custom clonezilla.. 1 source send local disk remote disk ocs-onthefly... custom-ocs working fine. however, custom-ocs destination reason not working.. problem last line "/usr/sbin/ocs-onthefly -s $src_ip -t $dest_disk" .. reason clonezilla balking @ line , gives usage/help output instead of running command.. any ideas on why ocs-onthefly command not accepting parameters? parameters correct. if run "/usr/sbin/ocs-onthefly -s 192.168.150.1 -t sda" runs fine. custom-ocs destination script here: https://www.dropbox.com/s/9mfrt0n50sheayn/custom-ocs_destination-revised.txt attempting code block also: #!/bin/bash # author: steven shiau <steven _at_ nchc org tw> # license: gpl # ref: http://sourceforge.net/forum/forum.php?thread_id=1759263&forum_id=394751 # in example, allow user use clonezilla live choose # (1) backup image of /dev/hda1 (or /dev/sda1) /dev/hda5 (or /dev/sda5) # (2) restore image in /dev/hda5 (or /dev/sda5) /dev/hda1 ...

java - Unable to work with Struts2 and REST Plugin -

i've been trying work rest plugin of struts2 unable make work simple project , following tutorials i'm unable make work. i literally feel tried nothing worked. can't post code , have no clue why project not working, here project attached (don't worry, it's base project 1 class only, not thousands of lines debug). https://www.dropbox.com/s/2wulbd7xmk5nwfl/basic_struts2_mvn.zip so problem when request /user, 404 :/ because have no controllers. your controllers need in src/main/java , not src/main/resources : . ├── pom.xml └── src └── main ├── resources │   ├── example │   │   └── userscontroller.java <-- not resource, java source. │   └── struts.xml └── webapp ├── web-inf │   └── web.xml └── index.jsp there may other issues well. note don't need explicitly include convention plugin in pom.

c++ - Unnamed struct declaration inside for loop initialization statement -

in 1 of thread, had seen usage of unnamed struct acting placeholder multiple variables of different types inside loop: for example: for(struct { int i; double d; char c; } obj = { 1, 2.2, 'c' }; obj.i < 10; ++obj.i) { ... } this compiles fine g++. standard c++03 syntax? you can use unnamed struct anywhere can use struct - difference doesn't name can used somewhere else. can declare new type anywhere can use type, pretty much. may not particularly meaningful in places, that's matter. i wouldn't recommend this, other in special cases, it's valid.

java returning "NoClassDefFound" error; thinks -jar option is a runnable class -

java -jar <name of executable jar> results in 1.6 jvm returning noclassdeffound error 'jar'. why isn't recognising -jar option , not class run? jar structure: manifest points main-class @ com.mycompany.entrypoint.class, inside jar. specifies ant-version , haven't set ant_home env variable (running on windows). exact runtime error: exception in thread "main" java.lang.noclassdeffounderror: ûjar caused java.lang.classnotfoundexception: ûjar ... manifest: manifest-version: 1.0 ant-version: apache ant 1.8.1 created-by: [redacted] main-class: com/mycompany/entrypoint edit: no idea why tried once more , time executed jar expected. probably '-' character you're using '-jar' flag not standard ascii '-' sign, kind of utf-8 special character. remove , replace normal ascii '-' sign.

strange ruby behavior with a constant -

could explain me, why original constant list beginning getting manipulated @ end? thought constant once initialized. want store manipulations in new array ( new_list ) without affecting original 1 ( list ). $ned = "foo" $med = "" print list = [:nrd, :mrd_y] # -> [:nrd, :mrd_y] list = list new_list = list.delete_if { |element| case element when :nrd $ned.empty? when :mrd_y $ned.empty? || $med.empty? end } print new_list # -> [:nrd] print list # -> [:nrd] instead of [:nrd, :mrd_y] array#delete_if -> deletes every element of self block evaluates true. $ned = "foo" $med = "" list = [:nrd, :mrd_y] p list.object_id #=> 84053120 list = list p list.object_id #=> 84053120 new_list = list.delete_if { |element| case element when :nrd $ned.empty? when :mrd_y $ned.empty? || $med.empty? end } list , list holding same array object, object_id tells above. each true evaluation block delete_if ...

code signing is required for iOS 6.1 -

Image
this question has answer here: xcode 'codesign error: code signing required' 14 answers i error when try test device. codesign error: code signing required product type 'application' in sdk 'ios 6.1' xcode ver 4.6.2 thanks help. right in build settings , looks you have code sign app test it, change looks note able test on device, must registered apple developer (payed $99), , have device set development provisioning profile installed. edit make sure in organizer->devices, phone set development , has ios team provisioning profile installed. also, make sure device set used provisioning profile in provisioning portal. if nothing else works, @ this answer.

how do i match just spaces and newlines with python regex? -

how match empty spaces including newlines python regex? hereissometext thereisspacepreceding basically trying match space between 2 groups of text. four seconds of searching docs have found answer in docs. said, if you're looking matching group whitespace + newlines, here go . (/s+)

java - Way to determine if a charset is multibyte? -

is there way determine whether given charset (java.nio.charset.charset) encodes characters using multiple bytes? or, alternatively, there list somewhere of character sets do/do not use more 1 byte per character? the reason i'm asking performance tweak: need know how long (in bytes) arbitrary string in given character set. in case of single-byte encodings, it's length of string. knowing whether or not charset single-byte save me having re-encode first. you might think puny optimization couldn't possibly worth effort, lot of cpu cycles in application spent on sort of nonsense, , input data i've encountered far has been in 20+ different charsets. the simplest way probably: boolean multibyte = charset.newencoder().maxbytesperchar() > 1.0f; note newencoder can throw unsupportedoperationexception though if charset doesn't support encoding. while newdecoder isn't documented throw that, maxcharsperbyte isn't appropriate. use averagechars...

R - Function to create a data.frame containing manipulated data from another data.frame -

hi new r , have question. have data.frame (df) containing 30 different types of statistics years 1960-2012 100 different countries. here example of looks like: country statistic.type 1960 1961 1962 1963 ... 2012 __________________________________________________________________________________ 1 albania death rate 10 21 13 24 25 2 albania birth rate 7 15 6 10 9 3 albania life expectancy 8 12 10 7 20 4 albania population 10 30 27 18 13 5 brazil death rate 14 20 22 13 18 6 brazil birth rate ... 7 brazil life expectancy ... 8 brazil population ... 9 cambodia death rate ... 10 cambodia birth rate ... etc... note there 55 ...

link to - Rails, link_to helper with an URL as a param -

i want generate next html link: <a href="http://url.com">http://url.com</a> to reproduce using link_to helper have write: <%= link_to "http://url.com", "http://url.com" %> what doesn't dry @ all, expecting work: <%= link_to "http://url.com" %> but above code generate link targeting actual request.url , not 1 i'm sending in param. am missing something? you're not missing --- normal case url , text shows user different. if you'd like, create helper like def link_to_href(link, args={}) link_to link, link, args end then, when use it, <%= link_to_href "http://url.com" %> will output <a href="http://url.com">http://url.com</a>

PHP code doesn't insert records into database -

this question has answer here: my php code not insert records sql dabase table [closed] 4 answers my php program wont insert records entered in browser sql database. see code below. code update 1 asked earlier. suggested security among other reasons. i not errors @ program runs fine in browser whenever check database no entries have been put in after running code. missing something? <html> <head> </head> <body> <form action="register_development_file_1b.php" method="post"> email: <input type="text" name="email"><br /> date: <input type="text" name="date"><br /> time: <input type="text" name="time"><br /> <input type="submit" name="submit"> </form> <?php ...

web scraping - Extracting the same data from various HTML documents -

let's have several html pages unrelated websites, contain same overall information. want extract information in flexible manner, i.e. want have write small number of data extractors of pages (ideally, one). fields (to use blog example) author, date, title, text . classes of html tags denote these totally different each page, still display on page in same way. example, take this post cnn , this post gawker. both contain same information - information want - somewhere on page when displayed. there nice way extract data? writing separate extractors option, not one; there thousand styles of documents in dataset want use. the way can finding common element in of websites (e.g. share same dom structure, or have same id, or preceded same content in previous tag <h1> ). otherwise, need write different rules or regular expressions each case. unless, of course, write algorithm intelligent capable of recognizing content intention/meaning different html - not simple no...

android - Web View Fragment html embeed video fullscreen suport -

hello got question regarding how enable full screen support in html embed videos on webview have hardware accelerated true on manifest , video works ok wen pressed go fullscreen video stops. here code import com.photoshop.video.tutorials.r; import android.annotation.suppresslint; import android.os.bundle; import android.support.v4.app.fragment; import android.text.textutils; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.webkit.webchromeclient; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.progressbar; public class webviewfragment extends fragment { public final static string tag = webviewfragment.class.getsimplename(); private webview viewcontentwebview; private string url; private boolean resethistory = true; @suppresslint("setjavascriptenabled") @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { fina...

c - What does pthread_exit do so that main should call it to prevent other threads from dying prematurely -

http://man7.org/linux/man-pages/man3/pthread_exit.3.html the man page above not tell why main() should terminate calling pthread_exit, says should. comments appreciated. the thread executes main special, returning equivalent call exit whole process. kill other threads. if terminate pthread_exit process keeps running until other threads terminate 1 way or another. the other alternative give other threads time job join threads created means of pthread_join .

jquery - Knockout clearing field in view model after submission -

how can clear value of department name in view model after submit department server saved? here code: self.adddepartmentmodel.adddepartment = function () { self.errors = ko.validation.group(this, { deep: true, observable: false }); if (self.adddepartmentmodel.errors().length == 0) { $.ajax({ url: "/department/add/", type: 'post', data: ko.tojson(self.adddepartmentmodel), contenttype: 'application/json', success: function (result) { $('#success').html('department added successfully.'); $("#success").dialog({ dialogclass: 'noclose', autoopen: true, show: "blind", hide: "explode", modal: true, open: function(event, ui) { settimeout(function() { ...

java - Timer and timerTask small issue -

i noob @ java. first time use timer , timertask class in java. purpose of app: it multi client app implemented mysql. app read database data repeatly. if database updated, want every client's panel updated well. assume need timer class can automatically perform repeating query read database , make change on component of client side. problem: i thought tutorial , found way it. since this.updatetablestatus() method in table class, how can use method in mytimer(timertask) class. public class table extends javax.swing.jframe { public table() { initcomponents(); mytimer mytime = new mytimer(); } public void updatetablestatus(){ // refresh table status reading database data , make change. } class mytimer extends timertask{ public mytimer() { timer timer = new timer(); timer.scheduleatfixedrate(this, new java.util.date(), 1000); } public void run(){ this.updatetablest...

whitelist - Google CCS (GCM) - project not whitelisted -

i'm trying python code working found on: http://developer.android.com/google/gcm/ccs.html i've change first 2 rows (i think) correct data. projectnr , api key fake, it's show how looks. import sys, json, xmpp server = ('gcm.googleapis.com', 5235) username = '489713985816' password = 'aizd237jjn_it7yrxlwihrreqax45xamjq6vj98' i've created google api project (tried 2 different projects). activated gcm. copied following: project number: 489713985816 api key : aizd237jjn_it7yrxlwihrreqax45xamjq6vj98 tried code key server, , key browser apps, both , without specific ip address. when execute code #python ccs.py following result: if problem, how project whitelisted? invalid debugflag given: socket debug: debug: debug created /usr/lib/python2.7/dist-packages/xmpp/client.py debug: flags defined: socket debug: socket start plugging <xmpp.transports.tcpsocket instance @ 0x1ea2950> <xmpp.client.client instance @ 0x1ea27...

php - Why does calling drush command by system() fail? -

i have drupal 7 site on iis 7.5 server. inside iis services manager choose user administrator rights in anonymous authentication settings. i'm sure drush command in evn path. when logged user (win7) can call command everywhere. however when try launch command inside drupal module: $output = array(); $res = exec('drush --version', $output, $retval); $retval 1 (error), $output , $res empty. different command (sqlcmd) works ok. both commands has identical rights (file system) what doing wrong here? using absolute paths solves issue, paths without spaces.

c++ - Moving around the lblas library and using it with the g++ compiler -

so on current computer have library use blas functions, need run c++ program on external server. know how transfer files server, i'm having trouble figuring out how find blas library that's on current computer , how link compiler. so here's command use current on computer g++ program -lblas , works great. run program , swell. how move library external server? ideally, i'd move library same folder program resides , link compiler library somehow. know how this? if helps, know how download blas library , ".a" file out. have no idea there though. never mind, simple question. thought lot more complicated. for stumbles upon this, here's do: get .a file. me, downloaded makefile components necessary make .a file here blas: http://www.netlib.org/blas/ next, put in same folder program if want i'm doing. finally, command! compiler, code, library for me, g++ program.cpp blas.a

javascript - Embed Twitter User Timeline in Webpage -

on website, user enters twitter username when register , timeline embedded on profile page. until now, i've achieved following javascript code: <script type="text/javascript"> var twitterusername = // read database new twtr.widget({ version: 2, type: 'profile', rpp: 4, interval: 30000, width: 'auto', height: 210, features: { scrollbar: true, loop: false, live: false, behavior: 'all' } }).render().setuser(twitterusername).start(); </script> recently noticed following messages appearing in javascript console twitter widget: widget being deprecated, , cease functioning soon. https://twitter.com/support/status/307211042121973760 twitter widget: can obtain new, upgraded widget https://twitter.com/settings/widgets/new/user?screen_name=electricpicnic it seems instead of using widget should use emb...

activeadmin - Filter by association in ruby on rails using active admin gem -

i have 2 models: login , account class login belongs_to :account attr_accessible: first_name, primary_admin # primary_admin boolean end class account has_many: logins def primary_admin @primary_admin ||= self.logins.find { |l| l.primary_admin } end end so in resume account has many logins, there 1 login primary_admin = true . in filters of account want search login (the 1 primary_admin = true) using first_name of login. using active admin in app/admin/account.rb have this filter :primary_admin, as: :string but not working, appreciated, in advance! here database schema: login id :integer(4) not null, primary key email :string(255) default(""), not null first_name :string(255) last_name :string(255) primary_admin :boolean(1) account_id :integer(4) account id :integer(4) not null, primary key name :string(255) try if primary_admin string field activeadmin.regist...

ruby - watir open each link of a page -

i need scrape info on website has table each row contains link. i want watir click each link in table, grab info generated page , go previous page. t = browser.table(:class => "tblelencoprodotti") t.links(:class => "txt10b").each |l| l.click #do stuff browser.back end unfortunately action brings me "document expired document no longer available" error. this works if manually operation on default ff session , hit arrow, somehow not work if in watir opened window. any reason why need click , go browser each time? why not store links , visit them 1 one: browser.table(:class => "tblelencoprodotti"). links(:class => "txt10b").map(&:href). each { |url| browser.goto url } update : if links clickable due javascript magic , try this: links_count = browser.table(:class => "tblelencoprodotti").links(:class => "txt10b").size links_count.times |index| browser.table...

spring - setFirstResult and setMaxResult doesn't work well with Order By -

what cause criteriaquery orderby method stop working? here implementations: openjpaentitymanager kem = openjpapersistence.cast(entitymanager()); kem.getfetchplan().clearfetchgroups(); kem.getfetchplan().addfetchgroup("order_search"); criteriabuilder builder = kem.getcriteriabuilder(); criteriaquery<order> query = builder.createquery(order.class); root<order> order = query.from(order.class); query.select(order); predicate main_condition = buildwhereclause(builder, query, order, target_states, orderdate_from, orderdate_to, duedate_from, duedate_to, username); query.where(main_condition); query.orderby(builder.desc(order.get("orderdate"))); typedquery<order> q = entitymanager().createquery(query); if (firstresult != 0) q.setfirstresult(firstresult); if (maxresults != 0) q.setmaxresults(maxresults); with pagniation, when there 15 records , want 5 records per page, sho...

Idiomatic Proof by Contradiction in Isabelle? -

so far wrote proofs contradiction in following style in isabelle (using pattern jeremy siek ): lemma "<expression>" proof - { assume "¬ <expression>" have false sorry } show ?thesis blast qed is there way works without nested raw proof block { ... } ? there rule ccontr classical proofs contradiction: have "<expression>" proof (rule ccontr) assume "¬ <expression>" show false sorry qed it may use by contradiction prove last step. there rule classical (which looks less intuitive): have "<expression>" proof (rule classical) assume "¬ <expression>" show "<expression>" sorry qed for further examples using classical , see $isabelle_home/src/hol/isar_examples/drinker.thy

Python indentation error after try: -

i have problem, whenever try run python script on raspberry pi: import socket import sys # create tcp/ip socket sock = socket.socket(socket.af_inet, socket.sock_stream) # bind socket port server_address = ('localhost', 10000) print >>sys.stderr, 'starting on %s port %s' % server_address sock.bind(server_address) # listen incoming connections sock.listen(1) while true: # wait connection print >>sys.stderr, 'waiting connection' connection, client_address = sock.accept() try: print >>sys.stderr, 'connection from', client_address # receive data in small chunks , retransmit while true: data = connection.recv(16) print >>sys.stderr, 'received "%s"' % data if data: print >>sys.stderr, 'sending data client' connection.sendall(data) else: print >>sys.stderr...

c++ - having some issues when i am compiling my code -

i not know why having these compiling issues here when compiled program yesterday compiled nicely today not,the code shows how ro create shapes ball , cone , map shadows im getting these errors 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(125): error c2065: 'rgbimage' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(125): error c2146: syntax error : missing ';' before identifier 'thetexmap' 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(125): error c3861: 'thetexmap': identifier not found 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(126): error c2065: 'texture' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(127): error c2065: 'texture' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(135): error c...

c# - How to display in a picturebox an byte array image from a sql table? -

this question has answer here: reading binary table column byte[] array 2 answers i have image in sql table converted byte array.how can display in picture box when click on record datagridview contains table?i need actual code.thanks.this code have conversion: private void button2_click(object sender, eventargs e) { sqlconnection cn = new sqlconnection(@" data source=home-d2cadc8d4f\sql;initial catalog=motociclete;integrated security=true"); memorystream ms = new memorystream(); picturebox1.image.save(ms, system.drawing.imaging.imageformat.jpeg); byte[] pic_arr = new byte[ms.length]; ms.position = 0; ms.read(pic_arr, 0, pic_arr.length); sqlcommand cmd = new sqlcommand("insert motociclete(firma,model,poza,pret,anf,greutate,caprez,putere,garantie,stoc) values (@firma,@model,@poza,@pret,@anf,@greutate,@caprez,@putere,@gara...

android - jQuery mobile button press event slow to process -

it seems whenever press input button or anchor button on mobile device, takes second or 2 process onclick or press event. there way speed up? i using phonegap + jquery mobile on android device, seems little faster on ios using fast buttons eliminate 300ms of delay.

optimization - speed up an update join query in mysql -

i have 2 tables each of 1 hundred million rows, key1 , str_key both non-unique keys. following mysql query, according show engine innodb status, performing around 80 reads/sec, no updates yet. no other query running. update table_r r, table_w w set r.key1=0 r.str_key=w.str_key is correct query take 100 million / 60 > 1 million seconds finish? how optimize query finish quickly? whenever query slow, first thing make sure have index on columns mentioned in clause.

No database selected: login php code -

<?php session_start(); $con=mysqli_connect("localhost","xxx","xxxxxx","xxx"); if (mysqli_connect_errno($con)) { echo "failed connect mysql: " . mysqli_connect_error(); } $eadd = $_post['eadd']; $pass = $_post['pass']; $eadd = htmlspecialchars(stripslashes(strip_tags($eadd))); $pass = htmlspecialchars(stripslashes(strip_tags($pass))); if (filter_var($eadd, filter_validate_email)) { $sql = mysql_query("select * accounts emailadd = '$eadd' , password = '$pass'"); if(!$sql){ die('there error in query '. mysql_error()); } $count = mysql_numrows($sql) or die(mysql_error()); if ($count<=0) { echo " <html> ...

java - How to sort a large text file's data into a multi-dimensional array? -

i have large data file. starts off big paragraph want ignore or remove equation, has year e.g. 1974, 6 spaces, number represent month, e.g. 1, has 31 data entries want sort 3d array. i think i'm close solving it, keep getting exception java.lang.arrayindexoutofboundsexception . full error is: exception in thread "main" java.lang.arrayindexoutofboundsexception: 31 @ pkg110_term3.getdata.readfile(getdata.java:48) @ pkg110_term3.main.main(main.java:25) java result: 1 here code: public class getdata { public string[][][] sorteddata = new string[34][12][31]; int = 0; int b = 0; int c = 0; private scanner rainfile; //method opening file public void openfile() { try{ rainfile = new scanner(new file("c:\\\\users\\\\admin\\\\documents\\\\netbeansprojects\\\\110_term3\\\\weatherdatafiles\\\\rainfall.txt")); } catch(exception e){ joptionpane.showmessagedialog(nu...

asp.net - Get values from dropdown menu's, run query and add values to formview c# -

i have asp.net webform contains formview, 3 dropdown menus , submit button. dropdown menus values database. when user clicks submit button values dropdown menus should run through our query , display outcome in formview. not happening. when give standard values other, meat , vegetables in callselectproduct() can see correct output in form view, on page load. this click method submit button: protected void getrecipe(object sender, eventargs e) { string ddlother = dropdownother.selectedvalue; string ddlvegetables = dropdownvegetables.selectedvalue; string ddlmeat = dropdownmeat.selectedvalue; int ddlintother = int.parse(ddlother); int ddlintvegetables = int.parse(ddlvegetables); int ddlintmeat = int.parse(ddlmeat); business.class1.callselectproduct(ddlintother, ddlintmeat, ddlintvegetables); } this callselectproduct(): debug.writeline gives values in debug console, page reloads because of submit button click ...