Skip to content
View joy.rb
# Small module intended for enhancing a string object.
module Joy
def joy
self + ' Joy!'


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.


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.


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.


View rspec failure error
1) Ruzo::Crm#get_records should get more than 1 slice for counts over @max_records
Failure/Error: crm.should_receive(:get_record_slice).with("Contacts",{from:1, to: 4}).ordered
#<Ruzo::Crm:0x00000002e2f980> received :get_record_slice with unexpected arguments
expected: ("Contacts", {:from=>1, :to=>4})
got: ("Contacts", {:from=>1, :to=>8}), ("Contacts", {:from=>5, :to=>12})
# ./spec/crm_spec.rb:88:in `block (4 levels) in <top (required)>'

expected result in from excel function where =(NORMDIST(test,0,1,FALSE)) * 2.506628274631

actual result from (Normdist.normdist(test, 0 , 1, false) * 2.50663).round(4)

test value expected Actual
0 1.0 1.0
0.05 0.9988 0.9753
0.1 0.995 0.9512
0.15 0.9888 0.9277
View model.rb
<% module_namespacing do -%>
class <%= class_name %> < <%= parent_class_name.classify %>
<% if !accessible_attributes.empty? -%>
attr_accessible <%= {|a| ":#{}" }.sort.join(', ') %>
<% else -%>
View controller_spec.rb
require 'spec_helper'
describe <%= controller_class_name %>Controller do
# This should return the minimal set of attributes required to create a valid
# <%= class_name %>. As you add validations to <%= class_name %>, be sure to
# update the return value of this method accordingly.
def valid_attributes
attributes_for(:<%= file_name %>)
View gist:3881265
class Project < ActiveRecord::Base
has_and_belongs_to_many :project_types
scope :has_any_project_types, ->(*project_types) do
where(" IN (?)", project_types)
scope :has_all_project_types, ->(*project_types) do
View addendum_grid.yml
:dom_id: "addendums_grid"
:caption: "Addendums"
:edit: true
:search: false
:add: true
View clause.rb
def clause(op, field, data)
out = []
out << ops_table[op][:field_proc].call(field)
out << ops_table[op][:data_proc].call(data)
model.where(*clause(op, field, data))
View exception.rb
module MyModule
class MyModuleError < StandardError
@@ignore = :warn
def ok_to_ignore?
def self.ok_to_ignore
Something went wrong with that request. Please try again.