This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load DSL and Setup Up Stages | |
require 'capistrano/setup' | |
# Includes default deployment tasks | |
require 'capistrano/deploy' | |
# Rails (includes bundler, rails/assets and rails/migrations) | |
require 'capistrano/rails' | |
# Whenever |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'openssl' | |
tcp_client = TCPSocket.new "google.com", 443 | |
ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client | |
ssl_client.hostname = "google.com" # SNI, if not it returns the first SSL cert for this IP instead of hostname | |
ssl_client.connect | |
# Work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hash_diff(hash_a, hash_b) | |
hash_changes = {} | |
(hash_a.keys + hash_b.keys).uniq.each do |key| | |
if hash_a[key] != hash_b[key] | |
hash_changes[key] = [hash_a[key], hash_b[key]] | |
end | |
end | |
hash_changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# services/csv_importer.rb | |
class CSVImporter | |
attr_reader :failed_rows, :success_count | |
def initialize(content, separator, paid_column) | |
@content = content | |
@separator = separator | |
@paid_column = paid_column | |
@failed_rows = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/deep_struct.rb | |
# Source: http://andreapavoni.com/blog/2013/4/create-recursive-openstruct-from-a-ruby-hash | |
require 'ostruct' | |
module Utils | |
class DeepStruct < OpenStruct | |
def initialize(hash=nil) | |
@table = {} | |
@hash_table = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.treat_symbols_as_metadata_keys_with_true_values = true | |
config.around(:each) do |example| | |
if example.metadata[:freeze_time] | |
Timecop.freeze(Time.now) | |
example.run | |
Timecop.return | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/post | |
class Post < ActiveRecord::Base | |
include Votable | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Coder < ActiveRecord::Base | |
after_save :clear_caches | |
private | |
def clear_caches | |
Stats.expire_coder_punten | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This library fixes common problems with turbolinks | |
# - Overwrite setTimeout and setInterval to intercept generated ID's | |
# - Keep track of Ajax requests | |
# | |
# When turbolinks' unload event is called, we: | |
# - Cancel all setTimeouts and setIntervals | |
# - Abort all still running Ajax requests | |
$.turboTurbo = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'erb' | |
# Nginx needs its config files to contain absolute paths, so | |
# we need to compile them to set the correct paths. | |
def expand(filename) | |
full_path = File.expand_path(File.dirname(__FILE__)) # "~/Users/david/poetry/sslqsquire/canary" | |
File.join(full_path, filename) | |
end |