Skip to content

Instantly share code, notes, and snippets.

View KelseyDH's full-sized avatar

Kelsey Hannan KelseyDH

  • Bite Interactive
  • Vancouver
View GitHub Profile
@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
@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
@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"
@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

@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

@KelseyDH
KelseyDH / ruby_rails_windows.md
Last active May 16, 2024 07:48
Ruby on Rails Microsoft Windows Troubleshooting Tips

Ruby on Rails Windows Troubleshooting Tips & Survival Guide

Intro/Overview

The Ruby on Rails Windows Troubleshooting tips & Survival Guide is a random catalogue of issues I faced working with Ruby on Rails on Windows (Windows 7 specifically). This guide is not exhaustive, but covers many of the challenges that causes Windows Ruby developers to jump ship to Linux or Mac. If you're reading this guide then you're probably new to Ruby/Rails, so also included is more general beginner advice to help you get going.

Personal Side Note

Before you follow this guide, I strongly recommend you consider using Linux or Mac OS X for Ruby Development instead. Looking to prove a point as a challenge, I ignored this strongly given advice while learning Ruby/Rails. While I eventually did succeed in getting Ruby on Rails to work in Windows, it was not easy, and I easily lost 40+ hours on StackOverFlow to Windows/Ruby configuration issues--time I could have devoted to learning more about th

@dannysmith
dannysmith / osx_setup.sh
Last active October 17, 2023 08:20
Sensible defaults for New Mac
#!/usr/bin/env bash
# ~/.osx — http://mths.be/osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@rxaviers
rxaviers / gist:7360908
Last active June 8, 2024 15:23
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@marcusmalmberg
marcusmalmberg / CarrierWave.md
Last active June 14, 2021 23:22
Guide to setup CarrierWave which will upload a file to Amazon S3 in production environment and use local storage in development and test

CarrierWave home

https://github.com/jnicklas/carrierwave

This example will create an uploader that will upload a file stored in a model Model. The file will be stored locally in development and test environment and will use Amazon S3 in production.

CarrierWave installation

First add the gems.

@klange
klange / _.md
Last active May 23, 2024 13:45
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le