Skip to content

Instantly share code, notes, and snippets.

View adamlogic's full-sized avatar

Adam McCrea adamlogic

View GitHub Profile
ENV = window.ENV || {};
ENV.VIEW_PRESERVES_CONTEXT = true;
task :deploy => ['heroku:push',
'airbrake:deploy']
namespace :deploy do
task :migrations => ['heroku:maintenance:on',
'heroku:db:backup',
'heroku:push',
'heroku:db:migrate',
'heroku:restart',
'heroku:maintenance:off',
@adamlogic
adamlogic / compass_and_css_sprites.md
Created September 1, 2012 15:26
Compass and CSS Sprites, Explained

Compass and CSS Sprites, Explained

Last week I attempted to use the CSS sprites feature of Compass for the second or third time. It's been a struggle each time, but the power and potential is there, so I keep coming back. This time was a bit different, though, because I finally decided to stop relying on the docs and dive into the code.

Before I go into the nitty-gritty, let's take a step back and talk about why I

@adamlogic
adamlogic / ghpreview.sh
Created November 9, 2012 17:14
Preview a Markdown file using Github's conversion and styling
#!/bin/bash
md_filename=$1
html_filename=/tmp/ghpreview.html
url=https://api.github.com/markdown/raw
# Markdown to HTML
html=`curl --data-binary @$md_filename -H 'Content-Type:text/plain' $url`
# Grab Github's fingerprinted stylesheets
@adamlogic
adamlogic / extracting.md
Created November 19, 2012 18:26
Extracting to a Gem

Extracting to a gem

Notes for a Columbus Ruby Brigade live-coding talk on 11-19-2012.

  1. Compartmentalize the feature within your project
    • define your API
    • use bundle open and undefined method errors to discover "hooks" for your feature
  2. Create gem skeleton
    • bundle gem gemname
  • add info to gemspec
# This is a simple script to convert an XML file exported
# from Evernote into a bookmarks file that can be imported
# into Pinboard. In my case, all I cared about were notes
# that had a source-url, and all I'm retaining is the title
# and URL. I'm adding a fixed "evernote" tag for all notes.
require 'nokogiri'
def note_attributes(note)
{
@adamlogic
adamlogic / pgpull
Last active January 17, 2018 15:13
Wrapper script around `heroku pg:pull` for loading a local database
#!/bin/bash
# Example:
# pgpull -r production
#
# Options are passed through to `heroku pg:pull`, so this would look for a git branch
# named "production".
opts=$*
# Replace this with your local database name
@adamlogic
adamlogic / Procfile
Created September 8, 2018 14:51
Sample Procfile using parameter expansion
release: RAILS_MAX_THREADS=1 rails db:migrate
web: RAILS_MAX_THREADS=$PUMA_THREADS rails c
worker: RAILS_MAX_THREADS=$SIDEKIQ_THREADS bundle exec sidekiq
# heroku config:add RAILS_MAX_THREADS=1 so one-off dynos don't consume more than necessary
Event.where(date_end: (Time.current.midnight .. Time.parse('2020-01-01'))).cache_key
#=> "events/query-38261fed1ce8f823ec1c05f19e0123fb-0"
Event.where(date_end: (Time.current .. Time.parse('2020-01-01'))).cache_key
#=> "events/query-a5aea4fdf9842521af708f1d663a710b-0"
@adamlogic
adamlogic / In the beginning, there was require.md
Created November 24, 2019 01:45
Presentation given at RubyConf 2019. This is the source for my slides, used with Deckset (paid Mac app).

build-lists: true

In the beginning
there was require


confession