Skip to content

Instantly share code, notes, and snippets.

View joshuapinter's full-sized avatar
🎯
Focusing

Joshua Pinter joshuapinter

🎯
Focusing
View GitHub Profile
@joshuapinter
joshuapinter / Default (OSX).sublime-keymap
Created October 26, 2014 00:31
Sublime Text 2 Keybinding to Allow Shift + Space Exit Insert Mode.
[
{
"keys": ["shift+space"],
"command": "exit_insert_mode",
"context": [
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
}
]
@joshuapinter
joshuapinter / model.template.txt
Last active November 20, 2023 12:34
Rails Model Template
class [Your Class Here] < ActiveRecord::Base
##################################################################################################
### Attributes ###################################################################################
##################################################################################################
### Constants ####################################################################################
@joshuapinter
joshuapinter / irb.rb
Created March 16, 2015 22:11
Activate Authlogic in Console
if defined?(ActiveRecord::Base) && defined?(Authlogic)
controller = ApplicationController.new
require 'action_controller/test_case'
controller.instance_variable_set(:@_request, ActionController::TestRequest.new)
controller.instance_variable_set(:@_response, ActionController::TestResponse.new)
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(controller)
end
UserSession.new( User.first )
@joshuapinter
joshuapinter / .npmrc
Created March 14, 2019 17:01
Common Configuration Files
save-exact = true # Saves exact version without needing --save-exact.
@joshuapinter
joshuapinter / video_file_extensions.rb
Created June 20, 2014 19:00
Video File Extensions.
VIDEO_FILE_EXTENSIONS = ['.264',
'.3g2',
'.3gp',
'.3gp2',
'.3gpp',
'.3gpp2',
'.3mm',
'.3p2',
'.60d',
'.787',
@joshuapinter
joshuapinter / gist:b165381f888b9c8db3ac
Created September 19, 2014 17:44
Rails Status Codes in Symbol Form
100 = :continue
101 = :switching_protocols
102 = :processing
200 = :ok
201 = :created
202 = :accepted
203 = :non_authoritative_information
204 = :no_content
205 = :reset_content
206 = :partial_content
@joshuapinter
joshuapinter / gist:e1774473e5a492e78874
Created November 3, 2014 01:35
Get Airmail cache directory sizes.
cd ~/Library/Containers && du -h -d 0 *airmail*
@joshuapinter
joshuapinter / symbolize_with_care.rb
Created November 14, 2013 03:54
Simple String method to only symbolize with a given array of whitelist values.
class String
def symbolize_with_care *args
valid_values = args
valid_values.each do |v|
if v.to_s == self
return v
break
end
end
module ExternalResource
# Adds ability to use view helpers, like number_to_currency.
# e.g. @@view_context.number_to_currency( 2.48 )
@@view_context = ActionController::Base.new.view_context
# # Handles timeout and other issues for blocks requesting external resources.
# For example, when using nokogiri to scrape a site.
# Requires a block with the HTTPClient.get call or what-have-you
#
# @param [Hash] options Options for the timeout.
<%= “#{`git branch`.to_s.gsub(‘* ‘,”)} | #{Rails.env.upcase} |” unless Rails.env == ‘production’" %>