Skip to content

Instantly share code, notes, and snippets.

View also's full-sized avatar

Ryan Berdeen also

View GitHub Profile
// fix a tsv with unescaped newlines
val lines = io.Source.fromFile(argv(0)).getLines
val header = lines.next()
val tabCount = header.count(_ == '\t')
println(header)
while (lines.hasNext) {
@also
also / onkyo.rb
Created August 31, 2012 00:49
Control Onkyo Receivers via ISCP
require 'socket'
s = TCPSocket.new ARGV[0], 60128
def hexify_command(cmd)
cmd = '!1' + cmd unless cmd.start_with? '!1'
"ISCP\x00\x00\x00\x10\x00\x00\x00#{(cmd.length + 1).chr}\x01\x00\x00\x00#{cmd}\x0D"
end
s.write hexify_command(ARGV[1])
@also
also / file-source.coffee
Created September 2, 2012 19:45
remixjs2 node test
fs = require 'fs'
class FileSampleSource
constructor: (filename) ->
@fd = fs.openSync filename, 'r'
# FIXME
@bytesPerSample = 1
@channels = 2
@offset = 44
user=> (try
#_=> (/ 1 0)
#_=> (catch Throwable t (throw (RuntimeException. t))))
ArithmeticException Divide by zero clojure.lang.Numbers.divide (Numbers.java:156)
user=> (try
#_=> (/ 1 0)
#_=> (catch Throwable t (throw (RuntimeException.))))
RuntimeException user/eval4065 (NO_SOURCE_FILE:2)
colors = require 'colors'
targets = (randomWalkFunction('test.' + i) for i in [1..9])
graph targets, maxDataPoints: 200, d3_colors: colors.brewer.Set3[11], lineWidth: 1.5, width: 1280, height: 720
fs = require 'fs'
_ = require 'underscore'
lead = require './dist/nodejs/node.js'
parser = lead.require 'graphite_parser'
dsl = lead.require 'dsl'
filename = process.argv[2]
s = fs.readFileSync filename, 'ascii'
exposed_scope = {}
top_scope = null
push_scope = ->
top_scope = exposed_scope.__proto__ = Object.create exposed_scope.__proto__
pop_scope = ->
top_scope = exposed_scope.__proto__ = exposed_scope.__proto__.__proto__
with_scope = (fn) ->
@also
also / README.md
Last active December 26, 2015 17:48

This lives in the npm module oog (https://npmjs.org/package/oog).

Running the ClojureScript Hello World example in node.js without creating a goog global.

$ cljsc hello.cljs > hello.js
$ coffee test.coffee
Hello node.js
@also
also / simple_checks.coffee
Last active December 27, 2015 10:39
calling simple-check generators from node.js/coffeescript
# https://github.com/also/simple-check/tree/cljx
goo = require './goog' # https://gist.github.com/also/7189192
goog = goo 'target/unoptimized/goog'
goog.load 'target/unoptimized.js'
cljs = goog.require 'cljs.core'
gen = goog.require 'simple_check.generators'
console.log cljs.clj__GT_js gen.sample gen.int$
console.log cljs.clj__GT_js gen.sample gen.vector gen.string_ascii
@also
also / kafka.clj
Created November 8, 2013 04:58
riemann kafka transport
(ns riemann.transport.kafka
(:import java.util.concurrent.Executors
java.util.Properties
kafka.consumer.Consumer
kafka.consumer.ConsumerConfig
kafka.javaapi.consumer.ConsumerConnector)
(:use [riemann.service :only [Service ServiceEquiv]]))
(defn- consumer-properties
[opts]