This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CaesarCipherizer | |
def initialize(distance = nil) | |
@distance = distance.to_i | |
end | |
def encrypt(text) | |
text.tr(alphabet, cipher) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BinarySearchExtensions | |
refine Array do | |
def mean | |
reduce(&:+) / length.to_f | |
end | |
end | |
end | |
class BinarySearch | |
using BinarySearchExtensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = [5,6,7,8,9] | |
y = x.map(&:succ) | |
(x - y) + (y - x) == [(x+y).min, (x+y).max] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder