Skip to content

Instantly share code, notes, and snippets.

View audionerd's full-sized avatar

Eric Skogen audionerd

View GitHub Profile
-- via https://stackoverflow.com/questions/5723154/truncate-a-string-in-the-middle-with-javascript
-- https://stackoverflow.com/questions/831552/ellipsis-in-the-middle-of-a-text-mac-style/36470401#36470401
function truncateMiddle (str, maxLength, separator)
maxLength = maxLength or 30
separator = separator or "…"
if (maxLength < 1) then return str end
if (string.len(str) <= maxLength) then return str end
if (maxLength == 1) then return string.sub(str, 0, 1) .. separator end
@audionerd
audionerd / spout.lua
Created May 31, 2018 04:09
spout for norns
-- spout.
--
-- key2 = sample A
-- key3 = sample B
-- enc2 = tempo
-- enc3 = rate selection
--
engine.name = 'Ack'
@audionerd
audionerd / index.js
Last active May 27, 2018 04:36
Callbags and Canceling with CAF
require('regenerator-runtime/runtime')
import { forEach, map, pipe, fromEvent, scan } from 'callbag-basics'
import CAF from 'caf'
let source = pipe(
fromEvent(document, 'keydown'),
map(event => function * (signal) {
console.log('%cbegin', 'color:red')
yield CAF.delay(signal, 1000)
@audionerd
audionerd / .block
Last active February 26, 2017 07:10
Oscar Ballot Bingo 2017
We couldn’t find that file to show.
@audionerd
audionerd / vinegrabber.rb
Last active July 21, 2016 02:31
given a vine.co uri, downloads the MP4 and creates an image sequence / GIF from it
# space150 vine grabber
# given a vine.co uri, downloads the MP4 and creates an image sequence / GIF from it
# requires ruby, ffmpeg, and imagemagick
require 'open-uri'
require 'nokogiri'
id = ARGV[0]
# try to convert from URL to id.
@audionerd
audionerd / gist:5059500
Created February 28, 2013 19:46
tiny hex to rgb
# tiny hex to rgb
# via http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb/11508164#11508164
def rgb(color)
[16, 8, 0].map { |n| color >> n & 255 }
end
rgb 0xfa029a
=> [250, 2, 154]
@audionerd
audionerd / middleman_mustache.rb
Created March 13, 2012 02:24
Mustache support for Middleman
require 'tilt-mustache'
# Mustache Renderer
module Middleman::Renderers::Mustache
class << self
def registered(app)
# Mustache is not included in the default gems,
# but we'll support it if available.
begin
@audionerd
audionerd / token.rb
Last active December 17, 2015 07:58
A minimal re-usable module for "token" slugs on ActiveRecord models (AKA shortcodes, tiny urls)
# token.rb
# A minimal re-usable module for "token" slugs on ActiveRecord models (AKA shortcodes, tiny urls)
#
# USAGE
#
# class Project < ActiveRecord::Base
# include Token
# end
#
# see also:
@audionerd
audionerd / sc-blend.coffee
Last active December 15, 2015 12:29
SuperCollider's SequenceableCollection blend, blendAt in CoffeeScript
# SuperCollider's SequenceableCollection blend, blendAt in CoffeeScript
# SEE ALSO:
# https://github.com/supercollider/supercollider/blob/master/SCClassLibrary/Common/Core/Object.sc
# http://danielnouri.org/docs/SuperColliderHelp/Collections/SequenceableCollection.html
# http://coleingraham.com/2012/12/31/notes-between-chromatic-just-intonation/
# http://mohayonao.github.com/subcollider.js/
class ArrayUtil
# via https://github.com/supercollider/supercollider/blob/master/SCClassLibrary/Common/Core/Object.sc
@blendAt: (array, index) ->
@audionerd
audionerd / index.html
Created November 9, 2012 21:48
Testing borismus/srcset-polyfill and paulirish/matchMedia.js
<html>
<head>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="https://raw.github.com/paulirish/matchMedia.js/master/matchMedia.js"></script>
<script src="https://raw.github.com/paulirish/matchMedia.js/master/matchMedia.addListener.js"></script>