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
<canvas> | |
<script> | |
ctx = document.querySelector('canvas').getContext('2d') | |
ctx.clearRect(0, 0, 1000, 1000) | |
const blur = 12 | |
ctx.shadowBlur = blur | |
ctx.shadowColor = 'black' | |
ctx.shadowOffsetX = blur | |
ctx.shadowOffsetY = blur | |
const x = 20 |
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
require 'chunky_png' | |
case ARGV[0] | |
when 'red' | |
FLOOR_COLOR = [0xff, 0x80, 0x80] | |
LEAF_COLOR = 0xff0044 | |
TRUNK_COLOR = 0xff8888 | |
RAY_COLOR = [2, 1, 1] | |
LIGHT_THETA = 0.1 | |
when 'green' |
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
codepoints = File.read('EastAsianWidth.txt').scan(/^[0-9A-F]{4,6}/).map { _1.to_i(16) } | |
widths = codepoints.map do |cp| | |
c = cp.chr('utf-8') rescue (next nil) | |
print "\e[H\e[K#{c}\e[6n" | |
STDOUT.flush | |
/\e\[\d+;(\d+)R/ =~ STDIN.raw { STDIN.readpartial(1000) } | |
$1.to_i - 1 | |
end | |
codepoints.zip(widths).reject { | |
!_2 || Reline::Unicode.get_mbchar_width(''<<_1) == _2 || ('a'<<_1).grapheme_clusters.size == 1 |
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
<body> | |
<script> | |
const width = 1600 | |
const height = 900 | |
function f(x) { | |
return 0.48+(-Math.cos(12*x+3*Math.sin(6*x-4)/4-1)*(1.1-x)+(3*x-(2*x-1)**2)*0.5)/20 | |
} | |
function g(x, a) { | |
return ( | |
Math.sin(12.4*x-a)+Math.sin(14.3*x+a)+ |
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
require 'io/console' | |
require 'pty' | |
command = ARGV.join(' ') | |
if command.empty? | |
puts 'Error: Command not specified.' | |
puts "Usage: `ruby #{File.basename __FILE__} options -- command`" | |
exit | |
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
srand 0 | |
6.times do |index| | |
bg = "##{3.times.map{"%02x" % rand(0..128)}.join}" | |
fg = "##{3.times.map{"%02x" % rand(128..255)}.join}" | |
face = :"face#{index}" | |
Reline::Face.config(face) do | |
_1.define(:default, foreground: fg, background: bg) | |
end | |
pointClass = Data.define :x, :y | |
Reline.add_dialog_proc :"dialog#{index}", ->{ |
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
require 'irb' | |
require 'reline' | |
$status = nil | |
Reline::Face.config(:editor_status) do |face| | |
face.define :default, foreground: :white, background: :blue | |
end | |
Reline.add_dialog_proc :editor_status, ->(*) do | |
if (message = $status) | |
$status = nil |
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
# compile.c:L3057 | |
# if (lab->unremovable) { | |
# rb_gv_set("$FOO", Qtrue); // Add this to run this script | |
# break; // maybe bug | |
# } | |
require 'prism' | |
class StringVisitor < Prism::Visitor | |
attr_reader :strings | |
def initialize; @strings = [] 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
require 'ripper' | |
$VERBOSE = nil | |
tokens = <<'S'.split | |
def if true false nil + - = a A :: '' "#{ | |
class module ? : . ( [ { -> | & * , / % ! @ $ ; < << | |
S | |
loop do | |
code = (tokens.sample(9) + [' ']*5).shuffle.join | |
# code = tokens.sample(9).join(' ') |
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
# RDOC_USE_PRISM_PARSER=1 bundle exec rdoc --op foo/bar | |
path_a = 'prism' | |
path_b = 'legacy' | |
files_a = Dir.chdir(path_a){Dir.glob('**/*.html')} | |
files_b = Dir.chdir(path_b){Dir.glob('**/*.html')} | |
def red(s) = "\e[31m#{s}\e[m" | |
def green(s) = "\e[32m#{s}\e[m" |
NewerOlder