Skip to content

Instantly share code, notes, and snippets.

@stevenleeg
stevenleeg / Coffeescript version
Created June 16, 2012 19:45
Compiled source of app.js
window.App = {}
get_template = (el, tpl, callback, context = {}) ->
$(el).html(_.template("hello", context));
callback();
class App.IndexView extends Backbone.View
template: "index"
el: $("#container")
@stevenleeg
stevenleeg / git.sh
Created October 10, 2012 01:21 — forked from clehner/git.sh
Simple Interactive Git Shell
#!/bin/bash
# git.sh - Interactive Git Shell
# store command history here
HISTFILE=~/.gitsh_history
control_c() {
# save history before exiting
history -a
# i can't figure out how to make this just break out of the read command
@stevenleeg
stevenleeg / artist_albums.sql
Created November 20, 2012 18:39
[Musicbrainz] Get albums by artist mbid
SELECT
musicbrainz.release_group.gid AS release_mbid,
musicbrainz.release_group.type AS primary_type,
musicbrainz.release_group_secondary_type_join.secondary_type AS secondary_type,
musicbrainz.release_name.name AS release_name
FROM
musicbrainz.artist
INNER JOIN musicbrainz.artist_credit_name
ON musicbrainz.artist_credit_name.artist = musicbrainz.artist.id
@stevenleeg
stevenleeg / gist:4128236
Created November 21, 2012 22:20
[Musicbrainz] Get meta data from release mbid
SELECT
musicbrainz.release.gid AS release_mbid,
musicbrainz.release_meta.amazon_asin AS asin,
musicbrainz.release_meta.cover_art_presence AS art
FROM
musicbrainz.release_group
INNER JOIN musicbrainz.release
ON musicbrainz.release.release_group = musicbrainz.release_group.id
@stevenleeg
stevenleeg / threadtest.c
Created May 8, 2013 14:49
Playing with threads
#include <pthread.h>
#include <stdio.h>
void count() {
int i = 0;
for(i = 0; i < 10; i++) {
usleep(1);
printf("Counting: %d\n", i);
}
}
@stevenleeg
stevenleeg / audiostreaming.wip.patch
Created July 12, 2013 04:31
WIP: Audio streaming support in Grooveboat.
diff --git a/static/application.js b/static/application.js
index b4dc334..e83086b 100644
--- a/static/application.js
+++ b/static/application.js
@@ -116,16 +116,21 @@ function RoomCtrl($scope, $routeParams, groove, localStorageService) {
$scope.tracks = groove.playlists[groove.activePlaylist];
$scope.files = [];
$scope.tempGravatarEmail = groove.me.gravatar;
-
$scope.currentTrack = null;
var WebSocketServer = require('websocket').server;
var http = require('http');
var WebsocketExporter = function(stat_manager) {
var self = this;
self.stat_manager = stat_manager;
self.connections = [];
self.server = http.createServer(self.handleServerRequest);
self.server.listen(8080);
#!/usr/bin/env coffee
# install dependencies: npm install irc
irc = require 'irc'
server = 'hubbard.freenode.net'
nickServPassword = ''
nick = 'bongbot'
client = new irc.Client server, 'bongbot',
@stevenleeg
stevenleeg / meh.js
Last active December 20, 2015 13:39
var MongoClient = require("mongodb").MongoClient;
MongoClient.connect(process.env.MONGO_URI, function(err, db) {
var users = db.collection("users");
var places = db.collection("places");
var one_done = 0;
function checkDone() {
if(one_done == 3) {
db.close();
var EventEmitter = require('events').EventEmitter;
var redis = require("redis");
var StatManager = function() {
var self = this;
self._data_handlers = [];
self._listeners = {};
self.stats = {};
self.aggregate_interval = undefined;
self.redis = redis.createClient();