Skip to content

Instantly share code, notes, and snippets.

function star_color()
return shuffle_colors({7,7,7,7,7,0,1}) -- white, black, dark blue
end
function shuffle_colors(colors)
local i=ceil(rnd(#colors))
return colors[i]
end
debug=false
pause=debug
skip_speed=50
start_time=0
t_offset=-5000
x_offset=-5
y_offset=-3
z_offset=-600
pan=0.075
zoom=0.025
@revdan
revdan / gist:3199ddbbe652a593a6cf
Created September 23, 2015 13:44
PGP Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFYCqIwBEACu20+nYk9Md02jG9jwOPRPY1tfDM5YuCIuhCa5I8Gr4/zZeFnY
wyN/Y0fq1hunb6K4XOW/b26Cg7ii5ePzVigRfpWuU3zKhEJLMidr+rwaLRjFOQOz
QIlqS1MXz69AeK+dWJ/CyYc+ZjyGM1npLB0BBIySHbvxKFKyPwZfs/VBXDpo5ee+
xWaehidp9jVxIL5KcMpPPhSfvLwVEKW5F6wfRGdvDY1looLnvMoHryrgbx+5zMCj
o6h+IXvtrsVnb9bccZr3qbblxdxsaWQL9d3N+8LxF6RzyK5eGCQsjXYhss3jZuvG
vpLR3/7xEImq9XZYtF7S+UoklyWrGHwy1fMH9fsd8kmBkOk3LkKockhTGb7qm12f
ianp16/qN36JluAY2RL0zajIeHLPg/kCrfx388rNgoxqQxSTo9XzlpSAxNxjFi1V
1Gm7f3lImR+DhQdOIY0tYcejC7Pny4+ZvyvbfY1DKd7yaSBnRCd6/y++9VjCC/4v
defmodule Divisible do
def sum_reversed(number, target) do
enumerate(number, target)
|> Stream.filter(&(is_divisible_reversed(&1, number)))
|> Enum.sum
end
def enumerate(number, target) do
Stream.iterate(number, &(&1 + number))
@revdan
revdan / sublist.exs
Last active August 29, 2015 14:24
exercism sublists
defmodule Sublist do
@doc """
Returns whether the first list is a sublist or a superlist of the second list
and if not whether it is equal or unequal to the second list.
"""
@spec compare(List, List) :: atom
def compare(a, b) do
cond do
a === b -> :equal
class CaesarCipherizer
def initialize(distance = nil)
@distance = distance.to_i
end
def encrypt(text)
text.tr(alphabet, cipher)
end
@revdan
revdan / binary_search.rb
Last active August 29, 2015 14:17
Binary Search Class in Ruby
module BinarySearchExtensions
refine Array do
def mean
reduce(&:+) / length.to_f
end
end
end
class BinarySearch
using BinarySearchExtensions
@revdan
revdan / straight.rb
Last active August 29, 2015 14:17
Algorithm to find a poker straight
x = [5,6,7,8,9]
y = x.map(&:succ)
(x - y) + (y - x) == [(x+y).min, (x+y).max]
@revdan
revdan / watch_folder.js
Created February 6, 2015 11:58
node.js folder watcher
const watcher = require('chokidar').watch(process.argv[2], {ignored: /^\./, persistent: true})
watcher
.on('add', function(path) {console.log('✅ ', path) })
.on('change', function(path) {console.log('💃 ', path) })
.on('unlink', function(path) {console.log('❌ ', path) })
.on('error', function(err) {console.error('💩 ', err) })
@revdan
revdan / complement.rb
Last active August 29, 2015 14:14
exercism.io Rna Transcription
class Complement
def self.of_dna(dna)
dna.chars.map { |char| transpositions[char] }.join
end
def self.of_rna(rna)
rna.chars.map { |char| transpositions.invert[char] }.join
end