Posts

Showing posts from September, 2010

post the headers with curl php -

when post reply in forum, use live http header view parameter used post reply. but, headers no parameter. but, there header this: content-length: 1115 -----------------------------5959623329472 content-disposition: form-data; name="subject" title of reply -----------------------------5959623329472 content-disposition: form-data; name="message" content of reply how post headers curl ? code don't work curl_setopt($ch, curlopt_httpheader, array('post /post http/1.1', 'referer: http://*****.n-stars.org/post?t=4221&mode=reply', 'content-disposition: form-data; name="subject" test lagi kk 2', 'content-disposition: form-data; name="message" test lagi ya kk 8)' )); please me :d these not headers, if trying make multipart post request, should content of request body. in headers should inform endpoint multipart request , boundary between parts: // headers curl_setopt($ch

iphone - Vertical UITableView Section Header -

Image
i want implement uitableview vertical header following image as can see test word section header , can create custom header that. no, cant in uitableview controller. can use custom horizantal table view https://github.com/thevole/horizontaltable

android - How to call multiple webservices in the same activity -

i new android , working on calling multiple web services in 1 activity in different asynctask. if call 2 web services in same activity gives me server connection not close. how can handle it? private class asynpickfromfavrt extends asynctask<void, void, void> { private final progressdialog dialog = new progressdialog(specifypickupplace.this); protected void onpreexecute() { this.dialog.setmessage(""); this.dialog.setindeterminate(false); this.dialog.setcancelable(false); this.dialog.show(); } protected void doinbackground(final void... unused) { retrivefavrt(user_id); return null; } protected void onpostexecute(void result) { if (this.dialog.isshowing()) { this.dialog.dismiss(); } } private string retrivefavrt(string user_id) { soapprimitive resultstring = null; soapobject request = n

java - Type mismatch: cannot convert from ASuperClass to ASubClass -

when have thes codes: asuperclass super1 = new asuperclass(); asubclass sub1 = new asubclass(3); sub1 = (asubclass) super1; // line compiled ok has runtime error line 3 asubclass sub2 = new asuperclass(); // line compiled not ok line 4 my question why error in line 3 ("asuperclass cannot cast asubclass") in line 3 runtime error not compile error similar error in line 4 , compile error. logics behind that? many thanks! you're getting runtime error because you're telling compiler (by explicit cast) trust you're not making errors, it's ignoring errors , doesn't detect in compilation time. when program runs, you'll exception since super1 asuperclass , not asubclass . in second case, you're getting compilation error since compiler knows making mistake (and you're not telling him trust casting example).

How to hide or show html tags with javascript -

i have 2 div tags in html code , have defined class can expand or hide them.the problem have fact when click on 1 of the value of other changes. <html> <body> <form> <script language="javascript"> function setvisibility(id) { if (document.getelementbyid('btnshowhide').value == '-') { document.getelementbyid('btnshowhide').value = '+'; document.getelementbyid(id).style.display = 'none'; } else { document.getelementbyid('btnshowhide').value = '-'; document.getelementbyid(id).style.display = 'inline'; } } </script> <fieldset style="width: 600px;"> <legend> <input type=button name=type id=

mahout - What's difference between Collaborative Filtering Item-based recommendation and Content-based recommendation -

i puzzled item-based recommendation in 《mahout in action》.there algorithm in book: for every item u has no preference yet every item j u has preference compute similarity s between , j add u's preference j, weighted s, running average return top items, ranked weighted average what can calculate similarity between items? if using content, isn't content-based recommendation ? item-based collaborative filtering the original item-based recommendation totally based on user-item ranking (e.g., user rated movie 3 stars, or user "likes" video). when compute similarity between items, not supposed know other users' history of ratings. similarity between items computed based on ratings instead of meta data of item content. let me give example. suppose have access rating data below: user 1 likes: movie, cooking user 2 likes: movie, biking, hiking user 3 likes: biking, cooking user 4 likes: hiking suppose want make recommendations user 4.

java - Android Scroll Text in TextSwitcher -

i have texswitcher add 2 text views (created dynamically using textview class). switching between child text views using gesture detector. when text large fit in current viewable area, scrolling doesn't work textswitcher. when tried using settextmovement method of child text views, textswitcher stopped listening horizontal swipe gestures. has been successful in showing scrollable text views inside textswitcher. i solved problem creating own textswitcher. public class myownswitcher extends viewswitcher { public myownswitcher (context context) { super(context); } public myownswitcher (context context, attributeset attrs) { super(context, attrs); } } i moved "ontouchevent"-method new class. had override "onintercepttouchevent"-method that: @override public boolean onintercepttouchevent(motionevent ev) { ontouchevent(ev); return super.onintercepttouchevent(ev); } i had move of fields , variables activ

c++ - opengl indexed drawing issue -

Image
i'm trying render sphere opengl (3.0). algorithm below computes vertices , according indices. in works quite well, however, there seem glitch in matrix, cause ugly cone inside sphere. vertices.resize(rings * segments * 3); colors.resize(rings * segments * 3); indices.resize(6 * rings * segments); auto v = vertices.begin(); auto c = colors.begin(); auto = indices.begin(); auto dtheta = m_pi / (f32)rings; auto dphi = 2 * m_pi / (f32)segments; ( u32 ring = 0; ring < rings; ++ring ) { auto r0 = radius * sinf(ring * dtheta); auto y0 = radius * cosf(ring * dtheta); ( u32 segment = 0; segment < segments; ++segment ) { auto x0 = r0 * sinf(segment * dphi); auto z0 = r0 * cosf(segment * dphi); *v++ = x0; *c++ = color.r; *v++ = y0; *c++ = color.g; *v++ = z0; *c++ = color.b; if (ring < rings) { *i++ = ( (ring ) * segments ) + segment; *i++ = ( (ring+1) * segments ) + segment;

c# - how to handle system.net.mail.smtpfailedrecipientsexception failed recipients -

i wanna send email multiple addresses (more 1000 users) , use following code, when use send email less 100 users works, more 100 users not work , throw smtpfailedrecipientsexception failed recipients! why? how can send email valid addresses , ride of error? public void sendmailmessage (string[] to,string message,string subject) { mailmessage mmailmessage = new mailmessage (); int lenght = to.getlength(0); if (lenght > 1) { foreach (string email in to) { mmailmessage.bcc.add ( email ); } } else { mmailmessage.to.add ( to[0] ); } mmailmessage.from = new mailaddress ("no-replay@mycompany.net"); smtpclient msmtpclient = new smtpclient (); mmailmessage.body = message; mmailmessage.isbodyhtml = true; mmailmessage.priority = mailpriority.normal; mmailmessage

Positioning in HTML/CSS? -

here html code: <div id="slider" class="images"> <img src="img/image1.png" height=200 width=200> <p>image1 corresponding text here</p> <img src="img/image2.png" height=200 width=200> <p>image2 corresponding text here</p> <img src="img/image3.png" height=200 width=200> <p>image3 corresponding text here</p> <div class="switch_image"> <a href="#" id="prev">prev</a> <a href="#" id="next">next</a> how can change text location to right of image , not below it? after above question answered, images stacked on top of each other, how can space images apart margin? once done, how can each image , it's corresponding text move respect original position when re-size broswer window? i'd suggest wrapping images , text: <div id="slider" clas

Jquery slider and draggable dont work -

i'm making banner can resize , drag image. works fine in jsfiddle. reason dont work on webpage. here example in jsfiddle: http://jsfiddle.net/dennisbetman/tnaga/ and here how looks on webpage: http://jewelbeast.com/posts/imgreplace.html so if can see. slider dont work. , image draggable doing weird to. i called script jquery , jquery ui in head. he code used webpage. <!doctype html> <html> <head> <meta charset="utf-8" /> <title>jquery ui draggable - default functionality</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <style> div { width:370px; height:204px; position:relative; overflow:hidden;

io - Permission denied doing os.mkdir(d) after running shutil.rmtree(d) in Python -

very in windows 7 console if run python program twice does if os.path.isdir(d): shutil.rmtree(d) if not os.path.exists(d): os.mkdir(d) where d name of directory many files, "permission denied" mkdir command. if run once, wait seconds, run again not such error. problem here? there 3 things come mind: windows delays file operations in order preserve metadata. if example rename file , create 1 in location, windows has time-window things acls transferred new file. "feature" preserve metadata programs write new file before deleting old one, in order not loose data when fails in middle. malware scanners hook filesystem operations , perform scan on files, searching malware (or government-critic texts, if you're paranoid, , maybe if you're not paranoid). during scan, other accesses file blocked. lastly, i'm not sure how shutil.rmtree() implemented, under windows, tree operations implemented not os core shell (i.e. explorer) , ex

cordova - Make theme settings in Phonegap app persistent - with jQuery cookies -

i've got phonegap app different theme options. make theme selection persistent each app start, want set cookie jquery. after each refresh in browser (where test), standard theme back. can u give me hints? that's markup @ beginning of app: <body> <div class="theme1"> <div id="page1"> (...) // app markup <script src="js/jquery.js"></script> <script src="js/jquery.cookie.js"></script> <script>here goes script</script> </body> there set standard theme. now, do, is, when click on theme (#theme8, instance) happens in my script :    $('#theme8').bind('click', function () { if ($('body > div').hasclass('theme8')) { // go home screen } else { $('body > div').removeclass(); $('body > div').addclass("theme8"); // go homescreen } $.cookie('theme_

Filtering records based on string array PHP and MySQL -

i have string array in php called groups . array looks based on user input: groups[all, sales] . example: (updated table schema) groups[] = ['sales', 'all'] announcement |description|masterid| groupname | ======================================= | hello | 1 | all, final, | | greetings | 2 | sales, all, | | demo | 3 | final, | so above table should return " hello " , " greetings " output because groups[] has sales , all row 1 has , row 2 has both. please help. amateur in sql , php both. my current try: select * announcement groupname regexp '(sales | all)' output: no rows affected i guess, groups should in string format: groups[] = ['final', 'all', 'test'] . this $search = implode('|', $groups) produce string final|all|test . now need put string query search either or words. so, where groupname regexp '({$search})' . do

PHP mysql bigint issue -

i have 2 tables bigint: table1 id bigint(20) pk autoincrement name varchar(40), text table2 id bigint(20) pk autoincrement created datetime text_field id_table1_ref bigint(20) after inserting data table1 , trying insert table1.id table2.id_table1_ref, number different, i.e.: number 1552545662588 table1.t1 becomes 1552545662, or worse, negative number. i know issue settings, can't figure out how manage this. tried set signed/unasigned values fields, doesn't work. this happening on unix local computer, on server working ok, @ least now. any appreciated. you need convert string in sql before getting php. in php, can use gmp handle number. mysql docs on converting: http://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_convert

wait - How use `cin` to pause the program for 10 seconds in C++ -

exacly stated in subject: how use cin wait(pause program) 10 seconds in c++. make act simiral java's thread.wait . edit: asking cin that not way cin works, has no notion of timeouts. what want is, mentioned java, pause thread. can done in several ways... c++11: std::this_thread::sleep_for(std::chrono::seconds(10)); posix (linux et al.): sleep(10); windows: sleep(10000); (in milliseconds)

Wicket SELECT doesn't update it's model -

Image
i've wicket panel list of productviews (as select) after choose productview select, load product database id of productview details form. can modify product entity , can save when finish. after save try refresh select list update data, doesn't work(i mean, example, select contains old name of product after rename it, when select same productview, reload entity details form again, , of course new data appears database) don't want reload product list again, want solve memory. here source: productview: @entity @table(name = "product") @xmlrootelement public class productview implements serializable{ private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.identity) @basic(optional = false) @column(name = "id") private long id; @column(name = "name") private string name; @enumerated(enumtype.ordinal) @column(name = &qu

c# - Trouble with Update command for datagridview and npgsql -

i'm having issues npgsqlcommandbuilder , datagridview. there no problem filling datagridview data can't updatecommand work. my code looks this using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using npgsql; namespace golfklubben { public partial class laggtillresultat : form { private databaseconnection dataconnection = new databaseconnection(); private bindingsource bindingsource1 = new bindingsource(); private npgsqldataadapter daresult = new npgsqldataadapter(); public laggtillresultat() { initializecomponent(); filltavlingar(); datagridview1.datasource = bindingsource1; fillresultat(); datagridview1.columns[0].headertext = "deltagare"; datagridview1.columns[1].headertext =

ios - UIView size after transform -

i need size of uiview after applying transform such cgaffinetransformscale , cgaffinetransformrotate .i use below method size of view not able accurate size after applying cgaffinetransformrotate . cgsizeapplyaffinetransform(view.bound.size,view.transform) i using method because view.frame becomes null after applying transform.as mentioned in apple docs. help. the notion of "size" has no obvious meaning after application of transform, , rotation transform. why not supposed access frame of view transform not identity transform. cgsizeapplyaffinetransform give accurate information under 1 interpretation of notion of size (and frame , gives nonrotated bounding box). might want think further, though, why believe need information.

swing - Java - how can I check what is exactly entered into a JOptionPane.showInputDialog -

this code import java.util.random; import javax.swing.joptionpane; public class randomnumbersv2 { public static void main(string[] args){ double randomnumber = double.parsedouble(joptionpane.showinputdialog("please enter maximum number program generate")); random rnd = new random(); system.out.println(rnd.nextint(how make sure eneted in joption can put here)); // change int whatever number want, number max random number generated joptionpane.showmessagedialog(null, "your random number is" + randomnumber); } } random#nextint accepts integer value upper bound. therefore value entered should such. also, per docs, number should positive: try { int maxnumber = integer.parseint(joptionpane.showinputdialog("please enter input")); if (maxnumber > 0) { random rnd = new random(); system.out.println(rnd.nextint(maxnumber)); } else { throw new illegalargumentexcepti

django - Show error message when decorator fails -

the decorator working fine display error message (i'd use messages framework ) if user doesn't belong of required groups. here's decorator: def group_required(*group_names): """requires user membership in @ least 1 of groups passed in.""" def in_groups(user): if user.is_authenticated(): if bool(user.groups.filter(name__in=group_names)) or user.is_superuser: return true return false return user_passes_test(in_groups) i call using like: @require_http_methods(['get']) @group_required('supervisor') def home_view(request): return render(request, 'home.html') i tried using snippet use messages framework (since requires request object) realized messages framework middleware didn't appear installed inside decorator. i'm willing change whatever takes :) update: what i'm looking for: def group_required(request, *group_names): &q

android - Cast exception in eclipse designer -

how solve exception in eclipse designer when placing custom view in another. java.lang.classcastexception: com.fitness.app.stopper cannot cast android.widget.button @ com.fitness.app.stopper.<init>(stopper.java:25). com.fitness.app.stopper xml: <merge xmlns:android="http://schemas.android.com/apk/res/android" > <button android:id="@+id/btnstartstopper" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_margintop="25dp" android:text="start" /> <chronometer android:id="@+id/chronometer1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_aligntop="@+id/btnstartstopper" android:layout_marginleft="18dp" android:layout_torightof

jquery - Change background color saturation based on percentage loaded -

i want make preloader of sorts page loads instead of resizing divs width based on % loaded change saturation of background-color of div based on % loaded. to honest don't mind if have set #fff , fade color red don't know how saturation change or % of color faded % loaded. this have been trying: js $("#preloader").each(function() { $(this) .data("origcolor", $(this).backgroundcolor()) .backgroundcolor('#f4421a') .animate({ backgroundcolor: $(this).data("origcolor") }, 1200); }); css @-webkit-animation changecolor { 0% { background-color: $white; } 100% { background-color: $orange; } } .js div#preloader { @include position(fixed, $z:9999); width: 100%; height: 100%; overflow: visible; background: $loading no-repeat center center, $header-bg-mobile repeat top left, lighten($black,70%); -webkit-animation: changecolor 2s linear infinite; }

Delphi - MemoryStream or FileStream -

i downloading exe file internet using indy (idhttp), , can use memorystream or filestream save disk, not know if there difference between them (maybe in result structure of file?). could't find yet answer this. where, here 2 simple functions simulate doing: function downloadms(furl, dest: string): boolean; var http: tidhttp; strm: tmemorystream; begin result := false; http := tidhttp.create; strm := tmemorystream.create; http, strm try try get(furl, strm); if (size > 0) begin position := 0; savetofile(dest); result := true; end; except end; strm.free; http.free; end; end; function downloadfs(furl, dest: string): boolean; var http: tidhttp; strm: tfilestream; begin result := false; http := tidhttp.create; strm := tfilestream.create(dest, fmcreate); http, strm try try get(furl, strm); result := (size > 0); except end; strm.free; http.fre

scala - Implementing trait PartialOrdered[T] -

as exercise, supposed implement trait partialordered[t]. trait partialordered[t] { def below(that: t): boolean def < (that: t): boolean = (this below that) && !(that below this) /* followed other relations <=, >, >=, ==, .. */ } a class k extends trait should have below implemented such that a.below(b: k) = { true if <= b, false in other case however, compiling gives following error: value below not member of type parameter t def < (that: t): boolean = (this below that) && !(that below this) ^ so missing? in advance edit: example class rectangle (in coordinate system), 2 opposing corners given, rectangle below if included case class rectangle (x1: int, y1: int, x2: int, y2: int) extends partialordered[rectangle] { def below(r: rectangle): boolean = { val (rx, ry) = r.topleft val (tx, ty) = this.topleft tx >= rx &&

Warranty of storing variable value before next command in java -

i curious if after value assign command this: a = 5; there warranty new value has been stored variable? , if different primitive , other data types? , runnable objects. i have run method in myclass containing: synchronized(this){ while(pleasewait){ try { system.out.println("sleeping"); wait();} catch (exception e) { e.printstacktrace(); } } } is other classes calling method sleepme() contains: synchronized (myclass){ myclass.pleasewait = true; myclass.notify(); } and question is, have insert waiting after calling sleepme, instance of myclass have time change value of myclass.pleasewait ? i have several set methods, assing complex objects (objects of objects) instance of myclass. thanks the fact 2 threads synchronizing on same object means changes made pleasewait 1 thread visible other thread when returns wait() call. synchronization (in case regaining of lock on this when return wa

ruby on rails - undefined local variable or method `city' ROR -

i created form using scaffold , creating models make nested model error in browser , cannot solve , looking here, getting error : nameerror in clients#new line #33 raised: undefined local variable or method `city' #<#<class:0xc4fb5bc>:0xb704f94> extracted source (around line #33): 30: <% end %> 31: </div> 32: <div class="field"> 33: <%= city.fields_for :street |street| %> 34: <%= street.label :street %> 35: <%= street.text_field :name %> 36: <% end %> client.rb class client < activerecord::base attr_accessible :email, :name has_one :city accepts_nested_attributes_for :city end city.rb class city < activerecord::base attr_accessible :client_id, :name belongs_to :client has_many :streets accepts_nested_attributes_for :streets end street.rb class street < activerecord::base attr_accessible :city_id, :name belongs_to :city end clients_co

visual studio 2012 - Auto compiling a dependent project without having a dependency on it -

i'm developing asp.net mvc extensive usage of spring.net. i have lots of services implemented in different assemblies. purpose of using spring , abstract interfaces decouple application implementation of services. example, data access layer implemented nhibernate, solution designed allow change. so have defined lots of spring objects foreign assemblies e.g. <object id="repositoryfactory" type="org.zighinetto.myapp.nhibernatebasedrepositoryfactory, org.zighinetto.myapp,nhibernate" /> as know, works org.zighinetto.myapp.nhibernate.dll example assembly either is in gac is in bin directory as of today, in order allow quick debugging hitting f5, have set dependency main project projects depends on. know, spring designed allow cut dependency between projects, in case use dependencies tell visual studio compile , deploy dll automatically, otherwise have copy right dlls every time want debug project. the question straightforward: given wan

ffmpeg - Pseudo-streaming mp4 files does not work with flash player -

i've got problem streaming audio on website. thought put mp3 file inside mp4 container h264 codec, can use pseudo-streaming ability of mp4 codec. the code i'm using convert files is: ffmpeg -i 1.mp3 -y -b:a 32k -vn 1.mp4 pseudo-streaming (seeking in not-loaded parts of media) works in html5 player not in flash media players such jwplayer or flowplayer. i've tested files on both apache server h264 module enabled , nginx mod_mp4 enabled, without lucks. i tried mp4box , qtindexswapper , creating real video file mixing of image loop , audio file. ffmpeg -y -i joojoo.png -i 2.mp3 -vcodec mjpeg havij.mp4 mp4box -add havij.mp4 -isma havij_new.mp4 what doing wrong? can make work? you have hint file. check out mp4box -hint

jquery - How to read json file located in project folder in iPhone PhoneGap using Javascript -

i have read json file folder located in project. i using following code: var obj = "www/places.json"; how can read json file located in project folder www in iphone phonegap using javascript? you read on server. solution 1 - jquery if jquery usage not problem use this: //load categories object json jquery.getjson("categories.json", function(data){ // data yours parsed object }); example : html : <!doctype html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/> <script src="http://www.fajrunt.org/js/jquery-1.9.1.min.js"></script> <title>read json demo</title> <script> jquery.getjson("categories.json", function(dat

android - Listview inside SherlockFragment On Load. Layout not inflating -

Image
here sample setup splashscreen --> points mainactivity --> 2 tabs (tab1 , tab2) need inflate listview in tab1. here codes. from splashscreen ( works ok ) protected void onpostexecute(void result) { // todo auto-generated method stub intent = new intent(splashscreen.this, mainactivity.class); startactivity(i); } mainactivity.java ( works ok - loads 2 tabs @ top ) public class mainactivity extends sherlockfragmentactivity { public static string active_tab = "activetab"; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // setcontentview(r.layout.categories_list); apprater.displayask2rate(this, 7, 1, false); getsupportactionbar().settitle("keto recipes"); getsupportactionbar().setsubtitle("ketozen.com"); final actionbar actionbar = getsupportactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs)

Boolean Logic & gate delays -

Image
assuming 2 gate-delays sum or carry function, estimate time ripple-through carry addition adders following word lengths:- i) 4-bit ii) 8-bit iii) 16-bit in notes have written: "delay word width times each bit stage delay (2 gate delays)". therefore: i) 2*4 = 8 ii) 2*8 = 16 iii) 2*16 = 32 looking @ ripple carry adder wikipedia page: http://en.wikipedia.org/wiki/ripple_carry_adder#ripple-carry_adder the formula used here different, can explain discrepancy between notes , wikipedia article. of 2 correct? thanking in advance. joe as can see figure in linked wikipedia article, assumption simplification: the critical path c_out contains three gates, i.e. delays. however, need 3 delays first stage, since following c_in changes, leads critical path of 2 gates second , following stages.

objective c - When is KVC & KVO worth the trouble? Always? -

it seems new superset on objective-c, combinations of dot notation mixed directives, e.g.: studentsinclassa.@union.studentsinclassb.pets(...) , compliance syntax, e.g.: -replaceobjectin<key>atindex:withobject: . seems large portion of kvc akin simple accessor methods, can synthesized anyway. however, kvobserving seems make mvc apps easier. opinions? key-value coding allows arbitrarily nested attributes identity known @ runtime. example, kvc not replacement person.name — it's needlessly generic such specific task. let's didn't know when writing our program whether wanted name, age or favorite shoe brand. run sort of thing quite nstableview data sources. write big, repetitive conditional send message want, kvc makes easy: return [personcontroller.selectedperson valueforkeypath:desiredattribute]; then can set desiredattribute @"name" , @"age" or @"favoriteshoebrand.name" , we'll correct value without branching th

r - How to test if a formula is one-sided? -

i need test if formula one-sided (e.g. ~ a rather a~b ). right i'm doing this: test <- list( ~ + b, ~ b + c, b + c ~ ) isonesided <- function(form) length(form)==2 && sum(grepl("~",form))==1 > sapply(test,isonesided) [1] true false false is there better way? i'm worried there types of formulae don't know elude test. i use terms function , extract response attribute: test <- list( ~ + b, ~ b + c, b + c ~ ) sapply( test , function(x) attr( terms(x) , "response" ) == 0 ) # [1] true false false edit as @arun points out terms can't expand formula object special . in without knowing data.frame special refers to. workaround include dummy data.frame in terms function call: ## if want expand '.' in b + c ~ . test <- list( ~ + b, ~ b + c, b + c ~ , b + c ~ . , . ~ b + c ) sapply( test , function(x) attr( terms(x , data = data.frame(runif(1))) , "response" ) == 0 ) # [1] true f

html - Size a background image? -

i have div 200px 200px. it's background image 500px x 500px. is there way make sure entire background image fits div? know can size css3 i'm looking solution older browsers. thanks is there way make sure entire background image fits div? the background-size property . i know can size css3 i'm looking solution older browsers. there no other standard way scale background image. older versions of internet explorer can supported via non-standard filter property , alphaimageloader . /* untested */ background-image: url(images/someimage.png); background-resize: cover; filter: "progid:dximagetransform.microsoft.alphaimageloader(src='images/someimage.png',sizingmethod='scale')"; -ms-filter: "progid:dximagetransform.microsoft.alphaimageloader(src='images/someimage.png',sizingmethod='scale')"; alternatively, hack, use <img> element, , absolutely position behind content. content i

javascript - What is a reasonable procedure for figuring where a certain line of code on a wordpress site comes from? -

i have specific example question, question more general. in example, wordpress site has line of code, in header: <script src="http://s.ytimg.com/yts/jsbin/www-widgetapi-vfld_dur5.js" async=""></script> where should 1 figure out plugin/script/file responsible line? search part or of string in site's source using favorite editor's "find in project" feature. there aren't many occurrences of vfld_dur5 in wp...

java - ThreadPoolExecutor.worker.run spends too much time -

i have several tasks executed in cachedthreadpool . after profiling found task runs 10% of time , other 90% used threadpoolexecutor$worker.run (i'm using jvisualvm profiling). and here i'm stuck. can't figure out hell threadpoolexecutor$worker.run doing, why consumes time , how fix problem. need tasks run fast possible. that's profiler says: pool-2-thread-2 44542 ms (100%) java.util.concurrent.threadpoolexecutor$worker.run 44542 ms (100%) self time 39598 ms (88.9%) myclass.run 4943 ms (11.1%) may self time means thread sleeping? thanks in advance. p.s. please sorry stupid, i'm not great java programmer.

php - Saving time() IN Mysql -

i using following code save time. have tried updating column type datetime , timestamp $statement = $conn->prepare('update users set update = :update id = :clientid'); $statement->bindparam(':clientid', $clientid, pdo::param_str); $statement->bindparam(':update', time(), pdo::param_str); $statement->execute(); {"error":"sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near 'update = '1367692928' id = 'i9pm90r-b4'' @ line 1"} update reserved keyword , happens name of column. in order avoid syntax error, column name should escaped using backticks. ex, update users set `update` = :update id = :clientid mysql reserved keywords list if have privilege alter table, change column name not on reserved keyword list prevent same error getting again o

jquery mobile and php headers break buttons on next page -

i making login php file uses headers redirect different types of users , when ever redirects user specific page buttons on page become un-clickable. me? login html: <form action="login-all.php" method="post"> <lable>login:</lable> <input type="text" id="name" name="name" placeholder="first name"/> <input type="password" id="pass" placeholder="password" name="pass"/> <button type="submit">log-in</button> </form> php: if($role === '1' ) { //1 admin - 0 user header('location: admin.php'); //echo "admin"; }else{ header('location: user.php'); //echo "user"; } buttons on user.php (not working header redirect) <a href="#input"><button>input</button></a>

multithreading - C: pthread failing to listen, bind, and accept on a socket -

i trying create process listen connections on socket. seems work when bind, listen, , wait accepts in main() function. when attempt create new thread , bind, listen, , accept on new thread, fails. here code. void request_handler(int clientsock) { file *requestedfile = null; long filesize = 0; struct stat st; long bytesread; char buffer[1024]; requestedfile = fopen("/path/book.txt", "rb"); while(!feof(requestedfile)) { bytesread = fread(buffer, 1, sizeof(buffer), requestedfile); send(clientsock, buffer, bytesread, 0); } } void listener() { int server_sock_desc; struct sockaddr_in name; int client_sock_desc; struct sockaddr_in client_name; socklen_t addr_size; pthread_t handler_thread; printf("waiting"); //connection setup server_sock_desc = socket(pf_inet, sock_stream, 0); if(server_sock_desc != -1) { memset(&name, 0, sizeof(name)); na

PHP Convert a big binary file to a readable file -

i having problems simple script... <?php $file = "c:\\users\\alejandro\\desktop\\integers\\integers"; $file = file_get_contents($file, null, null, 0, 34359738352); echo $file; ?> it gives me error: file_get_contents(): length must greater or equal zero i tired, can me? edit: after dividing file in 32 parts... the error php fatal error: allowed memory size of 1585446912 bytes exhausted (tried al locate 2147483648 bytes) fatal error: allowed memory size of 1585446912 bytes exhausted (tried allocat e 2147483648 bytes) edit (2): now deal convert binary file list of numbers 0 (2^31)-1 why need read file, can convert binary digits decimal numbers. looks file path missing backslash, causing file_load_contents() fail loading file. try instead: $file = "c:\\\\users\\alejandro\\desktop\\integers\\integers"; edit: can read file, we're finding because file large, it's exceeding memory limit , causing script crash. tr

assembly - Having Trouble Saving Boot Sector On Disk And OS On Disk Then Loading It In Memory -

Image
background information i developing simple dos os. not planning enter in protected mode anytime soon. os written in assembly; nasm syntax way. boot sector supposed save boot sector on first sector of hard disk, , os' code on second sector. can boot hard disk, , not cd image. the issue the problem boot sector seems save on hard disk. when restart vmware player, , eject virtual cd-rom. boots background green color (figure 1.1). can mean boot sector isn't loading second sector @ address 0x7e00, , fails jump. weird thing carry flag not being set, assuming no error has occurred. when boot cd-rom image, shows fine in (figure 1.2). when restart , boot hard disk fails jump os should have been loaded @ 0x7e00. boot sector loaded @ 0x7c00. assuming segment address correct, maybe offset address incorrect, or maybe disk writing , reading totally wrong? things os has accomplished basic system calls in form of software interrupts. modified ivt (interrupt vector table) load bo