Skip to content

Instantly share code, notes, and snippets.

Josh Cheek JoshCheek

Block or report user

Report or block JoshCheek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JoshCheek
JoshCheek / hydra.js
Last active Jun 22, 2019
Attempting to draw a hydra with hydra
View hydra.js
solid().constructor.prototype.sin = function (radius, frequency, offset=0) {
return this.scrollX(radius).rotate(offset,frequency)
}
// need to figure out how to convert these to epicycles
// 94.75,70.19999694824219 87.60526275634766,68.36907196044922 81.8226547241211,69.729736328125 79.25341796875,76.64624786376953 76.66010284423828,83.35103607177734 69.29661560058594,83.73706817626953 62.081077575683594,85.23097229003906 57.438026428222656,80.36616516113281 53.0716667175293,74.41837310791016 47.33558654785156,73.1541748046875 40.800262451171875,76.56771850585938 34.873775482177734,80.94866180419922 36.75628662109375,87.4500503540039 39.90579605102539,94.12261199951172 38.09734344482422,100.01497650146484 33.584781646728516,105.8336181640625 28.309032440185547,108.61717224121094 21.038862228393555,107.36031341552734 14.398143768310547,107.5927505493164 12.04347038269043,114.56926727294922 10.539800643920898,121.79061889648438 13.436785697937012,126.81439208984375 20.323444366455078,129.46315002441406 25.62
@JoshCheek
JoshCheek / scrape_sigs
Last active Jun 16, 2019
My hydra signature scraping script
View scrape_sigs
#!/usr/bin/env bash
node -e 'console.log(JSON.stringify(require("./src/composable-glsl-functions.js")))' \
| ruby -r json -e '
puts JSON.parse($stdin.read, symbolize_names: true)
.map { |name, defn| {**defn, name: name} }
.group_by { |defn| defn[:type] }
.sort
.each { |cat, defns| defns.sort_by! { |defn| defn[:name] } }
.map { |category, defns|
defns.zip([category]).map.with_index { |(defn,category),i|
View duo_lingo_clone.rb
#!/usr/bin/env ruby
require 'readline'
# copied from https://www.vistawide.com/spanish/top_100_spanish_words.htm
list = <<~WORDS
el / la (def. art.) the
de (prep.) of, from
que (conj.) that, which
y (conj.) and
a (prep.) to, at
@JoshCheek
JoshCheek / readline_insta_closes_in_worker_thread.js
Created Jun 9, 2019
Readline instacloses in worker thread
View readline_insta_closes_in_worker_thread.js
const readline = require('readline')
const { Worker, isMainThread } = require('worker_threads')
if(isMainThread)
new Promise((resolve, reject) => {
const worker = new Worker(__filename, {})
worker.on('message', message => console.log(message))
worker.on('error', err => reject)
worker.on('exit', resolve)
})
@JoshCheek
JoshCheek / you_spin_me_right_round.sh
Last active Jun 8, 2019
You spin me right round (iterations)
View you_spin_me_right_round.sh
# Tweet: https://twitter.com/josh_cheek/status/1137422115181871104
# Video: https://vimeo.com/341108197
# 1
node -e h=$LINES,w=$COLUMNS,p=process,t=0,T=6.28,s='""
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit())
setInterval(()=>{++t;p.stdout.write(`\x1b[2J`)
l=s.length+5
r=l/T
x=i=>Math.round(Math.cos(T*(i-t)/l)*r*2+r*2)+1
@JoshCheek
JoshCheek / v0.rb
Last active May 25, 2019
Tweetable Mandelbrot Set
View v0.rb
# The first version was one I made in 2017 for Graphics,
# it has much better resolution but isn't animated:
# https://twitter.com/josh_cheek/status/846199094519443456
# https://gist.github.com/JoshCheek/dbb07c35e46d45f57c33579e03095f1c
@JoshCheek
JoshCheek / abandon_all_hope_ye_who_enter_here.md
Last active May 30, 2019
Evil Ruby: Turning procs into first class functions
View abandon_all_hope_ye_who_enter_here.md
  • To read the original tweet and comments, click here.
  • For my followup abomination, click here
  • If you're thinking about treating this as anything other than art, read there 👇

DISCLAIMER:

THIS IS ART, DON'T ACTUALLY DO THIS IN ANY CODE THAT YOU CARE ABOUT!

☠️ This is not a place of honor ☠️

@JoshCheek
JoshCheek / list.c
Last active May 19, 2019
Writing Ruby Like C (fun video of the process here: https://vimeo.com/336921852)
View list.c
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct list {
char* data;
struct list* successor;
} List;
@JoshCheek
JoshCheek / progression_of_terminal_drawer.sh
Created May 14, 2019
Progression of "Terminal Drawer"
View progression_of_terminal_drawer.sh
require 'benchmark'
RUBY_VERSION # => "2.6.0"
n = 10_000
# arbitrarily sized callstack
def call_at_depth(n, &b)
n.zero? ? b.() : call_at_depth(n-1,&b)
end
ary = []
@JoshCheek
JoshCheek / mouse_reporting.sh
Last active May 17, 2019
Mouse reporting in the terminal
View mouse_reporting.sh
# https://gist.github.com/JoshCheek/8c4ee41ddfd305fdb628f5feabb515ce
ruby -rio/console -e '
# 1003 = report all mouse events,
# 1006 = in SGR format (CSI "<" button ";" Cx ";" Cy {"M","m"})
print "\e[?1006h\e[?1003h\e[?25l"
at_exit do
print "\e[?1006l\e[?1003l\e[?25h"
end
loop do
str = $stdin.raw { $stdin.readpartial 1000 }
You can’t perform that action at this time.