Skip to content

Instantly share code, notes, and snippets.

@andypalmer
andypalmer / install.md
Last active February 20, 2018 02:29
Fresh install

Command line

  • brew
  • zsh
  • prezto (TODO: check out Antigen, ZPlug or other lightweight plugin manager)
  • nvim
  • fzf
  • nerd-fonts
  • powerlevel9k

Essential apps

@andypalmer
andypalmer / twitter.html
Created October 10, 2017 20:52
Twitter card playground
<meta content='summary_large_image' name='twitter:card'>
<meta content='@RiverGlide' name='twitter:site'>
<meta content='Working Effectively with Legacy Code' name='twitter:title'>
<meta content='Working effectively with Legacy Code is one of those books that should be on every development team’s bookshelf. Many teams are working with code that has been around for quite some time, created before the team valued (or needed) practices like Test-Driven Development and SOLID principles.' name='twitter:description'>
<meta content='http://images.amazon.com/images/P/0131177052.01._SS1094_SCLZZZZZZZ_.jpg' name='twitter:image'>
<meta content='Working Effectively with Legacy Code' name='twitter:image:alt'>
public Result someMethod() throws IUsedToReturnNullPleaseFixMe {
Result result = someMethodIDontControl();
if(null == result) {throw new IUsedToReturnNullPleaseFixMe();}
// This is temporary. The right thing _might_ be an exception, but we’ll work that out later
return result;
}
public Result someMethod() {
Result result = someMethodIDontControl();
if(null == result) {return null;}
// Actually, this is really crap because in reality, I’d just return result, but bear with me!
return result;
}
@andypalmer
andypalmer / AnEbayUserCan.java
Last active August 29, 2015 14:24
Serenity Journey example
public class AnEbayUserCan {
@Test
public void searchForAnItem() {
EbayUser andy = new EbayUser().with(WebBrowsing.capability());
andy.doesTheFollowing(
Go.to(EBay.homepage),
Search.for("fire poi"),
Count.the(Results)
@andypalmer
andypalmer / keybase.md
Created April 18, 2015 11:49
keybase.md

Keybase proof

I hereby claim:

  • I am andypalmer on github.
  • I am andypalmer (https://keybase.io/andypalmer) on keybase.
  • I have a public key whose fingerprint is DB19 FBB6 D48C 9868 C6DE 70A4 D4D8 4755 FEBA 3DD9

To claim this, I am signing this object:

module MethodLogging
def self.logger=(logger)
@@logger = logger
end
def self.included(base)
base.extend(ClassMethods)
end
def log(method, something)
@andypalmer
andypalmer / rubywarrior-intermediate
Last active August 29, 2015 14:05
rubywarrior-intermediate
Rubywarriors hierarchy of needs
* Stay alive
* Free all the prisoners
* Kill all the enemies
* Explore all the level
* Progress to the next level
@andypalmer
andypalmer / level5.rb
Last active December 20, 2015 13:59
Slightly complicated solution to level 5 of RubyWarrior: https://www.bloc.io/ruby-warrior
class Safe
def next_move_for(player)
return Attack.new if player.is_under_attack?
self
end
def act(warrior)
return warrior.rest! if warrior.health < 15
return warrior.attack! if warrior.feel.enemy?
return warrior.rescue! if warrior.feel.captive?
@andypalmer
andypalmer / SomethingOrNull.java
Created May 16, 2011 10:48
Instead of checking nulls all the way down the list
import static org.junit.Assert.*;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.*;
public class SomethingOrNothingTest {
@Test
public void shouldGiveMeSomething() throws Exception {