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
# mDNS client | |
# | |
# Usage: ruby script.rb "_http._tcp.local." | |
require "socket" | |
require "ipaddr" | |
require "fcntl" | |
require "resolv" | |
module DNSSD |
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
#!/Users/aaron/.rubies/arm64/ruby-trunk/bin/ruby | |
# Configure Vim (using vim-lsp) like this where `ls.rb` is this script: | |
# | |
# if executable('./ls.rb') | |
# au User lsp_setup call lsp#register_server({ | |
# \ 'name': 'ls.rb', | |
# \ 'cmd': ['./ls.rb'], | |
# \ 'allowlist': ['ruby'], | |
# \ }) |
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 "strscan" | |
class Lexer | |
IDENTIFIER = /[_A-Za-z][_0-9A-Za-z]*\b/ | |
IGNORE = %r{ | |
(?: | |
[, \c\r\n\t]+ | | |
\#.*$ | |
)* | |
}x |
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
profiler = Thread.new do | |
while true | |
p Thread.main.backtrace | |
sleep 0.5 | |
end | |
end | |
def slow_function | |
sleep 2 | |
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
#!/Users/aaron/.rubies/arm64/ruby-trunk/bin/ruby | |
# Configure Vim (using vim-lsp) like this where `ls.rb` is this script: | |
# | |
# if executable('./ls.rb') | |
# au User lsp_setup call lsp#register_server({ | |
# \ 'name': 'ls.rb', | |
# \ 'cmd': ['./ls.rb'], | |
# \ 'allowlist': ['ruby'], | |
# \ }) |
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
#!/Users/aaron/.rubies/arm64/ruby-trunk/bin/ruby | |
# This is a demo language server for Ruby, written in Ruby. It just checks | |
# the syntax of Ruby programs when you save them. | |
# | |
# Configure this in Vim by adding the vim-lsp plugin, then doing this | |
# in your vimrc: | |
# | |
# au User lsp_setup | |
# \ lsp#register_server({ |
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 "benchmark/ips" | |
require "graphql/language/lexer" | |
require "graphql/language/token" | |
require "graphql/language/block_string" | |
schema = DATA.read | |
Benchmark.ips { |x| | |
x.report("graphql") { GraphQL::Language::Lexer.tokenize(schema) } | |
} |
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
# Okasaki style Functional Red Black Tree | |
# https://www.cs.tufts.edu/comp/150FP/archive/chris-okasaki/redblack99.pdf | |
# | |
# leaves and root are black | |
# BST | |
# No red node has a red child | |
# Every path from the root to a leaf has the same number of black nodes | |
module RBTree | |
class Leaf |
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 "fisk" | |
require "aarch64" | |
require "jit_buffer" | |
require "fiddle" | |
x86 = Fisk.new | |
x86.put_label(:foo) | |
x86.mov(x86.rax, x86.imm(42)) | |
x86.ret | |
x86.jmp(x86.label(:foo)) |
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
# Smart Health Card decoder | |
# This decodes the SHC url thing that is stored in smart health card QR codes | |
str = DATA.readline | |
require "base64" | |
require "zlib" | |
require "json" | |
require "pp" |
NewerOlder