Skip to content

Instantly share code, notes, and snippets.

@kdisneur
kdisneur / gist:2337544
Created April 8, 2012 14:19
improve ordinal_array speed
require './lib/ordinal_array'
require "benchmark"
number_values = (0...999).sort_by{rand}
number_letters = [
:first, :second, :third, :fourth, :fifth, :sixth, :seventh, :eighth, :ninth,
:tenth, :eleventh, :twelfth, :thirteenth, :fourteenth, :fifteenth, :sixteenth, :seventeenth, :eighteenth, :nineteenth,
:twentieth, :twenty_first, :twenty_second, :twenty_third, :twenty_fourth, :twenty_fifth, :twenty_sixth, :twenty_seventh, :twenty_eighth, :twenty_ninth,
:thirtieth, :thirty_first, :thirty_second, :thirty_third, :thirty_fourth, :thirty_fifth, :thirty_sixth, :thirty_seventh, :thirty_eighth, :thirty_ninth,
:fortieth, :fourty_first, :fourty_second, :fourty_third, :fourty_fourth, :fourty_fifth, :fourty_sixth, :fourty_seventh, :fourty_eighth, :fourty_ninth,
@kdisneur
kdisneur / gist:3104921
Created July 13, 2012 13:36
shared class variables in module
module SpecialAttributes
module ClassMethods
def attr_special(*attrs)
class_attribute :special_attributes
self.special_attributes = attrs
end
def special_attributes
self.special_attributes
end
@kdisneur
kdisneur / tmux.conf
Created July 13, 2012 13:37
tmux.conf
set -sg escape-time 1
set -g base-index 1
set-window-option -g pane-base-index 1
set-window-option -g automatic-rename off
# pane configuration
bind | split-window -h
bind - split-window -v
bind h select-pane -L
syntax on
filetype plugin indent on
set nowrap
set tabstop=2
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set shiftwidth=2 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
@kdisneur
kdisneur / recreate_database.sh
Created August 29, 2012 16:02
Recreate database
#! /bin/sh
env=${1:-test}
for action in drop create migrate; do
RAILS_ENV=$env rake db:$action;
done
@kdisneur
kdisneur / a.md
Created September 11, 2012 19:52 — forked from menkel/a.md
Proxy for Netfix, Hulu....

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Netflix
  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
@kdisneur
kdisneur / gist:4045596
Last active October 12, 2015 15:08
trouve toutes les couleurs définies dans le css
color_pattern='#[a-fA-F0-9]{3,6}';
for color in $(find app/assets/stylesheets -iname '*.scss*' -exec grep -oE "${color_pattern}([^_-]|$)" {} \; | grep -oE $color_pattern | sort | uniq); do
if [ $color != ':' ]; then
echo "couleur: $color, occurences: $(grep -R $color app/assets/stylesheets | wc -l)"
fi
done

UIActivityIndicatorView

@property (readwrite, nonatomic, retain) UIColor *color

UIBarButtonItem

- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics
@kdisneur
kdisneur / gist:5138400
Last active December 14, 2015 19:39
flac2mp3 - find all flac in your directory and sub directories and convert them to mp3.
find . -iname '*.flac' -exec sh -c 'flac -c -d "{}" | lame -h -m s -b 192 - "$(dirname "{}")/$(basename "{}" .flac).mp3"' \;
#!/usr/bin/ruby
# Convert a Markdown README to HTML with Github Flavored Markdown
# Github and Pygments styles are included in the output
#
# Requirements: json gem (`gem install json`)
#
# Input: STDIN or filename
# Output: STDOUT
# Arguments: "-c" to copy to clipboard (or "| pbcopy"), or "> filename.html" to output to a file
# cat README.md | flavor > README.html