Skip to content

Instantly share code, notes, and snippets.

View alecbz's full-sized avatar

Alec Benzer alecbz

View GitHub Profile
# https://www.reddit.com/r/askmath/comments/kic0id/uneven_probabilities/
from collections import defaultdict
from functools import lru_cache
import math
import matplotlib.pyplot as plt
from pytablewriter import MarkdownTableWriter
PROB = {
/* rendered css */
.info { background-color: #eff4ff; padding: 25px; }
.info:before { content: "\f05a"; padding-right: 10px; }
.info:before { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; display: inline-block; font-style: normal; font-variant: normal; font-weight: normal; line-height: 1; }
.info:before { font-family: 'Font Awesome 5 Free'; font-weight: 900; }
#!/bin/bash
set -u
git fetch --all --quiet
for b in $(git for-each-ref refs/heads --format="%(refname:short)"); do
if [[ ! $(git cherry -v origin/master $b | grep "^+") ]]; then
git branch -D $b
elif git diff --exit-code --quiet "origin/master...${b}"; then
git branch -D $b
fi
@alecbz
alecbz / .md
Last active August 29, 2015 14:26
int x = new int(5);
int x = new int(5);
<pre class="prettyprint">
<code class="language=c++ hljs cs">
int x = <em>new</em> int(5);
</code>
</pre>
```c++
int x = new int(5);
```
buckets = defaultdict(list)
for z, root in root_from.iteritems():
closest = next((k for k in buckets if abs(k - root) < 1e-3), None)
if closest:
buckets[closest].append(z)
else:
buckets[root].append(z)
roots = buckets.keys()
#include <unistd.h>
#include <stdio.h>
int main() {
int i;
pid_t pid = fork();
if (pid == 0) {
printf("I am the child. I'm going to print 'Hello, World!' 15 times\n");
for (i = 0; i < 15; ++i) {
printf("Hello, World!\n");
#include <stdio.h>
#include <unistd.h>
int main() {
pid_t pid = fork();
if (pid == 0) {
printf("I'm the child -- about to run ls -a -l\n");
execlp("ls", "ls", "-a", "-l", (char*)NULL);
} else {
printf("I'm the parent -- about to run pwd\n");
package main
import (
"fmt"
"math/rand"
"reflect"
)
func worker(n int, ch chan int) {
count := rand.Intn(5) + 3