Skip to content

Instantly share code, notes, and snippets.

View n3bulous's full-sized avatar

Kevin McFadden n3bulous

View GitHub Profile

Keybase proof

I hereby claim:

  • I am n3bulous on github.
  • I am kmcfadden (https://keybase.io/kmcfadden) on keybase.
  • I have a public key ASDsqs5_YHvYC13MGy9GZzANdPeNvMwv96qfGUokvTR7kAo

To claim this, I am signing this object:

@n3bulous
n3bulous / README.md
Created April 3, 2017 16:33 — forked from ericcj/README.md
Pluck in batches

pluck_in_batches

Sometimes you need to iterate over a ton of items and you don't want the overhead of creating AR objects out of all of them. Hell, you only need a few things! Well, #pluck has your back.

But what if you want to iterate over many tonnes of items?

Pluck in batches to the rescue!

This fork works on any orderable primary key not just integers just like http://api.rubyonrails.org/classes/ActiveRecord/Batches.html#method-i-find_in_batches

@n3bulous
n3bulous / add_environment_to_host.rb
Created November 2, 2016 14:24
Idempotent Rails Migrations for Columns
class AddEnvironmentToHost < ActiveRecord::Migration
def self.up
- add_column :hosts, :environment, :string
+ unless ActiveRecord::Base.connection.columns(:hosts).collect {|c| c.name}.include?("environment")
+ add_column :hosts, :environment, :string
+ end
end
def self.down
- remove_column :hosts, :environment
@n3bulous
n3bulous / README.md
Last active January 12, 2016 21:31 — forked from magnetikonline/README.md
AWS Elastic Beanstalk deploy user restricted IAM policy.

AWS Elastic Beanstalk deploy user restricted IAM policy

An IAM user policy document to give minimal rights for deploying an Elastic Beanstalk application.

Where:

  • REGION: AWS region.
  • ACCOUNT_ID: AWS account ID.
  • APPLICATION_NAME: Desired target Elastic Beanstalk application name(space).
  • IAM_INSTANCE_PROFILE_ROLE: The instance profile (IAM role) Elastic Beanstalk EC2 instaces will run under.
DELIMITER |
CREATE FUNCTION uuid_from_bin(b BINARY(16))
RETURNS CHAR(36) DETERMINISTIC
BEGIN
DECLARE hex CHAR(32);
SET hex = HEX(b);
RETURN LOWER(CONCAT(LEFT(hex, 8), '-', MID(hex, 9,4), '-', MID(hex, 13,4), '-', MID(hex, 17,4), '-', RIGHT(hex, 12)));
END
|
#!/bin/bash
#
# The MIT License
#
# Copyright 2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

Keybase proof

I hereby claim:

  • I am n3bulous on github.
  • I am kmcfadden (https://keybase.io/kmcfadden) on keybase.
  • I have a public key whose fingerprint is CFB8 A03D 32F5 75C5 0B43 F2F7 68BC 0C53 69A2 0530

To claim this, I am signing this object:

@n3bulous
n3bulous / 0_reuse_code.js
Created January 3, 2014 02:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# An example of the below
virtualenv "/home/dvcsmirrors/hg" do
owner "root"
group "dvcsmirrors"
mode 0775
packages "Mercurial" => "1.6.3",
"hgsubversion" => "1.1.2"
end
# Nginx+Unicorn best-practices congifuration guide. Now with SPDY!
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#