This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "by $USER" | |
git log --shortstat --author "$USER" \ | |
| grep "files\? changed" \ | |
| awk '{files+=$1; inserted+=$4; deleted+=$6} END \ | |
{print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}' | |
echo "total" | |
git log --shortstat \ | |
| grep "files\? changed" \ | |
| awk '{files+=$1; inserted+=$4; deleted+=$6} END \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class str_const { // constexpr string | |
private: | |
const char* const p_; | |
const std::size_t sz_; | |
public: | |
template<std::size_t N> | |
constexpr str_const(const char (&a)[N]) : // ctor | |
p_(a), sz_(N - 1) { | |
} | |
constexpr char operator[](std::size_t n) { // [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(graphics) | |
#some data | |
d <- density(faithful$eruptions, bw = "sj") | |
#make it a time series | |
ts_y<-ts(d$y) | |
#calculate turning points (extrema) | |
require(pastecs) | |
tp<-turnpoints(ts_y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(xts) | |
library(ggplot2) | |
#cad gdp | |
#curl http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/03790031-eng.zip -o /tmp/ca.gpd.zip && unzip /tmp/ca.gpd.zip -d /tmp | |
#curl http://www.statcan.gc.ca/cgi-bin/sum-som/fl/cstsaveascsv.cgi?filename=gdps04a-eng.htm&lan=eng -o | |
#http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/03790031-eng.zip | |
#Ref_Date,GEO,SEAS,PRICES,NAICS,Vector,Coordinate,Value | |
if( !exists( "ca.gdp" ) ) { | |
ca.gdp <- read.csv("/tmp/03790031-eng.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#$ curl -o /tmp/cad.cpi.csv http://www.statcan.gc.ca/daily-quotidien/160122/cg160122a001-eng.csv | |
# "The 12-month change in the Consumer Price Index (CPI) and the CPI excluding gasoline, 12-month % change" | |
# ,"CPI","CPI excluding gasoline" | |
library(ggplot2) | |
cad.cpi <- read.table( "/tmp/cad.cpi.csv", sep = ",", col.names=c("date", "cpi", "exgas"), skip=2, fill=T ) | |
cad.cpi <- cad.cpi[1:(nrow( cad.cpi ) - 1),] | |
cad.cpi$date = as.Date( paste( cad.cpi$date, '01' ), "%B %Y %d" ) | |
df <- data.frame(cad.cpi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
sstash = "!f() { git stash save $1; }; f" | |
sshow = "!f() { echo $@; git stash show stash^{/$*} -p; }; f" | |
sapply = "!f() { git stash apply stash^{/$*}; }; f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* AlmostEqual.h | |
* | |
*/ | |
#ifndef ALMOSTEQUAL_H_ | |
#define ALMOSTEQUAL_H_ | |
// Usable AlmostEqual function - http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm | |
bool AlmostEqual(float A, float B) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/02820087-eng.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
#curl 'http://research.stlouisfed.org/fred2/series/PAYEMS/downloaddata' --data 'form%5Bnative_frequency%5D=Monthly&form%5Bunits%5D=lin&form%5Bfrequency%5D=Monthly&form%5Baggregation%5D=Average&form%5Bobs_start_date%5D=1939-01-01&form%5Bobs_end_date%5D=2015-01-01&form%5Bfile_format%5D=csv&form%5Bdownload_data_2%5D=' -o /tmp/PAYEMS.csv | |
nfp <- read.csv("/tmp/PAYEMS.csv") | |
nfp$DATE <- as.Date( nfp$DATE, "%Y-%m-%d" ) | |
df <- data.frame( change=diff(nfp$VALUE), date=tail(nfp$DATE,-1) ) | |
plot <- ggplot(df,aes(x=date,y=change)) + | |
geom_area() | |
plot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#curl http://www.dailyfx.com/files/Calendar-02-01-2015.csv -o /tmp/Calendar-02-01-2015.csv | |
cal <- read.csv("/tmp/Calendar-02-01-2015.csv") |
NewerOlder