Posts

path - Sublime Text 2 and Repl - Run python -

i start using sublime text 2 , repl , got problems. when run file tells me file du not exist. script works perfect if build directly terminal. code def stopwords(text): open('danish', 'ru') f: line in f: text = text.replace(' '+line.strip()+' ', "") return text log ioerror: [errno 2] no such file or directory: 'danish' i have tried things os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) reload(sys) , __file__ not work. any ideas why __file__ don't work when running through sublime text 2 repl or file stored??

javascript - jQuery php variable echo not working -

i have little contact form, ask user calculate , enter correct value in order prevent spam. now, when send button clicked, fire php script, change calculation values. echo these values , show them new placeholder in case of both, success, failure. $("#send_button").click(function() { var url = "contact.php"; // script handle form input. $.ajax({ type: "post", url: url, data: $("#contact_form").serialize(), // serializes form's elements. success: function(data) { var txt = "<?php echo 'spam protection: calculate ($first_num + $second_num) x $multiplier';?>"; $("#form_info_label").css('color','#0ed68d'); $("#form_info_label").text(data); $("#user_answer").attr("pla...

java - Exporting variables with multiple values? -

import java.util.*; import java.text.*; import java.io.*; public class avgtime { static double hrs1; static double min1; public static void main(string[] args) throws interruptedexception, filenotfoundexception { scanner in = new scanner(system.in); system.out.print("how many times? "); int numoftimes = in.nextint(); double hrtotal = 0; double mintotal = 0; (int = 1; <= numoftimes; i++){ system.out.println("\nenter time in military time notation: "); system.out.print("hour "); double hrs1 = in.nextdouble(); system.out.print("minute "); double min1 = in.nextdouble(); hrtotal += hrs1; mintotal += min1; } //calculate average double avghr1 = hrtotal/numoftimes; double timemin1 = math.round(mintotal/numoftimes); decimalformat df = new decimalformat("###"); string hours = df.format(avghr1); string minutes = df.format(timemin1); string time = hours+":"+minutes+":"+00; string mt = hours+...

google apps script - Collect Data from several Spreadsheets and copy it into another sheet -

i want copy data 1 spreadsheet one. 1. data on several sheets 2. columns (just speed up, don't need columns) for beginning used following script: function copydatatonewfile() { var sss = spreadsheetapp.openbyid('0ajn7uzg....'); // sss = source spreadsheet var ss = sss.getsheetbyname('monthly'); // ss = source sheet //get full range of data var srange = ss.getdatarange(); //get a1 notation identifying range var a1range = srange.geta1notation(); //get data values in range var sdata = srange.getvalues(); var tss = spreadsheetapp.openbyid('8ajn7u....'); // tss = target spreadsheet var ts = tss.getsheetbyname('rawdata'); // ts = target sheet //set target range values of source data ts.getrange(a1range).setvalues(sdata); } i took 1 user2741, posted here : ..this 1 works fine 1 sheet. unsure how data more sheets , sort it. has idea on how this? thank all, sascha this 1 here works, if happens in same spreadsheet ...

Listening to events in Durandal -

i'm reviewing durandal documentation, , can't find concrete implementation of listening durandal events , e.g, router events . can point me docs, or (if there no documentation on this) example? in view model should listen activator events. link . check example durandal starter template. listening activate , candeactivate events: define(['plugins/http', 'durandal/app', 'knockout'], function (http, app, ko) { //note: module exports object. //that means every module "requires" same object instance. //if wish able create multiple instances, instead export function. //see "welcome" module example of function export. return { displayname: 'flickr', images: ko.observablearray([]), activate: function () { //the router's activator calls function , waits complete before proceding if (this.images().length > 0) { return; ...

Multidimensional sparse matrices in Julia -

why aren't there multidimensional sparse matrices/arrays in julia? why can have 2d sparse matrices , not example 3d sparse matrices (or arrays)? the problem understand (i'm not sparse linear algebra expert, although viral shah, 1 of other julia co-founders is) libraries (e.g. suitesparse) doing sparse computations matrix-only. don't support sparse vectors , don't support higher dimensional tensors either. define types higher-dimensional sparse tensors, wouldn't able useful them.

reshaping time series data in R -

i have quarterly time series economic data imf ifs need long form. right now, rows variables per country , columns time, looks this. country variable q1 q2 [1,] "usa" "inflation" "1" "5" [2,] "usa" "gdppc" "2" "6" [3,] "uk" "inflation" "3" "7" [4,] "uk" "gdppc" "4" "8" i need long form: country time inflation gdppc [1,] "usa" "q1" "1" "2" [2,] "usa" "q2" "5" "6" [3,] "uk" "q1" "3" "4" [4,] "uk" "q2" "7" "8" i haven't been able find advice on using reshape when id variable , measurement variables both in rows. it partial melt followed dcast in reshape...