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
end
end
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:
# https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/relation/batches.rb#L98-L115
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")
end
relation = relation.reorder(target.send(:batch_order)).limit(batch_size)
View learn_clojure_recipe.md
View go_kinesis_with_structs.go
/**
NOTE:
Assumes env contains aws credentials:
AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY
AWS_SECRET_KEY_ID or AWS_SECRET_KEY
and AWS_REGION_NAME (e.g. 'US-EAST-1')
see EnvAuth() below
*/
View 2014-09-30-sample.rb
message.to = 'Person Name <person@example.com>'
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
Hey-
This is a sample
Thanks
HERE
View dontforget.bash
#!/bin/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.
#
View _dev_badge.html.slim
/ In app/views/shared/
#dev-badge
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}"]]
end
View file.md