Skip to content

Instantly share code, notes, and snippets.

View KelseyDH's full-sized avatar

Kelsey Hannan KelseyDH

  • Zepto Payments
  • Australia
View GitHub Profile
@ccschmitz
ccschmitz / data_migrations_in_rails.md
Created August 19, 2014 13:10
Some tips for handling data migrations in Rails

Data Migrations in Rails Apps

If you need to manipulate existing data when your code is deployed, there are two main ways to do it:

  1. Create a rake task to migrate the data after the code is deployed. This is ideal for more complex data migrations.
  2. Use ActiveRecord models in a migration. This is acceptable for smaller data manipulations.

Regardless of the method you use, make sure to test your migrations before submitting them.

Data Migrations in Models

@nsbingham
nsbingham / local-dnsserver.md
Last active June 5, 2023 21:44
Testing a CNAME

Setting up a local DNS server with bind on OSX Mavericks

This is really just an approach for locally testing DNS changes, which can easily be done with a HOSTS file if the change involves an IP address, but gets a bit trickier when things like CNAMEs are involved. This is only meant to test locally off a single machine.

  1. Install bind using homebrew

    brew install bind

  2. Follow the installation steps to start up bind

@jzntam
jzntam / Brent's Git Aliases
Last active December 28, 2015 23:59
Git Aliases used by Brent
alias gs="git status"
alias gbr="git for-each-ref --sort=-committerdate refs/heads/"
alias ga="git add"
alias gaa="git add -A"
alias gc="git commit"
alias gci="git ci"
alias gph="git push origin HEAD"
alias gphk="git push heroku master"
alias gdc="git diff --cached"
alias gd="git diff"
@mahemoff
mahemoff / application_model.rb
Last active December 14, 2017 02:00
Rails - Turn empty strings into nil before validation
class ApplicationModel < ActiveRecord::Base
# http://stackoverflow.com/questions/1183506/make-blank-params-nil
class_attribute :null_attrs
self.null_attrs = %w( )
def nil_if_blank
self.class.null_attrs.each { |attr|
self[attr] = nil if self[attr].blank?
}
end
@jfeaver
jfeaver / deploy.rake
Last active September 29, 2015 00:45
Heroku Deploy Script
class DeployTask
attr_accessor :app_suffix, :heroku_app, :git_branch, :force, :enter_maintenance
def initialize(options = {})
@app_suffix = options[:app_suffix]
@heroku_app = options.fetch(:heroku_app, default_app_name)
@git_branch = options.fetch(:git_branch, current_branch)
@force = options.fetch(:force, false)
@enter_maintenance = options.fetch(:enter_maintenance, true)
end
@solnic
solnic / anima_vs_virtus.rb
Last active December 11, 2017 23:33
Anima + Transproc vs Virtus
require 'anima'
require 'transproc'
require 'virtus'
require 'benchmark/ips'
USERS = 1000.times.map { |i| { id: "#{i+1}", name: "User #{i+1}", age: "#{(i+1)*2}" } }
module Mappings
anonymous
anonymous / -
Created November 6, 2015 04:02
gicof() {
git co $( (git branch -r | sed 's/origin\///'; git branch) | sort | uniq | fzf --query="$1" --select-1 --exit-0 )
}
gimf() {
git merge $( (git branch -r | sed 's/origin\///'; git branch) | sort | uniq | fzf --query="$1" --select-1 --exit-0 )
}
@brunofacca
brunofacca / rails_api_token_auth_with_tiddle.md
Last active October 13, 2023 00:55
Rails API token authentication with Tiddle gem in apps with web views

This gist attempts to explain how to implement token authentication in Rails, using Devise and Tiddle. Tiddle was designed to provide token auth for API-only Rails apps. However, the following instructions will enable you to use it in Rails apps which have both APIs and web views.

##Why Tiddle?

Devise is the obvious choice for authentication on Rails. However, token authentication was

@plutoegg
plutoegg / TetherToken.sol
Last active April 17, 2025 10:25
TetherToken.sol - Tether.to USD
pragma solidity ^0.4.11;
/**
* Math operations with safety checks
*/
library SafeMath {
function mul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
@ramonrails
ramonrails / puma-dev.sh
Last active September 10, 2020 18:14
puma-dev management script
#!/bin/bash
# author: ramonrails.in
# version: 1.0
# release date: 7-Aug-2017
# license: MIT
# style for output
bold=$(tput bold)
cyan=$(tput setaf 6)