Skip to content

Instantly share code, notes, and snippets.

Ryan Angilly ryana

Block or report user

Report or block ryana

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ryana
ryana / a.rb
Last active Aug 29, 2015 — forked from ahoward/3.1.6.txt
View a.rb
require 'mongoid'
Mongoid.configure do |config|
config.connect_to('test')
end
class Room
include Mongoid::Document
has_one :table, as: :parent, autobuild: true
@ryana
ryana / sha.rb
Created Apr 7, 2015
Testing to see if the to_i(16)/modulo of SHA256 has a uniform distribution
View sha.rb
h = {}
1_000_000.times do |i|
puts i if (i % 1_000 == 0)
str = (0...16).map { (65 + rand(26)).chr }.join
digest = (Digest::SHA256.new << str).to_s
num = digest.to_i(16) % 100
h[num] ||= 0
h[num] += 1
end
View detect IE and version number through injected conditional comments.js
//EnhanceJS isIE test idea
//detect IE and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//version arg is for IE version (optional)
//comparison arg supports 'lte', 'gte', etc (optional)
function isIE(version, comparison) {
var cc = 'IE',
b = document.createElement('B'),
@ryana
ryana / bool_tools.rb
Created Oct 24, 2008
annoys me to no end that to_bool isnt built in to ruby and that to_i isnt built into boolean classes. fixed.
View bool_tools.rb
class TrueClass
def to_i
1
end
def to_bool
self
end
end
@ryana
ryana / sh200.headers.txt
Created Feb 21, 2015
Southwest WIFI Hacking lingers on...
View sh200.headers.txt
Remote Address:199.27.79.184:80
Request URL:http://s7.addthis.com/static/r07/sh200.html
Request Method:GET
Status Code:304 Not Modified
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-GB,en;q=0.8,en-US;q=0.6
Cache-Control:max-age=0
View Script output
ra:~ ryan$ ruby reconnect.rb
......Connection reset by peer - recvfrom(2)
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/db.rb:349:in `recv'
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/db.rb:349:in `receive_full'
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/message/message_header.rb:31:in `read_header'
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/cursor.rb:206:in `read_message_header'
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/cursor.rb:194:in `read_all'
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/cursor.rb:277:in `send_query_if_needed'
Broken pipe
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/db.rb:507:in `write'
@ryana
ryana / controller.rb
Created Oct 14, 2009
Using ThinkingSphinx in ActiveScaffold, but the pagination links dont get created properly
View controller.rb
class Admin::PostController < AdminController
active_scaffold :post do |config|
config.action_links.add 'sphinx_search', :label => 'Search'
config.actions.exclude :search
CRU_COLUMNS = [:name, :content]
config.list.columns = CRU_COLUMNS
config.create.columns = CRU_COLUMNS
config.update.columns = CRU_COLUMNS
end
@ryana
ryana / regex.perf.rb
Created Apr 12, 2010
Testing regex parsing/evaluation performance of Ruby regexes
View regex.perf.rb
#!/usr/bin/ruby
require 'benchmark'
ryan = /\ARyan/
blake = /\ABlake/
darren = /\ADarren/
devin = /\ADevin/
composite3_regex = /\A(Ryan|Blake|Darren)/
composite4_regex = /\A(Ryan|Blake|Darren|Devin)/
View app_config.rb
module AppConfig
def self.config
unless @config
raw_config = File.read(File.join(File.dirname(__FILE__), '..', 'config', 'harmony.yml'))
config = YAML.load(raw_config)
config = config[RAILS_ENV] if defined?(RAILS_ENV)
@config = defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess.new(config) : config
end
@config
end
View error.txt
ra:timeline[master*]$ ruby wtf.rb
/Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb:35:in `assign_references': undefined method `_parent_document=' for nil:NilClass (NoMethodError)
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb:19:in `replace'
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/associations.rb:41:in `membership='
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/keys.rb:260:in `send'
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/keys.rb:260:in `load_from_database'
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/bson-1.0.2/lib/../lib/bson/ordered_hash.rb:72:in `each'
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/bson-1.0.2/lib/../lib/bson/ordered_hash.rb:72:in `each'
from /Users/ryan/.rvm
You can’t perform that action at this time.