Skip to content

Instantly share code, notes, and snippets.

@rgo
rgo / conocer_relaciones_modelo.txt
Created February 20, 2009 23:26
Show relations in a model
# Show relations in a model
Model.reflect_on_all_associations.map(&:class_name)
@rgo
rgo / gist:69297
Created February 24, 2009 00:36
Top cpu use
# Display top cpu use
ps aux|sort -nr +2|head -5
@rgo
rgo / gist:69521
Created February 24, 2009 11:26
Test routes from console
# Testing routes from console
>> app.users_path
=> "/users"
@rgo
rgo / gist:69904
Created February 25, 2009 00:23
Diff 2 files vertically
# Diff two files(vertically) without use vimdiff from shell
vert diffsplit
@rgo
rgo / gist:70110
Created February 25, 2009 10:04
FuzzyFinder textmate solution to work with TagList
FuzzyFinder has a bug when works TagList plugin (it open the file in taglist, very annoying). It’s solved in fuzzyfinder 2.16 changing the line 1483:
wincmd p
to:
wincmd j
Then the next time that you open a file it’ll open in correct window.
@rgo
rgo / gist:70498
Created February 25, 2009 22:50
Top cpu used by process
# Top cpu used by process
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -n10
@rgo
rgo / ruby.SlackBuild
Created February 26, 2009 16:55
ruby.Slackbuild for Ruby 1.8.6-p287
#!/bin/sh
#
# Modified ruby.Slackbuild for Ruby 1.8.6-p287
# Ruby 1.8.7-p72 give me problems with rails 2.2
#
# Copyright 2008 Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
@rgo
rgo / gist:74026
Created March 4, 2009 21:45
Awesome truncate
# Awesome truncate
# From: http://daniel.collectiveidea.com/blog/2007/7/10/a-prettier-truncate-helper
#
# First regex truncates to the length, plus the rest of that word, if any.
# Second regex removes any trailing whitespace or punctuation (except ;).
# Unlike the regular truncate method, this avoids the problem with cutting
# in the middle of an entity ex.: truncate("this & that",9) => "this &am..."
# though it will not be the exact length.
def awesome_truncate(text, length = 30, truncate_string = "...")
return if text.nil?
@rgo
rgo / gist:76361
Created March 9, 2009 16:16
Rename multiples files with a regex.
# Rename multiples files with a regex.
# If filename are "*bazbar.txt" rename them to "*foobar.txt"
for f in *;do mv "$f" "${f/baz/foo}";done
@rgo
rgo / gist:82325
Created March 20, 2009 11:22
MySQL to CSV
# Mysql to csv
mysqldump -u XXX -p -t <table> --tab=tables --tables users --fields-enclosed-by=\" --fields-terminated-by=, --where="<where condition here[optional]"