This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# plot the cumulative distribution function of bunch of numbers | |
import numpy as np | |
import matplotlib.pyplot as pl | |
A = np.loadtxt('/dev/stdin', delimiter=',') | |
assert len(A.shape) == 1, f'Data must be one-dimensional but has shape {A.shape}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
#include <time.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
/* | |
* Test different methods of uniformly sampling a point on the unit circle. | |
* Inspired by https://www.youtube.com/watch?v=4y_nmpv-9lI | |
* Sample outputs: | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- find numbers that are both a square and a triangle number. | |
-- https://www.youtube.com/watch?v=Gh8h8MJFFdI | |
squares = map (\x -> x * x) [0..] | |
triangle_number x = div (x * (x + 1)) 2 | |
triangle_numbers = map triangle_number [0..] | |
-- Check if you can arrange x points in a triangle with an integer side length | |
is_triangle x = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Tracks contents of the clipboard by printing changes to | |
# stdout with a timestamp | |
last=$(pbpaste) | |
# Check if the clipboard content has changed, and if it has | |
# output the new contents with a timestamp | |
sample() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# This script parses a strava athlete page to get the amount of bicycling kilometers this year | |
# to date from strava, and calculates some statistics from that (km/day and km/week to date and | |
# necessary to hit a target, and km to go / km already done). | |
# | |
# usage: $ ./kmtogo.py [target] | |
# If no target is specified, it'll take the default value (2000). | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solution to advent of code, day 6 | |
#include <ctype.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
// Part 1 | |
bool lights[1000][1000] = {false}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFAB IDS | |
0|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|7|7|7|7|7|7|15|15|15|15|15|15|2|2|2|2|2|2|2|2|2|2|22|22|22|22|22|22|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|13|13|13|13|26|26|26|26|13|13|13|13|13|13|13|13|26|26|26|26|26|26|26|26|13|13|13|13|13|13|13|13|13|13|13|13|26|26|26|26|26|26|26|26|26|26|26|26|1|1|7|7|7|7|7|7|7|7|7|7|15|15|15|15|15|15|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|15|16|16|16|16|16|16|16|14|14|14|14|14|14|14|14|14|14|14|14 | |
POSITIONS | |
0,0,0|-0.5,0,0|-2.5,0,-4.145808E-07|-4.5,0,-1.713005E-06|-6.500001,0,-3.716458E-06|0.5,0,0|2.5,0,-4.145808E-07|4.5,0,-1.713005E-06|6.500001,0,-3.716458E-06|8.500001,0,-6.509234E-06|-8.500001,0,-6.42494E-06|-10.5,0,-9.922745E-06|10.5,0,-1.010156E-05|6,0,-0.5000032|6,0,-2.500003|6,0,-4.500003|6,0,-6.500003|6.000001,0,0.4999969|6.000001,0,2.499997|6.000001,0,4.499997|6.000001,0,6.499997|-6.000001,0,0.4999969|-6.000001,0,2.499997|-6.000001,0,4.499997|-6.000001,0,6.499997|-6,0,-0.5000032|-6,0,-2.500003|-6,0,-4.5000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFAB IDS | |
0|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|2|2|2|2|22|22|22|22|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|35|13|13|13|13|13|13|13|13|13|13|13|13|13|13|13|13|7|7|7|7|7|7|7|7|1|1|1|1|16|16|16|16|23|23|23|23|23|23|23|23|23|27|27|27|27|27|27|27|27|27|14|14|14|14|14|14|14|14|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|1|7|7|7|7|1|11|11|11|11|26|26|26|26|26|26|26|26|26|26|26|26|26|26|26|26 | |
POSITIONS | |
0,0,0|0.4999998,0,2.340613E-09|2.5,0,-4.170207E-07|4.499999,0,-1.706465E-06|6.499999,0,-3.72107E-06|1.170307E-09,0,-0.4999999|7.802043E-10,0,-2.5|7.021839E-09,0,-4.499999|1.484407E-09,0,-6.499998|3.098017E-08,0,-8.499993|8.499994,0,-6.448053E-06|-7.802043E-10,0,2.5|-7.021839E-09,0,4.499999|5.965535E-09,0,6.499998|1.371948E-08,0,8.499993|-0.5,0,3.724971E-09|-2.5,0,-4.099228E-07|-4.499999,0,-1.716784E-06|-6.499999,0,-3.699072E-06|-8.499994,0,-6.485046E-06|3.332078E-08,0.5,-9.999993|9.999994,0.5,-9.202191E-06|1.137887E-08,0.5,9.999993|-9.999994,0.5,-9.154466E-06|9.999994,1,-9.053192E-06|1.137887E-08,1,9.999993|3.332078 |