Skip to content

Instantly share code, notes, and snippets.

View DAddYE's full-sized avatar

Davide D'Agostino DAddYE

  • Endor Labs
  • San Francisco
View GitHub Profile
task :bash do
tpl = <<-TXT.gsub(/^ {4}/, '')
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Colors
export PS1='\\[\\033[01;31m\\]\\u\\[\\033[01;33m\\]@\\[\\033[01;36m\\]\\h \\[\\033[01;33m\\]\\w \\[\\033[01;35m\\]\\$ \\[\\033[00m\\]'
export LS_OPTIONS="--human --color=always"
desc 'sample plugin'
task :sample do
log "Hey!"
end
##
# File watcher
#
# Example for: https://twitter.com/rakaur/status/107070299400441858
#
loop do
if File.exist?('tmp/restart.txt')
# TODO: add here code to reboot
# Remember to remove restart.txt to prevent loops
@DAddYE
DAddYE / gist:1231797
Created September 21, 2011 11:01
WTF key repeat under Lion
open ~/Library/Preferences/.GlobalPreferences.plist
defaults write -g ApplePressAndHoldEnabled -bool false
reboot -h now
@DAddYE
DAddYE / gist:1241981
Created September 26, 2011 10:22
CSS Coding rule

NEVER USE INLINE STILE!

An haml template like:

#content.padding{:style => "background:url(/images/middle.png) no-repeat top center #fff;"}

must be converted in css:

@DAddYE
DAddYE / image_uploader.rb
Created December 30, 2011 22:57
CarrierWave on the fly resizer (work as dragonfly)
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def thumb(size)
begun_at = Time.now
size.gsub!(/#/, '!')
uploader = Class.new(self.class)
uploader.versions.clear
uploader.version_names = [size]
@DAddYE
DAddYE / pong.vim
Created January 15, 2012 20:55
Pong colorscheme for vim 256.
" Vim Color File
" Name: pong.vim
" Version: 0.1
" Maintainer: @DAddYE
"
" Based on bubblegum.
set background=dark
hi clear
@DAddYE
DAddYE / invalid.rb
Created January 20, 2012 22:58
Fix malformed ruby gemspec
#!/usr/bin/env ruby
#
# Usage: curl -sL https://raw.github.com/gist/1650084/invalid.rb | ruby
#
require 'open3'
stdin, stdout, stderr = Open3.popen3('gem check')
invalid = stderr.read
errors = invalid.scan(/\[(.+)\]:/).flatten
abort 'No errors in your gems specs' if errors.empty?
errors.each do |spec|
@DAddYE
DAddYE / patch.rb
Created February 16, 2012 18:26
Postmark w/Padrino
# Add me in lib or somewhere
# lib/postmark_patch.rb
Mail::Message.class_eval do
def html?
content_type_without_symbol && content_type_without_symbol.include?('text/html')
end
end
@DAddYE
DAddYE / install_homebrew.rb
Created February 22, 2012 15:26 — forked from mxcl/install_homebrew.markdown
Installs Homebrew to /usr/local so you don't need sudo to `brew install`
#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end