Posts

Showing posts from February, 2014

javascript - Sticky Element catching on down scroll and catching on up scroll -

i have sticky side bar , right using js have catching , staying fixed t point. when scroll need catch , not go further starting point. code far. $(window).scroll(function(e){ $el = $('.why_social'); if ($(this).scrolltop() > 735 && $el.css('position') != 'fixed'){ $('.why_social').css({'position': 'fixed', 'top': '-62px'}); } }); you should have add opposite check. should started. $(window).scroll(function(e){ $el = $('.why_social'); if ($(this).scrolltop() > 735 && $el.css('position') !== 'fixed') { $('.why_social').css({'position': 'fixed', 'top': '-62px'}); } if ($(this).scrolltop() <= 735 && $el.css('position') === 'fixed') { { $('.why_social').css({'position': ''}); // remove `position: fixed;` } }); btw: if you...

python - Calculate number of jumps in Dijkstra's algorithm? -

what fastest way in numpy calculate number of jumps dijkstra's algorithm uses? have 10000x10000 element connectivity matrix , use scipy.sparse.csgraph.dijkstra calculate filled distance matrix , predecessor matrix. naive solution follows: import numpy np numpy.random import rand scipy.sparse.csgraph import dijkstra def dijkway(dijkpredmat, i, j): """calculate path between 2 nodes in dijkstra matrix""" wayarr = [] while (i != j) & (j >= 0): wayarr.append(j) j = dijkpredmat[i,j] return np.array(wayarr) def jumpvec(pmat,node): """calculate number of jumps 1 node others""" jumps = np.zeros(len(pmat)) jumps[node] = -999 while 1: try: rvec = np.nonzero(jumps==0)[0] r = rvec.min() dway = dijkway(pmat, node, r) jumps[dway] = np.arange(len(dway),0,-1) except valueerror: break return jumps #...

Javascript value set null if value equals nothing -

right working on timesheet users can set in time, out time, , how long they've been @ lunch. use function subtracts in time & lunch out time figure out hours, plus possible overtime. want have javascript set value of overtime field '' (aka null) if amount of time @ work 8 hours or less. my code checking overtime this: // return difference between 2 times in hh:mm[am/pm] format hh:mm function checkovertime(timein, timeout, away) { // small helper function pad single digits function z(n){return (n<10?'0':'') + n;} // difference in minutes var subtotal = daytimestringtomins(timeout) - daytimestringtomins(timein) - timestringtomins(away); var regularhours = '08:00'; if (subtotal > timestringtomins(regularhours)) {var overtime = daytimestringtomins(timeout) - daytimestringtomins(timein) - timestringtomins(away) - timestringtomins(regularhours);} else {var overtime = '0';} return z(overtime/60 | 0) + ':...

python - Pythonic way of checking bit values -

i have set of constants declarations self.poutput = 1 self.ppwm = 2 self.pinput = 4 self.punused = 8 self.psonar = 16 self.pultra = 32 self.pservod = 64 self.pstepper = 128 self.pcount = 256 self.pinputdown = 512 self.pinputnone = 1024 what pythonic way of checking whether value matches of input states (4,512 , 1024) please? info: i'd use bit pattern checking in simpler languages wondered if there better way in python :) each pin can have 1 of i/o states above if pin of of input values 1 action occurs e.g if pin == 4 or 512 or 1024 -> something testing set membership (which seem doing) best done using set . self.input_states = {self.pinput, self.pinputdown, self.pinputnone} # later if value in self.input_states: do_something() of course handle in variety of essentially-identical ways, 1 way or have encode knowledge of these magic numbers "input states". now if, has been suggested, want bit-maski...

how to default a value for non existing node in xslt -

i have following xml element in source , map element in target. whenever there no node in source, want default string "none" --------------------------source xml---------------------------------------------- <?xml version="1.0" encoding="utf-8"?> <instructions instructiontype="gen">some message</instructions> <instructions instructiontype="test">some other message</instructions> ---------------------------transformation xsl-------------------------------------- <xsl:if test='/ns1:orderresponse/ns1:orderresponsebody/ns1:orderresponseproperties/ns1:instructions/@instructiontype = "gen"'> <xsl:choose> <xsl:when test='/ns1:orderresponse/ns1:orderresponsebody/ns1:orderresponseproperties/ns1:instructions[@instructiontype = "gen"] != ""'> <ns0:sigen> <xsl:value-of select='substring(/...

graph - Segmentation Fault C++ -

the input in following format 5 1 2 9.0 1 3 12.0 2 4 18.0 2 3 6.0 2 5 20.0 3 5 15.0 0 1 5 the first number number of vertexes in graph. next lines 0 edges of graph. first , second numbers being vertexes , third being how far edge between them. trying read in data , store edges there locations in list adjacency vertex. example make graph 5 vertexes edges 1 2&3. 2 4&3&1 etc. i getting segmentation fault after entering 4 numbers. fault happening on line mygraph.vertexinfo[p1].adjacency -> vertex=p2; starts trying store information. why getting fault? #include <cstdio> using namespace std; struct listcell { listcell* next; int vertex; double weight; listcell(int v, double w, listcell* nxt) { vertex = v; weight = w; next = nxt; } }; typedef listcell* list; struct vertex { bool signaled; long distance; list adjacency; }; struct graph { int numvertices; vertex* vertexinfo; graph(int n) { ...

PHP is not working on Apache 2 on Windows -

i have installed apache 2.4.9 windows 7 64 , php 5.5.10 (also 64 bit), used articles step step detailed manual installation. cannot open php files in browser reason. have checked other threads similar problems on different websites , made sure httpd.conf has necessary lines included or uncommented. apache starts , stops after enter httpd -k start/stop. when enter httpd -t says 'syntax ok'. when enter localhost/phpinfo.php in address bar in browser 'not found on server'. when try in command line 'php phpinfo.php' 'could not open input file'. i don't know else check, answers found in forum threads give same hints , include same elements of configuration file must included in httpd.conf, including root directory, engine = on, display errors = on, load module, addtype , used . i appreciate or suggestions. if not - go through installation once again. troubleshooting: check files stored in right directory (generally htdocs apache) look...

r - dplyr summarise: Equivalent of ".drop=FALSE" to keep groups with zero length in output -

when using summarise plyr 's ddply function, empty categories dropped default. can change behavior adding .drop = false . however, doesn't work when using summarise dplyr . there way keep empty categories in result? here's example fake data. library(dplyr) df = data.frame(a=rep(1:3,4), b=rep(1:2,6)) # add level df$b has no corresponding value in df$a df$b = factor(df$b, levels=1:3) # summarise plyr, keeping categories count of 0 plyr::ddply(df, "b", summarise, count_a=length(a), .drop=false) b count_a 1 1 6 2 2 6 3 3 0 # try dplyr df %.% group_by(b) %.% summarise(count_a=length(a), .drop=false) b count_a .drop 1 1 6 false 2 2 6 false not hoping for. there dplyr method achieving same result .drop=false in plyr ? the issue still open, in meantime, since data factored, can use complete "tidyr" might looking for: library(tidyr) df %>% group_by(b) %>% summarise(count_a=leng...

Is it possible to create a css class that has dynamic value? -

assume have div elements these: <div class="mystyle-10">padding 10px</div> <div class="mystyle-20">padding 20px</div> <div class="mystyle-30">padding 30px</div> is possible create class or : .mystyle-*{padding: *px; margin-left: *px; border: *px solid red; } that replace * value set div's class? thanks in advance! as @bjb568 said, can achieve using css pre-processors ( sass, less, stylus .. etc ) below sass example @for $i 1 through 5 { .mystyle-#{ $i * 10 } { $result: ( $i * 10 ) + 0px; padding: $result; margin-left: $result; border: $result solid red; } } which output following: .mystyle-10 { padding: 10px; margin-left: 10px; border: 10px solid red; } .mystyle-20 { padding: 20px; margin-left: 20px; border: 20px solid red; } .mystyle-30 { padding: 30px; margin-left: 30px; border: 30px solid red; } .mystyl...

php - Substr Logic Function -

i want ask substr() function. have code this: <?php $word = 'diriku'; $word2 = $word; //first condition if ( (substr($word,-3)=="kah") or (substr($word,-3)=="lah") or (substr($word,-3)=="pun") or (substr($word,-3)=="nya")) { $word2 = substr($word,0,-3); } //second condition else if( (substr($word,-2)=="ku") or (substr($word,-2)=="mu") ) { $word2 = substr($word,-2); } echo $word2; echo "<br />"; echo $word; ?> result must : diri don't know why result dir . opinion substr cut word @ first condition although it's true or false. so know how logic compare substr function if first condition true, pass else, , if cond false, continue else, not true. sorry mess explanation.. don't know how describe clearly. <?php $word = 'songsangkukah'; $word2 = $word; if ( (substr($word,-3)=="kah") ...

android - AutoLink link square brackets of URL in TextView -

i have url: https://<site name>/pallavi/[songs.pk]%2002%20.mp3 i have text view, property: android:autolink="all" if set text text view, text view highlights portion preceding [. looks this: https://< site name >/pallavi/ [songs.pk]%2002%20.mp3 what want is, whole link should highlighted like: https://< site name >/pallavi/[songs.pk]%2002%20.mp3 what have tried till now: used < pre > tag , html.fromhtml, doesn't seem work! (i don't know if < pre > supported in android though.) used jsoup.parser. doesn't seem work me. update have tried answer too: https://stackoverflow.com/a/12376115/1320263 please let me know if issue android text view's linkall property not consider parenthesis valid character or not? if supported, how hyperlink too? also note : text(or link) have written in question sample text. in reality, getting block of text, difficult identify hyper link starts , ends. also, number of links pre...

facebook - FB.UI big thumbnail for link -

how share link big thumbnail picture. using java sdk fb.ui feed method? no matter how big picture put thumbnail, facebook in feeds not appear big thumbnail. fb.ui({ method: 'feed', name: 'name', link: link, picture: picurl, caption: 'caption', display: 'popup', }, function(response){console.log(response);}); use 2x1 ratio pic like 800pix 400pix image on ur wall ll crop square on news feed big central image url underneath. don't forget set meta tags of url page

Delphi 2007 keyboard navigation - back to recent editor tab -

below listed keyboard navigation shortcuts form d2007. shift+alt+f11 moves focus structure view. ctrl+alt+f11 moves focus project manager view. ctrl+alt+b moves focus breakpoints view. ... is possible recent editor tab above views (using keyboard only)?

spring mvc - how can I use hibernate to get OneToMany reference datas -

i want make ordermeal web project in using springmvc+spring+hibernate. seens got problems @ printing datas on jsp pages. when debug project(i'm sorry can't post debug picture t_t) i can not figure out why property "mealorders" empty... have insert many datas tables. here entitys , hql query user class @entity @table(name="userbaseinfo") public class user implements serializable { private static final long serialversionuid = 1l; private long userid;//id private string username; private string loginname; private string userpassword; private string cleartextpassword; private string postion; private string telephone; private string email; private string userlocation; private date createtime; private date lastedittime; private date passwordedittime; private int onlinetime; private string lastloginip; private int logincount; private int userstate; private set<mealord...

php - Elastic Beanstalk - set .htpasswd on specific environment -

i have php website configured within elastic beanstalk on 2 environments, production environment , stage environment. within each environment have application_env environment variable set identifies code environment it's running on. don't want stage website accessible public , wanted place htpasswd on environment not on production one. to try achieve have created configuration within .ebextensions. entire .ebextensions folder has 3 files: 01stage.config container_commands: command-01: command: "/bin/bash .ebextensions/set_stage_htpasswd.sh" leader_only: true set_stage_htpasswd.sh #!/bin/bash if [ "$application_env" == "stage" ]; cp /var/app/current/.ebextensions/.htpasswd /var/app/current/ fi .htpasswd my_username:my_password i want elastic beanstalk run config file 01stage.config in turn run shell script set_stage_htpasswd.sh copy .htpasswd file specific location. however when try deploy this: i error message ...

sql - to get the multiple maximum-count of repeated values in mysql -

how can output maximum count of repeated values table , contains repeated values corresponding column such way there multiple different distinct values having maximum-counts . thanks ! consider r table data below : +---------+------------+-------------+--------------+ | bill_no | bill_date | customer_id | total_amount | +---------+------------+-------------+--------------+ | 101 | 2012-04-10 | c001 | 64 | | 102 | 2012-04-10 | c002 | 8 | | 103 | 2012-04-11 | c002 | 140 | | 104 | 2012-04-13 | c001 | 29 | | 105 | 2012-04-12 | c003 | 125 | | 106 | 2012-04-16 | c004 | 258 | +---------+------------+-------------+--------------+ we see here maximum count(customer_id) same c001 , c002 . want both values. the final output should follows: customer_id | count(customer_id) //max value ----------------+----------------------- c001 | ...

sql - How to give alias to results returned after inner join in mySQL -

i need correlated sql query , purpose need provide alias outer query in perform inner join. not able alias select distinct(name) person inner join m_director dira on (dira.pid = m_director.pid) dira 9 > ( select count(mid) m_director name = dira.name ) ; i didn't understand want do, guess select distinct p.name, count(d.mid) cnt hindi2_person p inner join hindi2_m_director d on p.pid = d.pid group p.name having count(d.mid) > 9 ; would want

ruby on rails - wrong number of arguments (1 for 0) in sunspots -

my controller: def index @search = onj.search fulltext params [:search] end @onjs = @search.results logger.debug params end index.html.erb: <%= form_tag onj_index_path, :method => :get %> <p> <%= text_field_tag :search, params[:search] %> <%= submit_tag "search", :name => nil %> </p> <% end %> error is: argumenterror in onjcontroller#index wrong number of arguments (1 0) " def index @search = onj.search fulltext params [:search] end @onjs = @search.results " remove space in params [:search] on line 3 in index method.

perl - How can I sum up the exponent value in bash shell? -

here example values 2.31312e+06 4.34234234e+07 4.578362e+06 3.213124124e+06 how can add them? numbers args: perl -le'$s += $_ @argv; end { print $s }' numbers on stdin or file named argument (one per line): perl -nle'$s += $_; end { print $s }' use printf '%e\n', $s instead of print $s if want result in exponent notation.

notepad++ - Deleting multiple occurrences of a string in notepad ++ -

i have following strings in error log: > [mon mar 17 20:14:34 2014] [error] [client 71.79.132.230] file not exist: /home/dom/public_html/404.shtml, referer: http://www.dom.com/ [mon mar 17 20:14:47 2014] [error] [client 68.62.210.110] file not exist: /home/dom/public_html/404.shtml, referer: http://www.dom.com/ [mon mar 17 20:15:05 2014] [error] [client 68.230.61.226] file not exist: /home/dom/public_html/404.shtml, referer: http://www.dom.com/ i want able sort them have 1 report of /home/dom/public_html/404.shtml , strings not technically duplicates because client ips not same. used notepad++ textfx function don't see how sort based on /home/dom/public_html/404.shtml string. thanks in advance if have (or can adjust) left parts of log entries ( [mon mar 17 20:14:34 2014] [error] [client 71.79.132.230] ) of same length , here unique sort functionality searching for: ensure menu item textfx > textfx tools > +sort outputs unique (at column) ch...

c++ - Deleting objects from a vector of pointers -

i have looked @ number of questions similar still can't manage fix this. consider simple class: class obj { public: obj(int moose); ~obj(); private: int* val; }; obj::obj(int num) { val = new int; *val = num; } obj::~obj() { printf("cleanup"); delete val; } now want have vector of pointers objs. source details problem: int main(int argc, const char * argv[]) { std::vector<obj*> objs; obj* o = new obj(10); objs.push_back(o); objs.erase(objs.begin() + 0); // should have been deleted - want destructor have been called // have tried delete objs[0], casting , deleting it. return 0; } the destructor in obj called when program has finished. want called when object erased vector. clarification: trying delete object using reference vector. cannot so. know vector doesn't deallocate memory. removes reference vector. can provide code delete object , call destructor using reference vector. e...

python - What suppose to be the answer to 6/-132? -

this question has answer here: why -1/2 evaluated 0 in c++, -1 in python? 4 answers in python, 6/-132 gets answer of -1 , should 0 ? what's rules behind it? python floors result, means 1/2 floors zero, 1/-2 floors -1. different c, 'truncates toward 0'. afaik, languages follow c. python uses different rules keep division 'in sync' modulo. article job of explaining. http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html

c# - Best way to associate metadata with a class type -

i want build little entity framework, need information entity class type e.g dbtype(sql, mongodb), dbname, tablename, idproperty. thought about: static methods (needs reflection hard coded strings invoke type) instance methods (need instantiate type) app.config (not directly in class) class attribute (needs reflection) store in database (to entity db need data db first, seems not nice) what best , fastest method metadata entity type? attributes want this. broad topic i'll link msdn documentation: http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx attributes provide powerful method of associating metadata, or declarative information, code (assemblies, types, methods, properties, , forth). essentially can create attribute class (or use existing one) , apply classes , when want can query metadata whatever information you've stored in them.

How to get source and destination city name using inner query in mysql -

table_cities - city_id, city_name table_booking - booking_id, source_city_id, destination_city_id i want booking_id | source_city_name | destination_city_name result. i trying this: select * table_bookings inner join table_cities on table_bookings.source_city_id = table_cities.city_id inner join table_cities on table_bookings.destination_city_id = table_cities.city_id; but giving not unique table/alias: 'table_cities' can help? you need add aliases query, because join on table table_bookings twice , select * table names ambiguous, need add aliases after joins make clear: select table_bookings.booking_id, sourcecities.source_city_name, destinationcities.destination_city_name table_bookings inner join table_cities sourcecities on table_bookings.source_city_id = table_cities.city_id inner join table_cities destinationcities on table_bookings.destination_city_id = table_cities....

android - does setStorageEncryption encrypt all mobile storage memory? -

i've been requested apply "setstorageencryption" in android app security policy. once policy applied, affect storage memory in device? can used encrypt selected files? thanks once policy applied, affect storage memory in device? quoting the documentation : this policy controls encryption of secure (application data) storage area. data written other storage areas may or may not encrypted, , policy not require or control encryption of other storage areas. there 1 exception: if isexternalstorageemulated() true, directory returned getexternalstoragedirectory() must written disk within encrypted storage area. most devices have emulated external storage, mean external storage part of same partition internal storage, , isexternalstorageemulated() return true . can used encrypt selected files? no, sorry.

How to move database and attach it to SQL Server 2008 -

Image
i not able attach database sql server 2008 on different machine. moved .mdf , .ldf files after detaching database 1 computer another. when try attach database on new machine database not show on file location. if browse manually can see files ( .mdf , .ldf ). there no hidden files under mssql > data folder contains other database files. also there way backup database, move new machine , add under sql server? if yes how can so? please advise. if see mdf , ldf files via file explorer, not in sql server management studio, sql server management studio login might have insufficient permissions if sql server version same both original , destination instance, there should no problems attach mdf , ldf files right-click databases node in object explorer select attach... 3.click add 4.navigate folder mdf , ldf files stored. make sure ssms login has enough privileges files/folders 5.select mdf file , click ok the patch ldf file automatically added if ...

python mechanize forms() err -

i'm using python 2.7.6 , mechanize 0.2.5 , want log in 'dining.ut.ac.ir' (i have username , password)- when try run below script forms list : import mechanize br = mechanize.browser() br.set_handle_robots(false) br.addheaders = [('user-agent', 'firefox')] br.open("http://dining.ut.ac.ir/") br.forms() i error: traceback (most recent call last): file "script.py", line 8, in <module> br.forms() file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_mechanize.py", line 420, in forms return self._factory.forms() file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_html.py", line 557, in forms self._forms_factory.forms()) file "/home/arman/workspace/python/mechanize/venv/lib/python2.7/site-packages/mechanize/_html.py", line 237, in forms _urlunparse=_rfc3986.urlunsplit, file "/home/arman/works...

asp.net mvc - Can't get "likes" our of Facebook JSON data using MVC -

i'm trying display # of "likes" of user selected entity has facebook site. url that's passed in entities facebook name: public int getlikes(string url) { string jsonstring = new webclient().downloadstring("http://graph.facebook.com/?ids=" + url); dictionary<string, dynamic> values = jsonconvert.deserializeobject<dictionary<string, dynamic>>(jsonstring); int keyvalues = values.count; int likes = values["likes"]; return likes; } i error "likes" not found in value. it's there. below sample of json data that's returned facebook: { "disney": { "about": "\"it's kind of fun impossible.\" - walt disney", "category": "company", "checkins": 26, "description": "this page place our fans. however, need have rules. please aware not accept or consider unsolicited idea s...

element id is not accessible javascript -

i have following code. here declaring element id's variables global before functions declared. variables taken functions below sample: var ddlpf=document.getelementbyid('<%=ddlpf.clientid%>'); var disp_msg=document.getelementbyid('<%=disp_msg.clientid%>'); function btn_proceed_click() { var ses='<%=session("hcur").tostring %>'; if(pos_valid()==true) alert('success'); } function pos_valid() { var pos_valid=false; var ses; var ccy; var ccy1; var ccy2; var as11costbud; ses='<%=session("hcur").tostring %>'; var bm='<%=session("benchmark").tostring %>'; var dtsheet='<%=session("dtsheet").tostring %>'; var ratedis='<%=session("ratedis").tostring %>'; if(ddlpf.selectedindex <= 0) { message("please select portfolio"); ...

Coordinate mapping at an angle -

i have issue have possibly overcomplicated in head. i've been @ long time , appreciate if give me direction. so i'm trying do, map coordinates on image taken sky, coordinate on flat surface on ground. fine directly above point, can scale coordinates factor calculated using basic trigonometry. the problem if camera @ angle. http://i61.tinypic.com/359wsok.png [note, height z axis here] i hope diagram makes sense. centre line (the 1 ends @ (x2,y2) bisects 2 other lines i.e. each of outer lines (1/2)a degrees centre one. understand complicated. more horizontal camera points, more surface going in view of image. means distance between 2 pixels @ furtherest away parts of image greater distance between closer pixels 'magnified' in sense. if manage works reasonably 40 degrees vertical, great. my first attempt size of surface in view, use scale coordinates. however, not believe worked. (x2,y2) may not in centre of captured surface , there kind of offset needs add...

Recursive sum function in scheme -

i want add consecutive values in stream , return list. like, stream : (1,2,3,4) output: (3,5,7) have code here giving me error car: contract violation expected: pair? given: '() i have tried using head , tail separately , working fine! whats wrong here ? (define (sum-primes prime-stream) (if (empty-stream? prime-stream) '() (cons (+ (head prime-stream) (head (tail prime-stream))) (sum-primes (tail prime-stream))))) (+ (head prime-stream) (head (tail prime-stream)) the tail might '() , in case, (head (tail)) amount (head'()) you need replace nil condition this, cheking tail of tail instead , returning final sum consed '() something like (if (empty-stream? (cdr (cdr p))) (+(car p) (car (cdr p))) ...

sql - MySQL String, check is column exists -

i creating column created current date if not exist. current query check column name , create 1 if not exist. variable $date , not work, please can suggest wrong it. $result = mysqli_query($con," if not exists ( select * information_schema.columns table_name = 'scouts' , column_name = '$date' ) begin alter table scouts add '$date' varchar( 255 ) end "); sql injection not problem being hosted on local machine. sorry if wasn't clear @ first.

Java String function can not be called because it's not static -

let me explain further. have string function (called stringreversal) returns reversed string, has no errors in function. but, when try print using system.out.println() main function, gives me error "can not make static reference non static method stringreversal (string s) type stringreverse". i tried giving stringreversal static modifier, after doing so, gave me run time errors. here's code looks like: public class stringreverse { public string stringreversal(string s){ if(s == null){ return null; } else if(s.length()% 2 == 0){ int size = s.length(); for(int =0; i<s.length(); i++){ s.replace(s.charat(i), s.charat(size)); size--; if(i == (s.length()/2) || size==0) break; } } else{ for(int =0; i<s.length(); i++){ int size = s.length(); s.replace(s.ch...

php - When I update MySQL row when i request same row by json i recieve old value -

when update mysql row when request same row json receive old value although value on server correct in phpmyadmin . , after calling 2 or 3 time receive correct value . $id=$_post['id']; $type=$_post['type']; $study=$_post['study']; $text=$_post['text']; $date=$_post['date']; $picture=$_post['picture']; $notes=$_post['notes']; $text= addslashes($text); $text=htmlspecialchars($text); $notes= addslashes($notes); $notes= htmlspecialchars($notes); $continued = mysql_connect(localhost,somebodyuser,password); if($continued){ echo(""); }else{ echo("connection fail"); } mysql_select_db("u599749231_rose")or die("cannot select db"); mysql_query("set character_set_server='utf8'"); mysql_query("set names 'utf8'"); $update=mysql_query("update achive set type= '$type', study = '$study', text= '$text', ...

Python curses.initscr() bug? terminal doesn't show input and each new output is on same line -

i tried using curses w/ python 2.7.6 running os 10.9.2 curses.beep() function work. got beep terminal stopped showing me input (i'm not talking echo interactive python typing in @ moment - kind of entering password w/ sudo) when hit return new prompt on same line. i've tried w/ interactive python , using .py script. importsucceed = true try: import curses except importerror: print "error" importsuc = false if importsucceed == true: print "trying init screen" stdscr = curses.initscr() print "trying beep" curses.beep() i got output: trying init screen #30ish lines of space trying beep prompt> # prompt started indented 2ish tabbed spaces if continued entering commands terminal get prompt> prompt> prompt> prompt> with nothing input showing up. any thoughts?

PHP check for double posting on the site -

i want run check when user submits form compare new post old once avoid double (or more) postings of same content. i thought of like if(strtolower($string1) == strtolower($string2)) { //do } but not sure how work checking entire website full of posts unique id's any appreciated! you use similar_text in php.. <?php $post1 = 'test1'; $post2 = 'test2'; similar_text($post1, $post2, $percent); if(round($percent)>90) { echo "the 2 posts 90% similar.. sorry try again. no spamming !"; }

c++ - Why use bind instead of function call? -

what advantage of using boost::bind in case std::for_each(participants_.begin(), participants_.end(), boost::bind(&chat_participant::deliver, _1, boost::ref(msg))); instead of for(iterator actual = participants_.begin(); actual != participants_.end(); ++actual) (*actual)->deliver(msg); link whole code (this simple server example provided boost tutorials). i think it's pre c++11, algorithms recommended on plain for-loops things. in theory, it's easier understand purpose of code, don't have understand whole loop implementation first. for_each perhaps extreme though, since for-loop implementation simplest. before lambda functions, 'boost::bind' requirement if wanted use algorithm without defining custom functor. nowadays, range-based loops, you'd this: for (auto& participant : participants) participant->deliver(msg); algorithms still better more complicated loops though (especially don't have use 'bo...

R: knitr to pdf, attach file -

task: generating pdf document knitr , latex in rstudio. code generates in addition dataframe can export .xls/xlsx-file xlsx package. problem: easier distribution, want attach/embed .xls/.xlsx-file .pdf-file. preference achieve during knitr run in rstudio? question: possible? other suggestion achieve embedding?

Bash(awk) - Comparing numbers in a column -

i familiar comparing numbers in row using bash, if wanted compare columns? if had file with 4 2 5 7 6 1 3 8 and want find largest out of each column 6 2 5 8 how can using awk? assuming data in file called "data": $ awk '{for(j=1;j<=nf;++j){max[j]=(max[j]>$j)?max[j]:$j};mnf=mnf>nf?mnf:nf} end{for(j=1;j<=mnf;++j)printf " " max[j]; print "" }' data 6 2 5 8 or, different output formatting: $ awk '{for(j=1;j<=nf;++j){max[j]=(max[j]>$j)?max[j]:$j};mnf=mnf>nf?mnf:nf} end{for(j=1;j<=mnf;++j)print "max of column " j "=" max[j]}' data max of column 1=6 max of column 2=2 max of column 3=5 max of column 4=8 the body of above awk program consists of: { for(j=1;j<=nf;++j) {max[j]=(max[j]>$j)?max[j]:$j};mnf=mnf>nf?mnf:nf } this loop run every line in input file. loop runs through every column (field) in input line 1 number of fields ( nf ). each column, checks see if...

javascript - Setting a the background image of a div from an array -

i have make div , set background image array of images, , make 2 buttons change picture next image in array, or previous image of array. i've been looking around stackoverflow , w3 schools, don't know why it's not working. var backgroundimage = new array(); backgroundimage[0] = "np.jpg"; backgroundimage[1] = "putin.png"; backgroundimage[2] = "fob.jpg"; function nextimage() var img = document.getelementbyid(element); for(var = 0; < backgroundimage.length;i++) for(var = 0; < backgroundimage.length;i++) { document.getelementbyid(element).src = [0].src; document.style.backgroundimage="url(backgroundimage[0])"; } you not evaluating array, creating literal want document.style.backgroundimage="url(" + backgroundimage[0] + ")";

database - What is CAS in nosql and how to use it? -

write operations on coucbahse accepts parameter cas (create , set). return result object of non-data fetching query has cas property in it. googled bit , couldn't found conceptual article it. could tell me when use cas , how it? should common work-flow of using cas ? my guess need fetch cas first write operation , pass along next write. need update using result's cas . correct me if wrong. cas stands check-and-set , , method of optimistic locking. cas value or id associated each document updated whenever document changes - bit revision id. intent instead of pessimistically locking document (and associated lock overhead) read it's cas value, , perform write if cas matches. the general use-case is: read existing document, , obtain it's current cas ( get_with_cas ) prepare new value document, assuming no-one else has modified document (and hence caused cas change). write document using check_and_set operation, providing cas value (1). step ...

java - Inserting data into online server using mysql, json in android. -

i used this example insert data in table in online server. may post duplicate unable figure out going wrong in code. saw many posts here , modified mine accordingly still errors. kindly me. inser.php <?php $response = array(); $connect = mysqli_connect(" "," "," "," "); if(mysqli_connect_errno($connect)) { echo "failed connect mysql: " . mysqli_connect_error(); } else { echo "success"; } $make = isset($_post['make']) ? $_post['make'] : ''; $model = isset($_post['model']) ? $_post['model'] : ''; $regno=isset($_post['regno']) ? $_post['regno'] : ''; $engine=isset($_post['engine']) ? $_post['engine']: ''; $chasis=isset($_post['chasis']) ? $_post['chasis']: ''; $query = mysqli_query($connect, "insert car (make, model,regno,engine,chasis) values...

How can I hide the status bar in iOS 7.1. with iPhone app running in iPad? -

this question has answer here: cannot hide status bar in ios7 25 answers i have used below methods hide status bar. set .plist configuration hiding status bar , added below method - (bool)prefersstatusbarhidden { return yes; } but in ios 7.1 update, status bar not hides while running app. 1 have solution ? issue exist iphone app while running on ipad add following info.plist: -(bool)prefersstatusbarhidden { return yes; }

soap - BizTalk 2013 Verify auto-generated web message deployed correctly -

i've got soap service i'm connecting using wcf-custom adapter. i've generated xsd , web-message multipart message types using .net 2.0 add web-reference i'm getting standard biztalk message finding document specification message type "http://mynamespace#webmessagename" failed. verify schema deployed properly. usually, in application schemas in biztalk server admin console , verify schemas. these web messages verify these have deployed correctly? did deploy solution/project schemas? must appear in biztalk administrator other schema. that soap or came add web reference doesn't matter @ runtime. schema schema.

c# - Save single column datatable to disk fast -

i've got save datatable disk. single column , i've been looping round saving each row, , i've tried adding rows string , saving that. = 0 dt.rows.count - 1 fd.savefile("c:\filename.txt, " " & dt.rows(i).item("word"), "append") 'appends file 'or wordlist = wordlist & " " & dt.rows(i).item("word") 'builds word list and.. next ' fd.savefile("c:\filename.txt", "overwrite") 'then saves disk. it slow. i've found this: http://bytes.com/topic/c-sharp/answers/250808-storing-datatable-data-hard-disk filestream fs = new filestream(@"c:\test.bin", filemode.create); binaryformatter bf = new binaryformatter(); bf.serialize(fs, dt); fs.close(); that whacks out serialized version of data in super quick time. faster looping processes. how can dump datatable that, no meta-data? doesn't need read datatable. serialize method puts etc tags ev...

umbraco7 - Is it possible to Customise BackOffice -

i'm trying start out on umbraco 7 view sticking mvc route as possible. i've noticed has different backoffice webforms route , looks quite nice. however, i'd able modify office. partically things i'd are: change appearance (modifying html , css) add additional pages i can't seem find explains how v7 of umbraco. first question is, possible achieve this? if how go doing so? i've adding umbraco v7 nuget package don't have of backend files default (assuming they're compiled dll's). how go making these modifications existing or registering new pages? great site customizing backoffice - http://www.nibble.be/?p=454 . can whatever want umbraco.

objective c - iOS - method (in another class) executed twice -

Image
i'm calling appcontroller viewcontroller upon viewdidload @implementation viewcontroller - (void)viewdidload { [super viewdidload]; nslog(@"viewdidload"); [appcontroller initialize]; } @end @implementation appcontroller + (void)initialize { nslog(@"initialize"); } @end i expected initialize executed once. but, seen in console, it's executed twice. is bug or missing something? + (void)initialize method called objective-c runtime first time class referenced. you should never call yourself, , never call super. if you're looking setup on data controller override init. here's similar answer

php - Form submission without revealing form content -

i run website includes several radio streams. have set icecast request .htaccess account in order authenticate , start streaming. there same account streams. submit form (it hidden via css ) jquery once page loads user not have know account nor submit form. the problem form information being revealed if user views source. there way hide these information? searching internet people not possible because browser needs able read these information in order function properly. know way, if possible? personally, need bit more information deduct solution issue, hope can give me that. however, have tried .remove()ing form after submission? way gets submitted on page load , gets removed time page loads , user clicks view source, not able see it. can, of course, disable js example, or other workaround, quick fix amount of information have.

c++ - Access Memory Mapped I/O -

i new embedded system programming, need learn how manipulate given via c++ code. given: motor 1 mapped 0x60000000 motor 2 mapped 0x50000000 the following definitions of current 32-bit registers register name | byte offset | notes ---------------------------------------------------------------------- motor_interrupt 0x00 service interrupts motor_status 0x01 enable on demand access status elements motor_command 0x02 enable command of motor register name | name | bits | access type | desc ---------------------------------------------------------------------------------- motor_interrupt_register closed 0 r/w high when motor transitions closed position open 1 r/w high when motor transitions open position rese...

multithreading - Using Threads with Java Swing -

i'm building user-interface java's swing library, , i've run problem. when updating text-area in long method, there pause while method runs, , text area updated @ once, instead of little bit @ time. i managed fix problem using new thread in following manner: private void jbuttonactionperformed(java.awt.event.actionevent evt) { thread x = new thread() {public void run() { // things update text area }}; x.start(); } this works having text area update in small pieces, opposed @ once. however, problem method can called once or java crashes. read has being able create thread 1 time. how can modify code keep desired functionality? any appreciated. well, doubt codes crashing because of thread creation, because each time method called, you're creating new thread (you can't restart existing instance of thread has been started (even if it's completed or not)), cause you're getting concurrent modification exception because swing...

Eclipse Kepler specify appearance theme through command line -

in eclipse kepler, each time start new workspace, theme reverts default one. so need go windows > preferences > appearance > theme , select theme want use. after need restart workspace theme applied completely. this repetitive , task , time consuming. is possible specify theme in command line or in eclipse.ini file ? you can specify org.eclipse.ui/current_theme_id=theme id in plugin_customization.ini file in plugins/org.eclipse.platform_<version> directory in install. you can specify location of file in eclipse.ini : -plugincustomization plugin_customization.ini

Show only the user's own account in a table that is editable when logged in, PHP Mysql -

i have problem regarding on how can access account able see logged in account, please on mysql statement should use :). so made page checks if user admin or customer , working.(code below login if admin or customer). verify if admin or customer page. <?php include("dbcon.php"); $username=$_post['username']; $password=$_post['password']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="select * admininfo username='$username' , password='$password' , type='admin'"; $sql1="select * customerinfo username='$username' , password='$password' , type1='customer'"; $result=mysql_query($sql); $result1=mysql_query($sql1); $count = mysql_num_rows($result); $count1 = mysql_num_rows($result1); if ($count==1) { ...