Skip to content

Instantly share code, notes, and snippets.

View h0rs3r4dish's full-sized avatar

Chris Szentkiralyi h0rs3r4dish

View GitHub Profile
@h0rs3r4dish
h0rs3r4dish / canine.rb
Created October 16, 2009 00:47
Canine, an easy Ruby "binary" library
class Canine
VERSION = '1.3'
def initialize(&block)
@commands = Hash.new
@default = @latest = :commands
@empty = nil
@auto = {
:commands => hash_command("commands","Show a list of commands",Proc.new {
@commands.each { |cmd| c = cmd[1]
name = c[:name].to_s
@h0rs3r4dish
h0rs3r4dish / errfree.md
Created December 11, 2009 03:24
errfree IRC bot manual

errfree Factoid/Markov Bot

errfree is a factoid & Markov chain text processing bot that features semi- intelligent conversation and the ability to discern question/answer phrases.

Table of Contents

  1. Basic Functions
@h0rs3r4dish
h0rs3r4dish / rt
Created December 16, 2009 02:35
RubyTask, a todo sort of app
#!/usr/bin/ruby
# Viewing as a Gist? See rubytask.md at the bottom
ARGV.push 'help' if ARGV.empty?
command = ARGV.shift.downcase
Taskfile = '/home/'+ENV['USER']+'/.rtasks'
system "touch #{Taskfile}" if !File.exist? Taskfile
@h0rs3r4dish
h0rs3r4dish / humane-examples.rb
Created December 17, 2009 04:42
HumaneBrick: WEBrick for sane people
require 'humane'
server = HB::Server.new # use "include HB" for even more fun
server.path "/" do # Hello world, HB style
write true, "h1. Hello, world!" # write() = puts() for the web; hx. = <hx></hx>
write true, "The URL you entered was '%s'" % url # Just pop that word in there and enjoy
end
server.path "/submit" do |name| # auto-magically gives you POST/GET-ed variables
@h0rs3r4dish
h0rs3r4dish / enum.rb
Created December 24, 2009 00:54
Enums, the Ruby Way
class Enum; class << self; def new(*list)
i = (list[0].class == Fixnum) ? list.shift : 0
Class.new.class_eval do
list.each { |item| const_set item, i; i += 1 }
class << self;
def each(&blk); self.constants.each { |i| blk.call(i) }; nil; end
def map(&blk); self.constants.map { |i| blk.call(i) }; end
end
self
end
@h0rs3r4dish
h0rs3r4dish / jsrepl.html
Created January 2, 2010 05:57
A Javascript REPL/console thing
<html>
<head>
<title>Javascript REPL</title>
<script type="text/javascript">
function $(i){return document.getElementById(i);}
</script>
</head>
<body>
<pre><span id="repl"></span><span style="font-size:12px;">&#x2588;</span></pre>
<script type="text/javascript">
@h0rs3r4dish
h0rs3r4dish / tree.rb
Created March 18, 2010 22:54
A pure-Ruby 'tree' utility
#!/usr/bin/ruby
=begin
Changelog for 1.7
* Fixed a bug where bottom-level directories did not, in fact, have their '/'
* Allowed the specification of flags and directories in any order. Thus, the
results of `tree -depth 1 test` and `tree test -depth 1` are identical, and
either can be used.
Changelog for 1.6.2
@h0rs3r4dish
h0rs3r4dish / tcg-commands.md
Created December 23, 2010 20:25
A command reference for the Ruby Dvorak TCG IRC bot

Dvorak TCG Command Reference

All commands need to either be sent to the bot via a PM, or prefixed with the command character (default: ;)

Table of Contents

@h0rs3r4dish
h0rs3r4dish / spec_runner.rb
Created April 3, 2011 18:16
This is my <100-line spec framework, and some accompanying demo code that showcases all the features.
#!/usr/bin/env ruby
module Spec
class AssertionError < Exception; end
class Should
def initialize(obj, invert=false)
@invert = invert
@self = obj
end
@h0rs3r4dish
h0rs3r4dish / meth.markdown
Created July 14, 2011 20:26
IAmA Former meth addict

Preface

About a month ago, "s0ck" made an "ask me anything" thread on Reddit. It's probably the absolute best description of a meth user I've ever seen, probably because it comes from. Watching Breaking Bad only makes me realize how spot-on that show is in how it portrays meth culture.

This document's basically what I find to be the most important and interesting bits of the IAmA thread.

Contents