Skip to content

Instantly share code, notes, and snippets.

View dinjas's full-sized avatar
:shipit:
Alive

Jason Dinsmore dinjas

:shipit:
Alive
  • Battle Ground, WA
View GitHub Profile
@dinjas
dinjas / namer.rb
Last active December 14, 2018 03:23
Why dinjas?
# Usage:
# >> Namer.new("Jason Dinsmore").computer_name
# => "dinjas"
require 'concord'
class Namer
include Concord.new(:full_name)
def computer_name
names
@dinjas
dinjas / gist:abde6a931e0efdf228cf
Created February 4, 2016 17:23 — forked from nicolasblanco/gist:1069378
Rails i18n framework for your meta tags

Rails i18n framework for your meta tags

Here is a convenient method for page titles and other meta tags.

One common solution is to use "yield" and some kind of helpers that would call content_for (like in this Railscasts).

The problem is that for Search Engines Optimization, you should change all your meta tags for every page to avoid duplicate content, and call your helpers on every page...

This workaround uses the i18n framework and tries to find the good tags depending on the page you are, so you don't have to call any helper by default.

@dinjas
dinjas / recursive_require.rb
Last active October 2, 2015 01:11 — forked from skorks/Ruby recursively require all files in directory
Ruby recursively require all files in directory
# recursively require all files in directory (and subdirectories)
Dir["#{File.dirname(__FILE__)}/squat/**/*.rb"].each do |file|
require file
end
# recursively require all files in directory but skip paths that
# match a pattern
Dir["#{File.dirname(__FILE__)}/squat/**/*.rb"].each do |file|
require file unless file =~ /\/model\//
end
@dinjas
dinjas / gist:8b55e6e01503ea617cb2
Last active August 26, 2015 23:35 — forked from damontorgerson/gist:2231f42302da9f9f078b
Launch SIDEKIQ in Amazon Elastic Beanstalk (AMI 1.0.9)
files:
"/etc/rsyslog.d/11-sidekiq.conf":
mode: '000644'
content: |
EB_CONFIG_APP_LOGS=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
$InputFileName $EB_CONFIG_APP_LOGS/sidekiq.log
$InputFileTag sidekiq
$InputFileStateFile sidekiq-state
$InputFileSeverity info
@dinjas
dinjas / 0001_fix_permissions.config
Last active August 26, 2015 21:59 — forked from jgautsch/0001_fix_permissions.config
AWS Elastic Beanstalk Ruby 2.0/Passenger Environment - .ebextensions tweaks and Sidekiq configuration. This is known to work fine with AWS Elastic Beanstalk 's 64bit Amazon Linux 2014.03 v1.0.2 running Ruby 2.0 (Passenger Standalone) stack. This is everything in my .ebextensions folder. Based on https://gist.github.com/gcarrion-gfrmedia/11396682
# Fixing permissions of packaged gems
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/10_fixing_permission.sh":
content: |
#!/usr/bin/env bash
# . /opt/elasticbeanstalk/containerfiles/envvars
. /opt/elasticbeanstalk/support/envvars
CACHE_GEM_DIR=$EB_CONFIG_APP_ONDECK/vendor/cache
@dinjas
dinjas / http_status_codes.rb
Created June 10, 2014 01:18
http status codes
HTTP_STATUS_CODES = {
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
# from @toasterlovin's implementation:
# https://github.com/toasterlovin/orphaned_routes/blob/master/test/integration/orphaned_routes_test.rb
require "spec_helper"
describe "Check for orphaned routes" do
def defined_routes
Rails.application.routes.routes.map do |route|
# Turn the route path spec into a string:
# - Remove the "(.:format)" bit at the end
# - Use "1" for all params
### Core library for EchoSign APIs
### Use a wrapper file for validations & response handling
### Get a Developer Edition account & replace "YOUR_ACCOUNT_API_KEY" with API key of your account.
### With Rails, use Savon gem for SOAP based requests.
module EchoSignApi
API_URI = 'https://secure.echosign.com/services/EchoSignDocumentService15?wsdl'
API_KEY = YOUR_ACCOUNT_API_KEY
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
#!/usr/bin/env ruby
PRESUMPTIVE_RAILS_ROOT = "/data/[APP_NAME]/current"
LOG_PATH = "/data/[APP_NAME]/shared/log/delayed_job_singleton.log"
Dir.chdir PRESUMPTIVE_RAILS_ROOT
require 'home_run'
require "rubygems"
require "bundler/setup"