VisualC++ 2008
This file contains hidden or 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
snippet updr | |
options(repos=c(CRAN='http://cran.revolutionanalytics.com')) | |
update.packages(ask=F) | |
snippet package.installer | |
install.packages('devtools') | |
library(devtools) | |
install_github("ririzarr/rafalib") | |
essential <- c('data.table', 'dplyr', 'reshape2', 'ggplot2', 'foreach', 'tidyr', 'ggvis', |
This file contains hidden or 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
serList <- function(serlist){ | |
## Function to serialize list of R objects and returns a dataframe. | |
## The argument is a list of R objects. | |
## The function returns a serialized list with two elements. | |
## The first element is count of the elements in the input list. | |
## The second element, called payload, containts the input list. | |
## If the serialization fails, the first element will have a value of 0, | |
## and the payload will be NA. | |
## Messages to use in case an error is encountered. |
This file contains hidden or 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
def triangle(r): | |
def row(n, previous=None): | |
if n == 1: | |
return n+1, [1] | |
else: | |
rown = [] | |
rown.append(1) | |
for i in xrange(n): | |
if i + 1 < n-1: | |
rown.append(previous[i] + previous[i+1]) |
This file contains hidden or 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
# Plot at https://plot.ly/~jzegan/0 | |
# install.packages("devtools") | |
# library("devtools") | |
# install.packages("microbenchmark") | |
# install.packages("Lahman") | |
# install.packages('hflights') | |
# install.packages('RSQLite') | |
# install.packages('RSQLite.extfuns') | |
# devtools::install_github("dplyr") |
This file contains hidden or 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
SELECT DATETIME(1379478541.13277 + tz.gmt_offset, 'unixepoch', 'localtime') AS local_time, z.country_code, z.zone_name, tz.abbreviation | |
FROM timezone tz JOIN zone z | |
ON tz.zone_id=z.zone_id | |
WHERE tz.time_start < 1379478541.13277 AND z.zone_name='Europe/Warsaw' | |
ORDER BY tz.time_start DESC LIMIT 1; |
This file contains hidden or 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
#!/usr/bin/env python | |
# | |
# Copyright 2012 by Jeff Laughlin Consulting LLC | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
This file contains hidden or 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
# | |
# (c) 2011, 2012 Georgia Tech Research Corporation | |
# This source code is released under the New BSD license. | |
# Please see http://wiki.quantsoftware.org/index.php?title=QSTK_License | |
# for license details. | |
# Created on Sep 08, 2013 | |
# @original author: look QSTK installation directory |
This file contains hidden or 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
export MARKPATH=$HOME/.marks | |
function jump { | |
cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1" | |
} | |
function mark { | |
mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1 | |
} | |
function unmark { | |
rm -if $MARKPATH/$1 | |
} |
This file contains hidden or 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
import csv | |
import json | |
with open('metrics.json', 'r') as f: | |
data = json.load(f) | |
keys = data[0].keys() | |
writer = csv.DictWriter(open('metrics.csv', 'wb'), keys) | |
writer.writer.writerow(keys) | |
writer.writerows(data) |
NewerOlder