Skip to content

Instantly share code, notes, and snippets.

View randompast's full-sized avatar

randompast

View GitHub Profile
@randompast
randompast / list.md
Last active July 9, 2024 12:16
Paper title to Two Minute Papers video
@randompast
randompast / TMP_video_lookup.py
Last active August 24, 2021 00:09
Paper Title to TMP Video Link
API_KEY = 'your_key_here'
# https://developers.google.com/youtube/v3/docs/playlistItems/list?hl=en&apix_params=%7B%22part%22%3A%5B%22snippet.publishedAt%22%2C%22snippet.title%22%2C%22snippet.description%22%5D%2C%22playlistId%22%3A%22UUbfYPyITQ-7l4upoX8nvctg%22%7D
# -*- coding: utf-8 -*-
# Sample Python code for youtube.playlistItems.list
# See instructions for running these code samples locally:
# https://developers.google.com/explorer-help/guides/code_samples#python
import os
import pickle
@randompast
randompast / Squirrel3.c
Created December 28, 2020 14:20
GDC noise function by Squirrel Eiserloh
// Credit to Squirrel Eiserloh https://twitter.com/SquirrelTweets
// https://www.gdcvault.com/play/1024365/Math-for-Game-Programmers-Noise
// https://youtu.be/LWFzPP8ZbdU?t=2831
// http://www.mathforgameprogrammers.com/
// python version: https://github.com/sublee/squirrel3-python/blob/master/squirrel3.py
unit32_t Squirrel( int p, uint32_t seed ){
constexpr unsigned int BIT_NOISE1 = 0xB5297A4D;
constexpr unsigned int BIT_NOISE2 = 0x68E31DA4;
constexpr unsigned int BIT_NOISE3 = 0x1B56C4E9;
@randompast
randompast / squiggle.frag
Created December 28, 2020 12:55
a simple squiggle shader
//http://glslsandbox.com/e#70157.0
//squiggle
#ifdef GL_ES
precision mediump float;
#endif
#extension GL_OES_standard_derivatives : enable
uniform float time;
@randompast
randompast / cusignal1d3o_comparison.py
Last active October 22, 2020 08:23
Third order convolution. Mini sanity check with benchmark: cusignal vs njit vs numba.cuda
# (cusignal-dev) ~/Desktop/code/cs_fork/cusignal$ python3 discourse_2.py
# [-0.06169884 -0.07237074 0.08575766 -0.03845544 0.37396236]
# [-0.06169884 -0.07237074 0.08575766 -0.03845544 0.37396236]
# [-0.06169884 -0.07237074 0.08575766 -0.03845544 0.37396236]
# [-0.06169884 -0.07237074 0.08575766 -0.03845544 0.37396236]
# True True True
# 481 -135.8448081001215
# 481 -135.84480810012172
# 481 -135.8448081001215
# 481 -135.84480810012175
@randompast
randompast / test_cusignal_fork.py
Created October 19, 2020 05:08
I implemented 2nd and 3rd order convolutions for cusignal. This is a sanity check and micro benchmark
import time
import cusignal as cs
import numpy as np
import cupy as cp
from numba import cuda, njit, jit
@njit
def nbconv_1d3o(x,k): #numba_conv 1 dimension 3rd order
y = np.zeros(x.size-k.shape[0]+1)
for n in range(0, y.size):
@randompast
randompast / carscom.js
Last active April 19, 2018 00:18
Grabbing / plotting data from cars.com
//cars.com
//https://twitter.com/randompast/status/986749286208634881
// gnuplot -p PLOTFILEBELOW
// set palette defined (2012 "#ffff00", 2013 "#ff0000", 2014 "#ff00ff", 2015 "#00ff00", 2016 "#00ffff", 2017 "#0000ff", 2018 "#aaffaa")
// set xlabel "mileage"
// set ylabel "price"
// set xrange [0:250000]
// plot "corolla.csv" u 3:2:1 w p lc palette
var getYear = function(c){
var info = c.getElementsByClassName("listing-row__title")[0]
@randompast
randompast / logisticmap.py
Last active April 12, 2018 23:11
This generates a series of images that I turned into a logistic map. (link to gif in comment)
import sys
import matplotlib.pyplot as plt
import numpy as np
def f(a, x):
return a*x*(1 - x)
n = 1000
imgs = 50
for k in np.arange(imgs):
@randompast
randompast / conv.chpl
Last active April 3, 2018 08:39
Slow implementation of convolve in chapel
use Random;
use LinearAlgebra;
proc rand(D: int, seed : int, mag: real):[1..D] real {
var X: [1..D] real;
fillRandom(X, seed, algorithm=RNG.NPB);
return mag*(2*X-1);
}
proc conv(A: [?D1] real, K: [?D2] real) {
@randompast
randompast / save.cs
Created January 28, 2018 14:28
Simple save with C#/Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class io : MonoBehaviour {
// Use this for initialization
void Start () {
dat d = new dat ();