Skip to content

Instantly share code, notes, and snippets.

@theirishpenguin
theirishpenguin / .vimrc.before
Created January 31, 2012 10:23
Janus .vimrc configuration to set indentation to 4 spaces instead of 2
# Note: Best Janus practice is to drop these into ~/.vimrc.before rather than ~/.vimrc itself
set tabstop=4
set shiftwidth=4
set softtabstop=4
autocmd User Rails/**/* set tabstop=4
autocmd User Rails/**/* set shiftwidth=4
autocmd User Rails/**/* set softtabstop=4
# P.S. Thanks to http://www.savagevines.com/post/2011/8/14/overriding_indentation_settings_for_vimrails for shining light on this area
@theirishpenguin
theirishpenguin / rsub
Created January 30, 2012 17:46
Recursively replace files in the current directory and subdirectories using regular expressions
# Usage
# (Note: This command does not handle spaces in filenames!)
# * cd into the directory containing the files and subdirectories of files in
# which you wish to carry out string substitution using a regex
# * Run the command:
# rsub 'search regex' 'replacement text'
# * This will effect the desired substitution in files in the current directory
# and in any subdirectories
# Explaination
aptitude install vim-gnome
The following NEW packages will be installed:
libruby1.8{a} vim-gnome
@theirishpenguin
theirishpenguin / sort_dir
Created January 17, 2012 11:45
Sort the contents of each file in the current directory (non-recursive)
# Usage:
#
# (Note - This command does not recursively traverse subdirectories!)
#
# * Save the script to a directory that is in your PATH variable so it can be executed
# * chmod u+x path/to/sort_dir # so that it can be executed
# * cd into the directory containing the files who's contents you wish to sort
# * Simpy run the command 'sort_dir'
# * This will product an subdirectory called 'sorted' containing all the current
# directory's files with their contents sorted
@theirishpenguin
theirishpenguin / psgrep
Created January 11, 2012 10:13
psgrep Bash function for no-nonsense ps output
# Drop this into your .bash_aliases or .bashrc
# Usage:
# psgrep some_substring_of_the_process_command
psgrep() { ps -ea -o pid,cmd|grep -v grep|grep $1 ;}
@theirishpenguin
theirishpenguin / enhanced_logger.rb
Created January 1, 2012 20:44
Override Logging messages in Rails
# drop this into config/initializers/enhanced_logger.rb
raise 'Check logger workaround if Rails version has changed' unless
Rails::version == "3.0.7"
# Overrides /path/to/gems/activesupport-3.0.7/lib/active_support/buffered_logger.rb
module ActiveSupport
class BufferedLogger
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
Thanks for your reply. It was a set of Sony headphones where one earphone stopped working the other day so I popped in to see ...
... what was required to get an exchange. I was told that a simple exchange was only possible within the first 28 days or if I had purchased a special warranty. I will try to track down the receipt and call into the store again if the purchasing of the special warranty is not crucial.
Thanks,
Declan
@theirishpenguin
theirishpenguin / The Ruby Ireland Shorts Pre-April.txt
Created April 3, 2011 15:11
Week Starting Mon 15th Feb 2011
* Declan shares a gotcha conerning Shams and Machinist 2 - Machinist 2 doesn't use it any more! http://www.theirishpenguin.com/2011/02/16/machinist-2-and-the-undefined-method-foo-for-shammodule-error/
* Good news for Netbeans users, JRuby is working on a deal to keep Rails support in Netbeans via a plugin. http://markmail.org/message/r7fliknkieg7fnwq
* I've been a long time TextMate user, but the lack of window splits and a terminal have always grated. This week I had a little time to look at the state of the art for editors for Rails development. I looked at RubyMine (too slow), Emacs (too hard to setup and slow), Sublime (incomplete), Coda (not deep enough), and BBEdit (didn't click with me). Finally, I revisited Vim (MacVim). It seems to have a loyal following and after I spent the time going through the Vimtutor, I am now a convert. As an editor, Vim rocks. The power of the text navigation and manipulation alone were worth switching for, but add in Rails.vim (http://rails.vim.tpope.net/) and a ready
# a simple/configurable rake task that generates some random fake data for the app (using faker) at various sizes
# NOTE: requires the faker or ffaker gem
# sudo gem install faker - http://faker.rubyforge.org
# OR
# sudo gem install ffaker - http://github.com/EmmanuelOga/ffaker
require 'faker'
class Fakeout
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789a