Skip to content

Instantly share code, notes, and snippets.

View raggi's full-sized avatar

James Tucker raggi

View GitHub Profile
@raggi
raggi / .gitignore
Last active March 30, 2017 05:50
Example plain text gem indexer
specs.4.8
prerelease_specs.4.8
versions.list
names.list
specs
deps
gems
@raggi
raggi / cloudbleed.md
Created February 25, 2017 01:00
Some advice on appropriate cloudbleed response

Cloudbleed: Users can't fix themselves

TL;DR

Site-owners MUST invalidate all their users sessions and tokens now, and might want to consider doing so again in the not distant future.

Cloudflare domain lists

There has been a great deal of discussion about the Cloudflare domain lists that are being constructed. These lists are not really all that useful for cleaning up this mess. Let me explain.

@raggi
raggi / bm_dci_pounding.rb
Last active September 22, 2016 23:19
Show the effects of method cache damage from runtime extend, as it relates to extend vs. delegate for DCI.
require 'benchmark'
number_of_rails_methods = 300
@rails = Class.new do
number_of_rails_methods.times do |i|
class_eval <<-RUBY
def call#{"%02d" % i} # def call01
end # end
RUBY
@raggi
raggi / alias_task.rake
Created November 12, 2009 15:11
A helper to alias a task in rake
def alias_task(name, old_name)
t = Rake::Task[old_name]
desc t.full_comment if t.full_comment
task name, *t.arg_names do |_, args|
# values_at is broken on Rake::TaskArguments
args = t.arg_names.map { |a| args[a] }
t.invoke(args)
end
end
@raggi
raggi / em_chat_channel_server.rb
Created October 17, 2010 17:42
chat server example using EM::Channel pub-sub, with simple tracing for teaching
require 'eventmachine'
require 'socket'
class Client < EM::Connection
include EM::P::LineText2
HELP = "Server - Welcome to ghettochat. Use /nick to set your nick.\n"
def initialize(global_channel)
@global = global_channel
@raggi
raggi / keybase.md
Created June 30, 2016 23:06
keybase.md

Keybase proof

I hereby claim:

  • I am raggi on github.
  • I am raggi (https://keybase.io/raggi) on keybase.
  • I have a public key whose fingerprint is 2F4F F34C A2E1 06F6 67A6 0378 BA61 B1EC D0C6 87C3

To claim this, I am signing this object:

@raggi
raggi / handler.js
Last active May 7, 2016 22:25
Modern JS event handling mixin
const Handler = Base => class extends Base {
handleEvent (evt) {
return this[`on${evt.type.replace(/^./, c => c.toUpperCase())}`](evt)
}
}
@raggi
raggi / escape_like.rb
Created September 27, 2011 21:31
YOU WON'T (escape likes)
module EscapeLike
# Escape SQL LIKE arguments. N.B. This should be combined with use of the
# ESCAPE parameter also. See:
# http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
#
# pattern = escape_like(params[:pattern]) << '%'
# query = where(["name LIKE ? ESCAPE ?", pattern, '\\'])
#
# By default this method uses MySQLs default escape, backslash.
# Unfortunately, this can get exceedingly confusing in output. As soon as
# Bugs..
p __FILE__, __dir__, eval('__FILE__', binding, __FILE__, 0), eval('__dir__', binding, __FILE__, 0)
# "dir.rb"
# "/Users/raggi"
# "dir.rb"
# nil
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.12 (Darwin)
mQINBFEkHmoBEACqeBffB0ytt4m3qvZi3+PLDeh8aQ8irYJl4BXm+A5Gih0ApTE1
+ahMCFuqSfN0MJDvFxcFYPHto4GTQZqG8h+J0AVnh/8zoJnVrvi6k/il1gs0oZSz
lJ9xJb5Wu9sL0ohST51DcOW/JnVEEsz5EamnzNwxFsIHLFmqmZ9gRFeeauKWMpQl
GUlFggMuuGb+LUDEsI3XMv4ISce1F3vugNLXrhanpjKH/qmqTgDQlxIazvxzI87b
VArV9Ol5MSc7o+xvFPR6vozLlGM4I9rUj/kfwVQX6A4ga6TE9D9qdArqRtDPARQN
0vkApbbpQilQy0ydw50O+M6MtKaxqe65h7y2cxr5enmaZNdqxRByv+qf7ilKXcmr
daCoTVPvWi9H/o2Ufxia6GrC4E5qaEL35WWADYV+LNH2P33izu6Vnw0CCfNsFBlw