Skip to content

Instantly share code, notes, and snippets.

import json1 from 'ot-json1'
const integerRegEx = /^\d+$/
function isInteger (v) {
return Boolean(v.match(integerRegEx))
}
export function patchAtomToOpAtom (patchOp) {
const { path, op, value } = patchOp
const pathArray = path.split('/').slice(1).map(pathItem => {
@adorsk
adorsk / DrippyTron_Initialize
Last active September 25, 2019 01:40
DrippyTron Arduino
int counter = 0;
int signalPin = 3;
int feeding = 1;
int msPerPulse = 100;
int msPerPulseInterval = 500;
// Feed time (affects how much material to feed)
int numPulses = 25;
int delayPerPulse = 100;
source ~/.zplug/init.zsh
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/tmux", from:oh-my-zsh
zplug "themes/robbyrussell", from:oh-my-zsh
ZSH_THEME="robbyrussell"
zplug load
# oh-my-zsh config.
export ZSH=$HOME/.oh-my-zsh
plugins=(git tmux)
#!/usr/bin/env python
import sys
import os
import string
import random
import subprocess
import multiprocessing
class NotAuthorizedException(Exception): pass
@adorsk
adorsk / reverseadmin.py
Created April 13, 2016 02:41 — forked from wolever/reverseadmin.py
Forked from https://gist.github.com/mzbyszewska/8b6afc312b024832aa85 , updated to work with Django 1.8
'''
adminreverse from here http://djangosnippets.org/snippets/2032/
changed for working with ForeignKeys
'''
'''
reverseadmin
============
Module that makes django admin handle OneToOneFields in a better way.
A common use case for one-to-one relationships is to "embed" a model
inside another one. For example, a Person may have multiple foreign
@adorsk
adorsk / math_engine.py
Created April 24, 2015 18:51
Math Engine
#!/usr/bin/env python
"""
A Flask-powered math engine microservice.
"""
from flask import Flask, request, jsonify, Response
import json
import datetime
@adorsk
adorsk / number_to_spoken_number.py
Created April 24, 2015 18:51
Numbah Convertah
#!/usr/bin/env python
"""
Number-to-spoken-numbers converter.
"""
max_value = 10**66 - 1
big_words = {
3: "thousand",
6: "million",
@adorsk
adorsk / metronome.js
Created October 8, 2013 19:33
Metronome
var audioContext = null;
var isPlaying = false; // Are we currently playing?
var startTime; // The start time of the entire sequence.
var current16thNote; // What note is currently last scheduled?
var tempo = 80; // tempo (in beats per minute)
var lookahead = 25.0; // How frequently to call scheduling function
//(in milliseconds)
var scheduleAheadTime = 0.1; // How far ahead to schedule audio (sec)
// This is calculated from lookahead, and overlaps
// with next interval (in case the timer is late)
from javax.swing import (Spring, SpringLayout)
def makeGrid(parent, rows,cols, initialX, initialY, xPad, yPad):
layout = parent.getLayout()
xPadSpring = Spring.constant(xPad)
yPadSpring = Spring.constant(yPad)
initialXSpring = Spring.constant(initialX)
initialYSpring = Spring.constant(initialY)
max_ = rows * cols
@adorsk
adorsk / gist:4186757
Created December 2, 2012 03:07
mvn dependency management, for use w/ jython installer
Copying all dependencies to a dir:
mvn dependency:copy-dependencies -DoutputDirectory=/tmp/foo
Listing dependencies:
mvn dependency:resolve -DoutputFile=/tmp/bar.txt
per these pages:
http://maven.apache.org/plugins/maven-dependency-plugin/usage.html
http://maven.apache.org/plugins/maven-dependency-plugin/list-mojo.html