Skip to content

Instantly share code, notes, and snippets.

View pyk's full-sized avatar
🐈‍⬛
I may be slow to respond.

pyk pyk

🐈‍⬛
I may be slow to respond.
View GitHub Profile
char buff[6] = {'h', 'e', 'l', 'l', 'o', '\0'};
/* or */
char *buff = "hello"; /* \0 implicitly appended */
/* or */
char buff[] = "hello";
@pyk
pyk / fix-clock-skew.sh
Last active August 9, 2016 16:27
Fix clock skew
# http://stackoverflow.com/questions/23281050/makefile-warning-warning-file-main-cpp-has-modification-time-2-1e04-s-in-th
# http://stackoverflow.com/questions/4210042/exclude-directory-from-find-command
find . -path ./.git -prune -o -type f -exec touch {} +
NEW_VERSION=206179d
OLD_VERSION=cd5726e
if [ ! -f "${NEW_VERSION}.tar.gz" ]; then
wget https://api.github.com/repos/facebookresearch/fasttext/tarball/${NEW_VERSION} -O ${NEW_VERSION}.tar.gz
else
echo "fastText: ${NEW_VERSION}.tar.gz exists"
fi
if [ ! -d "facebookresearch-fastText-${OLD_VERSION}" ]; then
@pyk
pyk / rnorrexp.c
Created August 23, 2016 14:55
The ziggurat method for RNOR and REXP https://www.jstatsoft.org/article/view/v005i08
/* The ziggurat method for RNOR and REXP
Combine the code below with the main program in which you want
normal or exponential variates. Then use of RNOR in any expression
will provide a standard normal variate with mean zero, variance 1,
while use of REXP in any expression will provide an exponential variate
with density exp(-x),x>0.
Before using RNOR or REXP in your main, insert a command such as
zigset(86947731 );
with your own choice of seed value>0, rather than 86947731.
(If you do not invoke zigset(...) you will get all zeros for RNOR and REXP.)
@pyk
pyk / whitespace_tokenizer.rs
Last active December 26, 2016 16:07
Whitespace Tokenizer in Rust
// file: whitespace_tokenizer.rs
use std::env;
use std::process;
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 2 {
import tensorflow as tf
import sys
import os
def create_graph(pattern):
print 'pattern:', pattern
graph = tf.Graph()
with graph.as_default():
# Initializer
tf.variables_initializer(tf.global_variables(), name='init')
(function() {
var width = 320;
var height = 0;
var streaming = false;
var video = null;
var canvas = null;
var photo = null;
var startbutton = null;
# Convolutional layer 1
with tf.name_scope('conv1'):
W = tf.Variable(
tf.truncated_normal(
shape=(
CONV1_FILTER_SIZE,
CONV1_FILTER_SIZE,
NUM_CHANNELS,
CONV1_FILTER_COUNT),
dtype=tf.float32,
def read_images(data_dir):
pattern = os.path.join(data_dir, '*.png')
filenames = tf.train.match_filenames_once(pattern, name='list_files')
queue = tf.train.string_input_producer(
filenames,
num_epochs=NUM_EPOCHS,
shuffle=True,
name='queue')

CLI

Install aspell first. For example on debian-based system:

apt-get install aspell

Check all markdown files inside src directory: