Saturday, 15 May 2010

Strings in rows in R -



Strings in rows in R -

i have file , made function in r accepts string 110110110110110.

now, input file has 1000's of rows , each row has these numbers in subsequent columns.

example:

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 1 1 1 0 1 1 0 1 1 0 1 1 0 1 1 2 0 1 0 1 0 1 0 1 0 1 0 1 0 1 3 4 5 6

like this, have thousand's of rows. column v1 row number , v2-v28 contains either 1 or 0. now, want apply function every row of input file such numbers in columns v2-v28 forms input string. know how if had simple strings in rows in file, how columns?

thanks.

edit: function have written accepts string input such "110110110". however, have sequence of 1's , 0's in different columns (v2-v28) in each row.

like this?

df <- data.frame(v1 = c(1,0,0,0,1), v2= c(0,1,0,1,0), v3=c(0,0,0,0,0), v4=c(1,1,1,1,1)) input <- do.call(cbind, df[,2:ncol(df)])

now can utilize apply margin 1 rows, pass specified function:

apply(input, 1, do.something.with.vector)

edit: convert string , remove commata etc utilize this

apply(input, 1, function(x) print(gsub(", ","",tostring(x))))

you can exchange "print" "do.something.with.vector" function.

r

binary - C- Run-length encoding doesn't work on large file, worked on smaller file -



binary - C- Run-length encoding doesn't work on large file, worked on smaller file -

i have problem, when utilize on 41 kb file compressed (although because uses run-length encoding seems double size of file) , decompresses properly. when tried utilize on 16,173 kb file , decompressed it, didn't open , file size 16,171 kb....so decompressed didn't homecoming it's original form....something screwed up....has me baffled, can't seem figure out doing wrong....

the method used run-length encoding, replaces every byte count followed byte.

before:

46 6f 6f 20 62 61 72 21 21 21 20 20 20 20 20

after:

01 46 02 6f 01 20 01 62 01 61 01 72 03 21 05 20

here code:

void compress_file(file *fp_in, file *fp_out) { int count, ch, ch2; ch = getc(fp_in); (count = 0; ch2 != eof; count = 0) { // if next byte same increment count , test 1 time again { count++; // set binary count ch2 = getc(fp_in); // set next variable comparing } while (ch2 != eof && ch2 == ch); // write bytes new file putc(count, fp_out); putc(ch, fp_out); ch = ch2; } fclose(fp_in); fclose(fp_out); fprintf(stderr, "file compressed\n"); } void uncompress_file(file *fp_in, file *fp_out) { int count, ch, ch2; (count = 0; ch2 != eof; count = 0) { ch = getc(fp_in); // grab first byte ch2 = getc(fp_in); // grab sec byte // write bytes { putc(ch2, fp_out); count++; } while (count < ch); } fclose(fp_in); fclose(fp_out); fprintf(stderr, "file decompressed\n"); }

you miss check run length count char overflow, go wrong if have more 255 identical characters in file in sequence.

c binary run-length-encoding

jquery - Javascript News Ticker -



jquery - Javascript News Ticker -

i'm using code fade in , out different messages. works ok. problem delays first loop. , have wait before first message shows up. tried prepare no luck!

var loops = 0; function t() { var news = new array("text01", "text02"); var l = news.length; var fade = 300; var delay = 6000; var process = delay+fade+fade; var n = 0; var f = ''; for(i=0; i<l; i++){ f += "<span class='ticker' id='str"+i+"'>"+news[i]+"</span> "; $("#newsticker").html(f); } for(i=0; i<l; i++){ n++; var offset = i*process; $("#str"+i).delay(offset).fadein(fade).delay(delay).fadeout(fade); } var loop_process = n*process; if(loops==0){ settimeout("t()", 0); } settimeout("t()", loop_process); loops++; } t();

html

<span id="newsticker"></span>

javascript jquery ticker

tfs - Connect TeamCity to Visual Studio Online -



tfs - Connect TeamCity to Visual Studio Online -

i'm trying migrate on-premises tfs visual studio online. have quite elaborate teamcity build process don't want migrate away from, having teamcity working vso ideal.

i've created alternative user credentials (as per this article) , using these credentials in teamcity. when create new vcs in teamcity, connection error:

tf30063: not authorized access https://myproject.visualstudio.com/defaultcollection/myproject

i've tried actual credentials (not alternative ones) nil changed - same error.

also i've tried using alternative credentials tf command line tool , not come in alternative credentials - window popped up, asking me liveid.

any thought how prepare this?

p.s. how teamcity configuration like:

to connect visual studio online indeed need enable alternate credentials on business relationship you'll utilize team city. ensure @ to the lowest degree team explorer 2012 , update 4 installed on team city server, install whole visual studio 2012 incl update 4. team city requires @ to the lowest degree update 2, microsoft supports visual studio 2012 rtm , latest update (which update 4).

then in connection screen utilize next information:

repository url: https://myaccount.visualstudio.com/defaultcollection

username: ##liveid##\your.email@live.com // visual studio online user name, must match liveid.

password: ***** // password setup alternate credentials.

you can use vso service business relationship credentials instead of using alternate credentials.

then in vcs root configuration map tfvc root in next way:

root: $/myproject/path/to/branch/root

check out post on jetbrains confluence site more details.

tfs visual-studio-online teamcity-8.0 tfvc

java - How split large string in Intellij idea automatically? -



java - How split large string in Intellij idea automatically? -

i wirting test long string. need split big strings that:

privat static final string too_long_json = "{field1:field1, field2:field2 ... fieldn:fieldn}";

will become:

private static final string too_long_json = "{field1:field1, field2:field2" + "{field3:field3, field4:field4,field6:field6, field7:field7}" + "{field8:field8, field9:field9,field10:field10, field11:field11}" + " ... fieldn:fieldn}";

is possible set intellij thought split big string automatically?

you can utilize auto-formatting (ctrl + alt + l), after few changes in code style settings.

press ctrl + alt + s open settings window find code style / java section make sure uncheck "line breaks" alternative , check "ensure right margin not exceeded" option press ok take changes you've made

now when using auto-formatting (ctrl + alt + l) long strings exceeding line character limit automatically cutting multiple lines.

java string intellij-idea

How to GET a URL with User-Agent and timeout through some Proxy in Ruby? -



How to GET a URL with User-Agent and timeout through some Proxy in Ruby? -

how url if need through proxy, has have timeout of max n. seconds, , user-agent?

require 'nokogiri' require 'net/http' require 'rexml/document' def get_with_max_wait(param, proxy, timeout) url = "http://example.com/?p=#{param}" uri = uri.parse(url) proxy_uri = uri.parse(proxy) http = net::http.new(uri.host, 80, proxy_uri.host, proxy_uri.port) http.open_timeout = timeout http.read_timeout = timeout response = http.get(url) doc = nokogiri.parse(response.body) doc.css(".css .goes .here")[0].content.strip end

the code above gets url through proxy timeout, it's missing user-agent. how with user-agent?

you should utilize open-uri , set user agent parameter in open function .

below illustration setting user agent in variable , using parameter in open function .

require 'rubygems' require 'nokogiri' require 'open-uri' user_agent = "mozilla/5.0 (macintosh; intel mac os x 10_7_0) applewebkit/535.2 (khtml, gecko) chrome/15.0.854.0 safari/535.2" url = "http://www.somedomain.com/somepage/" @doc = nokogiri::html(open(url, 'proxy' => 'http://(ip_address):(port)', 'user-agent' => user_agent, 'read_timeout' => 10 ), nil, "utf-8")

there alternative set readtime out in openuri

you can review documentation of open uri in below link

open uri documentation

ruby-on-rails ruby url proxy get

ios - The imageView has been obstructing by navigationItem -



ios - The imageView has been obstructing by navigationItem -

i found sample code.

it show view next code in appdelegate.m

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // override point customization after application launch. uilocalnotification *notification = [launchoptions objectforkey:uiapplicationlaunchoptionslocalnotificationkey]; if (notification) { nslog(@"appdelegate didfinishlaunchingwithoptions"); application.applicationiconbadgenumber = 0; } aitpreviewviewcontroller *previewviewcontroller = [[aitpreviewviewcontroller alloc] initwithnibname:@"aitpreviewviewcontroller" bundle:nil]; navigationcontroller = [[uinavigationcontroller alloc]initwithrootviewcontroller:previewviewcontroller]; [self.window setrootviewcontroller:navigationcontroller] ; self.window.backgroundcolor = [uicolor whitecolor]; [self.window makekeyandvisible]; homecoming yes; }

the next image in aitpreviewviewcontroller.xib.

but view not normal when run on iphone , show next picture.

the three imageview on top has been obstructing navigationitem

but when turn other view , , utilize next code turn back.

uiviewcontroller *previewer = [[aitpreviewviewcontroller alloc] initwithnibname:@"aitpreviewviewcontroller" bundle:nil] ; previewer.edgesforextendedlayout = uirectedgenone; [self.navigationcontroller pushviewcontroller:previewer animated:yes];

it show normal view next picture.

the view show not normal @ first time... happened status ?

can utilize auto-layout solve problem ?

if don't want hide navigation bar in xib create little alter

just alter top bar property none shown in image. auto place image below navigation bar

ios objective-c

ruby on rails - Can not append to OpenSSL Cipher -



ruby on rails - Can not append to OpenSSL Cipher -

i running bit of problem creating cipher, unusual thing if run script in irb or .rb file out side of ror application works fine.

heres script.

require 'openssl' require 'digest/sha1' cipher = openssl::cipher::cipher.new("bf-cbc").encrypt cipher.key_len = 16 cipher.key= "random encryption key*" v = cipher.random_iv.unpack("h*").first xs = ((cipher << digest::sha1.hexdigest("you@example.com")) + cipher.final).unpack("h*").first

error:

nomethoderror: undefined method `<<' openssl::cipher::cipher:0x007f800b60c920

i tried replacing << force , same error.

irb ruby: 1.8.7

application details ruby: 1.9.2 rails: 3.0.6

has encountered problem before?

the << method on cipher deprecated in 1.8.7 , removed in 1.9 (see docs). looks should using update method instead.

at guess have multiple versions of ruby installed, in such way default version invoked 1.8.7, rails app running 1.9 or newer. because of .ruby-version file, .rvmrc file or because rails installed 1 of versions.

ruby-on-rails ruby openssl

java - Skip table if not found using selenium -



java - Skip table if not found using selenium -

i have html code similar this:

<th class="ddtitle">movieone</th> <table class="datadisplaytable" ><caption class="captiontext">movies</caption> <tr> <th class="ddheader" scope="col" >genre</th> <th class="ddheader" scope="col" >time</th> <th class="ddheader" scope="col" >days</th> <th class="ddheader" scope="col" >where</th> <th class="ddheader" scope="col" >date range</th> <th class="ddheader" scope="col" >seating</th> <th class="ddheader" scope="col" >actors</th> </tr> <tr> <td class="dddefault">action</td> <td class="dddefault">10:00 - 12:00 pm</td> <td class="dddefault">smtwthfsa</td> <td class="dddefault">amc showplace</td> <td class="dddefault">aug 20, 2014 - sept 12, 2014</td> <td class="dddefault">reservations</td> <td class="dddefault">will ferrel (<abbr title= "primary">p</abbr>) target="will ferrel" ></td> </tr> </table> <th class="ddtitle">movietwo</th> <table class="datadisplaytable" ><caption class="captiontext">movies</caption> <tr> <th class="ddheader" scope="col" >genre</th> <th class="ddheader" scope="col" >time</th> <th class="ddheader" scope="col" >days</th> <th class="ddheader" scope="col" >where</th> <th class="ddheader" scope="col" >date range</th> <th class="ddheader" scope="col" >seating</th> <th class="ddheader" scope="col" >actors</th> </tr> <tr> <td class="dddefault">action</td> <td class="dddefault">11:00 - 12:30 pm</td> <td class="dddefault">smtwthfsa</td> <td class="dddefault">showplace cinemas</td> <td class="dddefault">aug 20, 2014 - sept 12, 2014</td> <td class="dddefault">tba</td> <td class="dddefault">zach galifinakis (<abbr title= "primary">p</abbr>) target="zach galifinakis" ></td> </tr> </table> <th class="ddtitle">moviethree</th> <br> <br> coming <br>

what want able do, take individual table info relevant film title, , if film doesn't have table want values tba. far, able relevant table information, unable skip table. illustration utilize code genre of movie:

int tcounter = 1; (element elements : li) { webelement genre = driver.findelement(by.xpath("//table[@class='datadisplaytable']/descendant::table["+tcounter+"]//td[1]")); webelement time = driver.findelement(by.xpath("//table[@class='datadisplaytable']/descendant::table["+tcounter+"]//td[2]")); webelement days = driver.findelement(by.xpath("//table[@class='datadisplaytable']/descendant::table["+tcounter+"]//td[3]")); webelement = driver.findelement(by.xpath("//table[@class='datadisplaytable']/descendant::table["+tcounter+"]//td[4]")); webelement date_range = driver.findelement(by.xpath("//table[@class='datadisplaytable']/descendant::table["+tcounter+"]//td[5]")); webelement seating = driver.findelement(by.xpath("//table[@class='datadisplaytable']/descendant::table["+tcounter+"]//td[6]")); webelement actors = driver.findelement(by.xpath("//table[@class='datadisplaytable']/descendant::table["+tcounter+"]//td[7]")); tcounter++; }

elements refers list storing links on webpage (result [1] action, [2] 10:00 - 12:00pm ...). within loop increments value of tcounter 1 in order receive info different tables. there way can able tell programme see if table nowadays under th class, , if not give values tba , skip it?

this sec effort based on siking's answer:

list<webelement> linstings = driver.findelements(by.classname("ddtitle")); string genre = ""; string time = ""; string days = ""; string = ""; string daterange = ""; string seating = ""; string actors = ""; for(webelement potentialmovie : linstings) { seek { webelement actualmovie = potentialmovie.findelement(by.xpath("//table[@class='datadisplaytable']")); // system.out.println("actual: " + actualmovie.gettext()); // create assignments, example: type = actualmovie.findelement(by.xpath("/descendant::table//td")).gettext(); time = actualmovie.findelement(by.xpath("/descendant::table//td[2]")).gettext(); days = actualmovie.findelement(by.xpath("/descendant::table//td[3]")).gettext(); location = actualmovie.findelement(by.xpath("/descendant::table//td[4]")).gettext(); dates = actualmovie.findelement(by.xpath("/descendant::table//td[5]")).gettext(); schedtype = actualmovie.findelement(by.xpath("/descendant::table//td[6]")).gettext(); instructor = actualmovie.findelement(by.xpath("/descendant::table//td[7]")).gettext(); system.out.println(genre+" "+time+" "+days+" "+where+" "+daterange+" "+actors); } catch(exception ex) { // there no table, so: genre = "tba"; } }

the problem code keeps returning values first table.

i trimmed downwards html sample following:

<th class="ddtitle">movieone</th> <table class="datadisplaytable"> <caption class="captiontext">movies</caption> <tr> <th class="ddheader" scope="col">genre</th> </tr> <tr> <td class="dddefault">action</td> </tr> </table> <th class="ddtitle">movietwo</th> <br/> <br/> coming <br/> <th class="ddtitle">moviethree</th> <table class="datadisplaytable"> <caption class="captiontext">movies</caption> <tr> <th class="ddheader" scope="col">genre</th> </tr> <tr> <td class="dddefault">action</td> </tr> </table>

hopefully representative of cases!

don't utilize counter, utilize actual webelements iterate over:

// default variables tba, like: string genre = "tba"; // find listings on page... list<webelement> linstings = driver.findelements(by.classname("ddtitle")); // ... , iterate on them (webelement listing : linstings) { // grab whatever _first_ element under th ... webelement potentialmovie = listing.findelement(by.xpath("following-sibling::*[1]")); // ... check if has kid element caption if (potentialmovie.findelement(by.xpath("caption")) != null) { // create assignments, example: genre = potentialmovie.findelement(by.xpath("tr[2]/td[1]")).gettext(); } }

please note code untested, mileage may vary!

java selenium xpath

regex - try to restrict ips via regular expression -



regex - try to restrict ips via regular expression -

trying restrict next ip range tracking:

example:

123.142.132.217-222

now thinking was:

^46.140.137.[217 - 222]

however mach number in range. cleanest way grab ending number group?

thanks

city

this pretty specific question, answer, suppose, worthwhile.

the number range 217-222 captured with

2(?:1[7-9]|2[0-2])

in ip example, don't forget escape dots

123\.142\.132\.2(?:1[7-9]|2[0-2])

regex limit

two database hierarchy methods -



two database hierarchy methods -

i'm surprised searching hard because don't know term, , "database hierarchy" means else.

i familiar self-referencing hierarchy table each row has id field , parent_id field, row can have parent, creating "tree"

however know there method uses left , right fields , relative position left , right overall. have never used it's in codebase i'm working on. can give me links type of heirarchy structure? thanks

oops should have thought of this: search for:

left right hierarchy

that affords plethora of images, in add-on "nested set model" mentioned above. thanks!

database hierarchy

java - How do you cause Spring to inject into/call setters of a Spring annotated class? -



java - How do you cause Spring to inject into/call setters of a Spring annotated class? -

is there way add together annotations class below specify spring inject instances bean bar?

@scope("prototype") @component("vnetwork-start") //how inject bar value? public class vnetworkstartcommand extends vnetworkcommand { public vnetworkstartcommand() { super(vnetworkcommandtype.start); } @required public void setbar(bar bar) { system.out.println("bar="+bar); } }

annotate method spring's @autowired, or javax.inject's @inject, or javax.annotation's @resource.

this assumes annotation configuration enabled , bar bean available in context.

java spring annotations

algorithm - c# Add some values at List -



algorithm - c# Add some values at List -

i write code do:

list<datarow> rows=new <datarow>(); foreach (datarow dtrow in sqlrows) { foreach (datarow dtrowid in dttrows1) { if (convert.toint32(dtrowid[0]) == convert.toint32(dtrow[1])) rows.add(dtparrow); } }

can write more effective way? may utilize linq? or other algorihtm?

p.s. sqlrows , dttrows1 list. grub table query this:"select * table name";

you utilize linq join, more efficient nested approach:

var query = dtrow in sqlrows bring together dtrowid in dttrows1 on convert.toint32(dtrow[1]) equals convert.toint32(dtrowid[0]) select ???; // dtparrow unknown. did mean dtrow? var list = query.tolist();

note if values int values (so don't need parsing etc) cast instead:

var query = dtrow in sqlrows bring together dtrowid in dttrows1 on (int) dtrow[1] equals (int) dtrowid[0] select ???; // dtparrow unknown. did mean dtrow? var list = query.tolist();

or utilize field<t> extension method (again, if they're int values don't need converting):

var query = dtrow in sqlrows bring together dtrowid in dttrows1 on dtrow.field<int>(1) equals dtrowid.field<int>(0) select ???; // dtparrow unknown. did mean dtrow? var list = query.tolist();

c# algorithm linq

Android Google Map: Failed to load map. Error contacting Google servers -



Android Google Map: Failed to load map. Error contacting Google servers -

i know there lot of same questions out there. have read them , tried answers, mine still not working.

error message:

e/google maps android api﹕ failed load map. error contacting google servers. authentication issue (but due network errors).

i'm trying run google map android sample code in /extras/google/google_play_services/samples.

i'm using android studio, , keystore generated android studio. in developer's console, enabled both google maps android api v2 , google play android developer api. when in page generating api key, used sha1 got command line after running

keytool -list -v -keystore "the_keystore_genertated_by_android_studio" -alias "alias"

for bundle name used com.example.mapdemo since in sample code's manifest, says:

package="com.example.mapdemo"

i added

com.google.android.providers.gsf.permission.read_gservices android.permission.access_wifi_state

in manifest.

i'm using nexus 5 wifi.

it's still not working , getting same error.

the api generated public api access. uninstall app , clean android studio , run every time modified manifest.

the total manifest file

i seek generating new api key using sha1 debug keystore in .android directory; called debug.keystore , should located in next directory:

os x , linux: ~/.android/ windows vista , windows 7: c:\users\your_user_name\.android\

once locate can sha1 next command:

os x , linux: keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

windows vista , windows 7: keytool -list -v -keystore "%userprofile%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

android google-maps google-maps-android-api-2

How to get the latitude and longitude of location where user taps on the map in android -



How to get the latitude and longitude of location where user taps on the map in android -

in android application, i'm using google maps v2 show map getting latitute , longitude of device's current location , i'm showing pin on location.

now when user clicks or taps on other location on map, have points latitude , longitude , have set pin @ location.

could please tell me how latitude , longitude of user taps/clicks location.

an illustration of use. alter accordingly needs. utilize long press.

map.setonmaplongclicklistener(new onmaplongclicklistener() { @override public void onmaplongclick(latlng point) { map.addmarker(new markeroptions().position(point).title("custom location").icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_red)));enter code here } });

the latlng point contains coordinated of longpress

android google-maps latitude-longitude

How do I Delete Related entites in entity framework -



How do I Delete Related entites in entity framework -

i trying delete related entities main entity in ef6

groupagejob , groupageaddresses having fk relationship 1 groupagejob many groupageaddresses here code wrote

var gaddrs= groupagejob.groupageaddresses.where(i=>i.transportjobid==2); foreach (var gaddr in gaddrs) { // db.groupageaddresses.remove(gaddr); db.entry(gaddr).state = entitystate.deleted; } groupagejob.status = transportjobstatus.delivered.tostring(); db.entry(groupagejob).state = entitystate.modified; var effroes = db.savechanges();

i getting error , adding relationship entity in deleted state not allowed

entity-framework entity-framework-5

redirect - Redirecting every page in Apache after a certain segment? -



redirect - Redirecting every page in Apache after a certain segment? -

right in .conf file, i've got page redirecting /zzzzz/ so:

rewriterule ^/*xxxx/yyyyyyyy/*$ /zzzzz/ [l,r=301,nc]

how can configure subdirectory after /yyyyyyyy/ redirect /zzzzz/, without pointing them individually?

like this:

rewriterule ^/*xxxx/yyyyyyyy/(.*)$ /zzzzz/$1 [l,r=301,nc]

apache redirect

keyboard shortcuts - PyCharm switch between windows with split screen -



keyboard shortcuts - PyCharm switch between windows with split screen -

in pycharm, keyboard shortcut (or menu command can define own shortcut) switch between windows in split screen?

to rephrase, when can see 2 files on screen, 1 in left pane , other in right, how move cursor left pane right pane without using mouse?

in emacs, "c-x o", pycharm interprets switching between tabs.

pycharm 3.4 (windows)

ctrl + tab

keyboard-shortcuts pycharm

UISlider does not drag iOS -



UISlider does not drag iOS -

i implementing sound player. slider not drag.

.h

@property (strong, nonatomic) iboutlet uislider *currenttimeslider; @property bool scrubbing;

.m

/* * sets current value of slider/scrubber * sound file when slider/scrubber used */ - (ibaction)setcurrenttime:(id)scrubber { //if scrubbing update timestate, phone call updatetime faster not wait sec , dont repeat nslog(@"%@scrubber",@"drag"); [nstimer scheduledtimerwithtimeinterval:0.01 target:self selector:@selector(updatetime:) userinfo:nil repeats:no]; [self.audioplayer setcurrentaudiotime:self.currenttimeslider.value]; self.scrubbing = false; } /* * sets if user scrubbing right * avoid slider update while dragging slider */ - (ibaction)userisscrubbing:(id)sender { nslog(@"%@",@"slider drag"); self.scrubbing = true; } /* * updates time label display , * current value of slider * while sound playing */ - (void)updatetime:(nstimer *)timer { //to don't update every second. when scrubber mousedown the slider not set if (!self.scrubbing) { //self.currenttimeslider.value = [self.audioplayer getcurrentaudiotime]; } nslog(self.scrubbing ? @"yes" : @"no"); if(self.scrubbing) { nslog(@"%@ scrubbing",@"sdfs"); } [self.currenttimeslider addtarget:self action:@selector(sliderdidendsliding:) forcontrolevents:(uicontroleventtouchupinside | uicontroleventtouchupoutside)]; long currentplaybacktime = [self.audioplayer getcurrentaudiotime]; self.currenttimeslider.value = currentplaybacktime / [self.audioplayer getaudioduration]; self.timeelapsed.text = [nsstring stringwithformat:@"%@", [self.audioplayer timeformat:[self.audioplayer getcurrentaudiotime]]]; self.duration.text = [nsstring stringwithformat:@"%@", [self.audioplayer timeformat:[self.audioplayer getaudioduration] - [self.audioplayer getcurrentaudiotime]]]; }

the slider not drag if drag slider moves previous position. ideas why slider not dragging.

thanks,

hello did u set continuous property of uislider yes . everytime u alter slider value. set no give value of release.

[myslider addtarget:self action:@selector(slidervaluechanged:) forcontrolevents:uicontroleventvaluechanged]; - (ibaction)slidervaluechanged:(uislider *)sender { nslog(@"slider value = %f", sender.value); }

did u handle slide event?.

and

where method sliderdidendsliding u calling.

ios

gettext - How to get the String (label) of a Vertex by clicking on it (Jgraph)? -



gettext - How to get the String (label) of a Vertex by clicking on it (Jgraph)? -

in jgraph, there function similiar .gettext(); vertex? need text attached them in label.

thanks.

this illustration prints label of vertex if right click on it.

graphcomponent.getgraphcontrol().addmouselistener(new mouseadapter() { @override public void mousepressed(mouseevent e) { if (swingutilities.isrightmousebutton(e)) { mxcell cell =(mxcell) getgraphcomponent().getcellat(e.getx(), e.gety()); if(cell != null) { system.out.println(cell.getvalue().tostring()); } } } });

hope help.

label gettext vertex jgraph

Unable to create new java project in Eclipse 3.6.1 -



Unable to create new java project in Eclipse 3.6.1 -

i unable create "new java project" in eclipse 3.6.1? using linux sol24 2.6.32-431.17.1.el6.x86_64.

when go file , new, don't see new java project. there project. also, when create new project. unable access src.

can offer insight this?

thanks

since have "general" , "cvs", appears have eclipse, don't have java it.

please seek linux command in terminal.

apt-get install eclipse-jdt

this install necessary java development tools eclipse.

make sure run sudo , restart eclipse after installing.

java eclipse

shell - how to ftp a file from unix to a windows shared folder -



shell - how to ftp a file from unix to a windows shared folder -

please guide me in creating shell script in unix re-create file unix folder (ex: abc/users/fp.xls) windows shared folder/directory? assuming windows shared directory access has been provided. please share thoughts on this!!

shell unix

java - Format string containing date -



java - Format string containing date -

i receive string server contains date in format (2014-06-04 10:26:06).

i want convert date , apply date format it

simpledateformat longdateformat = new simpledateformat("dd mmmm yyyy");

this have @ moment, not working.

string formatteddate = longdateformat.format(messagegson.getcreated()); viewholder.textviewmessagedate.settext(formatteddate);

i cant seem find solution, think im missing a step there

try this..

1) parse() string date

2) format() date string

string formatteddate = longdateformat.format(new simpledateformat("yyyy-mm-dd hh:mm:ss").parse(messagegson.getcreated())); viewholder.textviewmessagedate.settext(formatteddate);

java android date datetime simpledateformat

language agnostic - What does it mean to "program to an interface"? -



language agnostic - What does it mean to "program to an interface"? -

i have seen mentioned few times , not totally clear on means. when , why this?

i know interfaces do, fact not clear on makes me think missing out on using them correctly.

is if do:

iinterface classref = new objectwhatever()

you utilize class implements iinterface? when need that? thing can think of if have method , unsure of object passed expect implementing iinterface. cannot think how need that... (also, how write method takes in object implements interface? possible?)

sorry if missed point.

additional questions:

does using interface nail performance? if how much? how can avoid without having maintain 2 bits of code?

there wonderful answers on here questions sorts of great detail interfaces , loosely coupling code, inversion of command , on. there heady discussions, i'd take chance break things downwards bit understanding why interface useful.

when first started getting exposed interfaces, confused relevance. didn't understand why needed them. if we're using language java or c#, have inheritance , viewed interfaces weaker form of inheritance , thought, "why bother?" in sense right, can think of interfaces sort of weak form of inheritance, beyond understood utilize language build thinking of them means of classifying mutual traits or behaviors exhibited potentially many non-related classes of objects.

for illustration -- have sim game , have next classes:

class="lang-java prettyprint-override"> class housefly inherits insect { void flyaroundyourhead(); void landonthings(); } class telemarketer inherits person { void callduringdinner(); void continuetalkingwhenyousayno(); }

clearly, these 2 objects have nil in mutual in terms of direct inheritance. but, both annoying.

let's our game needs have sort of random thing annoys game player when eat dinner. housefly or telemarketer or both -- how allow both single function? , how inquire each different type of object "do annoying thing" in same way?

the key realize both telemarketer , housefly share mutual loosely interpreted behavior though nil alike in terms of modeling them. so, let's create interface both can implement:

class="lang-java prettyprint-override"> interface ipest { void beannoying(); } class housefly inherits insect implements ipest { void flyaroundyourhead(); void landonthings(); void beannoying() { flyaroundyourhead(); landonthings(); } } class telemarketer inherits person implements ipest { void callduringdinner(); void continuetalkingwhenyousayno(); void beannoying() { callduringdinner(); continuetalkingwhenyousayno(); } }

we have 2 classes can each annoying in own way. , not need derive same base of operations class , share mutual inherent characteristics -- need satisfy contract of ipest -- contract simple. have beannoying. in regard, can model following:

class="lang-java prettyprint-override"> class diningroom { diningroom(person[] diningpeople, ipest[] pests) { ... } void servedinner() { when diningpeople eating, foreach pest in pests pest.beannoying(); } }

here have dining room accepts number of diners , number of pests -- note utilize of interface. means in our little world, fellow member of pests array telemarketer object or housefly object.

the servedinner method called when dinner served , our people in dining room supposed eat. in our little game, that's when our pests work -- each pest instructed annoying way of ipest interface. in way, can have both telemarketers , houseflys annoying in each of own ways -- care have in diningroom object pest, don't care , have nil in mutual other.

this contrived pseudo-code illustration (that dragged on lot longer anticipated) meant illustrate kind of thing turned lite on me in terms of when might utilize interface. apologize in advance silliness of example, hope helps in understanding. and, sure, other posted answers you've received here cover gamut of utilize of interfaces today in design patterns , development methodologies.

language-agnostic oop interface

c# - Why does Windows Forms control's property cannot be changed during the OnPaint event -



c# - Why does Windows Forms control's property cannot be changed during the OnPaint event -

i utilize onpaint (c#) event draw in form. want value of variable during onpaint process. cant during, before or after onpaint process...

in fact, variable counter want increment value of progressbar.

i tried adding thread, timer , "valuechanged" events, still can't value. code quite long (it's generating heatmap data).

i increment value in loops during event, , phone call onpaint event "invalidate()" function.

i hope clear without pasting code (it's long) ! thanks.

with code improve : (simplified)

public partial class heatpainter : usercontrol { public long _progress = 0; //my counter public heatpainter() { initializecomponent(); } public void drawheatmap(list<list<int>> items, decimal value, int maxstacks, int factor, string filename) { if (_allowpaint) //if command ready process { timer1.start(); _progress = 0; _allowpaint = false; invalidate(); } } protected override void onpaint(painteventargs e) { base.onpaint(e); (int pass = _factor; pass >= 0; pass--) { //some draw stuff //... _progress++; } } private void timer1_tick(object sender, eventargs e) { console.writeline(_progress); } }

it looks repainting takes lot of time. unable alter on form during repainting (it won't changed until end).

so should @ task other point of view. if create image(like how create jpg image dynamically in memory .net?) in parallel thread(or parallelization build http://www.dotnetperls.com/backgroundworker)? after painted set background or .image of picturebox. form responsive time.

you have synchronize(to update progress bar) isn't such hard task (thread not updating progress bar command - c#, c# windows forms application - updating gui thread , class?).

and future: threads , backgroundworkers going away the.net world. still used in .net < 4.0 .net 4.0 , higher provide improve abstractions asynchronous operations. recommend read tasks , async await. more appropriate many launch-the-work-get-the-result-on-completion scenoarios.

you should utilize 1 asyncronous construct(for illustration backgroundworker) paint image. user command should provide event (actually improve refactor functionality out of user interface) like

public event eventhandler progresschanged;

and raise event in code creates image when modify property of progress. don't forget synchronization , dispatching(see above).

c# events onpaint

html - Unexpected elements alignment with Flexbox -



html - Unexpected elements alignment with Flexbox -

premise 1: pen linked below contains bunch of code written angularjs. nevertheless, question html5+css3, can safely ignore it.

premise 2: developing web calendar. calendar divided in weeks, , features 2 main parts: navigator (displays weeks) , list of categories (each category contains event, , empty cells days) see basic version in pen.

the problem

i using flexible boxes in order develop layout adapts window resize. problem navigator's cells (days) , categories' cells (empty placeholders) not align vertically in expected way:

as can see, cells not aligned properly. thought problem reside in fact layout of category wasn't layout of navigator, since navigator divided in weeks. thus, divided empty placeholders in category, no luck.

the layout

the layour exploits bootstrap's grid system, , organized (i'll set classes, since divs):

.row .navigator <--------------------> .row .category .col-1 .navigator-header <-------------> .col-1 .category-header .col-11 .navigator-content <----------> .col-11 .category-content .week <-------------------------> .category-group .week-header (nothing here) .days <-------------------------> .cells

i set arrows associate elements of category , navigator. difference presence of week-header, doesn't have sizes set shouldn't relevant. can check css in pen, it's simple.

the question

the question is: why elements aligned differently? ignoring here?

in case need more information, allow me know. give thanks you.

the problem seem running character length of day numbers (1-31) different, causing each flex item start out @ different size. default, flex-basis set auto, means initial main size of flex item dependent upon contents (in case, numbers 1 through 31). in "holidays" row, each column has same contents ("stuff"). so, that's why each "stuff" item has same width while each day item has different size based on width of number character(s).

in pen, add flex-basis:0; .week, .category-group. sets intial main size 0px , increases size there.

here's simplified example, showing issue (demo):

class="lang-html prettyprint-override"><h1>flex:1 1 0;</h1> <div class="row"> <div class="cell">a</div> <div class="cell">a</div> <div class="cell">a</div> </div> <div class="row"> <div class="cell">a</div> <div class="cell">a</div> <div class="cell">hello world</div> </div> <h1>flex:1 1 auto;</h1> <div class="row"> <div class="cell auto">a</div> <div class="cell auto">a</div> <div class="cell auto">a</div> </div> <div class="row"> <div class="cell auto">a</div> <div class="cell auto">a</div> <div class="cell auto">hello world</div> </div> class="lang-css prettyprint-override">.row { display:flex; } .cell { flex:1 1 0; outline:1px solid red; } .cell.auto { flex:1 1 auto; }

html css twitter-bootstrap flexbox

php - bxslider reload slider not working in another file -



php - bxslider reload slider not working in another file -

i want add together slide bxslider dynamically, did when write code in 1 js file problem can not write bxslider reload code in 1 file.have @ code u understand

my php file

<!-- jquery library (served google) --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <!-- bxslider javascript file --> <script src="bxslider.min.js"></script> <script src="custom.js"></script> <!-- bxslider css file --> <link href="bxslider.css" rel="stylesheet" /> <ul id="slider" class="bxslider"> <li><img src="images/pic1.jpeg" /></li> <li><img src="images/pic2.jpeg" /></li> </ul> <input type="button" id="add" value="add"> <script> $(document).ready(function(){ slider = $('.bxslider').bxslider(); $('#add').click(function(){ var add_new = '<li><img src="images/pic3.jpeg" /></li>'; console.log($('#slider')); console.log(slider); $('#slider').append(add_new); slider.reloadslider(); }); }); </script>

my js file

var slider; $(document).ready(function(){ slider = $('.bxslider').bxslider(); });

when write php jquery code in js file works perfect not working.can tell me problem while ' adds when click on add together button if console.log(slider) showing me not reloading it.

i found solution myself :) declare variable window.slider worked

php jquery reload bxslider

javascript - Firefox extention to activate manually? -



javascript - Firefox extention to activate manually? -

i activate extension of firefox without asking user manually place extention in path: c: \ users \ xxxxx \ appdata \ roaming \ mozilla \ firefox \ profiles \ xxxxx \ extensions, alter extencions.json file , add together extention manually, can not create active, appears off me, have seen programs not understand files modified that

javascript firefox firefox-addon

node.js - How Do I Know A Document With Expires Attribute Got Deleted? -



node.js - How Do I Know A Document With Expires Attribute Got Deleted? -

i'm implementing verification procedures in node.js. had each verification stored in mongodb mongoose, , set expires attribute it, deleted after time. this

var verification = new schema({ // else createdat: { type: date, expires: '1d', default: date.now, }, });

but want know when doc deleted. can else, deleting docs related verification. i've tried using post() hooks,

verification.post('remove', function(){ // else };

but seems won't work, since it's on application level. doc deleted mongodb directly, remove() won't called.

you can't know when document deleted because mongodb removes expired documents in background task. there no way check documents deleted.

if need functionality, can create background job delete documents own collections every 60 seconds , notify documents deleted.

node.js mongodb mongoose

C++: Windows daily task schedule without user credentials -



C++: Windows daily task schedule without user credentials -

i know there bunch of illustration on msdn windows task scheduling , all(except logon/boot time) require users credentials saving task root folder , hence registering task.

// save task in root folder. iregisteredtask *pregisteredtask = null; hr = prootfolder->registertaskdefinition( _bstr_t( wsztaskname ), ptask, task_create_or_update, _variant_t(_bstr_t(pszname)), //username _variant_t(_bstr_t(pszpwd)), //password task_logon_password, _variant_t(l""), &pregisteredtask);

but have seen softwares schedule tasks on user scheme without prompting user credentials.

just want know how achieved? builting//administrator thing doesn't seem work scheduling daily tasks.

what other way out? help appreciated.

since been more 2 weeks , no reply received , answering way around solve problem.

to schedule tasks without user business relationship name , password , can take leverage of windows schtasks.exe nowadays in system32 directory.

you can create programme (which should running admin rights) execute schtasks.exe proper parameters schedule daily, weekly , monthly tasks.

for illustration : next command schedules daily task run @ time hh:mm , trigger exe every 1 hr duration of 24 hours.

schtasks.exe /create /tn "mydailytask" /tr "c:/path/to/trigger/app.exe" /f /sc daily /sd mm/dd/yyyy /st hh:mm /ri 60 /du 24:00

and can see dont need give username , password long our application running admin access.

c++ windows scheduled-tasks

Update coordinates every 5 secs by sending Post data to mysql - Android -



Update coordinates every 5 secs by sending Post data to mysql - Android -

i m totally newbie in android programming, , develop app send realtime location coordinates google map mysql every 5 seconds. problem dont know should set timer resend info each iteration. timer should placed within onlocationchanged method? or within httppost info method? thanks

@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // create locationrequest object mlocationrequest = locationrequest.create(); // utilize high accuracy mlocationrequest.setpriority(locationrequest.priority_high_accuracy); // set update interval 5 seconds mlocationrequest.setinterval(update_interval); // set fastest update interval 1 sec mlocationrequest.setfastestinterval(fastest_interval); if (mmap == null) { // seek obtain map supportmapfragment. mmap = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map)) .getmap(); // check if successful in obtaining map. if (mmap != null) { mmap.setmylocationenabled(true); } } mmap.setmylocationenabled(true); locationmanager = (locationmanager) getsystemservice(context.location_service); locationmanager.requestlocationupdates(locationmanager.network_provider, min_time, min_distance, this); } @override public void onlocationchanged(location location) { double latitude = location.getlatitude(); final double longitude = location.getlongitude(); latlng = new latlng(latitude, longitude); cameraupdate center= cameraupdatefactory.newlatlng(latlng); cameraupdate zoom=cameraupdatefactory.zoomto(16); mmap.movecamera(center); mmap.animatecamera(zoom); postdata(userid, latitude, longitude); } public void postdata( int a, double b, double c) { // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(url_create_user); seek { // add together info list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(3); namevaluepairs.add(new basicnamevaluepair("userid", string.valueof(a))); namevaluepairs.add(new basicnamevaluepair("latitude", string.valueof(b))); namevaluepairs.add(new basicnamevaluepair("longitude", string.valueof(c))); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request httpresponse response = httpclient.execute(httppost); } grab (clientprotocolexception e) { // todo auto-generated grab block } grab (ioexception e) { // todo auto-generated grab block }

php file linking app , mysql:

$userid = $_post['userid']; $latitude = $_post['latitude']; $longitude = $_post['longitude']; // include db connect class require_once __dir__ . '/db_connect.php'; // connecting db $db = new db_connect(); $con = $db->connect(); // mysql inserting new row , update existing row $result = mysqli_query($con,"insert `data` (`userid`, `latitude`, `longitude`) values ('".$userid."', '".$latitude."', '".$longitude."')"); $result = mysqli_query($con,"update info set latitude = '$latitude', longitude = '$longitude' userid = $userid")or die(mysql_error());

thank attending :))

android mysql gps http-post google-maps-api-2

c# - asp membership roles issue -



c# - asp membership roles issue -

i'm having issue when trying add together users roles using default membership provider. have asp.net schema installed on database , creating users works fine , creates users in dbo.users.

membership.createuser(username.text, password.text, email.text, null, null, true, out createstatus);

however when seek add together user role

roles.addusertorole(newuser.username, "administrators");

it keeps homecoming exception, inner exception

{"invalid column name 'roleid'.\r\ninvalid column name 'userid'.\r\ninvalid column name 'userid'.\r\ninvalid column name 'roleid'."}

not sure why claiming columns not exist when of membership tables exist in database.

this has had me scratching head past few hours...

any ideas help appreciated.

c# asp.net sql

jsf - Change "f:convertNumber" decimal separator symbol -



jsf - Change "f:convertNumber" decimal separator symbol -

can tell me how can replace "comma" "dot" one thousand separator on f:convertnumber?

jsf 2.2 primefaces 3.5

thanks.

you can customize number format locale attribute. have dot one thousand separator can utilize "es_pe" locale. see locale formats here: f:convertnumber remove comma one thousand separator

jsf primefaces

java - how to insert data from jtable to mysql database -



java - how to insert data from jtable to mysql database -

i want insert jtable multiple rows info mysql database on save button click. gives error....

this code...

package my.bill; import java.awt.*; import java.awt.event.*; import java.awt.event.*; import java.io.*; import java.lang.*; import java.sql.*; import java.sql.connection; import java.sql.drivermanager; import java.sql.preparedstatement; import java.sql.sqlexception; import java.util.*; import java.util.calendar; import java.util.gregoriancalendar; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; import javax .swing.table.defaulttablemodel; public class bill extends javax.swing.jframe { /** * creates new form bill */ object[][] data=null; string[] columnnames = new string[2]; /*static final string jdbc_driver = "com.mysql.jdbc.driver"; static final string db_url="jdbc:mysql://localhost:3306/gdb?zerodatetimebehavior=converttonull"; //static final string db_url = "jdbc:mysql://localhost/"; // database credentials static final string user = "root"; static final string pass = "root";*/ public bill() { initcomponents(); currentdate(); } public void currentdate(){ calendar cal=new gregoriancalendar(); int month=cal.get(calendar.month); int year=cal.get(calendar.year); int day=cal.get(calendar.day_of_month); date.settext(day+"-"+(month+1)+"-"+year); } @suppresswarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="generated code"> private void initcomponents() { jlabel1 = new javax.swing.jlabel(); date = new javax.swing.jtextfield(); jscrollpane2 = new javax.swing.jscrollpane(); jtable1 = new javax.swing.jtable(); netprofit = new javax.swing.jbutton(); netsum = new javax.swing.jtextfield(); save = new javax.swing.jbutton(); jmenubar1 = new javax.swing.jmenubar(); jmenu1 = new javax.swing.jmenu(); jmenu2 = new javax.swing.jmenu(); setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close); jlabel1.settext("date"); date.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { dateactionperformed(evt); } }); jtable1.setborder(javax.swing.borderfactory.createlineborder(new java.awt.color(0, 0, 0))); jtable1.setfont(new java.awt.font("tahoma", 0, 18)); // noi18n jtable1.setmodel(new javax.swing.table.defaulttablemodel( new object [][] { {"", null, null, null, null, null}, {"", null, null, null, "", null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null} }, new string [] { "job no", "item", "billed amount", "parts cost", "net profit", "percentage" } )); jtable1.setcolumnselectionallowed(true); jtable1.setgridcolor(new java.awt.color(0, 0, 0)); jtable1.setrowheight(20); jtable1.setrowmargin(2); jtable1.setselectionbackground(new java.awt.color(255, 255, 255)); jtable1.addinputmethodlistener(new java.awt.event.inputmethodlistener() { public void caretpositionchanged(java.awt.event.inputmethodevent evt) { } public void inputmethodtextchanged(java.awt.event.inputmethodevent evt) { jtable1inputmethodtextchanged(evt); } }); jscrollpane2.setviewportview(jtable1); jtable1.getcolumnmodel().getselectionmodel().setselectionmode(javax.swing.listselectionmodel.single_selection); if (jtable1.getcolumnmodel().getcolumncount() > 0) { jtable1.getcolumnmodel().getcolumn(0).setheadervalue("job no"); jtable1.getcolumnmodel().getcolumn(1).setheadervalue("item"); jtable1.getcolumnmodel().getcolumn(2).setheadervalue("billed amount"); jtable1.getcolumnmodel().getcolumn(3).setheadervalue("parts cost"); jtable1.getcolumnmodel().getcolumn(4).setheadervalue("net profit"); jtable1.getcolumnmodel().getcolumn(5).setheadervalue("percentage"); } netprofit.settext("total profit"); netprofit.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { netprofitactionperformed(evt); } }); save.settext("save"); save.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { saveactionperformed(evt); } }); jmenu1.settext("file"); jmenubar1.add(jmenu1); jmenu2.settext("edit"); jmenubar1.add(jmenu2); setjmenubar(jmenubar1); javax.swing.grouplayout layout = new javax.swing.grouplayout(getcontentpane()); getcontentpane().setlayout(layout); layout.sethorizontalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addcomponent(jscrollpane2) .addgroup(layout.createsequentialgroup() .addgroup(layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgroup(layout.createsequentialgroup() .addgap(114, 114, 114) .addcomponent(jlabel1, javax.swing.grouplayout.preferred_size, 32, javax.swing.grouplayout.preferred_size) .addpreferredgap(javax.swing.layoutstyle.componentplacement.related) .addcomponent(date, javax.swing.grouplayout.preferred_size, 77, javax.swing.grouplayout.preferred_size)) .addgroup(layout.createsequentialgroup() .addgap(350, 350, 350) .addcomponent(netprofit) .addpreferredgap(javax.swing.layoutstyle.componentplacement.related) .addcomponent(netsum, javax.swing.grouplayout.preferred_size, 75, javax.swing.grouplayout.preferred_size)) .addgroup(layout.createsequentialgroup() .addgap(221, 221, 221) .addcomponent(save))) .addcontainergap(147, short.max_value)) ); layout.setverticalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgroup(layout.createsequentialgroup() .addgap(20, 20, 20) .addgroup(layout.createparallelgroup(javax.swing.grouplayout.alignment.baseline) .addcomponent(jlabel1, javax.swing.grouplayout.preferred_size, 24, javax.swing.grouplayout.preferred_size) .addcomponent(date, javax.swing.grouplayout.preferred_size, 29, javax.swing.grouplayout.preferred_size)) .addpreferredgap(javax.swing.layoutstyle.componentplacement.related) .addcomponent(jscrollpane2, javax.swing.grouplayout.preferred_size, 350, javax.swing.grouplayout.preferred_size) .addgap(18, 18, 18) .addgroup(layout.createparallelgroup(javax.swing.grouplayout.alignment.baseline) .addcomponent(netprofit) .addcomponent(netsum, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size)) .addgap(1, 1, 1) .addcomponent(save) .addcontainergap(32, short.max_value)) ); date.getaccessiblecontext().setaccessiblename("date"); save.getaccessiblecontext().setaccessiblename("save"); pack(); }// </editor-fold> private void dateactionperformed(java.awt.event.actionevent evt) { // todo add together handling code here: } private void netprofitactionperformed(java.awt.event.actionevent evt) { // todo add together handling code here: } private void saveactionperformed(java.awt.event.actionevent evt) { // todo add together handling code here: connection conn = null; statement stmt = null; int count=jtable1.getrowcount(); int col=jtable1.getcolumncount(); string jobno[] =new string[count]; // name array , index 4 means no. of row string item[]=new string[count]; string bill[] =new string[count]; // name array , index 4 means no. of row string part[]=new string[count]; string profit[] =new string[count]; // name array , index 4 means no. of row string percent[]=new string[count]; for(int i=0;i<=count;i++) { for(int j=0;j<=col;j++) { no[i]=jtable1.getvalueat(i,j).tostring(); // value 0 row , 0 column it[i]=jtable1.getvalueat(i,j).tostring(); amount[i]=jtable1.getvalueat(i,j).tostring(); p[i]=jtable1.getvalueat(i,j).tostring(); cost[i]=jtable1.getvalueat(i,j).tostring(); s[i]=jtable1.getvalueat(i,j).tostring(); try{ string sql="insert m (no,it,amount,cost,sell,p,date) values('"+no[i]+"','"+it[i]+"','"+amount[i]+"','"+p[i]+"','"+cost[i]+"','"+s[i]+"','"+date.gettext()+"')"; // stmt.execute(sql); stmt.executequery(sql); //stmt.execute(sql); /*preparedstatement ps=conn.preparestatement(sql); ps.setstring(1, ""); ps.setstring(2, ""); ps.setstring(3, ""); ps.setstring(4, ""); ps.setstring(5, ""); ps.setstring(6, ""); ps.setstring(7,date.gettext()); ps.execute();*/ joptionpane.showmessagedialog(null,"saved"); } catch(exception e){ joptionpane.showmessagedialog(null,e); } } } private void jtable1inputmethodtextchanged(java.awt.event.inputmethodevent evt) { // todo add together handling code here: } /** * @param args command line arguments */ public static void main(string args[]) { /* set nimbus , sense */ //<editor-fold defaultstate="collapsed" desc=" , sense setting code (optional) "> /* if nimbus (introduced in java se 6) not available, remain default , feel. * details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ seek { (javax.swing.uimanager.lookandfeelinfo info : javax.swing.uimanager.getinstalledlookandfeels()) { if ("nimbus".equals(info.getname())) { javax.swing.uimanager.setlookandfeel(info.getclassname()); break; } } } grab (classnotfoundexception ex) { java.util.logging.logger.getlogger(bill.class.getname()).log(java.util.logging.level.severe, null, ex); } grab (instantiationexception ex) { java.util.logging.logger.getlogger(bill.class.getname()).log(java.util.logging.level.severe, null, ex); } grab (illegalaccessexception ex) { java.util.logging.logger.getlogger(bill.class.getname()).log(java.util.logging.level.severe, null, ex); } grab (javax.swing.unsupportedlookandfeelexception ex) { java.util.logging.logger.getlogger(bill.class.getname()).log(java.util.logging.level.severe, null, ex); } //</editor-fold> connection conn = null; statement stmt = null; try{ //step 2: register jdbc driver class.forname("com.mysql.jdbc.driver"); //class.forname("jdbc:mysql://localhost:3306/ganpatidb?zerodatetimebehavior=converttonull"); //step 3: open connection system.out.println("connecting database..."); conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/ganpatidb", "root", "root"); //step 4: execute query system.out.println("creating database..."); stmt = conn.createstatement(); }catch(sqlexception se){ //handle errors jdbc // se.printstacktrace(); }catch(exception e){ //handle errors class.forname // e.printstacktrace(); }finally{ //finally block used close resources try{ if(stmt!=null) stmt.close(); }catch(sqlexception se2){ }// nil can try{ if(conn!=null) conn.close(); }catch(sqlexception se){ //se.printstacktrace(); }//end seek }//end seek //system.out.println("goodbye!"); //int r=jtable1.selectedrow; //jtable1.getvalue(3,3); /* create , display form */ java.awt.eventqueue.invokelater(new runnable() { public void run() { new bill().setvisible(true); } }); } // variables declaration - not modify private javax.swing.jtextfield date; private javax.swing.jlabel jlabel1; private javax.swing.jmenu jmenu1; private javax.swing.jmenu jmenu2; private javax.swing.jmenubar jmenubar1; private javax.swing.jscrollpane jscrollpane2; private javax.swing.jtable jtable1; private javax.swing.jbutton netprofit; private javax.swing.jtextfield netsum; private javax.swing.jbutton save; // end of variables declaration }

how insert multiple rows info mysql database.... please help....

from looks like, not initializing connection , statement under saveactionperformed method, setting them null.

private void saveactionperformed(java.awt.event.actionevent evt) { // todo add together handling code here: connection conn = null; statement stmt = null;

in main method indeed initializing them..

try{ //step 2: register jdbc driver class.forname("com.mysql.jdbc.driver"); //class.forname("jdbc:mysql://localhost:3306/ganpatidb?zerodatetimebehavior=converttonull"); //step 3: open connection system.out.println("connecting database..."); conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/ganpatidb", "root", "root"); //step 4: execute query system.out.println("creating database..."); stmt = conn.createstatement(); }catch(sqlexception se){ //handle errors jdbc se.printstacktrace(); }catch(exception e){ //handle errors class.forname e.printstacktrace(); }finally{ //finally block used close resources try{ if(stmt!=null) stmt.close(); }catch(sqlexception se2){ }// nil can try{ if(conn!=null) conn.close(); }catch(sqlexception se){ //se.printstacktrace(); }//end seek }//end seek

you need either remove code set them null or add together same code straight afterwards , remember need set code within seek , grab block.

something this:

try{ //step 2: register jdbc driver class.forname("com.mysql.jdbc.driver"); //class.forname("jdbc:mysql://localhost:3306/ganpatidb?zerodatetimebehavior=converttonull"); //step 3: open connection system.out.println("connecting database..."); conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/ganpatidb", "root", "root"); //step 4: execute query system.out.println("creating database..."); stmt = conn.createstatement(); int count=jtable1.getrowcount(); int col=jtable1.getcolumncount(); string jobno[] =new string[count]; // name array , index 4 means no. of row string item[]=new string[count]; string bill[] =new string[count]; // name array , index 4 means no. of row string part[]=new string[count]; string profit[] =new string[count]; // name array , index 4 means no. of row string percent[]=new string[count]; for(int i=0; i&lt; =count; i++) { for(int j=0; j&lt; =col; j++) { no[i]=jtable1.getvalueat(i,j).tostring(); // value 0 row , 0 column it[i]=jtable1.getvalueat(i,j).tostring(); amount[i]=jtable1.getvalueat(i,j).tostring(); p[i]=jtable1.getvalueat(i,j).tostring(); cost[i]=jtable1.getvalueat(i,j).tostring(); s[i]=jtable1.getvalueat(i,j).tostring(); try{ string sql="insert m (no,it,amount,cost,sell,p,date) values('"+no[i]+"','"+it[i]+"','"+amount[i]+"','"+p[i]+"','"+cost[i]+"','"+s[i]+"','"+date.gettext()+"')"; stmt.execute(sql); joptionpane.showmessagedialog(null,"saved"); } catch(exception e){ joptionpane.showmessagedialog(null,e); } } catch(sqlexception se){ //handle errors jdbc se.printstacktrace(); } catch(exception e){ //handle errors class.forname e.printstacktrace(); } finally{ //finally block used close resources try{ if(stmt!=null) stmt.close(); } catch(sqlexception se2){ } // nil can try{ if(conn!=null) conn.close(); } catch(sqlexception se){ //se.printstacktrace(); } //end seek } //end seek

java mysql swing jdbc jtable

Webgl coloring the entire geometry? -



Webgl coloring the entire geometry? -

i using triangles(using vertices , face position) draw graphics.i storing color info each vertex , applying colors accordingly. problem geometries in scene of single color(say cone=red, cylinder=blue). so, storing color each vertex apparently of no utilize me.

is other approach coloring can done in webgl apart storing color info of each vertices in scene. maybe coloring entire geometry(say cone).

if geometry has color per object, doesn't alter across geometry, should pass color uniform variable.

so en 1 attribute - position of vertices, few matrix uniforms - model, view, projection matrices, vertex shader, , 1 vector uniform variable fragment shader "shading" object.

webgl

php - regex for any alphanumeric characters except the number 0 -



php - regex for any alphanumeric characters except the number 0 -

for non-zero have /^[1-9][0-9]*$/, , alphanumeric ^[0-9a-za-z ]+$, don't know how combine these.

please help regex alphanumeric pattern except single 0

you can utilize pattern prevent matches starting 0

^(?!0)[0-9a-za-z ]+$

if 01 ok not 0 utilize pattern

^(?!0$)[0-9a-za-z ]+$

php regex

.htaccess - Url rewrite in codeigniter using htaccess -



.htaccess - Url rewrite in codeigniter using htaccess -

how can rewrite url like

www.mydomain.com/products/product/products_name

to 1 more search friendly like

www.mydomain.com/products/products_name

this code have on htaccess file

rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule .* index.php/$0 [l]

i've been searching hr , nil worked me. pd: i'm using codeigniter, that's why i'm doing redirection advance

.htaccess codeigniter mod-rewrite

javascript - Watching ngModel of an element from attribute directive -



javascript - Watching ngModel of an element from attribute directive -

i want watch model within directive place attribute on input element:

<input id="mymodel_headline" name="mymodel[headline]" ng-model="mymodel.headline" sps-watch="true" type="text">

if i'm reading docs right should able value either through link function's attrs parameter, or requiring ngmodel. however, neither of these approaches working:

app.directive('spswatch', function() { homecoming { require: "ngmodel", link: function(scope, element, attrs, ngmodel) { console.log("directive called"); console.log(attrs.ngmodel); scope.$watch(scope[attrs.ngmodel], function(result) { console.log("watching via attribute"); console.log(result); }); scope.$watch(ngmodel, function(result) { console.log("watching via ngmodel"); console.log(result) }); } }; });

they seem run 1 time only, when directive first created.

plunkr here

you can retrieve value of model via ngmodel.$viewvalue. homecoming anonymous function in $watch expression, , changes in model trigger $watch function:

scope.$watch(function () { homecoming ngmodel.$viewvalue; }, function(result) { console.log("watching via ngmodel"); console.log(result) });

javascript angularjs angularjs-directive angularjs-scope

sql - How do I insert values into empty tables that have foreign keys attached to them? -



sql - How do I insert values into empty tables that have foreign keys attached to them? -

i have several tables created, lot of them referencing each other foreign keys. created them they're empty in sql server 2012.

create table candidate ( candidateid int primary key, qualificationid int not null, trainingsessionid int not null, prerequesiteid int not null, courseid int not null, qualification nvarchar(20), jobhistoryid int not null, name nvarchar(20) ) insert candidate values (1, 1, 1, 1, 1, 'plumer', 1, 'jordan')

i want error

the insert statement conflicted foreign key constraint "fk__candidate__quali__29572725". conflict occurred in database "tec", table "dbo.qualifications", column 'qualificationid'.

my qualification table

create table qualifications ( qualificationid int primary key, name nvarchar(20) )

and have other tables

create table trainingsession ( trainingsessionid int primary key, candidateid int foreign key references candidate(candidateid), courseid int not null, prerequesiteid int not null, qualificationid int not null, trainingname nvarchar(20) )

and said alot of them reference each other.

so how insert values these tables when error?

edit: after created tables altered them add together foreign keys not there

alter table candidate add together foreign key (qualificationid) references qualifications(qualificationid) alter table candidate add together foreign key (trainingsessionid) references trainingsession(trainingsessionid)

edit 2: seek , insert candidate, error above, seek inset training session, same error in candidate

the insert statement conflicted foreign key constraint "fk__trainings__candi__173876ea". conflict occurred in database "tec", table "dbo.candidate", column 'candidateid'.

there's don't understand database design. @ this:

create table candidate ( candidateid int primary key, qualificationid int not null, trainingsessionid int not null, /* reference trainingsession?*/ prerequesiteid int not null, courseid int not null, qualification nvarchar(20), jobhistoryid int not null, name nvarchar(20) ) create table trainingsession ( trainingsessionid int primary key, candidateid int foreign key references candidate(candidateid), courseid int not null, prerequesiteid int not null, qualificationid int not null, trainingname nvarchar(20) )

they both seem referencing each other seems weird me , not right. there should ideally 1 reference between them.

also, if trainingsessionid in candidate table not foreign key, why there? can value via bring together query. isn't reason why candidateid foreign key in trainingsession table?

update:

the problem having :

"you need trainingsesssionid value in trainingsession table insert row in candidate table. since don't have one, gives foreign key constraint error. similarly, need candidateid value in candidate table insert row in trainingsession table. gives foreign key constraint error. there's no escaping this. hence, design flawed.

what can is:

remove trainingsessionid column candidate table or remove candidateid column trainingsession table. point need remove 1 of these foreign key references. one? depends on particular scenario's , use-cases. main point here you'll have drop 1 of these foreign key references. redundant anyways. you need 1 foreign key create relationship between 2 tables. due existence of (note:single) foreign key, can relate between 2 tables , fetch values either tables based on foreign key. there no need have foreign key.

secondly, since qualifications has no foreign key reference, in context seems master table. so, insertion begins here. then, you'd have insert in candidate table (in case trainingsessionid not foreign key in table) , in trainingsession table.

hope helps!!!

sql sql-server

ios - VoiceOver - Don't say the position of UISlider -



ios - VoiceOver - Don't say the position of UISlider -

i have uislider, has voiceover label.

voiceover says position of slider in percent, have values between 5 ans 20, , want these user.

how stop voiceover saying position automatically?

ios accessibility uislider voiceover uiaccessibility

c++ - How do I move the result of a mul of two floats in x86 assembly? -



c++ - How do I move the result of a mul of two floats in x86 assembly? -

i trying multiply 2 floats, 1 comes float vector (address stored in ebx) , against value stored in ecx.

i have confirmed input values correct, however, if multiply 32 , 1, example, value in eax changes 00000000 , 1 in edx 105f0000. understanding of mul, happens because storing high order bits of result in edx , low order ones in edx. question is, how move result output variable (returnvalue) ? here code snippet in question:

addcolumnsiteration: cmp esi, 4 // if finished storing info jge nextcolumn // move next column mov eax, [ebx][esi * sizeof_int] // current column mul ecx // multiply tx add together [returnvalue][esi * sizeof_int], eax // add together info pointed @ eax running total inc esi // element x, y, z, or w of vec4 jmp addcolumnsiteration // go check our loop status

i aware if used x87 commands or sse instructions, orders of magnitude easier, constrains of problem require pure x86 assembly code. sorry if seems kinda basic, still learning idiosyncracies of assembly.

thank in advance help , have nice day

you’re multiplying representations of floating-point numbers integers, rather floating-point numbers themselves:

1.0 = 0x3f800000 32.0 = 0x42000000 0x3f800000 * 0x42000000 = 0x105f000000000000

to floating-point arithmetic, need 1 of following:

use x87. use sse. write own software multiplication separates encodings signbit, exponent, , significand, xors signbits sign bit of product, adds exponents , adjusts bias exponent of product, multiplies significands , rounds significand of product, assembles them produce result.

obviously, first 2 options much simpler, sounds aren’t alternative reason or (though can’t imagine why not; x87 , sse are "pure x86 assembly code”, they’ve been part of isa long time now).

c++ assembly floating-point x86 multiplication

r - Rcpp compilation error with Shiny -



r - Rcpp compilation error with Shiny -

i'm getting odd behavior using latest rcpp, r, r-shiny-pro, , ubuntu. in r-studio server can run shiny::runapp() , see application working properly. however, when go straight to website see in chrome's javascript console:

g++: error trying exec 'cc1plus': execvp: no such file or directory make: *** [file314215611f5d.o] error 1 warning: tools required build c++ code r not found. please install gnu development tools including c++ compiler. error in sourcecpp(code = code, env = env, rebuild = rebuild, showoutput = showoutput, : error 1 occurred building shared library.

i've tried re-installing rcpp apt-get install r-cran-rcpp , perhaps wrongly tried sudo apt-get install --reinstall g++-4.6 prior 1 attempt. other it's been:

follow instructions on http://cran.r-project.org/bin/linux/ubuntu/readme.html follow instructions on http://www.rstudio.com/products/shiny/download-commercial/ follow instructions on http://www.rstudio.com/products/rstudio/download-server/ sudo su - -c "r -e \"install.packages('rcpp', repos='http://cran.cnr.berkeley.edu/')\""

barring easy fix, i'm going seek on different server , perhaps create sample shiny app can share. worked fine on previous server not latest ubuntu or professional version of r-shiny. much appreciation help may provide. fwiw i'm using cppfunction.

added:

i created minimal illustration , works on different server free version of shiny not other server same exact setup other shiny version. here's ui.r:

library(shiny) shinyui(fluidpage( titlepanel("rcpp check fibonacci"), sidebarlayout( sidebarpanel( numericinput("inputnumber", "input number:", 10, min = 1, max = 100) ), mainpanel( textoutput("text1") ) ) ))

and server.r:

library(shiny);library(rcpp) cppfunction( 'int fibonacci(const int x) { if (x == 0) return(0); if (x == 1) return(1); homecoming (fibonacci(x - 1)) + fibonacci(x - 2); }') shinyserver(function(input, output) { output$text1 <- rendertext({as.character(fibonacci(input$inputnumber)) }) })

added: next along able create project in r studio server bundle rcpp sourcing .cpp file:

#include <rcpp.h> using namespace rcpp; // [[rcpp::export]] int fibonacci(const int x) { if (x == 0) return(0); if (x == 1) return(1); homecoming (fibonacci(x - 1)) + fibonacci(x - 2); }

the issue first ran resolved making sure ran compileattributes() described here. works both servers.

r shiny rcpp

php - get some words in html using simple_html_dom -



php - get some words in html using simple_html_dom -

i wanna zumbai, n, , something line of html below simple_html_dom:

<p> <div align="left" style="margin: 0.00mm 0.00mm ;"> <p style="font-family: arial; font-size: 1.0em;"> <b>zumbai</b> <i>n</i> </p> </div>

here's code :

foreach($html->find('div.align') $tag1) { foreach($tag1->parent()->find('p.style') $tag2){ $words1 = $tag2->first_child(); $words11= $words1->plaintext; $words2 = $tag2->first_child()->first_child(); $words22= $words2->plaintext; } }

but doesn't works. give thanks :)

php html simple-html-dom

ruby - Rails 4 multi-part identifier could not be bound -



ruby - Rails 4 multi-part identifier could not be bound -

the next activerecord query results in error "the multi-part identifer question_answer_response.response_group not bound."

this started happening after upgrading rails 3.2.x rails 4.0.x

class question < activerecord::base def self.fetch_dependencies(section_id) self.select('questions.*,question_answer_response.response response,question_answer_response.response_group response_group'). includes({:dependency_conditions => :dependency}). where("dependencies.survey_section_id = #{section_id} , questions.survey_section_id != dependencies.survey_section_id") end end

ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4

php - Avoiding $onlyActive boolean parameter -



php - Avoiding $onlyActive boolean parameter -

i started using phpmd observe bad coding practices , prepare them. project uses laravel 4 php framework , implement repository pattern.

so have class called eloquentproductrepository interacts product tables in database. methods all() method have boolean parameter called $onlyactive. when true fetches active products, otherwise returned.

phpmd tells me boolean parameters sign of violation of single responsibility pattern. did reading , agree booleans should avoided. question how should refactor regards maintainability, readability , extendibility?

the method rather simple , looks follows

/** * fetches products * * @param boolean $onlyactive flag returning active products * @return collection */ public function all($onlyactive = true) { if ($onlyactive) { homecoming $this->model->where('active', true)->get(); } homecoming $this->model->all(); }

i see 2 options. 1 using $options array instead key 'include_inactive'. other alternative creating 2 methods. all() , allwithinactive(). have 3 methods using $onlyactive boolean lastly alternative add together 3 methods class might create class rather big on methods. (phpmd prefers classes have no more 10 public methods)

you have 2 different functions - how it

public function getall() { homecoming $this->model->all(); } public function getonlyactive() { homecoming $this->model->where('active', true)->get(); }

note function names - getall() - records, no exceptions. getonlyactive() - active records - there no "all" in function name, because doesnt "all".

php methods laravel-4 boolean

jquery - Run javascript function when div is scrolled to -



jquery - Run javascript function when div is scrolled to -

this question has reply here:

jquery event trigger action when div made visible 16 answers

how run onclick function when div becomes visible user scrolling it. trying set infinite scrolling loads automatically instead of users clicking button.

the elements scroll horizontally within div.

<div id="bottom_end" class="next"> <a onclick="load_more('/orderby/rising/page/12', '12', 'app_index')"></a> <p>load more<br>in scroll</p> </div>

a simple plugin called waypoint should trick.

it's used here vikas ghodke.

i utilize quite lot , recommend it; works smoothly , has cross-browser support.

javascript jquery scroll infinite

php - Having error in saving image link to the database using pdo -



php - Having error in saving image link to the database using pdo -

this question has reply here:

how can upload files asynchronously? 22 answers

i want create image uploader scheme , send image upload folder , save link database.

my problem got errors in images.php can help me please.

html:

<form method="post" enctype="multipart/form-data"> <img id="picture" data-src="#" /> <br /> <input type='file' name="image" id="imginp" accept="image/*" /><br /> <input type="submit" name="submit" id="submit" value="submit" /> </form>

script:

<script type="text/javascript"> $(document).ready(function() { $('#submit').click(function (e) { e.preventdefault(); var info = {}; data.image = $('#imginp').val(); $.ajax({ type: "post", url: "images.php", data: data, cache: false, success: function (response) { } }); homecoming false; }); }); </script>

images.php

<?php $host = "localhost"; $user = "root"; $pass = ""; $db = "test"; $dbc = new pdo("mysql:host=" . $host . ";dbname=" . $db, $user, $pass); $dbc->setattribute(pdo::attr_errmode, pdo::errmode_exception); $image = addslashes(file_get_contents(@$_files['image']['tmp_name'])); $image_name = addslashes(@$_files['image']['name']); $image_size = getimagesize(@$_files['image']['tmp_name']); move_uploaded_file(@$_files["image"]["tmp_name"], "upload/" . @$_files["image"]["name"]); $location = "upload/" . @$_files["image"]["name"]; $q = "insert students( image ) values( :image)"; $query = $dbc->prepare($q); $query->bindparam(':image', $location); $results = $query->execute(); ?>

script image upload:

<script type="text/javascript"> $(document).ready(function() { var currentsrc = $('#picture').attr('src'); if(currentsrc==null || currentsrc==""){ $('#picture').attr('src','http://i38.photobucket.com/albums/e149/eloginko/profile_male_large_zpseedb2954.jpg'); $("#picture").on('click', function() { $("#imginp").trigger('click')} )} function readurl(input) { if (input.files && input.files[0]) { var reader = new filereader(); reader.onload = function (e) { $('#picture').attr('src', e.target.result); } reader.readasdataurl(input.files[0]); } } $("#imginp").change(function(){ readurl(this); }); }); </script>

the simplest thing rid of error messages place conditional checks if $_files has in it. past that, unclear on root cause of $files beingness empty. in experience ajax file uploading php receiver on other side doesn’t work consistently @ best. anyway, here version of code conditional in place:

if (!empty($_files)) { $image = addslashes(file_get_contents(@$_files['image']['tmp_name'])); $image_name = addslashes(@$_files['image']['name']); $image_size = getimagesize(@$_files['image']['tmp_name']); move_uploaded_file(@$_files["image"]["tmp_name"], "upload/" . @$_files["image"]["name"]); $location = "upload/" . @$_files["image"]["name"]; $q = "insert students( image ) values( :image)"; $query = $dbc->prepare($q); $query->bindparam(':image', $location); $results = $query->execute(); }

php html ajax file-upload pdo

html - Clarification of using a .php file in an image tag -



html - Clarification of using a .php file in an image tag -

sorry duplicate question, question concept used in reply previous question php base of operations 64 image info not working in image tag?

when create index.html file , getpicture.php file, index.html shows broken image. when inspect see source getpicture.php, somehow uncertainty getpicture.php firing off. there anywhere validate has done something? know not calling .php file

thanks!

since image on web own document, can access image location browser entering total url in address bar. come in total url php image script , create sure you're doing error reporting when troubleshoot. when image displays in browser accessing url directly, can utilize url in .html file image.

php html image rest

c++ - operator= overloading return argument instead of *this -



c++ - operator= overloading return argument instead of *this -

i have theoretical question:

usually, in operator= implementation, returns *this. happens if instead returned *other, other right hand side of assignment?

thanks

reason returning *this enable assignment in form

a = b = c

this same as

a.operator=( b.operator=(c))

if homecoming other, compiler wont able compile kind of assignments.

c++ operator-overloading

codeigniter - PHP File upload to NGINX & PHP5-FPM -



codeigniter - PHP File upload to NGINX & PHP5-FPM -

i uploading file server , getting next log, , after lot of googling cannot find reply can 1 help or suggest start?

2014/06/26 17:15:01 [error] 15035#0: *2491 fastcgi sent in stderr: "php message: height: 375 - width: 600" while reading response header upstream, client: , server: url, request: "post /user/updateprofile http/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "url", referrer: "url/user/edit/7"

i have hidden url's security purposes.

thanks!

edit *

php code upload

if(empty($_files['user_cover_image_url']['name'])) { } else { //cover elements $covername = $_files['user_cover_image_url']['name']; $coverextension=end(explode(".", $covername)); if($coverextension=='png') {$coverextension = 'jpg';} $cname = $uid.'-'.$pass->generaterandomstring($length=25); $coverimage = $cname.'.'.$coverextension; $csource = $_files['user_cover_image_url']['tmp_name']; $cdestination = '/var/www/html/tmp/cover-'.uniqid().'.'.$coverextension; $pass->imageresize($csource, $cdestination, $width=600, $height=600, $crop=false, $quality=72); if ($s3->putobjectfile($csource, "proaudiosocialstream", $coverimage, s3::acl_public_read)) {$s3cover ='http://bucket.s3.amazonaws.com/'.$coverimage;}else{return false;} $data['user_cover_image_url'] = $coverimage; } if(empty($_files['user_avatar_url']['name'])) { } else { //avatar elements $avatarname = $_files['user_avatar_url']['name']; $avatarextension=end(explode(".", $avatarname)); if($avatarextension=='png') {$avatarextension = 'jpg';} $aname = $uid.'-'.$pass->generaterandomstring($length=25); $avatarimage = $aname.'.'.$avatarextension; $asource = file_get_contents($_files['user_avatar_url']['tmp_name']); $adestination = '/var/www/html/tmp/avatar-'.uniqid().'.'.$avatarextension; $pass->imageresize($asource, $adestination, $width=400, $height=400, $crop=false, $quality=72); if ($s3->putobjectfile($adestination, "proaudiosocialstream", $avatarimage, s3::acl_public_read)) {$s3avatar ='http://bucket.s3.amazonaws.com/'.$avatarimage;}else{return false;} $data['user_avatar_url'] = $avatarimage; }

i think did not configured php-fpm nginx

nginx virtual host file should php-fpm

server { hear 80; server_name www.trakleaf.in trakleaf.in; access_log access_file_path compression; error_log error_file_path; root root_directory; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; if ($uri !~ "^/images/") { fastcgi_pass unix:/var/run/php5-fpm.sock; } fastcgi_index index.php; fastcgi_param script_filename root_directory$fastcgi_script_name; } }

php codeigniter nginx php-fpm