Skip to content

Instantly share code, notes, and snippets.

View 0b01's full-sized avatar

Ricky Han 0b01

View GitHub Profile
@chadbrewbaker
chadbrewbaker / dulien.md
Last active October 13, 2022 03:48
EasyPerf 1 August 2021 Twitter Space
@jdarpinian
jdarpinian / executable.c
Last active May 30, 2024 19:42
Add one line to your C/C++ source to make it executable.
///$(which true);FLAGS="-g -Wall -Wextra --std=c17 -O1 -fsanitize=address,undefined";THIS_FILE="$(cd "$(dirname "$0")"; pwd -P)/$(basename "$0")";OUT_FILE="/tmp/build-cache/$THIS_FILE";mkdir -p "$(dirname "$OUT_FILE")";test "$THIS_FILE" -ot "$OUT_FILE" || $(which clang || which gcc) $FLAGS "$THIS_FILE" -o "$OUT_FILE" || exit $?;exec bash -c "exec -a \"$0\" \"$OUT_FILE\" $([ $# -eq 0 ] || printf ' "%s"' "$@")"
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
@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:
--
@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;
@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,
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.
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.
@tartakynov
tartakynov / fourex.py
Last active July 15, 2024 16:24
Fourier Extrapolation in Python
import numpy as np
import pylab as pl
from numpy import fft
def fourierExtrapolation(x, n_predict):
n = x.size
n_harm = 10 # number of harmonics in model
t = np.arange(0, n)
p = np.polyfit(t, x, 1) # find linear trend in x
x_notrend = x - p[0] * t # detrended x
@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>
@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)