Skip to content

Instantly share code, notes, and snippets.

View 0b01's full-sized avatar

Ricky Han 0b01

View GitHub Profile
defmodule Bench do
@sample 1000
defp average(time) do
time / @sample
end
defp bench(fun) do
f = fn ->
Enum.each 1..@sample, fn _ -> fun.() end
@chrisdone
chrisdone / Drawing.hs
Last active October 7, 2017 09:12
Drawing language: first attempt
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wall #-}
-- Set your font to a monospace font which makes this character the same as the line-height: │
--
-- Otherwise, you'll see an ugly gap between connected lines if the
-- line-height of the font is high.
--
-- Example fonts:
--
anonymous
anonymous / lib.rs
Created June 6, 2016 20:49
#![feature(question_mark)]
use std::{cmp, ops};
use std::cell::Cell;
/// The condition graph.
///
/// Each edge represents an outlives relation between two regions.
pub struct Graph {
/// The nodes.
""" Generate lovely ideas for hack day talks """
import random
import re
productions = {
'tech': [
'HTML5',
'Audio',
'CoffeeScript',
anonymous
anonymous / order_book.ipynb
Created January 16, 2016 06:39
order_book.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Wunkolo
Wunkolo / ASCIIRayTrace.cpp
Last active June 13, 2021 05:36
Just a fun ASCII raytracer I made one day.
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <initializer_list>
#include <thread>
#include <chrono>
@ciamarro
ciamarro / random_radio.js
Created July 7, 2017 13:07
Randomly select all radio buttons on a form
var a = document.querySelectorAll('input[type=radio]');
for (var i=0; i<a.length; i++)
// from https://stackoverflow.com/a/18066088/8148848
a[i].checked = ( (Math.random()*10) > 5) ? true : false;
@lukechampine
lukechampine / a.c
Created October 19, 2014 01:00
a.c (with a.h expanded)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/mman.h>
typedef void V;typedef int I;typedef double F;typedef unsigned char C,*S;typedef long L;
#define O printf
#define R return
#define I(a...) if(a)
#define W(a...) while(a)
@chadbrewbaker
chadbrewbaker / dulien.md
Last active October 13, 2022 03:48
EasyPerf 1 August 2021 Twitter Space
@nikitakit
nikitakit / tf_beam_decoder.py
Last active January 6, 2024 08:48
Tensorflow Beam Search
"""
Beam decoder for tensorflow
Sample usage:
```
from tf_beam_decoder import beam_decoder
decoded_sparse, decoded_logprobs = beam_decoder(
cell=cell,