Posts

Showing posts from February, 2012

javascript - How to request the Garbage Collector in node.js to run? -

at startup, seems node.js app uses around 200mb of memory. if leave alone while, shrinks around 9mb. is possible within app to: check how memory app using ? request garbage collector run ? the reason ask is, load number of files disk, processed temporarily. causes memory usage spike. don't want load more files until gc runs, otherwise there risk run out of memory. any suggestions ? if launch node process --expose-gc flag, can call global.gc() force node run garbage collection. keep in mind other execution within node app paused until gc completes, don't use or affect performance. you might want include check when making gc calls within code things don't go bad if node run without flag: if (global.gc) { global.gc(); } else { console.log('garbage collection unavailable. pass --expose-gc ' + 'when launching node enable forced garbage collection.'); }

c# - Mysterious Negative Counter Value -

i'm creating new threads every sql call project. there millions of sql calls i'm calling procedure in new thread handle sql calls. in doing so, wanted increment , decrement counter know when these threads have completed sql query. to amazement output shows negative values in counter. how? when starting 0 , adding 1 @ beginning of process , subtracting 1 @ end of process? this int not called anywhere else in program.. following code.. public static int counter=0; while(!txtstream.endofstream) { new thread(delegate() { processline(); }).start(); console.writeline(counter); } public static void processline() { counter++; sql.executenonquery(); counter--; } output looks this: 1 21 -2 -2 5 nothing mysterious it, using threading, right? the ++ , -- operator aren't thread safe. this. public static void processline() { interlocked.increment(ref counter); sql.executenonquery(); interlocked.decrement(ref

javascript - Meteor Braintree -- Create Client Token via Meteor Method -

i'm trying braintree payments working in meteor app. i'm stuck @ trying return result of generating token (server side, via meteor method) used client side. i've tried this: /server/braintree.js meteor.methods({ createclienttoken: function() { var token = gateway.clienttoken.generate({ customerid: this.userid }, function(err, response) { clienttoken = response.clienttoken return clienttoken } ) console.log(token) return token } }) which returns true . i've tried this: meteor.methods({ createclienttoken: function() { var clienttoken gateway.clienttoken.generate({ customerid: this.userid }, function(err, response) { clienttoken = response.clienttoken } ) console.log(clienttoken) return clienttoken } }) which returns undefined . the function(err, response) being called asynchronously, yes? if so, explanation of problem. seems

javascript - File upload with nodejs, express and angular using dropzone -

i'm having trouble getting file recognized server side node. specifically when accessing request data, (req.files or req.body) here snippets if has advice. html : <form action="/upload" class="dropzone" drop-zone id="file-dropzone"></form> angular controller : 'use strict'; angular.module('app') .controller('samplectrl', function ($scope, $http) { }) .directive('dropzone', function() { return function(scope, element, attrs) { $(element).dropzone({ url: "/upload", maxfilesize: 100, maxthumbnailfilesize: 5 }); } }); node router : 'use strict'; var express = require('express'); var controller = require('./import.controller'); var router = express.router(); router.post('/', controller.import); module.exports = router; node controller : 'use strict'; var express = require('express

How to load a ListView using AsyncTask in android -

i have method called fetchdata() fetch data database , load listview. when activity starts there small lag because of this. need load data in background. wondering if tell me how using asynctask. this fetchdata() method. public void fetchdata() { database = helper.getreadabledatabase(); cursor c; date cdate = new date(); simpledateformat sdf=new simpledateformat("yyyy-mm-dd"); final string fdate = sdf.format(cdate); int thismonth=integer.parseint(fdate.split("-")[1]); month mn=new month(); string month=mn.getmonth(thismonth); calendar cal=calendar.getinstance(); int today=integer.parseint(fdate.split("-")[2]); int curtab=position; string whereclause=""; string sort=""; if(curtab==0){ whereclause=null; sort=database.name; } else if(curtab==1){ whereclause=database.month+" = '"+month+"' , "+database.day+" =&

javascript - PhysicsJs - how to remove a world behavior, "constant-acceration' after it has been added -

my behaviors on initialization added follows: world.add([ physics.behavior('interactive', { el: renderer.el }), physics.behavior('constant-acceleration'), physics.behavior('body-impulse-response'), physics.behavior('sweep-prune'), edgebounce ]); i'd to, @ later time, remove "constant-acceleration" behavior. read couple of posts said use remove() method i'm not getting happen using follows: world.remove( physics.behavior('constant-acceleration') ); can advise how achieve removing specific behavior world after has been added? the physics.behavior docs indicate behavior object returned when call physics.behavior (because constructs new one). need keep reference behavior object you'd call you've put world.add array, pass reference world.remove later. now, you're making new behavior (separate 1 made first) , passing brand new object world.remove , nothing.

loops - Assembly Language MASM jumping -

.386 .model flat exitprocess proto near32 stdcall, dwexitcode:dword include io.h cr equ 0dh lf equ 0ah .stack 4096 .data string byte 40 dup (?) number dword ? rejected byte cr, lf, "rejected", 0 .code _start: forever: input string, 40 atod string mov number, eax cmp number,0 jne processing je finish processing: cmp number,10 jg message cmp number,-10 jl message jmp forever message: output rejected jmp forever finish: invoke exitprocess, 0 public _start end i'm having difficulty adjusting assignment meet condition: make sure jump forward bottom of loop, , there top, every jump top comes same place. i have accomplished task seem jumping multiple places. how adjust program meet condition. you need change code have one jmp forever . label can jump several places jmp forever . suggestion: processing: cmp numb

php - PayPal not returning variables -

i'm adding paypal checkout form. rather using api, use form script. however, i'm not getting response variables paypal after payment has been made. confirm amount of money received see if user has paid amount should've paid. since dont receive response variables paypal, cannot see whether user has indeed paid amount of money. doing wrong? see alot of people have problems , none of them had answer. my form: <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" > <input type="hidden" name="business" value="seller@seller.com"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="upload" value="1" /> <input type="hidden" name="item_name" value="<?php echo $_amount_cred

go - How to construct an $or query in mgo -

i trying convert js mongodb query go mgo query: var foo = "bar"; db.collection.find({"$or": [ {uuid: foo}, {name: foo} ] }); this i've got far, doesn't work: conditions := bson.m{"$or": []bson.m{bson.m{"uuid": name}, bson.m{"name": name}}} edit: seem work now. maybe had typo somewhere. here complete example works fine me (with go 1.4, , mongodb 2.6.5) package main import ( "fmt" "log" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type person struct { num int uuid string name string } func main() { // connect database session, err := mgo.dial("localhost") if err != nil { panic(err) } defer session.close() // remove people collection if c := session.db("test").c("people") c.dropcollection() // add data err = c.insert(&person{ 1, "uuid1"

sharepoint - Pause ItemAdded event till all the attachments are added to it -

i have list item multiple attachments added it. added itemadded event fired. but if try access properties.listitem.attachments property, gives me 0 or number less original attached attachments. if sleep thread few seconds, rest of attachments in properties.listitem.attachments property. looks itemadded event being called before attachments added list item. is there way me pause itemadded event till attachments added list item? use itemattachedadded event.

.net - System.Diagnostics.Process.Kill doesn't work properly. C# -

i have winform (.net 4.5 c#) application have backgroundworker start new process using code below. void bw_dowork(object sender, doworkeventargs e) { backgroundworker bw = sender backgroundworker; string filename_ = e.argument.tostring(); process myprocess = new process(); int exitcode = 0; try { if (!file.exists(filename_)) { throw new filenotfoundexception("failed locate " + filename_); } #region start info: processstartinfo startinfo = new processstartinfo(filename_); startinfo.useshellexecute = false; startinfo.createnowindow = true; startinfo.redirectstandardoutput = true; startinfo.redirectstandarderror = true; myprocess.startinfo = startinfo; #endregion myprocess.start(); streamreader mystreamreader = myprocess.standardoutput;

c++ - “Overload” function template based on function object operator() signature in C++98 -

i want make template function takes function , vector , uses function map vector vector returned function template. if function taken argument free function, may have 1 of 2 signatures. // t parameter of function template t sig1(const t x); t sig2(const t x, const std::vector<t>& v); it may function object in operator() behave free functions. use of function template of 4 possibilities should transparent. std::vector<int> v; // ... fill v somehow ... // foo either free function or function object instance const std::vector<int> = map_vec(foo, v); i asked how c++11 , got great answer 0x499602d2. "overload" function template based on function object operator() signature 0x499602d2's answer makes use of fact these 2 distinct template signatures in c++11: template<typename f, typename t> auto map_vec(f&& fnc, const std::vector<t>& source) -> decltype(void(fnc(std::declval<t>())), std::vector<t

javascript - How to create a function that sorts a numeric array and be able swap arrays on the fly? -

this code var content = [ 409, 879, 483, 465, 907, 154, 838, 847 ]//the array var result = content.sort( function( a, b ){ return - b } )//this works alert( result )//works. want able swap out arrays below function order( ary )//this function returns undefined, why? { ary.sort( function( a, b ){ return - b } )//order numbers least greatest; } var result = order( content ); alert( result )//returns undefined not sure why order function returns undefined, yet outside of function code works? allow order function accept array when called. , yes i'm newbie. you should return result function order( ary ) { return ary.sort( function( a, b ){ return - b } )//order numbers least greatest; } demo: http://jsbin.com/?js,console

xcode - Limit Mac app Beta usage to selection of UDID-approved devices -

i have mac app created in xcode, , signed "mac app store" application, default team provisioning profile. have 2 udids registered in member center, , can run application on of devices (expected)... on other non-registered devices. is there way lock application registered udids purpose of beta testing? the documentation seems apply ios applications, , remains little unclear mac application procedure. oddly enough, wasn't able sign code udid-specific provisioning profile @ in xcode. however, setting provisioning profile restricted one, , setting code signing identity, able compile via command-line properly. now when loaded on machine other udid-approved ones, application fails launch (which desired behavior beta testing strategy).

rust - Why does an enum require extra memory size? -

my understanding enum union in c , system allocate largest of data types in enum. enum e1 { dblval1(f64), } enum e2 { dblval1(f64), dblval2(f64), dblval3(f64), dblval4(f64), } fn main() { println!("size {}", std::mem::size_of::<e1>()); println!("size {}", std::mem::size_of::<e2>()); } why e1 takes 8 bytes expected, e2 takes 16 bytes? in rust, unlike in c, enum s tagged unions . is, enum knows value holds. 8 bytes wouldn't enough because there no room tag.

ggplot2 - Output Plot and Table to Same Page for Each Group -

i trying output graph , table each group 1 page of pdf (one page each group). there having trouble final step. have both table , plot on same page table on top of plot. when move outside of plot window disappears. there way can put graph underneath plot (which outside of plot window)? here code: lss <- read.csv(file="withblanksfilled_4.csv",head=true, sep=",") # read in csv , name columns st<-lss$server_type tenant <- lss$tenant_n date<- lss$date_time ss <- lss$max_load_source_size df1 <- data.frame(st, tenant, date, ss) #create graph populated output of dlply library(ggplot2) library(scales) library(grid) library(gridextra) library(gtable) p<-ggplot(df1, aes(x=as.date(date, "%d/%m/%y %h:%m"), y=ss))+geom_point()+labs(x="date", y="load source size")+facet_wrap(~st+tenant, ncol=1)+scale_x_date(breaks = date_breaks("week"), minor_breaks=date_breaks("1 day"), labels = date_format("%d-%

php - jQuery check if username is taken -

ok, driving me nuts. have tried ton of other answers here, no avail , hate having post has been beaten death, cant work. i checking db see if username exists , no matter type in (whether existing or not), return says name available. if run check , dump screen, correct returns printed. <?php $query = new application_model_queries(); $false = $query->usernames('vikingblooded'); print_r( $false); //prints 1 $true = $query->usernames('someonespecial'); print_r($true); prints nothing ?> javascript: $(document).ready(function () { $("#username").keyup(function () { $("#message").html("<img src='<?php echo $this->baseurl('images/ajax-loader.gif'); ?>' class='status' /> checking..."); var username = $("#username").val(); $.ajax({ method: "post", url: "<?php echo $this->baseurl('

wordpress - Save cart on the current session -

i'm building wordpress ecommerce site woocommerce plugin, turns when user gets logged in , add products cart, user don't want proceed checkout process, user prefers logout , continue checkout process later... when user comes , gets logged in again cart empty. what going on here?. normal behavior of woocommerce?. have else? maybe plugin? thanks. i thought cart emptied when user logs out, , tracked down. on wp_logout() wordpress runs wp_clear_auth_cookie() function. wp_clear_auth_cookie() triggers do_action( 'clear_auth_cookie' ); action hook. woocommerce's session handler class runs it's destroy method on hook. add_action( 'clear_auth_cookie', array( $this, 'destroy_session' ) ); the destroy_session() method calls wc_empty_cart() function, wrapper cart class's empty_cart() method. wc()->cart->empty_cart( false ); but key thing here parameter false . because when track down empty_cart() method see d

c# - Include image from website in mailitem.HTMLBody -

i developing add-in microsoft outlook adds image right before tag of html body. image located on remote server source of image tag http://someserver.com/image.jpg this works expected on fresh e-mail ( aka new e-mail ) when user clicks reply, or forward reason image source gets changed cid:image001.jpg , actual image source gets put in alt tag. i altering body on send event want image added after e-mail finished being written. the code run @ send event void outlookapplication_itemsend(object item, ref bool cancel) { if (item outlook.mailitem) { outlook.mailitem mailitem = (outlook.mailitem)item; string image = "<img src='http://someserver.com/attach.jpg' width=\"100\" height=\"225\" alt=\"\" />"; string body = mailitem.htmlbody; body = body.replace("</body>", image + "</body>"); mailitem.bodyformat = outlo

verilog - Up Down counter code -

i need in project counter counts or down 0 20. did counter code , it's working in active hdl. need show numbers in 7-segment in nexys 3 fpga board. i have code of segment, have problem when call module of segment - giving me error in active hdl. can please tell me error? this current code : module main #(parameter n=7) ( input switch, input button, input fastclk, output [3:0] enable, output reg[6:0] out ); wire[n:0]count; wire slowclk; clock c1(fastclk,slowclk); updown u1(switch,button,slowclk,count); segment s1([3:0]count,[7:4]count,fastclk,enable,out); endmodule module clock(fastclk,slowclk); //clock code input fastclk; output wire slowclk; reg[25:0]period_count = 0; @(posedge fastclk) begin period_count <= period_count + 1; end assign slowclk = period_count[25]; endmodule module updown // updown counter #(parameter n=7) ( input switch, i

Rails 4 - When assigning attributes, you must pass a hash as an argument -

can me figure out why getting following error? when assigning attributes, must pass hash argument. the form: <%= form_for([current_user, current_user.suggestions.build]) |f| %> <%= f.label :category %>: <%= f.select :category, ['startup', 'cars', 'kids', 'food', 'other'] %> <br> <%= f.text_area :suggestion %><br> <%= f.submit 'submit suggestion' %> <% end %> suggestioncontroller: def create @suggestion = current_user.suggestions.create(suggestion_params) end private def suggestion_params params.require(:suggestion).permit(:suggestion, :category) redirect_to shirts_path end applicationcontroller: helper_method :current_user private def current_user @current_user ||= user.find(session[:user_id]) if session[:user_id] end suggestion_params returning last line of method redirect_

sql - Java app: Connect to PostgreSQL database -

i attempting connect postgres sql database. normally, can connect going link: test.ischool.testu.edu where connect phppgadmin entering credentials, , can connect database, testdb, selecting side. here relevant java code: try { class.forname("org.postgresql.driver"); } catch (classnotfoundexception e1) { e1.printstacktrace(); } string url = "jdbc:postgresql://test.ischool.testu.edu:5432/testdb"; string user = "testuser"; string pass = "testpassword"; connection db = null; try { db = drivermanager.getconnection(url,user,pass); } catch (sqlexception e1) { e1.printstacktrace(); } i receive following error: org.postgresql.util.psqlexception: connection refused. check hostname , port correct , postmaster accepting tcp/ip connections. i'm pretty sure doing wrong. assuming code correct (which i'm sure not case), connect database, need have .jar

python - Finding a subdirectory that matches a file name -

i'm pretty new python, grateful help. i'm trying find subdirectory in specified directory matching title of specified zip file. there folder titled "1008" in "projects" folder i'm not sure what's wrong. here code: import os zipfiles = r'c:\temp\python_test\zipped_files\1008.zip' prjfolder = r'c:\temp\python_test\projects' prjnum = os.path.basename(zipfiles) prjnum = os.path.splitext(prjnum) prjnum = prjnum[0] prjlist = os.walk(prjfolder).next()[1] prjlist = map(int, prjlist) if prjnum in prjlist: print "yes" else: print "no" since know name of directory looking for, check see if exists import os zipfiles = r'c:\temp\python_test\zipped_files\1008.zip' prjfolder = r'c:\temp\python_test\projects' prjnum = os.path.basename(zipfiles) prjnum = os.path.splitext(prjnum) prjnum = prjnum[0] print os.path.isdir(os.path.join(prjfolder, prjnum))

python - SQLAlchemy: filter on operator in a many-to-many relationship -

i have 2 classes many-to-many relationship, items , categories . categories have associated value. i query items highest categorie.value (if there any) less given value. so far have tried queries this: from sqlalchemy.sql import functions session.query(items).join(categories,items.categories).filter(functions.max(categories.value)<3.14).all() but in case (operationalerror) misuse of aggregate function max() error. is there way make query? you need group by , having instead of where filtering on aggregate. session.query(items).join(items.categories).group_by(items.id).having(functions.max(categories.value)<3.14).all() edit: include items without category, believe can outer join , put or in having clause: session.query(items).outerjoin(items.categories).group_by(items.id)\ .having( (functions.max(categories.value)<3.14) | (functions.count(categories.id)==0) )\ .all()

excel 2010 - Categorize cells by keywords -

i not if excel can trying simplify data dump twitter. basically this: if tweet (in column a) contains apple or orange or pear can classified (in column b) "fruit" if has carrot or squash or lettuce classified "vegetable". if has none of these can classified "none" is possible? thanks in advance. here using array constant , range . =if(sumproduct(if(iserror(search({"apple","orange","pear"},a1)),0,1))>0,"fruit",if(sumproduct(if(iserror(search({"carrot","squash","lettuce"},a1)),0,1))>0,"vegetable","none")) now example, both fruit , vegetable present in string, test fruit first since way formula arranged. (e.g. "more apple on salad lettuce" return "fruit"). can use range contains list instead of array constant. example, can put fruit list in column c (c1:c3) , vegetable list in column d (d1:d3). formula be: =if(sump

javascript - Is it possible to wildcard for an attribute name with a wildcarded attribute? -

i have [src*=example] selects html elements 'src' attribute containing 'example'. possible target attributes, pretty resulting in wildcarding attributes? more or less, [(any attribute)*=example] find elements attribute containing 'example'. thanks in advance! no. there's no such selector in css date! using jquery: $('*').filter(function(){ var selector = this; return $.grep(selector.attributes, function(attr) { return attr.value.indexof('example') !==-1 }).length > 0; }).css('color','red');

reload - TypeError: $.fn.datagrid.methods[_6dc] is not a function -

firebug 2.0.6 showing jquery type error using jquery-easyui. i know has been asked before , i've spent couple of hours ploughing through answers , i'm getting deeper , deeper. has seen in firebug? typeerror: $.fn.datagrid.methods[_6dc] not function... return $.fn.datagrid.methods_6dc; in http://www.jeasyui.com/easyui/jquery.easyui.min.js on line 9523 i have copied code straight site follows: <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> and function destroyuser(){ var row = $('#tbldata').datagrid('getselected'); if (row){ $.messager.confirm('confirm','are sure want destroy user?',function(r){ if (r){ $.post('destroy_user.php',{id:row.id},function(result){ if (result.success){

javascript - RequireJS - config; paths and shims not working -

i have common.js defines config requirejs: (function(requirejs) { "use strict"; requirejs.config({ baseurl: "/js", paths: { "jsroutes": "http://localhost:8080/app/jsroutes" }, shim: { "jsroutes": { exports: "jsroutes" } } }); requirejs.onerror = function(err) { console.log(err); }; })(requirejs); i have main.js file try use jsroutes path created: require(["./common", "jsroutes"], function (common, routes) { // interesting }); but not load resource @ http://localhost:8080/app/jsroutes instead tries load http://localhost:8080/js/jsroutes.js when main.js executed. resouce doesn't exist , 404. how jsroutes path work correctly? need shim (i'm not 100% sure)? i can debug common.js file, paths should being set, right? update 1 i believe paths should work

excel - VBA - Remove duplicates from bottom -

i running loop add notes end of running list. having problem removing duplicates based on identifier in column 1. following code works if duplicates same in both columns. sub note_update() dim ws worksheet dim notes_ws worksheet dim row dim lastrow dim notes_nextrow 'find worksheet called notes each ws in worksheets if ws.name = "notes" set notes_ws = ws end if next ws 'get nextrow print notes_nextrow = notes_ws.range("a" & rows.count).end(xlup).row + 1 'loop through other worksheets each ws in worksheets 'ignore notes worksheet if ws.name <> "notes" , ws.index > sheets("master").index 'find lastrow lastrow = ws.range("l" & rows.count).end(xlup).row row = 2 lastrow 'if cell not empty if ws.range("l" & row) <> "" notes_ws.range("b" & notes_nextrow).value = ws

Removing horizontal gap between image tags HTML/CSS -

Image
this question has answer here: remove white space below image [duplicate] 9 answers i practicing html , css , ran annoying problem. wondering horizontal gap , how remove it? thanks in advance <!doctype html> <html lang="en"> <head> <title>practice</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta content="text/html;charset=utf-8" http-equiv="content-type" /> <meta content="utf-8" http-equiv="encoding" /> <style> html,body { margin:0; padding:0; height:100%; } </style> </head> <body> <script src="./js/jquery.js"></script> <img id="sample-img" src="green-n

database - What is the missing operator in my command? -

my program works perfectly, problem when database has been updated, alert box appear saying: syntax error (missing operator) in query expression 'id='. private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim choice string choice = msgbox("do want delete?", msgboxstyle.yesno) if choice = vbyes cnn = new oledb.oledbconnection("provider=microsoft.ace.oledb.12.0;data source=database.accdb") dim str string = ("delete tablename id= " & combobox1.text & "") command = new oledb.oledbcommand(str, cnn) da = new oledb.oledbdataadapter(command) cnn.open() command.executenonquery() form1.timer1.enabled = true clearfields() form1.timer1.enabled = false me.close() end if cnn.close() end sub it says error located here: (id autonumber.) dim str string = ("delete tablename id= &quo

python - Create PDF from a list of images -

is there practical way create pdf list of images files, using python? in perl know that module . can create pdf in 3 lines: use pdf::fromimage; ... $pdf = pdf::fromimage->new; $pdf->load_images(@allpagesdir); $pdf->write_file($bookname . '.pdf'); i need similar this, in python. know pypdf module, simple. @edit if came through google, here's code: from fpdf import fpdf pil import image def makepdf(pdffilename, listpages, dir = ''): if (dir): dir += "/" cover = image.open(dir + str(listpages[0]) + ".jpg") width, height = cover.size pdf = fpdf(unit = "pt", format = [width, height]) page in listpages: pdf.add_page() pdf.image(dir + str(page) + ".jpg", 0, 0) pdf.output(dir + pdffilename + ".pdf", "f") install fpdf python : pip install fpdf now can use same logic: from fpdf import fpdf pdf = fpdf() # imagelist list image

r - calculate moving window correlation coefficients between one x and hundreds of y variables, then create a new dataframe of r-values -

i calculate 11-year moving window pearson correlation coefficients between 1 column of temperature data , growth many plants (e.g., hundreds thousands of plants). here's limited example of dataframe like: dat <- as.data.frame(rbind(c(1945,11.4,0.508,0.160,0.419,0.255), c(1946,12.5,0.065,0.127,0.881,0.541), c(1947,12.4,0.162,0.142,0.539,0.447), c(1948,12.9,0.274,0.102,0.862,0.728), c(1949,11.1,0.284,0.042,1.863,0.126), c(1950,13.0,0.015,0.109,1.925,0.142), c(1951,13.3,0.001,0.160,1.585,0.245), c(1952,12.2,0.233,0.033,1.199,0.076), c(1953,13.4,0.169,0.123,1.729,0.529), c(1954,12.6,0.135,0.166,1.754,0.171), c(1955,11.7,0.275,0.167,1.389,0.382), c(1956,11.9,0.092,0.032,0.697,0.325), c(1957,13.3,0.054,0.105,1.387,0.178), c(1958,13.4,0.311,0.041,1.585,0.593))) names(dat)<-c("year", "temp", "plant1", "pl

echo - Why won't PHP print 0 value? -

i have been making fahrenheit celsius (and vise versa) calculator. of works great, when try calculate 32 fahrenheit celsius it's supposed 0, instead displays nothing. not understand why not echo 0 values. here code: <?php // celsius , fahrenheit converter // programmed clyde cammarata $error = '<font color="red">error.</font>'; function tempconvert($temptype, $givenvalue){ if ($temptype == 'fahrenheit') { $celsius = 5/9*($givenvalue-32); echo $celsius; } elseif ($temptype == 'celsius') { $fahrenheit = $givenvalue*9/5+32; echo $fahrenheit; } else { die($error); exit(); } } tempconvert('fahrenheit', '50'); ?> looks $celcius has value 0 (int type) not "0" (string type), wont echoed because php read false (0 = false, 1 = true). try change code echo $celcius; to echo $celcius.""; or echo (stri

c# - How to use StreamSocket? -

i want know how use streamsocket in windows runtime, searched couldn't find way. i need point, should start from? thanks create streamsocketlistener , implement http server. know, browser request like: get / http/1.1 host: yourphone connection: keep-alive you can return list of links. http/1.1 ok 200 content-lnegth: <number of bytes> content-type: text/html connection: keep-alive <html> <body> <a href="/file1">file 1</a> ... notice can receive connections , reply when app in foreground. when app suspended, connections frozen. accomplish this, may ask user stick around , show chipmunk dancing.

cpu usage - Google App Engine : High CPU Utilization -

i have around 5 projects, simple under construction message on google app engine , suspended following reason : violation of cloud platform terms of service when contact google team, got : xxxx, can provide detailed description projects doing? detected high cpu utilization each of projects. xxxx. assuming pages/content in application according tos, can't use allotted instance it's full peak? i tried finding cpu utilization in cloud platform's tos. nothing found. what limitations of using instance's cpu utilization per google's cloud platform terms of service? what might other reasons, might lead suspension of google app engine project contains single under construction page? these domains has hardly visits. not sure if these logs saying anything, of logs website follows : 2014-11-25 17:29:48.342 200 1.23 kb 30ms / 192.99.107.208 - - [25/nov/2014:03:59:48 -0800] "get / http/1.1" 200 1257 - "mozilla/5.0 (compatible; meanpat

c# - How to create a Dictionary using foreach statement -

i have model tasks, in each task had write down name of client, have model clients contains id, name, adress , phone number. can create customer manually when create task, supposed have dropdownlist contains every customer created it's pretty hard me explain you... know have create dictionnary , add customers in dictionnary foreach. can any1 me showing me examples? if need more details let me know appreciate help using system; using system.collections.generic; using system.componentmodel; using system.componentmodel.dataannotations; using system.configuration; using system.data; using system.data.sqlclient; using system.linq; using system.security.cryptography; using system.text; using system.web; namespace taskmanager.models { public class client { public int id { get; set; } public string nom { get; set; } public string adresse { get; set; } public int numerotelephone { get; set; } public static list<client> get

excel - How to make multiple requests to Yahoo Finance to get around the 200 stock limit? -

i have developed excel sheet (with online tutorial) pulls stock information yahoo finance. here code have far: private sub btnrefresh_click() dim w worksheet: set w = activesheet dim last integer: last = w.range("a1000").end(xlup).row if last = 1 exit sub dim symbols string dim integer = 2 200 symbols = symbols & w.range("a" & i).value & "+" next symbols = left(symbols, len(symbols) - 1) dim url string: url = "http://finance.yahoo.com/d/quotes.csv?s=" & symbols & "&f=sl1w1t8ee8rr5s6j4m6kjp5" dim http new winhttprequest http.open "get", url, false http.send dim resp string: resp = http.responsetext dim lines variant: lines = split(resp, vbnewline) dim sline string = 0 ubound(lines) sline = lines(i) if instr(sline, ",") > 0 values = split(sline, ",") w.cells(i + 2, 4).value = values(1) w.cells(i + 2, 5).value = right(replace(values(2), chr

in ionic how to add a fixed logo bar at top -

i starting ionic framework hybrid app, , stuck right @ gates! want fixed-top bar having logos , search icon; , rest of content consisting of - context dependent menu followed content. i started 1 of start apps "sidemenu" ionic website , modified it. <ion-nav-bar class="logo-bar"> <button class="button button-clear"> <img class="pull-left" src="img/yourcompany-trans.png"> </button> <div class="title icon ion-search" ng-click="dosearch()"> </div> <button class="button button-clear"> <img class="pull-right" src="img/mycompanylogo.png"> </button> </ion-nav-bar> <ion-nav-view> </ion-nav-view> </body> but logo/search bar not appear @ all. if remove ion-nav-view can visualize it. have tried other combinations, placing within nav-view, using ion-content still stuck

Syntax Error Python 3 When Calling Function -

i cannot understand why keep getting syntax error in python 3 program on line 78. trying call function 2 parameters. reporthits(playerlist, num) i have checked indents, spacing, colons, , looked online nothing have done has fixed it. any appreciated! def quit(): """this function quits baseball database""" print("you leaving baseball database") print("program terminating gracefully...") def help(): """this function displays list of program functions user""" print("quit - exit progam") print("help - display list of functions") print("input - input file_path") print("team - sort baseball database team name identifier") print("report - sort baseball database number of hits") def filepath(): """this function allows users input file""" fileobject = input("please enter

wpf - How to bind a property of a user control to the MainViewModel and bind its datacontext to its own viewmodel? -

a newbie binding question. have multiple usercontrols called mainview.xaml, like: <i:inkrichtextview richtext ="{binding lastnote}" ... /> where richtext dependency property in code-behind of inkrichtextview.xaml user control , lastnote property of mainviewmodel. the mainviewmodel associated implicitly mainview way of datatemplate in app.xaml, like: <datatemplate datatype="{x:type vm:mainviewmodel}"> <v:mainview/> </datatemplate> i set usercontrol inkrichtextview own viewmodel, property of being held in mainviewmodel, like: <i:inkrichtextview richtext ="{binding lastnote}" datacontext="{binding ucfirstcontrol}" ... /> but when so, user control inkrichtextview loses context lastnote (or looses access dependency property in code-behind, or both??). how can maintain binding mainviewmodel's property of lastnote , still provide separate datacontext user control? (keep in mind usercont

webview - Way to show code snippet in android app? -

i want show code snippet in android application . know can use webview. is there other (better) way ? i want show them fetched db , formatted in code style. as per android developer forum, regarding webview : if goal display html part of ui, fine; user won't need interact web page beyond reading it, , web page won't need interact user. but need users / dislike / comment on code snippet. how can achieved ? of now, can think of using webview + android textview / editview is there better (or efficient) way ?

Ubuntu 12.04 unable to save all settings -

i reinstalled ubuntu while keeping /home folder of last version of ubuntu remaining. not able save settings more. every time lock program launcher, disappeared after restarting system. also, not able change background image. click pictures in background setting dialogue background never change. what wrong ubuntu 12.04? as have expected, issue privilege. executing chmod -r u+wr . in terminal. problem solved.