Skip to content

Instantly share code, notes, and snippets.

@naphthalene
naphthalene / mpdfifo
Created July 12, 2015 20:12
MPD FM Radio Init Script
#!/bin/bash
### BEGIN INIT INFO
# Provides: mpdfifo
# Required-Start: pulseaudio mpd
# Default-Start: 2 3 4 5
# Short-Description: MPD FM radio broadcasting
### END INIT INFO
# Author: Pavel Sadikov <pashalab@gmail.com>
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
var SUITS = ["H", "D", "S", "C"];
var CARDS = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"];
var RANKS = ["HC", "1P", "2P", "3K", "ST", "FL", "FH", "4K", "SF", "RF"];
@naphthalene
naphthalene / Makefile
Created April 2, 2015 16:19
Berkeley AI [all projects] Makefile
# Author: Pasha Sadikov <pashalab at gmail dot com>
# USAGE:
# Create a directory for each project with the code provided in the
# assignment.
# $ make PA0 # To make the tutorial; PA1, 2, 3 etc. for the other
# # projects
# CONFIGURE your USERNAME here
@naphthalene
naphthalene / Makefile
Last active August 29, 2015 14:18
Berkeley AI [all projects] Makefile
# Author: Pasha Sadikov <pashalab at gmail dot com>
# USAGE:
# Create a directory for each project with the code provided in the
# assignment.
# $ make PA0 # To make the tutorial; PA1, 2, 3 etc. for the other
# # projects
# CONFIGURE your USERNAME here
import bpy
from math import pi
## Create a set of keyframes for Suzanne using Blender python
bpy.ops.graph.interpolation_type(type="CUBIC")
suzie = bpy.data.objects['Suzanne']
# Each keyframe is (frame, location, rotation, scale)
#!/usr/bin/python2
from tabulate import tabulate
from random import random
from math import floor
DAYS = 7
SECTIONS = 10
MAX_TTR = 6 # minutes -> max time to read
MIN_TTR = 2
#!/usr/bin/python2
from tabulate import tabulate
from random import random
from math import floor
DAYS = 7
SECTIONS = 10
MAX_TTR = 6 # minutes -> max time to read
MIN_TTR = 2
#!/usr/bin/python
from Queue import Queue as Q
class UndirectedGraph:
def __init__(self, vertices, edges):
self.vertices = vertices
self.edges = edges
if not self.validate_edges(self.edges):
print "Invalid Graph"
#!/usr/bin/python
from Queue import Queue as Q
class UndirectedGraph:
def __init__(self, vertices, edges):
self.vertices = vertices
self.edges = edges
if not self.validate_edges(self.edges):
print "Invalid Graph"
@naphthalene
naphthalene / buckets.py
Created September 28, 2014 15:27
buckets_yo
from itertools import permutations
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
import pylab
class BucketGraph:
def __init__(self, buckets):
self.buckets = buckets
self.g = nx.DiGraph()