View undulating_waves.rb
# video @ https://vimeo.com/218743733
require 'graphics'
class Waves < Graphics::Simulation
include Math
def initialize
super 600, 600, 24
self.color.default_proc = -> h, k { k }
end
View you_spin_me_right_round.rb
require'io/console'
include Math
p,t=PI,"You spin me right round baby, right round round round."
.split(/\b/).flat_map.with_index{|w,i|w.chars.map{|c|"\e[9#{i%7+1}m#{c}"}}+
(" "*10).chars
r,ø=t.size/2/p,2*p/t.size
$><<"\e[H\e[2J\e[?25l"
at_exit{$><<"\e[?25h"}
loop.with_index{|*,c|t.each.with_index(-c){|c,i|print"\e[#{
(sin(ø*i)*r+r+1).to_i};#{(cos(ø*i)*r*2+r*2+1).to_i}H#{c}"}
View xoxo.rb
%%%%%%%%%%%%%%%%%%%%%%%
public def /*; self end
public def _*; self end
{}./{//}./$\,//./,//,$,
$.._$,,%,?,,?,,$_,$?,??
//=~$/&&__=-11+_=$.+111
$><<<<-"<<<"<<<<-">>"<<
<<<
>>
($`<<_-3<<_<<_+7<<-~__)
View melancholy.rb
# https://vimeo.com/217760201
# can't remember if this is the version from the video or not
# that one might've been simpler (w/o the lambdas)
require 'graphics'
class Smth < Graphics::Simulation
def initialize
super 1000, 600, 24
self.color.default_proc = -> h, k { k }
View walkers1.rb
# video @ https://vimeo.com/217144282
require 'graphics'
class Walkers < Graphics::Simulation
def initialize
super 800, 600, 24
color.default_proc = -> h, k { k }
@walkers = 50.times.map do
length = 15
colour = [
View bash_arrays_vs_multiline_strings.sh
#!/usr/bin/env bash
-----() { echo "----- $1 -----"; }
----- 'ARRAY' -----
ary=()
ary+=(abc)
ary+=("d e")
for val in "${ary[@]}"; do
View hilight
#!/usr/bin/env ruby -p
# Output hilighter for the Clojure koans:
# https://github.com/functional-koans/clojure-koans
# written against git commit
# 9b3efbb0268794c6f5e5516589bb17ed78000602
gsub /^clojure\.lang\.ExceptionInfo:\s+(.*)$/,
"\e[41;37;1m \\1 \e[0m"
View align_gemfiles.rb
require 'bundler'
require 'pathname'
path1 = ARGV[0]
path2 = ARGV[1]
lockfile1 = File.read File.join(path1, 'Gemfile.lock')
lockfile2 = File.read File.join(path2, 'Gemfile.lock')
ROOT = File.expand_path '.'
View mandelbrot.rb
# image @ https://twitter.com/josh_cheek/status/846199094519443456
require 'graphics'
# https://www.bowdoin.edu/~dfrancis/askanerd/mandelbrot/
#
# Consider the code:
# Z = 0
# C = /* some complex number */
# loop { Z = Z*Z + C }
#
View bezier_with_sindy.rb
# The JavaScript version is @ http://codepen.io/josh_cheek/pen/VpBJVQ?editors=0010
require 'graphics'
class BezierForSindy < Graphics::Simulation
def initialize
super 500, 500, 24
@initial_points = [
[50, h-50],
[50, 50],
[w/2-50, h-50],