Skip to content

Instantly share code, notes, and snippets.

bf4 / ams.rb
Created Apr 3, 2017 — forked from sineed/ams.rb
Upgrade AMS from 0.9.0 to 0.10.0
View ams.rb
module AMS
module V09
class Serializer < ActiveModel::Serializer
def serializable_hash(adapter_options = nil,
options = {},
adapter_instance = self.class.serialization_adapter_instance)
object.nil? ? nil : super
bf4 / find_relations_in_batches.rb
Created Mar 22, 2017
ActiveRecord Rails Find Relations in Batches
View find_relations_in_batches.rb
# Finds and yields relations in batches. Adapted from record.find_in_batches since that yields
# arrays and we want to operate on relationships.
# Adapted from:
def find_in_batches(target, batch_size: default_batch_size, start: nil)
relation = target
if logger && (target.arel.orders.present? || target.arel.taken.present?)
logger.warn("Scoped order and limit are ignored, it's forced to be batch order and batch size")
relation = relation.reorder(target.send(:batch_order)).limit(batch_size)
bf4 / go_kinesis_with_structs.go
Created Mar 14, 2017 — forked from pricees/go_kinesis_with_structs.go
Go + AWS Kinesis + Encode/Decode Structs
View go_kinesis_with_structs.go
Assumes env contains aws credentials:
and AWS_REGION_NAME (e.g. 'US-EAST-1')
see EnvAuth() below
View 2014-09-30-sample.rb = 'Person Name <>'
message.subject = 'Sample Subject'
# body is probably good enough, but you can set text_part/html_part below if you like
message.body = <<HERE.strip
This is a sample
bf4 / dontforget.bash
Created Feb 20, 2017 — forked from ttscoff/dontforget.bash
Quick reminders from Terminal (bash)
View dontforget.bash
# dontforget
# A stupid script for short term reminders in bash
# Arguments just need to contain a number and a bunch of words.
# The number can be anywhere in the arguments, but there shouldn't
# be any other numeric digits.
bf4 / _dev_badge.html.slim
Created Feb 1, 2017 — forked from stevenharman/_dev_badge.html.slim
A simple badge that shows your Rails environment.
View _dev_badge.html.slim
/ In app/views/shared/
span= Rails.env
span It ain't production!
View sidekiq_with_github.rb
require 'warden/github'
class SidekiqGithubChecker
def self.registered(app)
app.helpers do
def warden; env['warden'] end
def github_organization_authenticate!(name)
unless warden.user.organization_member?(name)
halt [401, {}, ["You don't have access to organization #{name}"]]
bf4 /
Created Jan 16, 2017 — forked from jjb/
Trying to figure out performance impact of RUBY_GC_HEAP_GROWTH_FACTOR
bf4 /
Created Jan 6, 2017 — forked from leonardofed/
A curated list of AWS resources to prepare for the AWS Certifications

A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.