Skip to content

Instantly share code, notes, and snippets.

@epitron
epitron / f.cr
Created January 31, 2015 05:40
A Crystal version of "f" (the file find utility)
#!/usr/bin/env ruby
#################################################################
## For author info, scroll to the end of this file.
#################################################################
#################################################################
## Load Modules
require "pp"
#################################################################
@epitron
epitron / pryrc-verbose-require.rb
Last active August 29, 2015 14:12
Alias for 'require' which tracks which modules get created and displays them in a tree.
command "req-verbose", "Requires gem(s). No need for quotes! (If the gem isn't installed, it will ask if you want to install it.)" do |*gems|
def tree_to_array(hash, indent=0)
result = []
dent = " " * indent
hash.each do |key,val|
result << dent+key
result += tree_to_array(val, indent+1) if val.any?
end
result
@epitron
epitron / double-gzip.txt
Last active August 29, 2015 14:11
The best compression algorithm for highly redundant text? Double gzip!
$ ls -lS hellos*
-rw-r--r-- 1 epi users 500001 Dec 17 01:49 hellos
-rw-r--r-- 1 epi users 770 Dec 17 01:50 hellos.gz
-rw-r--r-- 1 epi users 344 Dec 17 01:54 hellos.xz.bz2
-rw-r--r-- 1 epi users 272 Dec 17 01:50 hellos.xz.xz
-rw-r--r-- 1 epi users 235 Dec 17 01:50 hellos.xz.gz
-rw-r--r-- 1 epi users 212 Dec 17 01:50 hellos.xz
-rw-r--r-- 1 epi users 128 Dec 17 01:51 hellos.gz.xz
-rw-r--r-- 1 epi users 121 Dec 17 01:54 hellos.gz.bz2
-rw-r--r-- 1 epi users 75 Dec 17 01:50 hellos.gz.gz
@epitron
epitron / trebek.log
Last active August 29, 2015 14:11
Trivia bot test
$ ruby trivia.rb
Round 1! Category: NATIONAL HISTORIC SITES (from episode #4736, aired 2005-03-21)
Question: A portion of this avenue between the Capitol & the White House was designated a National Historic Site in 1965
Hint: ____________ ______
Hint: _____y______ ______
Hint: _____y______ ____u_
Hint: _____y______ ___nu_
Hint: ___n_y______ ___nu_
Hint: ___n_yl_____ ___nu_
Hint: ___n_ylv____ ___nu_
@epitron
epitron / gui-binding-stats.txt
Last active August 29, 2015 14:11
GUI bindings require a ridiculous amount of code. (Ranging from 19,000-200,000 lines.)
### wxruby #########################
1500 text files.
1480 unique files.
813 files ignored.
http://cloc.sourceforge.net v 1.60 T=4.21 s (172.6 files/s, 16513.3 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
#!/usr/bin/env ruby
require 'epitools'
class Array
def without(letters)
grouped = group_by { |letter| letter }
letters.each do |letter|
@epitron
epitron / page
Created December 12, 2014 08:16
#!/usr/bin/env ruby
require 'io/console'
thread = Thread.new do
$stdin.each_line do |line|
print "stdin: #{line}\r"
end
end
@epitron
epitron / crazytemplate.rb
Created December 4, 2014 04:59
Crazy Ruby Templating System, using Regular Ruby Strings!
require 'binding_of_caller'
class Tmpl
def initialize(&block)
@tmpl = block
end
def render
@thebinding = binding.of_caller(1)
@epitron
epitron / -
Created December 3, 2014 07:16
$ grep -i conlang *lesswrong*|field 3|sort|uniq -c
4 *
1 Betawolf
1 c0rw1n
3 capisce
1 cardboard_box
1 catern
1 cntarantula
1 cntgrational
1 cntnamstyle
@epitron
epitron / downto.c
Created December 1, 2014 04:34
A C "downto" operator, made of regular C syntax.
#include <stdio.h>
int main() {
int x = 10;
while (x --> 0) { // x downto 0
printf("%d ", x);
}
}