Skip to content

Instantly share code, notes, and snippets.

View muffinista's full-sized avatar

Colin Mitchell muffinista

View GitHub Profile
@muffinista
muffinista / gist:5766917
Created June 12, 2013 16:27
Gopher 2000 simple example
route '/' do
render :index
end
menu :index do
# output a text entry in the menu
text 'simple gopher example'
link 'current time', '/time'
br
end
@muffinista
muffinista / document.rb
Created June 14, 2013 12:59
Parsing wikimedia dumps
class Document < Nokogiri::XML::SAX::Document
attr_accessor :in_page, :in_title, :in_text, :text, :title, :depth, :root
def initialize
@depth = 4
@root = "/opt/wiki"
if File.exist?("/opt/wiki/redirects")
File.delete("/opt/wiki/redirects")
end
if File.exist?("/opt/wiki/titles")
loop do
search "medbotqna SGUL finals" do |tweet|
txt = tweet[:text]
if txt =~ /001/
reply "#{tweet_user(tweet)} Here is your question - SGUL finals", tweet
reply "#{tweet_user(tweet)} Mrs Jones is a 68 year old life long smoker who has an operation next week. To continue please reply with SGUL finals 002", tweet
elsif txt =~ /002/
# stuff to handle 002 here
elsif txt =~ /003/
# stuff to handle 003 here
@muffinista
muffinista / gist:7374275
Created November 8, 2013 17:10
Infinite Gettysburg Address

As the assassin's bullet pierced his skull, Abraham Lincoln's mind drifted to the Gettysburg Address. As we all know, Lincoln was an early believer in the theory of the multiverse, and as his conciousness slipped away, he drifted amongst infinite parallel universes.

The Gettysburg Address On Earth-1

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.

@muffinista
muffinista / mitchc2_ebooks.rb
Last active December 29, 2015 13:19
ebook yourself
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'chatterbot/dsl'
require 'marky_markov'
#
# this is the script for the twitter bot mitchc2_ebooks
# generated on 2013-11-26 16:31:48 -0500
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'chatterbot/dsl'
require 'spacejam'
consumer_key 'key'
This file has been truncated, but you can view the full file.
192.99.19.154 - - [12/Jul/2014:03:17:08 -0500] "GET / HTTP/1.1" 200 29308 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.99.19.154 - - [12/Jul/2014:03:17:08 -0500] "GET /home HTTP/1.1" 200 29308 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.99.19.154 - - [12/Jul/2014:03:17:08 -0500] "GET /the-band--2 HTTP/1.1" 200 23952 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.99.19.154 - - [12/Jul/2014:03:17:08 -0500] "GET /tour HTTP/1.1" 200 26522 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.99.19.154 - - [12/Jul/2014:03:17:08 -0500] "GET /tour-history HTTP/1.1" 200 26191 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.99.19.154 - - [12/Jul/2014:03:17:09 -0500] "GET /the-american-dog-store HTTP/1.1" 200 96317 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.99.19.154 - - [12/Jul/2014:03:17:09 -0500] "GET /music HTTP/1.1" 200 3747
@muffinista
muffinista / gist:0d2c21a6d0c37a7402ab
Created September 24, 2014 12:23
1st letter of us place names
mysql> select substr(name, 1, 1) as alpha, count(id) from places group by alpha;
+-------+-----------+
| alpha | count(id) |
+-------+-----------+
| 1 | 7 |
| 2 | 4 |
| 4 | 1 |
| 6 | 1 |
| 9 | 1 |
| A | 7479 |

Keybase proof

I hereby claim:

  • I am muffinista on github.
  • I am muffinista (https://keybase.io/muffinista) on keybase.
  • I have a public key whose fingerprint is 9C2C D454 A0EC 5BF2 2A71 C42F 0313 C791 F8D8 2CBE

To claim this, I am signing this object:

class String
def to_full_width
offset = 65248
self.each_byte.collect { |x|
[x == 32 ? 12288 : (x + offset)].pack("U").freeze
}.join("")
end
end