Skip to content

Instantly share code, notes, and snippets.

View jrk's full-sized avatar

Jonathan Ragan-Kelley jrk

View GitHub Profile
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active May 20, 2025 13:11
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

namespace api
{
namespace blah
{
// Opaque handle to the type this namespace exposes functions for
struct Blah;
// Lifetime management (malloc/free with construct/destruct)
Blah* New(u32 param);
@jrk
jrk / jpeg_io.h
Last active August 29, 2015 14:13
Halide image_io JPEG saver
#include "jo_jpeg.cpp" // http://www.jonolick.com/uploads/7/9/2/1/7921194/jo_jpeg.cpp
template<typename T>
void save_jpeg(Image<T> im, std::string filename, int quality = 90) {
_assert(im.channels() > 0 && im.channels() < 5,
"Can't write JPEG files that have other than 1, 2, 3, or 4 channels\n");
im.copy_to_host();
// convert to 8-bit and interleave
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep -B6 bindings:.*:
@jrk
jrk / elf.cpp
Last active August 29, 2015 14:13
Saving an ELF object of LLVM JIT-compiled assembly for a function
#include "elf.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void saveELF(const char *filename, void *buf, size_t len) {
FILE *f = fopen(filename, "w");
struct elf64_hdr {
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@karpathy
karpathy / min-char-rnn.py
Last active July 27, 2025 12:08
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
//Now with less jquery
//1) go to your my-list page, and scroll to the bottom to make sure it's all loaded:
//http://www.netflix.com/browse/my-list
//2) Next, paste this in your developer tools console and hit enter:
[...document.querySelectorAll('.slider [aria-label]')].map(ele => ele.getAttribute('aria-label'))
//or use this to copy the list to your clipboard:
copy([...document.querySelectorAll('.slider [aria-label]')].map(ele => ele.getAttribute('aria-label')))