Posts

Showing posts from March, 2010

php - Simple way to graph Wordpress publish dates? -

this first question on stack overflow , i'm non-programmer trying pick up. (familiar html, css, starting bit of php, did tutorials on javascript , ruby on rails forgot of stuff.) i'm doing writing project, i'm writing 1,000 blogposts of 1,000 words each, published wordpress blog, hosted on bluehost. i'm 315 posts published, means 315,000++ words , 315 publishing dates. when finish project, on 1,000,000 words , 1,000 published posts. (with 100 "summary" posts, , 100 more "common threads" or "themes" posts.) i'm hoping use project motivation teach myself programming. example, want print graph of publish dates of blogposts, can see @ glance publishing frequency like. for time being, i'll happy able @ graph generated other own manual labor. easier, better. well not difficult make graph out of posts. needs bit of understanding of javascript. guess need funky looking stuff on website :). here recommendations. https://

c# - How to save a file in a list box into a .txt file? -

this question has answer here: how permanently save input given user in c# console application? 2 answers how save file in list box .txt file? return string.format("{0} = {1}", jaialainumber, "₱" + bet.tostring()); how save file on .txt file? here's code of program. ): ^_^ . public partial class frmjaialai : form { list<jaialai> source; public frmjaialai() { initializecomponent(); } private void frmjaialai_load(object sender, eventargs e) { source = new list<jaialai>(); } private void btnadd_click(object sender, eventargs e) { int bet; if (string.isnullorempty(txtjaialainumber.text) || !int32.tryparse(txtbet.text, out bet)) { messagebox.show("must required field.", "entry error"); ret

f# - This expression was expected to have type xxxx but here has type unit -

the following code has type error both of printfn s. how should fix it? i'd seq.map loop continue if 1 of items fails. // files should seq of record let files = seqofstrs |> seq.map(fun s -> match s | helper.parseregex "(\w+) xxxxx" month -> let currentmonth = ..... if currentmonth = month.[0] doc.load(shelf) // parse doc , return record type. omitted else printfn "expect %s found %s." currentmonth month.[0] //error | _ -> printfn "no '(month) payment data on line' prompt." //error the problem different branches of logic producing different things. in "omitted" section you're apparently returning value of type xxxx (e.g. string ), in other branches printfn calls, you're returning without value, in f# represented unit , in other languages called void . if didn't want loop continue, simplest answer throw except

playframework - Prepare multi-databases with play framework -

i want prepare application compatible many databases types. try i've used h2, mysql , postgresql. 'ive added build.sbt : "mysql" % "mysql-connector-java" % "5.1.35", "org.postgresql" % "postgresql" % "9.4-1201-jdbc41" and i've added conf/prod.conf configuration without database configuration, , 3 files: conf/h2.conf include "prod.conf" db.h2.driver=org.h2.driver db.h2.url="jdbc:h2:mem:dontforget" db.h2.jndiname=defaultds ebean.h2="fr.chklang.dontforget.business.*" conf/mysql.conf include "prod.conf" db.mysql.driver=com.mysql.jdbc.driver db.mysql.jndiname=defaultds ebean.mysql="fr.chklang.dontforget.business.*" conf/postgresql.conf include "prod.conf" db.postgresql.driver=org.postgresql.driver db.postgresql.jndiname=defaultds ebean.postgresql="fr.chklang.dontforget.business.*" add i've 3 folders conf/evolutions with e

Continuously resizing windows in Vim -

i know can use ctrl-w - / ctrl-w + incrementally decrease/increase windows. however, same thing continuously. e.g. without having click everytime ctrl-w , shift = (to + ) (i know have ctrl-w 5+ incremental, continous increase). is possible? this mappings use myself. works continuously holding keys: " window resize via alt + shift + arrows map <a-s-left> <c-w>> map <a-s-right> <c-w>< map <a-s-up> <c-w>+ map <a-s-down> <c-w>-

angularjs - How to remove header authentication while logout? -

hi using header authentication web service call os working fine. $http.defaults.headers.common['authorization'] = 'basic ' + base64.encode(username + ':' + password); $http({method: 'get', url: url}). success(function(data) { if(data=='' || data==null || data=='undefined'){ var alertpopup = $ionicpopup.alert({ title: 'info!', template: 'invalid password, or no user found email address' }); alertpopup.then(function(res) { console.log('invalid password, or no user found email address '); }); problem if logged out , try login different username or password getting logged in first logged in user .how remove header authentication while logout? did try adding $http.defaults.headers.common['authorization'] = '' to logout

c - when the memory is cleared on stack for a local function? -

i want know when memory cleared in stack allocated local function calls. have seen in video tutorial when function call returned main memory allocated local function cleared. have few questions on below program, please explain. #include<stdio.h> void print(){ printf("testing \n"); } int* sum(int* a, int* b){ int c = *a + *b; return &c; } int main(){ int a=3,b=2; int *ptr = sum(&a,&b); print(); printf("sum is: %d",*ptr); return 0; } when run above program, printing garbage value expected. if comment "print()" function in main , run program printing correct value of sum. is mean though execution of local function completed in stack, until there function call stack, previous allocated memory not cleared ? if remove "printf" statement in "print()" , keep "print()" call in main, see result of sum normal. why didn't overwrite memory in stack? c has no stack, word stack no

java - How to continue draw something on JPanel after clicked the button without repaint? -

i have define jpanel named drawpanel , , button named jbutton1 actionlistener . want continue draw on drawpanel after clicked jbutton1 . , not want clear drawpanel first , draw more things, want continue draw on drawpanel , show in jframe . check out custom painting approaches 2 common ways this: keep list of objects want paint , iterated through list every time. paint bufferedimage , paint bufferedimage.

html - How to show a list with scrollbar in php -

<?php foreach ( $fields $name => $value ): if ( $name == 'firm name' ): ?> <dt> <?php echo $name ?> </dt> <dd class="tribe-meta-value"> <?php echo $value ?> </dd> <?php endif ?> <?php endforeach ?> the output code be.. firm name: firm1,firm2,firm3.. variable $value giving firm names stored in database. i want show these firm name in list scrollbar.. how this?? do mean this? <style> #div{ border:1px solid #000; font-family:arial; height:100px; width:200px; } ul{ list-style:none; max-height:100px; margin:0; overflow:auto; padding:0; text-indent:10px; } li{ line-height:25px; } li:nth-child(even){ background:#eee; } </style> <div id="div"> <?php $options = "firm1, firm2, firm3"; $option

selenium - What is the purpose of specifying a schema in a web xml? -

data type definition (dtd) , xml schema definition (xsd) - these 2 type of specifying schema in web xml. purpose of specifying exactly? i have specified in testng.xml file <!doctype suite system "http://testng.org/testng-1.0.dtd" > what purpose of testng-1.0.dtd here? i got information here on dtd don't understand purpose of adding in xml file? http://testng.org/testng-1.0.dtd.php any in explaining appreciated. building test automation framework using selenium webdriver , using in testng.xml file for 1 of basic use when using ide code complete feature dtd complete code. i.e. if using tag not sure of spelling or atributes can rite < , press ctrl+space bar , find code complete. its kind of xmldoc , counterpart of javadoc

php - Results and timing table -

Image
so far i've done google spreadsheets, issues import range , desire make better , more beautiful. before looked this: link google spreadsheet i want mysql , php. i've done various tables in database (tables: user, class, team, time, country). now i's far, web form got finish time mysql table updating status in time table , finish time = on update current_timestamp, think have working ranking system well. stuck "time", "differ. leader","diff.rev", , "speed" code far: $results = $mysqli->query(" select klass, nimi, synd, teamnimi, start, time('finish') finish bc2014 t1 inner join bc2014aeg t2 on t1.bc2014_id = t2.bc2014_id klass = 'ds1 (1 koera toukerattavedu al.14 a.)' "); and: print '<table class="mytable7">'; echo "<tr><th> klass ds1 $total_tvp1 </th></tr>"; print '</table>'; print '<table class=&qu

Calling text from XML to the manually created object in Activity's method in Android Studio -

i trying create submit , clear button loop in oncreate() method using programming instead of xml layout, , have defined label text of button string.xml , assigned it. however, application has been stopped when run it. i have tried hide button label setting , can work useal(2 button displayed on apps without error), wondering if not possible call string label directly xml?? or missed so. pls give me comment. protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); tablelayout tablelayout = new tablelayout(this); tablelayout.setorientation(tablelayout.vertical); setcontentview(tablelayout); button[] buttons = new button[2]; //button label buttons[0].settext(r.string.label_calc); buttons[1].settext(r.string.label_clear); for(int i=0; i<2; i++) { buttons[i] = new button(this); tablelayout.addview(buttons[i]); } } here label setting in string.xml: <!-- button label--> <str

c# - Display datatable at view with possibility of edit/add elements -

how can display datatable @ view possibility of edit/add elements? i pass datatable object view , , need code can display table @ page, possibility of edit_add elements you can using jquery bootgrid ( http://www.jquery-bootgrid.com/ ) lets say, datatable has 2 column. here view: <table id="grid-basic"> <thead> <tr> <th data-column-id="id"> header1 </th> <th data-column-id="name"> header2 </th> <th data-column-id="link" data-formatter="link" data-sortable="false">header3</th> </tr> </thead> <tbody> <tr> <td> value1 </td> <td> value2 </td> <td></td> // make empty display option (edit, de

java - Reference table overflow caused by SimpleDateFormat.format() -

i have android project , there's activity need display current time on screen. used working thread post message main thread handler once per second. , in handler, format current time , display on ui. got reference table overflow problem after running every 30 mins, , program crashed error. here's log: referencetable overflow (max=1024) jni pinned array reference table (0x6080b458) dump: last 10 entries (of 1024): 1023: 0x423b76d0 int[] (1 elements) 1022: 0x4209cea0 int[] (1 elements) 1021: 0x4209c890 int[] (1 elements) 1020: 0x42242198 int[] (1 elements) 1019: 0x421b7b60 int[] (1 elements) 1018: 0x420c0e08 int[] (1 elements) 1017: 0x42107c18 int[] (1 elements) 1016: 0x421078e8 byte[] (1 elements) 1015: 0x42116a18 int[] (1 elements) 1014: 0x42116408 int[] (1 elements) summary: 1 of byte[] (1 elements) 1023 of int[] (1 elements) (1023 unique instances) failed adding jni pinned array ref table (1024 entries)

security - PHP - Storing session username or ID preferred? -

i'm wondering, php session, preferred store session variable containing logged in user's id or username? at moment stores username, whereas id safer because potential "hackers", may not know user id correlates to? php sessions work giving "opaque" cookie users - is, cookie number, , actual data stored on server. when user sends session cookie, php looks number in table retrieve data you've stored user. this means impossible, without access server, listening on network figure out session cookie means. need table stored on server. doesn't matter if store id number or username in session: if have enough access see what's in session, username based on id number anyway.

c++ - How is `int main(int argc, char* argv<::>)` a valid signature of main? -

this question has answer here: how bracketless/braceless code valid? [duplicate] 4 answers i've seen in site int main(int argc, char* argv<::>) can used signature of main . surprisingly, following program: int main(int argc, char* argv<::>) { return 0; } compiles withput warnings in gcc , clang. compiles in c++. so, how int main(int argc, char* argv<::>) valid signature of main ? char* argv<::> equivalent char* argv[] . <: , :> used here digraphs. c11: 6.4.6 (p3): in aspects of language, 6 tokens 79) <: :> <% %> %: %:%: behave, respectively, same 6 tokens [ ] { } # ## except spelling. 80) foot note: 79) these tokens called ‘‘digraphs’’. 80) [ , <: behave differently when ‘‘stringized’’ (see 6.10.3.2), can otherwise freely interchanged . an example: %:

My local git folders are full of files. Why are they empty on github? -

my local folders git repository full of python files. why empty on github , how can fix this? repo mother_devices , mother_main should full of files, on local machine. git status reads: on branch master nothing commit, working directory clean ubuntu 15.04 latest github. advice wonderful.

java - JComboBox Multi Choice -

is possible select multiple items in jcombobox if so, how?if not, there way this? private jcombobox getjcombobox1() { if (jcombobox1 == null) { jcombobox1 = new jcombobox(); jcombobox1.setmodel(new defaultcomboboxmodel(new string[] {"a", "b", "c"})); jcombobox1.addactionlistener(new actionlistener() { public void actionperformed(actionevent arg0) { } }); jcombobox1.setfont(new font("verdana", font.italic, 15)); jcombobox1.setforeground(color.red); jcombobox1.setdoublebuffered(false); jcombobox1.setborder(null); jcombobox1.setenabled(false); jcombobox1.setbounds(314, 181, 176, 25); } return jcombobox1; }

Trying to understand Ruby's getter setter rules -

what can't understand def initialize(awesome_level2) @awesome_level2 = awesome_level2 does @awesome_level2 have have same name awesome_level2? it seems if change it, doesn't work properly class awesome attr_accessor :awesome_level2 def initialize(awesome_level2) p awesome_level2 #100 @awesome_level2 = awesome_level2 p @awesome_level2 #100 end end awesome_sauce = awesome.new(100) puts awesome_sauce.awesome_level2 #100 awesome_level2 from? awesome_sauce.awesome_level = 99 puts awesome_sauce.awesome_level #99 attr_accessor convenience method creates getter , setter methods symbols pass arguments. can access instance variable creates directly, in case @awesome_level2 . note has @ symbol in front of it, indicates it's instance variable. different local variable or method parameter not have @ sign. therefore in initialize method, variable names @awesome_list2 , awesome_list2 different , can hold different value

url rewriting - URL rewrite on IIS 8.0 -

i have installed url rewrite module on iis 8.0 , configure rules if user come without www , prefix www if user comes http redirect https if user comes mobile browser sends mobile website below rules <appcmd> <config config.section="system.webserver/rewrite/globalrules" path="machine/webroot/apphost" overridemode="inherit" locked="false"> <system.webserver-rewrite-globalrules> <rule name="mobile redirect" enabled="true" patternsyntax="ecmascript" stopprocessing="true"> <match url="^$" ignorecase="true" /> <conditions logicalgrouping="matchany" trackallcaptures="false"> <add input="{http_user_agent}" pattern="android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos" /> <ad

Why node.js server in Visual Studio for Azure is created differently? -

i ran strange problem in azure project seems related how server created. project created using basic azure node.js express 4 application template in visual studio 2013 ultimate. after struggle, project runs fine locally, until hit browser's refresh button never comes back. the project created in webstorm , didn't have problem. figured, difference between them minimal: in webstorm, used: var server = http.createserver(app); server.listen(process.env.port, process.env.ip); but in visual studio, used (created template in www file): app.set('port', process.env.port || 3000); var server = app.listen(app.get('port'), function() { console.log('express server listening on port ' + server.address().port); }); when replace webstorm version, seems work fine again. can explain why? by way, in app, i'm not using node views. instead, i'm using: app.set("view options", { layout: false }); app.all('*', function (req, res,

html - python RE findall() return value is an entire string -

i writing crawler parts of html file. cannot figure out how use re.findall(). here example, when want find ... part in file, may write this: re.findall("<div>.*\</div>", result_page) if result_page string "<div> </div> <div> </div>" , result ['<div> </div> <div> </div>'] only entire string. not want, expecting 2 divs separately. should do? quoting the documentation , the '*' , '+' , , '?' qualifiers greedy; match text possible. adding '?' after qualifier makes perform match in non-greedy or minimal fashion; few characters possible matched. just add question mark: in [6]: re.findall("<div>.*?</div>", result_page) out[6]: ['<div> </div>', '<div> </div>'] also, shouldn't use regex parse html, since there're html parsers made that. example using beautifulsoup 4

python 3.x - Any tips on creating a Pygame Developer Console? -

i've been getting feet wet python , pygame, , after few bugs in basic game have been making, i've thought myself having sort of console can deal string input (from developer) handy. here's example: i notice player disappears after double jumping. so, in console create, type in: >> report_bug("player disappears after double jumping") where report_bug(string) user-defined function following things: report_bug(string): # check if debug file exists; create new file if none exists # append string file, along other info could point me in right direction? have create scratch, , if so, how go doing that? i've attempted modify source code from: http://www.pygame.org/project-pygame-console-287-.html , 9 years-old , made python 2.x, when i'm using python 3.4. appreciated. i've managed 2.x pygameconsole version 0.7 working, stick that! edit: attempt port pyconsole python 3.x , add more features newcomers can understand g

ruby on rails - 'listen loop error: Socket operation on non-socket' when trying to run Unicorn -

i started working on else's rails project last week. working expected throughout week's work until couple days ago when tried run server locally (as had done many times). the project uses rake task start server, narrowed issue down trying unicorn running. error after running bundle exec unicorn : i, [2015-04-25t20:38:10.794243 #1249] info -- : listening on addr=0.0.0.0:8080 fd=9 i, [2015-04-25t20:38:10.794400 #1249] info -- : worker=0 spawning... i, [2015-04-25t20:38:10.795363 #1249] info -- : master process ready i, [2015-04-25t20:38:10.796474 #1250] info -- : worker=0 spawned pid=1250 i, [2015-04-25t20:38:10.797102 #1250] info -- : refreshing gem list i, [2015-04-25t20:38:17.102292 #1250] info -- : worker=0 ready e, [2015-04-25t20:38:17.102705 #1250] error -- : listen loop error: socket operation on non-socket - accept (errno::enotsock) e, [2015-04-25t20:38:17.102861 #1250] error -- : /users/me/.rvm/gems/ruby-2.2.0@project_name/gems/unicorn-4.8.3/lib/unicorn/htt

algorithm - Find a minimum weight spanning tree in the undirected graph where there are negative edges -

Image
so need solve graph, have general idea on how solve if doing wrong please correct me. so find mst need perform kruskals algorithm on graph here psuedocode kruskals algorithm kruskal(v,e) = null; each v contains in v make disjoint set(v) sort e weight increasingly each(v1, v2) contains in e if kruskal(v,e) a = null; each v contains in v make disjoint set(v) sort e weight increasingly each(v1, v2) contains in e if find(v1) not equal find(v2) = union {(v1,v2)} union(v1,v2) return a so first thing find nodes shortest distances right? 1) i assume s h has shortest distance since d(h,s) = -3 so = {(h,s)} so follow pattern 2) = {(h,s),(s,f)} 3) = {(h,s),(s,f)(s,n)} 4) = {(h,s)(s,f)(s,n)(f,k)} 5) = {(h,s)(s,f)(s,n)(f,k)(s,m)} (we skip h n because path made h n through s ) 6) = {(h,s)(s,f)(s,n)(f,k)(s,m)(d,b)} 7) = {(h,s)(s,f)(s,n)(f,k)(s,m)(d,b)(b,m)} so since there path connects edges right? but thing dont understand t

html - Vertical placement of an image is taking my div out of flow of document -

Image
i trying place image vertically on left side of screen (not vertical alignment in div). i have achieved using transform: rotate(270deg) , put property transform in css, taking div out of flow. used position (top, left, bottom, right) , used crazy values -1800px ... bring div (with image) wanted (left side, vertically) the problem is, when zoom out, page looking ugly. can please suggest me way keep vertically place image, still prone zoom in or zoom out html: <div class="leftsidelogo"> <h1>left side logo</h1> <img src="images/google_logo.png" alt="logo" /> </div> css: .leftsidelogotest { float: left; width: 15%; transform: rotate(-90deg); transform-origin: top top; transform-style: preserve-3d; background-color: red; background-image: url("../images/google_logo.png"); background-size: 100% 100%; background-repeat: no-repeat; background-position: l

php - Atom & Yii2 - How to add Yii2 Code Hints to Atom Text Editor? -

is possible (and how) add yii2 code hinting atom text editor? while searching question, came across youtube video person had type hinting on sublimetext yii2 functions. video example: https://www.youtube.com/watch?v=kg17wijfga8 a perfect example in video, @ 1:23 mark. pops activefield field(model $model, string $attribute, array $options = []) , documentation it. in aptana studio, imported library (such yii) somewhere in settings. pulled code hints comments. while video wasn't problem, glad stumbled upon it. use atom, , love have this. supposed able hack , make atom whatever want, how go getting added atom?

Azure Live Streaming RTMP with CDN -

previously i'm using amazon aws, i'm moving microsoft bizspark program can use azure free limitation. i'm new azure, , want setup rtmp live streaming cdn. i'm using flowplayer in website , obs software broadcast live stream. can use azure cdn rtmp live streaming ? azure media services supports ingesting live feeds using rtmp , uses dynamic packaging dynamically transmuxe live streams delivery in mpeg-dash, microsoft smooth streaming, apple hls, or adobe hds formats. you can use azure media player , wirecast instead of flow player , obs software. can follow this article setup live streaming.

jssor - responsive slider breaks image ratio on $FillMode: 2 -

when use following code recommended on jssor site (below) make slider reactive ends breaking image ratios if set $fillmode:1 (contain (keep aspect ratio , put inside slide)). guessing there being calculated in background after images loaded before responsive code below triggered potentially call again avert issue recalculating new ratios images have no idea start one, or pointers appreciated! function scaleslider() { var parentwidth = $('#slider1_container').parent().width(); if (parentwidth) { jssor_slider1.$scalewidth(parentwidth); } else window.settimeout(scaleslider, 30); } //scale slider after document ready scaleslider(); //scale slider while window load/resize/orientationchange. $(window).bind("load", scaleslider); $(window).bind("resize", scaleslider); $(window).bind("orientationchange", scaleslider); the $fillmode , responsive code work se

twitter4j - Android data is lost onCreate() after startActivity() for callback -

i have android app connects twitter via twitter4j. in activity there share button , textview. flow below; user opens activity starting oncreate() populates textview user clicks "share" twitter activity started oauth, user types account credentials , gives permission app user gets redirected activity again starting oncreate() my problem value of textview lost after second oncreate(). - oncreate() . . point = getintent().getextras().getint("point"); . . - sharebutton.onclick() . . thread thread = new thread(new runnable() { @override public void run() { intent intent = new intent(intent.action_view, uri.parse(requesttoken.getauthenticationurl()));// open twitter authentication intent .putextra("point", point); startactivityforresult(intent , 1); } }); thread.start(); . . things have tried far; using startactivityforresult() instead of startactivity() using intent.putextra() before startactivity() , calling getintent().ge

database - How do I get the selected value in the dropdown and then display further information -

i have dropdown fetches options database. know how can value of selected option after selecting, other datas database displayed in table or form? this before selecting select dropdown : option1 name: age: after selecting select dropdown : option2 name: michael age: 21 controller public function salesorders() { if ($this->session->userdata('logged_in')) { $this->header2(); $data['groups'] = $this->secretary_model->getallgroups(); $this->load->view('secretary/transactions',$data); } else { redirect('secretary/sec_login_view'); } } model function getallgroups() { $query = $this->db->query('select firstname tblcustomer'); return $query->result(); } view <?php echo "select customer"; $options = array(); foreach($groups $group) {

java - How to write an ImmutableMap that follows the Liskov Subsitution and other SOLID principles without code smells? -

i answered question regaurding immutablemap . suggested using proxy pattern. the problem map contains put method, throw unsupportedoperationexception . replacing other instances of map immutablemap break liskov subsitution principle. not that, need declare put , putall [violates interface segregation principle] technically, there no way replace map instance immutablemap , since map interface. question is: would creating immutablemap using map interface considered breaking lsp, since map contains put , putall method? not implementing map considered "alternative classes different interfaces" code smell? how 1 create immutablemap abides lsp yet doesn't contain code smells? in view, immutablemap should implement map . bad idea not implement map there many methods accept map argument , use in read-only sense. don't believe violate liskov subsitution principle because contract map makes clear put optional operation. it not ideal cla

ruby on rails - Outputting HTTP request/response data with RSpec -

i have rails project serves json api tests written in rspec. when running specs (request specs, specifically), i’m interested in seeing details http request/response...i.e. request url, request body, , response body, ideally json pretty-formatted readability. isn't purposes of documentation rather part of development / debugging process. i have helper method wrote this...you drop method call spec , prints stuff out. but, seems better if there switch that’s part of running specs. rspec has custom formatters thought might right direction, in trying build one, can't figure out how access request/response objects can inside of spec. how can access request/response objects in custom rspec formatter? or, perhaps way approach problem? here's approach: assuming rails project, in spec_helper.rb, define global "after" hook so: config.after(:each) #runs after each example if env['printhttp'] #use request/response objects here, e.g. puts r

r - Conversion from character to date/time returns NA -

i use as.posixct convert characters posixct , na , don't know why. example: date <- "fri apr 10 11:57:47 2015" date_in_posix <- as.posixct(date, format="%a %b %d %h:%m:%s %y") i tried too: date_in_posix <- as.posixct(date, format="%a %h %d %h:%m:%s %y") but result both always: > date_in_posix [1] na maybe input as.posixct long? , when it's long solution? it's because "fri" , "apr" not correct abbreviations in locale. use sys.setlocale("lc_time", locale) set r session's locale 1 correctly interpret english abbreviations. see examples section of ?sys.setlocale how specify locale in above function call. for example, on ubuntu machine be: > sys.setlocale("lc_time", "en_us.utf-8") > as.posixct("fri apr 10 11:57:47 2015", format="%a %b %d %h:%m:%s %y") [1] "2015-04-10 11:57:47 cdt"

php - Rate system warning mysql_fetch_assoc? -

hi i'm kind of beginner , not know how solve problem. i'm trying create rate system. got done there problem , not know how proceed. assistance thank you. here's code: <?php $query = mysql_query("select * hry"); while($data = mysql_fetch_assoc($query)){ $rate_db[] = $data; $sum_rates[] = $data['rate']; } if(@count($rate_db)){ $rate_times = count($rate_db); $sum_rates = array_sum($sum_rates); $rate_value = $sum_rates/$rate_times; $rate_bg = (($rate_value)/5)*100; }else{ $rate_times = 0; $rate_value = 0; $rate_bg = 0; } ?> here's error: warning: mysql_fetch_assoc () expects parameter 1 resource, boolean given in /data/web/virtuals/88892/virtual/www/domains/viveregames.cz/pohledy/clanek.phtml on line 28 error means query failed. because when query fails, mysql_query() returns false , false, think know, boolean.. well, using mys

Ember.JS loading sub-state issue -

i using ember-cli , show loading spinner when model loading. create application loading template , works fine, when ember debugger opened. here video bug . did have problem before? upd. answer question you need explicitly create loading route templates global loading template not working.

java - Method returns before executing all threads even though executor.awaitTermination is used -

i have method takes number of threads work , executes run() method each thread accordingly shown below public static map<string, integer> execute(int thread_count) { executorservice executor = executors.newfixedthreadpool(thread_count); file folder = new file("logfiles/"); collection<file> files = fileutils.listfiles(folder, null, true); for(file file : files){ //for rach file in folder execute run() system.out.println(file.getname()); executor.submit(new runner((file.getabsolutepath()))); } executor.shutdown(); try { executor.awaittermination(1, timeunit.days); } catch (interruptedexception e) { system.out.println("exception "+ e + " in countlines.execute()"); } for(map.entry<string, integer> entry: runner.linecountmap.entryset()){ system.out.println(entry.getkey() + &q

Elastic mapreduce cluster always in this status: Provisioning Amazon EC2 capacity -

when create elastic mapreducer cluster, within created vpc, showing message: provisioning amazon ec2 capacity after more 30 minutes error: failed start job flow due internal error im trying find issue without sucess, came here ask see if can me. i explain steps did create vpc , subnets im using in elasticmapreducer cluster: 1º create vpc: name tag: elasticvpc cidr block: 10.0.0.0/16 tenancy: default 2º create subnets (one in each availability zone): name tag: subnet1 vpc: elasticvpc availability zone: us-east-1b cidr block: 10.0.0.0/24 name tag: subnet2 vpc: elasticvpc availability zone: us-east-1c cidr block: 10.0.1.0/24 name tag: subnet3 vpc: elasticvpc availability zone: us-east-1d cidr block: 10.0.2.0/24 name tag: subnet4 vpc: elasticvpc availability zone: us-east-1e cidr block: 10.0.4.0/24 3º create route table name tag: elasticrt vpc: elasticvpc 4º create internet gateway name tag: elasticig attach ig vpc elasticvpc 5º route tabl

r - How to specify font sizes in plots with multiple plots per page? -

when generate .pdf file using knitr within rstudio, single plots exhibit desired font sizes of axis labels, legend, etc. however, when use layout() function generate multiple sub-plots, these font sizes reduced. please see example code below. \documentclass[12pt,english,twocolumn]{article} \begin{document} <<settings, message=false, echo=false, cache=false>>= # set tikz default options opts_chunk$set( out.width='15cm', fig.width=5.906, # inch fig.height=5.906, # inch dev='tikz', fig.align='center', fig.lp='fig:', fig.env='figure*', dev.args=list(pointsize=10), message=false, echo=false ) options(tikzdefaultengine = "pdftex") @ <<singleplot, fig.cap="single plot font size">>= par(cex=1) plot(rnorm(100)) @ <<multipleplots, fig.cap="multiple plots fonts being small">>= par(cex=1) layout(matrix(1:9, 3)) for(i in 1:9) plot(rnorm(100)) @ \end{document} how fo

c++ - libircclient : Selective connection absolutely impossible to debug -

i'm not type post question, , more search why doesn't work first, time did could, , can't figure out wrong. so here's thing: i'm programming irc bot, , i'm using libircclient, small c library handle irc connections. it's working pretty great, job , kinda easy use, ... i'm connecting 2 different servers, , i'm using custom networking loop, uses select function. on personal computer, there's no problem loop, , works great. but (here's problem), on remote server, bot hosted, can connect 1 server not other. i tried debug could. went examine sources of libircclient, see how worked, , put printfs could, , see comes from, don't understand why this. so here's code server (the irc_session_t objects encapsulated, it's kinda easy understand. feel free ask more informations if want to): // connect first session first.connect(); // connect osu! session second.connect(); // initialize sockets sets fd_set sockets, out_socke

html5 - Processing.js : reading information from file -

i have processing sketch in read coordinates file: float[][] points = new float[243][3]; void setup() { size(500, 500, p3d); background(255); camera(100, 50, 150, 0, 0, 0, 0, -1, 0); string lines[] = loadstrings("1xd3coordsknot"); (int = 0; < lines.length; i++) { string[] list = split(lines[i], " "); float x = float.parsefloat(list[0]); float y = float.parsefloat(list[1]); float z = float.parsefloat(list[2]); points[i][0] = x; points[i][1] = y; points[i][2] = z; } } void draw() { background(50); lights(); //the 3d lines here (int = 0; < 242; i++) { line(points[i][0],points[i][1],points[i][2],points[i+1][0],points[i+1][1],points[i+1][2]); stroke(255); strokeweight(2); } } it works fine when run within processing. trying embed web page. lines not drawn in case. javascript console gave me error saying files coordinates read not found in root directory of html file, copied there. not displ

c++ - "initializer_list" file not found -

trying install phash-image node error: > phash-image@3.1.0 install /users/jong/workspace/mgmtio/phash-image > node-gyp rebuild cxx(target) release/obj.target/phash/phash.o in file included ../phash.cpp:4: in file included /usr/local/cellar/phash/0.9.6_1/include/phash.h:50: /usr/local/include/cimg.h:160:10: fatal error: 'initializer_list' file not found #include <initializer_list> ^ 1 error generated. make: *** [release/obj.target/phash/phash.o] error 1 how fix this? on os x 10.10.3 , installed phash homebrew found out need add these flags: [ '-mmacosx-version-min=10.7', '<!@(pkg-config --cflags phash)', '-std=c++11', '-stdlib=libc++' ]

angularjs - Injecting a Angular service into controller results in $injector:unpr error (using AngularBooter) -

i using angularbooter angular in app. here code: emp.boot(); emp.services.socialservice = ['$http', '$q', function ($http, $q) { var deferred = $q.defer(); $http.get('/api/feed').then(function (data) { deferred.resolve(data); }); this.getstatuses = function () { return deferred.promise; } }]; emp.controllers.statusescontroller = ['$scope','socialservice', '$interval', function($scope, socialservice, $interval) { var statuses = socialservice.getstatuses(); statuses.then(function(data) { $scope.statuses = data; console.log($scope.statuses); }); }]; from understand error: error: [$injector:unpr] sign service isn't being registered or implemented correctly, have tried few things keep running same problem. ideas. two problems: 1) booting before register stuff (at least in code provided). emp.boot() right @ bottom after has been defined. 2

how to event more keys within javascript -

i want eventing more keys in javascript code: <script> function open(e) { if (e.type !== "blur") { if (e.keycode === 70) { alert("pressed f"); } } } document.onkeydown = open; </script> what getting question want detect more keys presses. best way detect key presses switch statement function open(e) { if (e.type !== "blur") { switch (e.keycode) { case 70: alert("pressed f"); break; case 65: alert("pressed a"); break; default: alert("i don't know key!");//this line removable break; } } } document.onkeydown = open; how works the way switch works is: switch (value) { case this_value: code break; default: code break; } that worst explanation you've seen can read here wi

mongodb queries find total number of cities in the database -

hi have huge data contains information below: { "_id" : "01011", "city" : "chester", "loc" : [ -72.988761, 42.279421 ], "pop" : 1688, "state" : "ma" } { "_id" : "01012", "city" : "chesterfield", "loc" : [ -72.833309, 42.38167 ], "pop" : 177, "state" : "ma" } { "_id" : "01013", "city" : "chicopee", "loc" : [ -72.607962, 42.162046 ], "pop" : 23396, "state" : "ma" } { "_id" : "01020", "city" : "chicopee", "loc" : [ -72.576142, 42.176443 ], "pop" : 31495, "state" : "ma" } i want able find number of cities in database using mongodb command. database may have more 1 recored has same city. example above. i tried: >db.zipcodes.distinct("city").c

javascript - Is there anyway that I can give a div a function in p5.js -

im trying take div created , make move across screen every hour using p5.js , i'm wondering if @ possible wonderig if div can change color randomly every hour in p5.js one way use window.setinterval function. function, can perform animation every hour. however, 1 problem arises that, according p5.js documentation, draw() function executes continuously after setup() function called. can fix taking advantage of noloop() , loop functions. the noloop() function call stop draw() function executing , loop() function start execution again. so, let's take @ how can code this: note: according documentation, there can 1 draw function each sketch. so, if have other things animating throughout course of hour approach may not best choice. //stores position of element on x-axis of screen var xpos = 0; var delay = 60000 * 60; //1,000 milliseconds in second window.setinterval(function(){ //code called every hour; make draw function loop loop(); }, delay);