Skip to content

Instantly share code, notes, and snippets.

@asaaki
asaaki / pygments-monokai.css
Created June 4, 2011 00:57
Jekyll module for github like source code highlighting
.highlight { background-color: #49483e }
.c { color: #75715e } /* Comment */
.err { color: #960050; background-color: #1e0010 } /* Error */
.k { color: #66d9ef } /* Keyword */
.l { color: #ae81ff } /* Literal */
.n { color: #f8f8f2 } /* Name */
.o { color: #f92672 } /* Operator */
.p { color: #f8f8f2 } /* Punctuation */
.cm { color: #75715e } /* Comment.Multiline */
.cp { color: #75715e } /* Comment.Preproc */
@jaymcgavren
jaymcgavren / heroku.md
Created May 25, 2012 05:47
A Code TV screencast on getting started with Heroku

Description

Heroku is a simple way to publish your Rails app, and a powerful platform that will allow it to scale. In this episode, Jay McGavren gets you started with your first Heroku app.

Set up your Rails app

Isolate your gem environment

  • You WANT Rails to fail locally if a gem isn't in your Gemfile
@olasitarska
olasitarska / pgessays.py
Created November 18, 2012 10:11
Builds epub book out of Paul Graham's essays.
# -*- coding: utf-8 -*-
"""
Builds epub book out of Paul Graham's essays: http://paulgraham.com/articles.html
Author: Ola Sitarska <ola@sitarska.com>
Copyright: Licensed under the GPL-3 (http://www.gnu.org/licenses/gpl-3.0.html)
This script requires python-epub-library: http://code.google.com/p/python-epub-builder/
"""
@rweald
rweald / convert-lat-long-to-state.R
Created February 6, 2013 06:40
Convert (long,lat) pairs into state names
#Code taken from SO
#http://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r/8751965#8751965
library(sp)
library(maps)
library(maptools)
# The single argument to this function, pointsDF, is a data.frame in which:
# - column 1 contains the longitude in degrees (negative in the US)
# - column 2 contains the latitude in degrees
galton <- read.csv("http://blog.yhathq.com/static/misc/galton.csv",
header=TRUE, stringsAsFactors=FALSE)
summary(galton)
# child parent
# Min. :61.7 Min. :64.0
# 1st Qu.:66.2 1st Qu.:67.5
# Median :68.2 Median :68.5
# Mean :68.1 Mean :68.3
# 3rd Qu.:70.2 3rd Qu.:69.5
# Max. :73.7 Max. :73.0
# Thanks to this post:
# http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x
$ brew install cabextract
$ cd ~/Downloads
$ mkdir consolas
$ cd consolas
$ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
$ cabextract PowerPointViewer.exe
$ cabextract ppviewer.cab
@FrozenQuant
FrozenQuant / Faber Monitor Web.Rmd
Last active January 1, 2016 13:39
R Markdown file for watching a Faber strategy
Faber Strategy Monitor
========================================================
This post was created in R using Markdown and posted directly to WordPress. It creates a table of data and a set of price charts for tracking funds used in Mebane Faber's trend following strategy. Data is gathered from Yahoo Finance using the API in the **quantmod** package, then rendered into a web page using RStudio and [***knitr***](http://yihui.name/knitr/), with the help of **googleVis** and **ggplot2**.
This particular implementation of the Faber strategy comes from his book *The Ivy Portfolio*. The program is to invest in a broad array of markets and buy individual ETFs when the price of the ETF exceeds its 10-month moving average and sell when it goes below. This particular example uses ten ETFs, two in each major category (as shown in Table 9.2 of *The Ivy Portfolio*).
The table shows some basic information about each ETF, the current price versus the 10-month SMA, and the same price/SMA data as of the prior m
{
"metadata": {
"language": "Julia",
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@ayman
ayman / areagraph.R
Created March 13, 2014 15:04
Some code for making AreaGraphs in R (from a tutorial but I made some memory and speed optimizations).
# Type 0: stacked area, 1: themeriver, 2: streamgraph
areaGraph <- function(thedata, type=2, smooth=TRUE) {
## Color palette
nColors <- 15
## pal <- colorRampPalette(c("#0f7fb4", "#e2e2e2"))
## pal <- colorRampPalette(c("#6364a9", "#e2e2e2")) # Purple
pal <- colorRampPalette(c("#48611d", "#f0f0f0"))
colors <- pal(nColors)
weights <- rowSums(thedata)
## Sort the data
@ceteri
ceteri / 01.repl.txt
Last active April 17, 2022 18:46
Intro to Apache Spark: general code examples
$ ./bin/spark-shell
14/04/18 15:23:49 INFO spark.HttpServer: Starting HTTP Server
14/04/18 15:23:49 INFO server.Server: jetty-7.x.y-SNAPSHOT
14/04/18 15:23:49 INFO server.AbstractConnector: Started SocketConnector@0.0.0.0:49861
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 0.9.1
/_/