View get_the_browser_to_talk_to_you.html
<!doctype html>
<!-- http://codepen.io/josh_cheek/pen/WpeqKp -->
<meta charset="utf-8"/>
<textarea autofocus cols="30" rows="6">Nuestras gatas beben leche</textarea>
<button onclick="say(document.querySelector('textarea').value)">
¡Hablas!
</button>
<script>
View location_distance.rb
loc1_name = 'Chicago' # => "Chicago"
loc2_name = 'Houston' # => "Houston"
# Get the lib with `gem install geocoder`
# it ultimately calls out to this API: http://maps.googleapis.com/maps/api/geocode/json?address=Chicago&language=en&sensor=false
require 'geocoder' # => true
include Math # => Object
def radians(n)
n * PI / 180 # => 0.7309109668442155, -1.5294285014482003, 0.5194174327134308, -1.664517065837707
View sampling_rate.rb
# image @ https://twitter.com/josh_cheek/status/833892618656477185
fn = -> ø, r { Math.sin(ø*r)*10+r }
include Math
require 'graphics'
d = Graphics::Drawing.new 800, 600, 24
sqrt(d.w**2+d.h**2)./(10).round.times { |r|
0.step(to: PI/2, by: 0.0075)
.map { |ø| [ø, fn[ø, r*10]] }
.each_cons(2) { |(ø1, r1), (ø2, r2)|
View shutter.rb
require "graphics"
class Shutter < Graphics::Simulation
CLEAR_COLOR = [36, 30, 10]
def initialize
super 800, 450, 24
@points = [
[-1, -1],
[-w/2, h/2],
View fruit_flies.rb
# video https://twitter.com/josh_cheek/status/833115369267150848
require "graphics"
class FruitFlies < Graphics::Simulation
CLEAR_COLOR = [10, 21, 36]
def initialize
super 600, 350, 24
@points = 400.times.map { rand_point }
@delayed_draw = []
View shaft_shearing.rb
require "graphics"
class ShaftShearing < Graphics::Simulation
# I should soooo make one called "fruit flies ponder a pond where the bg is
# like [10, 21, 36], and there is a circle at the end of the bezier
CLEAR_COLOR = [36, 30, 10]
def initialize
super 800, 450, 24
@points = [[-1, -1], [-1, h], [w, h], [w, -1]]
View coffee_skimmer.rb
require "graphics"
class CoffeeSkimmer < Graphics::Simulation
CLEAR_COLOR = [36, 30, 10]
def initialize
super 800, 450, 24
color.default_proc = -> h, k { k }
@points = 500.times.map { [rand(3*w)-1*w, rand(3*h)-1*h] }
@points.concat @points.take(200)
View coffee_and_cream.rb
# Video: https://twitter.com/josh_cheek/status/832215561841033216
# Related: https://gist.github.com/JoshCheek/445fb5cda04b579305c59350fe0c1ca7
#
# You might need to already understand how bezier curves work to understand this.
# This one is probably a reasonable way to explore it:
# https://gist.github.com/JoshCheek/9139ff5f2764493a69675268e5e9556d
require "graphics"
class CoffeeAndCream < Graphics::Simulation
# I should soooo make one called "fruit flies ponder a pond where the bg is
View writhing_electric_bezier.rb
# Video @ https://twitter.com/josh_cheek/status/832083163220475905
# You might need to already understand how bezier curves work to understand this.
# This one is probably a reasonable way to explore it:
# https://gist.github.com/JoshCheek/9139ff5f2764493a69675268e5e9556d
require "graphics"
class Integer
def of(obj)
times.map { obj }
View js_closure_thing.js
const actionsFor = state => {
const WITH = attrs => actionsFor(Object.assign({}, state, attrs))
return {
ADD_NAME: ({ name }) => WITH({names: [name, ...state.names] }),
LOG_STATE: () => console.log(state) || actionsFor(state),
}
}
// dispatcher
const buildDispatcher = actions => (action, options={}) =>