Skip to content

Instantly share code, notes, and snippets.

@umuro
umuro / .irbrc *.rb
Created March 18, 2009 16:34
IRB improvements: Command history, coloring, more shell like commands cd, pwd, dir, cat
# kate: syntax ruby;
# -*- mode: ruby -*-
# vi: set ft=ruby :
# IRB improvements: Command history, coloring, more shell like commands cd, pwd, dir, cat
# Use powerful shell commands
# dir
# dir '**/*.rb'
# cd 'app'
# pwd
@umuro
umuro / .bashrc.sh
Created March 24, 2009 16:34
My .bashrc; color prompt with current GIT and RVM info... And other improvements...
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
#[ -z "$PS1" ] && return
if [[ -n "$PS1" ]] ; then
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoreboth
@umuro
umuro / gist:257831
Created December 16, 2009 13:50
Backup LINUX
# Regularly execute this to have a nice difference backup
# No Restore. Backups of different dates will be available as if normal folders.
# Just use them normally.
# On each backup the list of apt-get installed applications are dumped so that
# they can be restored simply. You don't wast space to backup the whole system.
echo Getting package selections
dpkg --get-selections >/home/packages.txt
TGT=/media/Elements-1 #!!!! Define your backup target here !!!!
@umuro
umuro / Ruby header.rb
Created June 4, 2012 10:51
Ruby colorize non-rb files. Enable ruby coloring on files that does not end with .rb
# kate: syntax ruby;
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Add those comments to colorize non-rb files automatically. It happens that not all ruby files have the rb extension.
@umuro
umuro / template_umur_demo_blog.rb
Created August 17, 2012 14:05
Rails 3 template to create a demo blog
# Usage example: rails new demo_blog -m template_umur_demo_blog.rb
# 2 points demonstrated
# - Templates are powerful. You can create even a working application
# - Ruby on Rails is very DRY. Code reads as if it's design
# Required gems
gem 'therubyracer', :platforms => :ruby, :group=>:assets #Rails need
gem 'inherited_resources'
gem 'has_scope'
@umuro
umuro / gemset.thor
Created August 20, 2012 13:08
Thor: Create new RVM gemsets by example for new Rails projects
# kate: syntax ruby;
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'rubygems'
require 'thor'
class Gemset < Thor
include Thor::Actions
@umuro
umuro / template_demo_blog_hobo.rb
Created August 20, 2012 15:13
A template to create a blog with hobo. Quickly!
# Creates a demo blog in a new hobo project
# Usage: rake rails:template LOCATION=template_demo_blog_hobo.rb
# Or: rake rails:template LOCATION=https://raw.github.com/gist/3405055/9aaac7c1c9e9571b32c4359fa9fff77c89de82a9/template_demo_blog_hobo.rb
say ("Installing gems so that we can scaffold...")
run 'bundle install'
generate 'hobo:setup_wizard' if yes? "Wanna run hobo:setup_wizard?"
generate 'hobo:resource', 'Post title:string text:text'
@umuro
umuro / post_rvmrc.rb
Created August 21, 2012 11:48
If your old rvmrc is not ensuring a bundle then you can add this bit...
#This bit goes at the end of rvmrc and makes sure that bundle is installed and it installs gems
#If you use bundler, this might be useful to you:
if [[ -s Gemfile ]] && {
! builtin command -v bundle >/dev/null ||
builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
}
then
printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
gem install bundler
@umuro
umuro / match_mtd.rb
Created August 29, 2012 12:50
Match a ruby metdhod using regex. To use Thor scripts to replace method definitions in existing source code.
#Match a ruby metdhod using regex. To use Thor scripts to replace method definitions in existing source code.
# github: umuro, Umur Ozkul
def match_mtd(mtd)
/^\s*def (#{mtd})\s+((?!end).)*\s+end\s*$/m
end

Keybase proof

I hereby claim:

  • I am umuro on github.
  • I am umur (https://keybase.io/umur) on keybase.
  • I have a public key ASCDmpjT3ec7yNc555RFep9wNlsAQp1XiUthgJ0B63AzuAo

To claim this, I am signing this object: