Skip to content

Instantly share code, notes, and snippets.

@jtacoma
jtacoma / introspect.cpp
Created August 1, 2021 17:38
A way to implement introspection for C++ types allowing easier decoupling from data format and serialization libraries
// Copyright 2021 Google LLC
// SPDX-License-Identifier: Apache-2.0
#include <cstddef> // ptrdiff_t
#include <string>
#include <tuple>
#include <utility>
namespace introspect {
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active June 16, 2024 13:44
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

@gsomoza
gsomoza / .bashrc
Created January 17, 2013 16:50
SSH Agent in Windows (Git Bash / MinGW)
#!bash.exe
export SSH_AUTH_SOCK=/tmp/.ssh-socket
echo ;
echo Starting connection with ssh-agent...
ssh-add -l 2>&1 >/dev/null
if [ $? = 2 ]; then
rm -f /tmp/.ssh-script /tmp/.ssh-agent-pid /tmp/.ssh-socket
# Exit status 2 means couldn't connect to ssh-agent; start one now
echo Creating new ssh-agent...
ssh-agent -a $SSH_AUTH_SOCK > /tmp/.ssh-script
@arvearve
arvearve / gist:4158578
Created November 28, 2012 02:01
Mathematics: What do grad students in math do all day?

Mathematics: What do grad students in math do all day?

by Yasha Berchenko-Kogan

A lot of math grad school is reading books and papers and trying to understand what's going on. The difficulty is that reading math is not like reading a mystery thriller, and it's not even like reading a history book or a New York Times article.

The main issue is that, by the time you get to the frontiers of math, the words to describe the concepts don't really exist yet. Communicating these ideas is a bit like trying to explain a vacuum cleaner to someone who has never seen one, except you're only allowed to use words that are four letters long or shorter.

What can you say?

@jtacoma
jtacoma / html2json.html
Created February 5, 2011 00:36
Converting HTML to JSON with jQuery. Just a gist...
<dl>
<dt>selector</dt>
<dd>dl</dd>
<dt>apply</dt>
<dd>
<ul>
<li>
<dl>
<dt>selector</dt>
<dd>&gt; dt</dd>
@jtacoma
jtacoma / spec2class.js
Created February 4, 2011 22:09
One way to translate a spec(ification), that is a plain old object, into a proper class. The resulting class is to be instantiated from an object with a fixed set of properties (e.g. a table row) and to calculate other properties based on those received.
// Given a prototype-like object, create a class based on that object's
// properties.
function buildClass(spec) {
// Throw an exception of the argument is inappropriate:
if (typeof(spec) != 'object' || spec === null)
throw 'expected an object.';
var empty = true;
for (var name in spec) { empty = false; break; }
if (empty)
throw 'expected a non-empty object.';