Skip to content

Instantly share code, notes, and snippets.

@kennytm
kennytm / Cargo.toml
Created November 14, 2017 08:51
fetch_appveyor_build_time
[package]
name = "fetch-appveyor-build-time"
version = "0.1.0"
authors = ["kennytm <kennytm@gmail.com>"]
[dependencies]
regex = "0.2"
reqwest = "0.8"
serde = "1"
serde_derive = "1"
@kennytm
kennytm / issue-41993.rs
Created May 15, 2017 08:36
Benchmark for issue #41993.
#![feature(drop_types_in_const)]
#![feature(test)]
#![feature(rand)] // to be incorporated into libcore, so not using crates.io
#![feature(pattern)]
extern crate test;
extern crate rand;
use test::{Bencher, black_box};
use rand::{XorShiftRng, SeedableRng};
@kennytm
kennytm / split_view.py
Created April 19, 2015 19:54
split_view.py
#!/usr/bin/env python3
from tkinter import *
from tkinter.ttk import *
from PIL import Image
from PIL.ImageDraw import Draw
from PIL.ImageTk import PhotoImage
import enum
@kennytm
kennytm / adjust.py
Created November 19, 2014 13:33
ADJUST working environment
#!/usr/bin/env python3
def factorize(num):
while num % 2 == 0:
yield 2
num //= 2
prime = 3
while prime * prime <= num:
while num % prime == 0:
@kennytm
kennytm / explode.py
Created November 8, 2013 12:30
Explode *.gif for Android.
#!/usr/bin/env python3
#
# explode.py --- Explode *.gif for Android
# Copyright (C) 2013 HiHex Ltd.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
@kennytm
kennytm / test_nupic.py
Created June 11, 2013 14:07
Test NuPIC.
import nupic.frameworks.opf.modelfactory as mf
import nupic.frameworks.opf.opfutils as ou
import nupic.frameworks.opf.predictionmetricsmanager as pm
import nupic.frameworks.opf.metrics as mt
import random
import math
STEPS = 5
FIELD = 'latitude'
@kennytm
kennytm / test.cpp
Created November 30, 2012 20:49
Substituting template arguments in the clang C++ library
#include <type_traits>
#include <cstdio>
namespace L {
template <int n>
struct N {
static constexpr bool equals(int m) { return m == n; }
};
@kennytm
kennytm / PKGBUILD
Created November 28, 2012 13:05
PKGBUILD for rust-bin 0.4-3
# Maintainer: Chris Bolton <chris@pixelgen.co>
# Contributor: kennytm <kennytm@gmail.com>
pkgname=rust-bin
pkgver=0.4
pkgrel=3
pkgdesc="A safe, concurrent, practical programming language."
arch=(i686 x86_64)
url="http://rust-lang.org"
license=('MIT')
@kennytm
kennytm / gist:2045194
Created March 15, 2012 16:40
directfb-git
# Maintainer: kennytm <kennytm@gmail.com>
# Contributor: kennytm <kennytm@gmail.com>
pkgname=directfb-git
pkgver=20111209
pkgrel=1
pkgdesc='DirectFB is a thin library that provides hardware graphics acceleration, input device handling and abstraction, integrated windowing system with support for translucent windows and multiple display layers, not only on top of the Linux Framebuffer Device.'
arch=('i686' 'x86_64')
url='http://directfb.org/'
license=('LGPL')
makedepends=('git' 'gcc' 'autoconf' 'flux-git')
@kennytm
kennytm / gist:1022794
Created June 13, 2011 13:49
Interval arithmetic test.
import std.typecons, std.algorithm, std.conv, std.stdio;
ulong getMask(ulong v) {
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v |= v >> 32;
return v;