Skip to content

Instantly share code, notes, and snippets.

Avatar

Keisuke Fukuda keisukefukuda

View GitHub Profile
@keisukefukuda
keisukefukuda / streamsampler.cpp
Created Feb 17, 2014
Random sampling from a data stream using Reservoir algorithm.
View streamsampler.cpp
// Copyright(C) 2014 by Keisuke Fukuda
// License: MIT License
/*
// http://en.wikipedia.org/wiki/Reservoir_sampling
Reservoir sampling
array R[k]; // result
integer i, j;
View build-2.log
# Compiling DragonEgg
Compiling utils/TargetInfo.cpp
Linking TargetInfo
Compiling Aliasing.cpp
Compiling Backend.cpp
Compiling Cache.cpp
Compiling ConstantConversion.cpp
Compiling Convert.cpp
Compiling Debug.cpp
Compiling DefaultABI.cpp
View build-1.log
# Removing old versions of LLVM, Clang, DragonEgg, and Byfl from /tmp/fukuda-byfl-build
# Downloading LLVM into /tmp/fukuda-byfl-build
Checked out revision 203207.
# Downloading Clang revision 203207 into /tmp/fukuda-byfl-build
Checked out revision 203207.
# Downloading Clang RT revision 203207 into /tmp/fukuda-byfl-build
Checked out revision 203207.
# Downloading DragonEgg revision 203207 into /tmp/fukuda-byfl-build
Checked out revision 203207.
# Downloading Byfl into /tmp/fukuda-byfl-build
View build-3.log
# Compiling Byfl
make[1]: Entering directory `/tmp/fukuda-byfl-build/byfl/build/lib'
make[1]: Entering directory `/tmp/fukuda-byfl-build/byfl/build/tools'
make[2]: Entering directory `/tmp/fukuda-byfl-build/byfl/build/lib/byfl'
make[2]: Circular opcode2name <- opcode2name.cpp dependency dropped.
make[2]: Entering directory `/tmp/fukuda-byfl-build/byfl/build/tools/postproc'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/tmp/fukuda-byfl-build/byfl/build/tools/postproc'
make[2]: Entering directory `/tmp/fukuda-byfl-build/byfl/build/tools/wrappers'
make[2]: Nothing to be done for `all'.
View scal.cxx
// Stupidly simple scal & axpy example
#include <cstdlib>
#include <ctime>
#include <iostream>
#ifndef REAL
# define REAL double
#endif
View scal.cxx
// Stupidly simple scal & axpy example
#include <cstdlib>
#include <ctime>
#include <iostream>
#ifndef REAL
# define REAL double
#endif
View use-byfl.sh
#!/bin/sh
INSTALL_DIR=$HOME/local/byfl
GCC_ROOT=$HOME/local/gcc-4.8.3
GCC=${GCC_ROOT}/bin/gcc
GXX=${GCC_ROOT}/bin/g++
export PERL5LIB=$INSTALL_DIR/share/perl5:$PERL5LIB
export PATH=$INSTALL_DIR/bin:$PATH
View install-byfl.sh
#!/bin/sh
# -j [N] : same as "make -j N"
# -c : Compile only (not download the code)
# -d : Download only (not configure/compile the code)
#-------------------------------------
# Directory you want to install byfl
INSTALL_DIR=$HOME/local/byfl2
# Temporary directory. Should not be on NFS.
@keisukefukuda
keisukefukuda / nfslock.py
Created Aug 29, 2014
A very simple task management system using proper locking on NFS
View nfslock.py
import random
import os, os.path, sys
import time
import itertools
class TaskAssigner:
def __init__(self, *arrays, **kwd):
print arrays
self.arrays = arrays
View gist:1447c893f8cffca63318
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
x = np.logspace(-4, 8, 100, base=2.0)
y1 = x
y2 = x * x