Skip to content

Instantly share code, notes, and snippets.

View twe4ked's full-sized avatar
🐦
just setting up my twttr

Odin Dutton twe4ked

🐦
just setting up my twttr
View GitHub Profile

Keybase proof

I hereby claim:

  • I am twe4ked on github.
  • I am odin (https://keybase.io/odin) on keybase.
  • I have a public key whose fingerprint is E7CF B17B 6556 F44C 4D10 4B26 1ED7 776D C9D6 B110

To claim this, I am signing this object:

@twe4ked
twe4ked / tmux-last-output
Created March 26, 2015 17:20
Grab the last output from tmux
#!/usr/bin/env ruby
#
# The maximum length of a multiplexed packet is 32,768 bytes
#
# Unfortunately this works best (only works) if you have an uncommon character
# in your prompt to split on. I use "»".
FILE = '/tmp/tmux-pane'
PROMPT = '»'
@twe4ked
twe4ked / application_controller.rb
Created April 29, 2010 04:40
One idea for giving devise's controllers their own layout
# How to give your devise controllers all the same layout (e.g. "authentication" below)
class ApplicationController < ActionController::Base
layout :setup_layout
def setup_layout
return "authentication" if
[ConfirmationsController, PasswordsController, SessionsController,
RegistrationsController, UnlocksController].include? self.class
"application"
end
# Send email to MockSMTP
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "localhost",
:port => 1025,
:domain => "localhost"
}
# link_to 'Foo', bar_path, :class => active_link?('some_controller', 'some_action')
# link_to 'Foo', bar_path, :class => active_link?('some_controller') # Active anywhere within the controller
def active_link?(controller, action = nil)
action_match = case
when action.nil? then true
when action.is_a?(Array) then action.include? params[:action]
else action == params[:action]
end
params[:controller] == controller && action_match ? 'active ' : ''
- if Rails.env.development?
%link{:rel => 'shortcut icon', :href => "/favicon.ico?#{(100..200).to_a.shuffle[1]}"}
@twe4ked
twe4ked / 0_selector_hacks.scss
Created September 21, 2011 12:00 — forked from chriseppstein/0_selector_hacks.scss
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@twe4ked
twe4ked / input.scss
Created December 20, 2011 04:43
FREE! Sass (SCSS) mixin for easily setting the width and height (size) and an element.
@mixin size($width, $height: $width) {
width: $width;
height: $height;
}
// Examples
#foo {
@include size(10px);
}
@twe4ked
twe4ked / twitter_list.rb
Created March 26, 2012 06:26
Simple, slow script to add Twitter users to a list.
# Written in a taxi on the way to Railscamp X
require 'twitter'
Twitter.configure do |config|
config.consumer_key =
config.consumer_secret =
config.oauth_token =
config.oauth_token_secret =
end