Skip to content

Instantly share code, notes, and snippets.

@mshalaby
mshalaby / commit_count.sh
Created December 18, 2024 21:19
A script to collect commit count for all organization repos within a certain time range
#!/bin/bash
# Date helper functions
get_year_dates() {
local year=${1:-$(date +%Y)}
local start="${year}-01-01T00:00:00Z"
local end="${year}-12-31T23:59:59Z"
echo "$start $end"
}
Rails as it has never been before :)
@mshalaby
mshalaby / object_mock_test.rb
Created February 24, 2010 09:00
Tests for object_mock.rb mocking solution
require "object_mock"
require "rubygems"
require "shoulda"
class ObjectMockTest < Test::Unit::TestCase
context "With class X" do
setup do
class X
def m; "m"; end;
@mshalaby
mshalaby / object_mock.rb
Created February 24, 2010 08:31
A simple mocking solution
# A group of methods added to Object class to enable simple mocking
# of instance or class methods.
# This mocking can be done temporarily within the scope of a block.
# Alternatively it can be done indefinitely until explicitly undone.
class Object
# method for mocking or adding methods for a single object
# (or class methods if the object is a class instance)
# methods: a comma separated key value pairs