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
def previous_current_next(iterable): | |
"""Make an iterator that yields an (previous, current, next) tuple per element. | |
Returns None if the value does not make sense (i.e. previous before | |
first and next after last). | |
""" | |
iterable=iter(iterable) | |
prv = None | |
cur = iterable.next() | |
try: |
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
# Try to find gnu scientific library GSL | |
# See | |
# http://www.gnu.org/software/gsl/ and | |
# http://gnuwin32.sourceforge.net/packages/gsl.htm | |
# | |
# Based on a script of Felix Woelk and Jan Woetzel | |
# (www.mip.informatik.uni-kiel.de) | |
# | |
# Available at: http://www.miscdebris.net/blog/2010/06/21/cmake-module-to-find-gnu-scientific-library-findgsl-cmake/ | |
# |
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
#include <fstream> | |
#include <cstdlib> | |
template<class T> | |
T read_urandom() | |
{ | |
union { | |
T value; | |
char cs[sizeof(T)]; | |
} u; |
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
#include "Timer.hh" | |
#include <iostream> | |
#include <sys/times.h> | |
#include <unistd.h> | |
// --------------------------------------------------------------------- | |
// class Time | |
// --------------------------------------------------------------------- | |
const long Time::sc_clk_tck = sysconf(_SC_CLK_TCK); |
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
#include <iostream> | |
using namespace std; | |
struct type_t { | |
int i; | |
}; | |
void function() | |
{ |
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 python3 | |
import itertools | |
def powerset(iterable): | |
xs = list(iterable) | |
return itertools.chain.from_iterable( | |
itertools.combinations(xs,n) for n in range(len(xs)+1) | |
) | |
samples = [ |
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
// Create a vector of evenly spaced numbers. | |
vector<double> range(double min, double max, size_t N) { | |
vector<double> range; | |
double delta = (max-min)/double(N-1); | |
for(int i=0; i<N; i++) { | |
range.push_back(min + i*delta); | |
} | |
return range; | |
} |
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 python3 | |
import argparse | |
import os | |
import os.path | |
import re | |
import sqlite3 | |
def yumdb_packages(path): | |
dirs = os.listdir(path) | |
dirs.sort() |
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
module NoninteractiveGadfly | |
import Compose | |
import Compose: writemime | |
import Gadfly | |
export @noninteractive | |
type NoninteractivePlot | |
p::Gadfly.Plot | |
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
# ComposeHacks module | |
# | |
# This module is a collection of hacks to make working with Compose and Gadfly | |
# more convenient (in Julia). | |
# | |
# The MIT License (MIT) | |
# | |
# Copyright (c) 2015 Morten Piibeleht | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
OlderNewer