Skip to content

Instantly share code, notes, and snippets.

@anithri
anithri / README.md
Last active August 29, 2015 14:14
git status for i3blocks or other text based status tools.

Intro

This is a pair of scripts to facilitate display a repo status in my i3bar. Also included is a fragment of my .i3blocks.conf file where I use the scripts.

Purpose

To help me correct bad git habits, I want to bring the git status for the repo I'm wqorking on currently front and center in my i3bar.

Caveats

Because I like ruby, I used ruby. it's probably faster in all sorts of other implementations and I urge you to develop them if you want. I my eventually attempt a python translation as an excuse to learn something about python. I don't understand shell string manipulation well enough to summarize things with it, again I'm sure it's possible I just don't know how to do it and it isn't important enough to me to learn right now.

License

@anithri
anithri / joy.rb
Last active August 29, 2015 14:15
are there any gotcha's for this refinement scheme?
# Small module intended for enhancing a string object.
module Joy
def joy
self + ' Joy!'
end
end
#----------------------------------------------------------------------------
# Remove unnecessary Rails files
#----------------------------------------------------------------------------
run 'rm README'
run 'rm config/database.yml.example'
run 'rm config/database.yml'
run 'rm public/index.html'
run 'rm public/favicon.ico'
run 'rm public/images/rails.png'
run 'touch README'
#Anithri preinstall gems
#gem install rails -v 3.0.0.beta4
#gem install bundler -v 1.0.0.beta.4
# When ready run as
# rails new ArtificalCasting -d mysql -J -m http://gist.github.com/471391.txt
puts "=" * 80
puts "Step 1. Remove some unused files and directories"
puts "=" * 80
@anithri
anithri / gist:853303
Created March 3, 2011 19:05
Callback is run twice.
require 'paper_trail'
class EventLog < ActiveRecord::Base
#snipped stuff
before_create :on_creation
before_save :on_save
after_save :after_save
#snipped stuff
def after_save
#do stuff
@anithri
anithri / Execute once
Created April 19, 2011 19:11
script and commands to open txmt links in RubyMine on Ubuntu
gconftool-2 -s /desktop/gnome/url-handlers/txmt/command '/usr/local/bin/openInMine "%s"' --type String
gconftool-2 -s /desktop/gnome/url-handlers/txmt/enabled --type Boolean true
@anithri
anithri / gist:987622
Created May 23, 2011 21:11
Guardfile
guard 'bundler' do
watch('Gemfile')
end
guard 'passenger' do
watch(%r{lib/.*\.rb})
watch(%r{config/.*\.rb})
end
guard 'livereload' do
@anithri
anithri / mk_rvmrc.zsh
Created August 7, 2011 09:54
zsh function to create .rvmrc files
function mk_rvmrc() {
my_ruby=${argv[1]:=$ruby19} #I set ruby19=ruby-1.9.2@p290 elsewhere.
my_gemset=${argv[2]:=`basename $PWD`} #uses the name of the current directory if no 2nd arg is given
rvm --create --rvmrc ${my_ruby}@${my_gemset}
}
@anithri
anithri / Gemfile
Created September 5, 2011 20:25
guard examples
#Gemfile
group :development do
gem 'guard'
gem 'guard-bundler'
gem 'guard-rspec'
gem 'guard-annotate'
gem 'guard-spork'
#For linux
#gem 'rb-inotify'
#gem 'libnotify'
@anithri
anithri / gist:1208809
Created September 10, 2011 21:24
rmu color formatter example
class ColorFormatter < Log4r::Formatter
attr_accessor :color, :label, :colors, :format_string
def colors
@level_colors || [:cyan, :green, :yellow, :light_red, :red]
end
def initialize(opts={})
@depth = (opts[:depth] || 7 ).to_i
@color = opts[:color] || true