Skip to content

Instantly share code, notes, and snippets.

View destroytoday's full-sized avatar

Jonnie Hallman destroytoday

View GitHub Profile
module LoginMacros
def stub_env_for_omniauth
request.env['devise.mapping'] = Devise.mappings[:user]
env = { "omniauth.auth" => OmniAuth.config.mock_auth[:twitter] }
@controller.stub!(:env).and_return(env)
end
def login_user
before(:each) do
@destroytoday
destroytoday / routes.rb
Created December 21, 2011 21:18
Prettier URLs for Devise
devise_for :user, :path => 'account', :path_names =>
{
:sign_in => 'login',
:sign_out => 'logout',
:invitation => 'invite'
}
@destroytoday
destroytoday / style.sass
Created November 4, 2011 01:27
Prevents iOS from changing the font size of paragraphs in landscape
@media only screen and (min-device-width: 320px) and (max-device-width: 1024px)
html
-webkit-text-size-adjust: none
@destroytoday
destroytoday / list.html
Created October 16, 2011 17:29
Month-separated blog post list in Jekyll w/ Liquid
---
layout: default
title: All Posts
category: blog
---
<div id="blog">
<h2>{{page.title}}</h2>
{% for post in site.categories.blog %}
{% capture post_month %}{{post.date | date: "%m"}}{% endcapture %}
{% if post_month != prev_post_month %}{% if prev_post_month %}</ol>{% endif %}<h3>{{post.date | date: "%B %Y"}}</h3><ol class="blog-list">{% endif %}
@destroytoday
destroytoday / data.yml
Created October 12, 2011 04:31
YAML example
---
layout: blog-post
title: A super ghetto way of getting a function path in AS3
shortname: AS3 Function Path
category: blog
tags: [AS3, Code, Open Source]
thumbnail:
image: as3-function-path-thumb.jpg
colors: ['b8190c', 'ccac7b', 'cee3eb', '899088']
---
@destroytoday
destroytoday / post.rb
Created August 31, 2011 04:24
Add a slug Liquid param to Jekyll's post class
module Jekyll
class Post
alias :super_to_liquid :to_liquid
def to_liquid
super_to_liquid.deep_merge({"slug" => slug})
end
end
end
@destroytoday
destroytoday / remarry_widows_filter.rb
Created August 30, 2011 05:14
Adds a non-breaking space to the last space of a string, avoiding widows/orphans.
module Jekyll
module Filters
def remarry_widows(input)
newinput = input.gsub(/ ([^ ]+)$/, "&nbsp;\\1")
newinput
end
end
end
@destroytoday
destroytoday / site.rb
Created August 28, 2011 21:30
Adds Terminal and Growl notifications to Jekyll's build process
module Jekyll
class Site
require 'growl'
alias :super_process :process
def process
time = Time.now
super_process()
module Jekyll
class Pagination < Generator
# This generator is safe from arbitrary code execution.
safe true
# Generate paginated pages if necessary.
#
# site - The Site.
#
@destroytoday
destroytoday / Rakefile.rb
Created August 18, 2011 16:35
Tidies all html files in the site dir
require 'rubygems'
require 'tidy_ffi'
desc "Tidies HTML files"
task :tidy do
Dir.glob('site/**/*.html') do |path|
content = File.open(path).read
File.open(path, 'w') {|file|
file.write TidyFFI::Tidy.new(content, :numeric_entities => 1, :output_html => 1, :merge_divs => 0, :merge_spans => 0, :join_styles => 0, :clean => 1, :indent => 1, :wrap => 0, :drop_empty_paras => 0, :literal_attributes => 1).clean