Skip to content

Instantly share code, notes, and snippets.

View mame's full-sized avatar

Yusuke Endoh mame

View GitHub Profile
@mame
mame / README.md
Created September 28, 2022 14:35
A non-trivial quine written in Liquid markup language
$ gem install liquid

$ ruby -rliquid -e 'puts Liquid::Template.parse($<.read).render' quine.liquid
{%assign a="{Passign a=QZQ|split:QQP}{Pfor c in aP}{Pif c == a[12]P}{{a}}{Pelsif c == a[1]P}P{Pelsif c == a[11]P}Q{PelseP}{{c}}{PendifP}{PendforP}"|split:""%}{%for c in a%}{%if c == a[12]%}{{a}}{%elsif c == a[1]%}%{%elsif c == a[11]%}"{%else%}{{c}}{%endif%}{%endfor%}

$ diff -s quine.liquid <(ruby -rliquid -e 'puts Liquid::Template.parse($<.read).render' quine.liquid)
Files quine.liquid and /dev/fd/63 are identical
@mame
mame / dev-meeting-agenda-setup.rb
Last active May 14, 2021 00:09
A script to create an agenda for dev-meeting https://bugs.ruby-lang.org/issues/14770
#!/usr/bin/env ruby
require "open-uri"
require "json"
unless ARGV[0] =~ %r{\Ahttps://bugs.ruby-lang.org/issues/(\d+)\z}
puts "Usage: #$0 https://bugs.ruby-lang.org/issues/XXXX"
exit 1
end
$ ./miniruby -e 'use_symbol = Object.instance_methods[0].is_a?(Symbol)
nummodule = nummethod = 0
mods = []
ObjectSpace.each_object(Module) {|m| mods << m if m.name }
mods = mods.sort_by {|m| m.name }
mods.each {|mod|
nummodule += 1
mc = mod.kind_of?(Class) ? "class" : "module"
puts "#{mc} #{mod.name} #{(mod.ancestors - [mod]).inspect}"
mod.singleton_methods(false).sort.each {|methname|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.css">
<html><head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"></script><meta charset="utf-8" />
<!-- generated by ansi-to-html 0.0.3 https://github.com/uu59/ansi-to-html -->
</head><body style="color:#fff;background-color:#000">
<pre>
{"* malloc_info gen statistics"=>[["0", "29575", "12037320"], ["1", "16031", "2734752"], ["2", "910", "5874816"], ["3", "308", "5510752"], ["4", "8", "15440"], ["5", "12", "116848"], ["6", "4", "1312"], ["7", "177", "5559128"], ["8", "103", "59848"], ["9", "8", "768"], ["10", "15", "1288"], ["11", "11", "1080"], ["12", "14", "4496"], ["13", "18", "30400"], ["14", "1", "72"], ["15", "1", "120"], ["16", "30", "232976"], ["17", "7", "504"], ["18", "0", "0"], ["19", "18", "2224"], ["20", "0", "0"], ["21", "17", "18080"], ["22", "0", "0"], ["23", "0", "0"], ["24", "0", "0"], ["25", "0", "0"], ["26", "0", "0"], ["27", "0", "0"], ["28", "0", "0"], ["29", "0", "0"], ["30", "0", "0"], ["31", "0", "0"], ["32", "0", "0"], ["33", "0", "0"], ["34", "0", "0
@mame
mame / README.md
Last active September 11, 2021 10:23
M1 k1 = (call/cc (M2 k1)) + 3
M2 k1 k2 = if b then (k1 1) else (k2 2)
(call/cc M1) + 4
S1 k1 = (shift (λk2. k2 (S2 k1 k2))) + 3
S2 k1 k2 = if b then (k1 1) else (k2 2)
reset(exit(shift (λk1. k1 (S1 k1)) + 4))
require 'benchmark'
class MemberClass
def initialize(a, b, c, d, e, f, g)
@a = a
@b = b
@c = c
@d = d
@e = e
@f = f
@mame
mame / main.rb
Created November 8, 2015 16:48
eval(v=%(eval((e=*%w'662c3d220
214450800010840000001108420800
2084211000024cf324000000011c40
114a5288001184211c003242643c00
788c1498001194f108007a1c149800
321c9498007 844221000324c94980
032527098000 01e0780004a5e94a
400000e949c0 0421c94b8000006
420c00084e94 9c00000cb618001
148e21000421 2e4 a400308421
eval(v=%(eval((e=*%w'662c3d220
214450800010840000001108420800
2084211000024cf324000000011c40
114a5288001184211c003242643c00
788c1498001194f108007a1c149800
321c9498007844221000324c949800
3252709800001e0780004a5e94a400
000e949c00421c94b8000006420c00
084e949c00000cb618001148e21000
4212e4a4003084211c00001c972100