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
-- A nice collection of FizzBuzz implementations | |
-- GistID: 5313582 | |
module Main where | |
import Data.List | |
fb :: (Show a, Integral a) => a -> String | |
fb i | |
| i `rem` 15 == 0 = "FizzBuzz" |
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/sh | |
# GistID: 5163520 | |
usage () { | |
echo "Usage: $0 OPTION | |
Change multi-head display settings. | |
Options: | |
-a Do something reasonable | |
-0 Laptop | |
-1 Laptop + VGA |
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
// GistID: 4770251 | |
#ifndef THRUST_REPEAT_ITERATOR_H | |
#define THRUST_REPEAT_ITERATOR_H | |
/* Remove this header */ | |
#include <GNUC_47_compat.h> | |
#include <thrust/iterator/iterator_adaptor.h> |
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
TRACE: /dev/shm/test.cpp(27): int main(int, char**) | |
TRACE: /dev/shm/test.cpp(20): void where_am_I(int) | |
LOG: /dev/shm/test.cpp(22): void where_am_I(int) | |
x(3) is odd. | |
LOG: /dev/shm/test.h(10): void where_are_you() | |
Here I am! |
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
#!/usr/bin/env ruby | |
# GistID: 4717831 | |
# | |
# splitpatch is a simple script to split a patch up into multiple patch files. | |
# if the --hunks option is provided on the command line, each hunk gets its | |
# own patchfile. | |
# | |
# Copyright (C) 2007, Peter Hutterer <peter@cs.unisa.edu.au> | |
# | |
# This program is free software; you can redistribute it and/or modify |
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
// Header for compilation with GCC-4.7 | |
#if defined(__GNUC__) | |
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6) | |
#undef _GLIBCXX_ATOMIC_BUILTINS | |
#undef _GLIBCXX_USE_INT128 | |
#endif |
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
/* Generated by pandoc. */ | |
code { white-space: pre; } | |
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { | |
margin: 0; | |
padding: 0; | |
vertical-align: baseline; | |
border: none; | |
} | |
table.sourceCode { width: 100%; line-height: 100%; } | |
td.lineNumbers { |
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
#/usr/bin/env python | |
from pandas import np | |
from pandas.io.data import DataReader | |
def historical_volatility(sym, days): | |
"Return the annualized stddev of daily log returns of `sym`." | |
try: | |
quotes = DataReader(sym, 'yahoo')['Close'][-days:] |
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
# coding: utf8 | |
# distutils: language = c++ | |
# distutils: sources = b.cpp | |
# Using C calling convention works with "cdef extern ..." directly; no | |
# hpp header. | |
# Without it we need to use the cdef extern from "b.hpp": ... declaration. | |
# Implicitly forces C calling convenction? | |
cdef extern void c() |
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
# cython: infer_types=True | |
# Use the C math library to avoid Python overhead. | |
from libc cimport math | |
# For boundscheck below. | |
import cython | |
# We're lazy so we'll let Numpy handle our array memory management. | |
import numpy as np | |
# You would normally also import the Numpy pxd to get faster access to the Numpy | |
# API, but it requires some fancier compilation options so I'll leave it out for |