Skip to content

Instantly share code, notes, and snippets.

@ohAitch
ohAitch / gist:5078344
Last active December 14, 2015 11:19
Backend for the iOS app "Musix"
//Copyright 2013 ohAitch
//Released under GPL 3+, see http://www.gnu.org/licenses/gpl.html
n = NetAddr("127.0.0.1", 57120); // 57120 is sclang default port
~amp.free;
SynthDef(\looperAmpControl,
{ arg volumeAmp = 1, volumeLag = 0.1, volumeGate=1;
XOut.ar(0,
Linen.kr(volumeGate, releaseTime: 0.05, doneAction:2),
In.ar(0, Server.default.options.numOutputBusChannels) * Lag.kr(volumeAmp, volumeLag) );
$.getScript("https://rawgit.com/gilmoreorless/jquery-nearest/master/src/jquery.nearest.min.js");
$("#stdKeyboard").hide()
$("#stenoKeyboard").css({
width: "95%",
height: "50%",
left: "1%"
});
function sendKey(keyDiv, dir) {
var e = $.Event(dir);
@ohAitch
ohAitch / colors.js
Last active October 13, 2016 03:52
Rudimentary urbit chat tagging, notifications.
// ==UserScript==
// @include http://chat.urbit.org/
// ==/UserScript==
$.getScript("https://cdn.rawgit.com/boronine/husl/v2.0.0/husl.min.js");
colorMap = {}; memo={}; $('.hl').contents().unwrap();
getColor = function (s) {  
var hash = s.split("").reduce(function (a, b) {    
a = ((a << 5) - a) + b.charCodeAt(0);    
return a & a  
}, 0);
@ohAitch
ohAitch / hoons.coffee
Last active August 29, 2015 13:57
A more literal %rune representation, with reemvowelings as annotation.
#require 'jquery'
m= {gl: '<', pr: ')', br: '|', gr: '>', sl: '[', bs: '\\', hx: '#', sm: ';', bc: '$', hp: '-', sr: ']', cb: '_', kl: '{', sg: '~', cn: '%', kr: '}', cl: ':', kt: '^', tr: '*', cm: ',', ls: '+', tc: '`', dq: '"', pm: '&', ts: '=', dt: '.', pt: '@', wt: '?', fs: '/', pl: '(', zp: '!', zy:'Y', zz:'Z'}
m2={gl: 'gal', pr: 'per', br: 'bar', gr: 'gar', sl: 'sel', bs: 'bas', hx: 'hax', sm: 'sem', bc: 'buc', hp: 'hep', sr: 'ser', cb: 'cab', kl: 'kel', sg: 'sig', cn: 'cen', kr: 'ker', sq: 'soq', cl: 'col', kt: 'ket', tr: 'tar', cm: 'com', ls: 'lus', tc: 'tec', dq: 'doq', pm: 'pam', ts: 'tis', dt: 'dot', pt: 'pat', wt: 'wut', fs: 'fas', pl: 'pel', zp: 'zap', zy:'zey', zz:'zaz'}
$('body *').contents().filter ->
@nodeType is 3
.each ->
html = @textContent.replace /%\w{4}\b/g, (s) ->
s1=s[1..2]; s2=s[3..4]
if s1 of m and s2 of m
"%<ruby>'#{m[s1]+m[s2]}'"+
@ohAitch
ohAitch / pong
Last active August 29, 2015 14:04 — forked from arishal/pong
puts "1"
require "curses"
include Curses
include Math
def pong
# ALL THIS NEEDS TO BE DISPLAYED SOMEHOW
# show “CONTROL THE PADDLE WITH THE W AND S KEYS” in the middle of the board for a few seconds
score = 0
scof = 1.0
paddle = 50.0 # max y-coordinate/2, making the board 100x100 for now
@ohAitch
ohAitch / eyre-formal.md
Last active August 29, 2015 14:14
Eyre formal

Overview

The %eyre vane serves one purpose: receiving inbound HTTP requests from browsers and clients pretending to be browsers. To facilitate this communication, %eyre does two things: 1. provide an API for traditional clients to talk to; and 2. provide a mechanism for saving state that allows the server to keep track of identities/sessions, subscription data, and active connections.

This document outlines the following:

  1. perk, a pork subset that defines what URLs the client can send to %eyre.

  2. the values stored on the client, both statically in cookies and dynamically as the window.urb object, which facilitate this transaction.

  3. kiss, the requests %eyre will accept.

@ohAitch
ohAitch / repmin-mut
Created July 11, 2015 19:39
A semi-imperative approach to repmin.
# tree: {fork: {leaf:"int", node: ["tree", "tree"]}}
repmin-mut = (tree) -> _repmin-mut tree, {leaf: Infinity}
_repmin-mut = (tree,min)-> switch Object.keys(tree)[0] # shh js totally has pattern-matching
when 'node' then {node: [(repmin-mut tree, min), (repmin-mut tree,min)]}
when 'leaf'
if min.leaf > tree.leaf
min.leaf = tree.leaf
min
@ohAitch
ohAitch / issue-comment.json
Created April 1, 2016 20:18
Example issue_comment event from github docs
{
"action": "created",
"issue": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2",
"labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/labels{/name}",
"comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/comments",
"events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/events",
"html_url": "https://github.com/baxterthehacker/public-repo/issues/2",
"id": 73464126,
"number": 2,
@ohAitch
ohAitch / mini-redux.ls
Last active April 2, 2016 10:40
The abstraction model of Redux, implemented in 7 lines. Learning project.
## Info ##
# requires jquery, zepto, or such
# live demo at https://jsbin.com/kuyukucoxe/edit?js,output
## shim('react'): render an html string to the page
$ \#mount .remove!
$ \body .append '<div id="mount"/>'
mount = -> $ \#mount .html it
## shim('react-dom'): functionally compose html
fooBarReducer = (fooBar=0,{addFooBar,clearFooBar})->
switch
when addFooBar? then fooBar + addFooBar
when clearFooBar? then 0
else fooBar
connect(({fooBar})-> count: fooBar) ({count, dispatch})->
div {},
button {onClick: -> dispatch addFooBar:5}, "Bump ", count