Skip to content

Instantly share code, notes, and snippets.

@jswanner
jswanner / v2.3.18-v3.0.0.diff
Created April 28, 2014 22:46
Rails diff of v2.3.18 to v3.0.0
diff -Nr -U 1000 tmp/generated/v2.3.18/.gitignore tmp/generated/v3.0.0/.gitignore
--- tmp/generated/v2.3.18/.gitignore 1969-12-31 16:00:00.000000000 -0800
+++ tmp/generated/v3.0.0/.gitignore 2014-02-21 19:34:53.000000000 -0800
@@ -0,0 +1,4 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/**/*
diff -Nr -U 1000 tmp/generated/v2.3.18/Gemfile tmp/generated/v3.0.0/Gemfile
--- tmp/generated/v2.3.18/Gemfile 1969-12-31 16:00:00.000000000 -0800
@allolex
allolex / README.md
Last active August 29, 2015 14:00
Regular expression examples
Top 50 tests by objects allocated
224624: EagerLoadPolyAssocsTest#test_include_query
212146: SchemaDumperDefaultsTest#test_schema_dump_defaults_with_universally_supported_types
172186: EagerAssociationTest#test_eager_with_multiple_associations_with_same_table_has_many_and_habtm
154367: AttributeMethodsTest#test_time_zone_aware_attribute_saved
107256: MigrationTest#test_migrator_versions
105861: MigrationTest#test_filtering_migrations
104094: MigrationTest#test_migration_without_transaction
98828: MigrationTest#test_add_table_with_decimals
@andywenk
andywenk / email_address_validator.rb
Created September 3, 2014 10:34
simple email adress validator; checks if the server responds and has an MX or A record
require 'mail'
require 'resolv'
require 'net/telnet'
class EmailAddressValidator < ActiveModel::EachValidator
attr_reader :mail
def validate_each(record, attribute, value)
return if options[:allow_nil] && value.nil?
@pricees
pricees / ruby_queues_are_essentially_go_channels.rb
Last active August 29, 2015 14:09
Ruby Queue/SizedQueue are essentially Go channels, who knew?
#
# Apparently this has been in Ruby since 1.9.3... who knew?
# Also check out sized queue class
#
require 'thread'
#
# Create a new thread that blocks on queue pop
# Create an "exit" channel to send "stop" message when total of 100 is reached
#
@bf4
bf4 / introrx.md
Last active August 29, 2015 14:10 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@Zolmeister
Zolmeister / app.yml
Created March 19, 2015 22:32
Ansible Skeleton
---
# file: roles/app/tasks/main.yml
- name: ensure logging directory exists
file: path=/var/log/acme state=directory
tags:
- install
- name: ensure config directory exists
file: path=/etc/acme/app state=directory
@isaacs
isaacs / notes.md
Last active August 29, 2015 14:20

New approach:

  • spawn('sh', ...)

    Find the -c arg.

    Parse, and split up by && and || and | and ;, expanding each bit.

    Then spawn the exploded command line. When we explode it, we need to do the same thing with looking up env and shebang results.

require 'securerandom'
require 'benchmark'
# written to allow 65,536 unique array items
array_of_x = lambda {|x| SecureRandom.hex(x*2).scan(/..../) }
module Refinements
module BooleanUniqWithDupUniqBang
refine Array do
def uniq?
@claudijd
claudijd / update.rb
Created June 18, 2015 12:57
I way to manually update RubyGems without susceptibility to CVE-2015-3900
require 'digest'
require 'net/http'
gem_file = 'rubygems-update-2.4.8.gem'
# Reference: https://rubygems.org/gems/rubygems-update/versions/2.4.8
sha256hash = "dbed858db605923d9cc77080de1a5f1ce6ac3c68924877c78665e0d85d7b3e73"
##################################################
# Download the Gem from RubyGems.org (over HTTPS)