Skip to content

Instantly share code, notes, and snippets.

View timriley's full-sized avatar
🇺🇦
Standing with Ukraine

Tim Riley timriley

🇺🇦
Standing with Ukraine
View GitHub Profile
/*
Just the Notifications, please
==============================
1. Make a Fluid (http://fluidapp.com/) instance of https://twitter.com/i/notifications
2. Apply the below CSS as a Userstyles stylesheet
3. Enjoy just the conversation, not the timeline
Why?
Dir["#{Rails.root}/app/*/**"].each do |dir|
case File.basename(dir)
when 'assets'
Dir["#{dir}/*"].each do |assets_dir|
Rails.application.config.assets.paths << assets_dir
Dir["#{assets_dir}/*"].each do |asset|
parts = File.basename(asset).split('.')
name = "#{parts.first}.#{parts.second}"
Rails.application.config.assets.precompile += [name]
end
# RSpec's subject method, both implicitly and explicitly set, is useful for
# declaratively setting up the context of the object under test. If you provide a
# class for your describe block, subject will implicitly be set to a new instance
# of this class (with no arguments passed to the constructor). If you want
# something more complex done, such as setting arguments, you can use the
# explicit subject setter, which takes a block.
describe Person do
context "born 19 years ago" do
subject { Person.new(:birthdate => 19.years.ago }
it { should be_eligible_to_vote }
@timriley
timriley / Vagrantfile
Created March 28, 2012 06:44 — forked from joseph/Vagrantfile
Various fixes for Vagrant (Lucid64) on Mac OS X Lion
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Preventing kernel panics - VirtualBox 4.1 and Mac OS X Lion 10.7.
#
# This happens on my Macbook Air Mid-2011 Core i7. Every few hours, with
# one or (particularly) more VMs running, you will get a kernel panic.
#
# Some reading:
# https://www.virtualbox.org/ticket/9359
<ul>
<% User.all.with_item_counts do |user| %>
<li><%= user.username %> - Items: <%= user.calculated_item_count %>
<% end %>
</ul>
helpers do
def mobile_request?
[ /AppleWebKit.*Mobile/, /Android.*AppleWebKit/ ].any? {|r| request.env['HTTP_USER_AGENT'] =~ r}
end
def mobile_file(name)
File.exist?("#{options.views}/#{name}#{@mobile}.haml") ? :"#{name}#{@mobile}" : name.to_sym
end
def partial(name)
haml mobile_file("_#{name}"), :layout => false
end
not_found do
render_template_if_exists!
end
def render_template_if_exists!
name = File.basename(request.path)
Dir["#{Sinatra::Application.root}/views/#{name}.*"].each do |match|
@_format = File.extname(match).sub(/^./, '')
@_template = File.basename(match, File.extname(match))
end
@timriley
timriley / .gitconfig
Created January 14, 2010 04:48 — forked from kneath/._what.md
[alias]
up = !sh -c 'git pull && git log --pretty=format:\"%Cred%ae %Creset- %C(yellow)%s %Creset(%ar)\" HEAD@{1}..'
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
require 'pp'
class Object
def tap
yield self
self
end
def tapp
pp self
self