Skip to content

Instantly share code, notes, and snippets.

View andrewculver's full-sized avatar

Andrew Culver andrewculver

View GitHub Profile
@andrewculver
andrewculver / without-trailing-commas-example.diff
Created February 24, 2020 18:10
Example diff when adding attributes on a project that doesn't use trailing commas on multiline arrays and hashes.
diff --git a/app/controllers/account/sites_controller.rb b/app/controllers/account/sites_controller.rb
index 6f5936a0..5734b58b 100644
--- a/app/controllers/account/sites_controller.rb
+++ b/app/controllers/account/sites_controller.rb
@@ -64,9 +64,13 @@ class Account::SitesController < Account::ApplicationController
def site_params
params.require(:site).permit(
:name,
- :description
+ :description,
@andrewculver
andrewculver / trailing-commas-example.diff
Last active February 24, 2020 18:41
Example diff when adding attributes on a project that uses trailing commas on multiline arrays and hashes.
diff --git a/app/controllers/account/sites_controller.rb b/app/controllers/account/sites_controller.rb
index c99a3877..318e7c67 100644
--- a/app/controllers/account/sites_controller.rb
+++ b/app/controllers/account/sites_controller.rb
@@ -65,6 +65,8 @@ class Account::SitesController < Account::ApplicationController
params.require(:site).permit(
:name,
:description,
+ :keywords,
+ :copyright,
@andrewculver
andrewculver / prod.rb
Last active April 4, 2019 11:27
Change Mac OS X Terminal.app background color in a shell script using AppleScript.
#!/usr/bin/env ruby
# NOTE: this requires actually setting up a terminal profile called "Prod".
# TODO i have no idea if this is good enough, sorry.
def escape_for_applescript(string)
string.gsub("\"", "\\\"")
end
def execute_applescript(applescript)
resources :questions, followable_type: 'Question' do
collection do
get 'tagged/:tag', action: :index
[:unanswered, :popular, :following, :for_me].each do |filter|
get filter
get filter + "/tagged/:tag", to: "questions#" + filter
end
end
end
{"first_name":"Andrew",
"last_name":"Culver",
"company_name":"Churn Buster"}
@andrewculver
andrewculver / git-branch-select-sample.md
Created December 6, 2012 16:26
What's the best way to create a tool like this without misusing $stderr?

I like descriptive, sometimes long, branch names. However, typing them is annoying. So, I've created this script that I can inject in place of typing a branch name. It shows me a numbered list of current branches, and I select one using the number from the list.

Example:

andrewculver:~/Sites/sample-project (master)$ git branch -d `gb`
1. master
2. some-bugfix
3. some-new-feature
4. test

> 3

@andrewculver
andrewculver / fixing_x000a.rb
Created April 20, 2012 00:59
Temporary fix for the extra newline (&#x000A;) Rails 3.2.3 + Haml are adding to the output of the text_area form helper.
module ActionView
module Helpers
module FormHelper
def text_area(object_name, method, options = {})
html = InstanceTag.new(object_name, method, self, options.delete(:object)).to_text_area_tag(options)
html.gsub(/>\&#x000A;/, '>').html_safe
end
end
end
end
@andrewculver
andrewculver / twilio.xml
Created August 3, 2011 02:20
TwiML for (866) 221-LIME
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>757-739-0397</Dial>
</Response>
@andrewculver
andrewculver / registrations_controller.rb
Created March 28, 2011 02:41
Assign non-form data to a new user on sign-up with Devise.
class RegistrationsController < Devise::RegistrationsController
protected
def build_resource(hash=nil)
# let devise do it's magic with the form data.
super
# assign any additional information the form doesn't populate.
# (e.g. @organization is populated in ApplicationController.)
resource.organization = @organization