Skip to content

Instantly share code, notes, and snippets.

View mcfearsome's full-sized avatar
💭
hacking the mainframe

mcfearsome mcfearsome

💭
hacking the mainframe
View GitHub Profile
truffle(development)> catalog.productIdsLength()
{ [String: '0'] s: 1, e: 0, c: [ 0 ] }
truffle(development)> catalog.productIds(0)
{ [String: '1'] s: 1, e: 0, c: [ 1 ] }
pragma solidity ^0.4.0;
contract Parent {
uint public a;
function Parent() {
a = 1;
}
}
contract Child is Parent {
function Child() {
pragma solidity ^0.4.11;
import "./owned.sol";
contract Remit is owned {
uint public deadlineDelta = 100000;
enum ChallengeState { Active, Aborted, Claimed }
struct Challenge {
ChallengeState state;

Keybase proof

I hereby claim:

  • I am mcfearsome on github.
  • I am mcfearsome (https://keybase.io/mcfearsome) on keybase.
  • I have a public key whose fingerprint is 5CB7 1A53 A647 639D 8B51 19A1 7125 BE57 BADA 1884

To claim this, I am signing this object:

@mcfearsome
mcfearsome / recent_messages.rb
Created January 18, 2011 18:10
Getting Messages in the last week
# Assuming Rails3
# Just using ActiveRecord's where method
messages_in_last_week = Message.where("created_at >= ?", 1.week.ago)
# Even better, a named scope on the model
class Message < ActiveRecord::Base
scope :recent, where("created_at >= ?", 1.week.ago)
end
# And Then
messages_in_last_week = Message.recent
git diff <$commit1>:path/file <$commit2>:otherpath/otherfile
@mcfearsome
mcfearsome / git-save_changes_as_a_patch.sh
Created May 10, 2009 01:26
Saves changes on a git repo as a .diff and then resets the working copy back to HEAD
git diff --binary HEAD > tempPatch.diff
git reset --hard
require 'rubygems'
require 'utility_belt'
require 'alias'
require 'hirb'
UtilityBelt.equip(:all)
IRB.conf[:interactive_editors] = Hash.new
IRB.conf[:interactive_editors][:mate] = InteractiveEditor.new(:mate)
require 'rubygems'
require 'utility_belt'
require 'alias'
require 'hirb'
UtilityBelt.equip(:all)
IRB.conf[:interactive_editors] = Hash.new
IRB.conf[:interactive_editors][:mate] = InteractiveEditor.new(:mate)
if rails_env = ENV['RAILS_ENV']
rails_root = File.basename(Dir.pwd)
rails_env_string = case rails_env
when 'development'
'dev'
when 'production'
'prod'
else
rails_env