Skip to content

Instantly share code, notes, and snippets.

@dadarek
dadarek / funky.cpp
Created June 29, 2012 21:15
Funky CPP
class Something
{
public:
void PrintSomething() {
cout << "hi there" << endl;
}
};
int main()
{
@dadarek
dadarek / di.rb
Created November 15, 2013 19:15
Dependency Injection Example
# DEPENDENCY INJECTION
class A
def initialize(helper)
end
def doSomething
helper.someFunction
end
@dadarek
dadarek / gist:7343633
Created November 6, 2013 20:37
brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Users/dariusz/.rvm/bin/erb-ree-1.8.7-2011.12@ops-config
class Game
def initialize( printer, logicMachine )
end
def go
while logicMachine.continue?
printer.puts( "We are still playing the game." )
%p= @hey
@dadarek
dadarek / SomeClass-bad.cs
Created August 20, 2013 16:23
Command-Query Violation
class SomeClass{
private int reason;
public bool Go(){
int value = SomeBigCalculation();
if( value > 5 ){
this.reason = "Too Big";
return true;
@dadarek
dadarek / SomeClass-bad.cs
Created August 20, 2013 16:16
How to corner dependencies that are hard to mock or extract interface.
class SomeClass{
private BigHorrificMonsterClass myBaby = new BigHorrificMonsterClass();
public int DoSomething( int value ){
int cradled = myBaby.cradle( value );
return value + cradled;
}
}
@dadarek
dadarek / Hierarchy.md
Last active December 21, 2015 09:09
How to structure your test project files.
  • Project 1

    • Folder 1
      • Class1 cs
      • Class2 cs
    • Class3 cs
  • Project 1 Tests

    • Folder 1
  • Class1_Test.cs

@dadarek
dadarek / SomeClass-bad.cs
Last active December 21, 2015 09:09
How to inject globals without affecting client code.
class SomeClass{
private int someValue;
public SomeClass( int someValue ){
this.someValue = someValue;
}
public int SomeFunction(){
return someValue + GlobalReference.someFunction();
}
@dadarek
dadarek / vim.rb
Created October 12, 2012 19:00
vim.rb formula
require 'formula'
class Vim < Formula
# Get stable versions from hg repo instead of downloading an increasing
# number of separate patches.
url 'https://vim.googlecode.com/hg/', :revision => 'c0ac5ba66243'
version '7.3.646'
homepage 'http://www.vim.org/'
head 'https://vim.googlecode.com/hg/'