This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jamesshore.finances.domain; | |
// import .... | |
public class ValidDollars extends Dollars { | |
public static final double MAX_VALUE = 1000000000d; // one beeeellion dollars! | |
public static final double MIN_VALUE = -1000000000d; | |
private double amount; | |
// ... <snip> ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShouldReturnUnalteredUrl(TestCase): | |
def test__root_without_trailing_slash(self): self.assert_unchanged('http://www.example.com') | |
def test__root_with_trailing_slash(self): self.assert_unchanged('http://www.example.com/') | |
def test__explicit_html_page(self): self.assert_unchanged('http://www.example.com/page.html') | |
def test__root_with_querystring(self): self.assert_unchanged('http://www.example.com/?foo=bar') | |
def test__root_with_querystring_and_hash(self): self.assert_unchanged('http://www.example.com/?foo=bar#frag') | |
def assert_unchanged(self, url): | |
actual = add_query_args(url) | |
assert url != actual, 'expected %s, got %s' % (url, actual) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// re: for http://codemanship.co.uk/parlezuml/blog/?postid=1149 | |
// original code, called from inside the method: | |
Customer customer = DataRepository.GetCustomer(customerId); | |
// to enable the creation of the regression suite, | |
// I extract the implementation of DataRepository.GetCustomer into its own methpd | |
class DataRepository { | |
public static Customer GetCustomer(customerId) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@explained # adding it by AOP at startup or by codegen or whatever | |
def transient_condition(self, user) | |
character = random_character | |
return user.first_name.start_with?(random_character), "Checking if first_name:#{user.first_name} starts with character:#{character}" | |
end | |
def explained(wrapped, *args, **kwargs): | |
log.info('entering %s with params %s, %s' % (wrapped.__name__, args, kwargs)) | |
result, explanation = wrapped(*args, **kwargs) | |
log.info('exiting %s with params %s, %s - return value is %s because %s' % (wrapped.__name, args, kwargs, result, explanation)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def assuming_sorted_input_with_callbacks(sorted_unique_integers, callback_to_invoke_on_each_consecutive_set): | |
""" context: | |
""" | |
if not sorted_unique_integers: | |
return # empty input | |
curr_lo = curr_hi = sorted_unique_integers[0] | |
for num in sorted_unique_integers[1:]: | |
if curr_hi != (num - 1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ elixir macros-why-error.exs | |
false | |
** (UndefinedFunctionError) undefined function: MyMacro.unless/2 | |
MyMacro.unless(false, [do: :ok]) | |
(elixir) src/elixir_lexical.erl:17: :elixir_lexical.run/2 | |
(elixir) lib/code.ex:301: Code.require_file/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir vagrant-pytest-does-not-recogniz-pytest-django-on-ubuntu-trusty64 | |
cd vagrant-pytest-does-not-recogniz-pytest-django-on-ubuntu-trusty64 | |
vagrant init ubuntu/trusty64 | |
vagrant ssh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Showing off behave | |
Scenario: Run a simple test | |
Given we have behave installed | |
When we implement 5 tests | |
Then behave will test them for us! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.provision "shell", path: "bootstrap.sh" | |
config.vm.provider "virtualbox" do |vb| | |
vb.gui = true | |
vb.memory = "1024" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openpyxl.workbook import Workbook | |
from openpyxl.writer.excel import save_virtual_workbook, save_workbook | |
from openpyxl.reader.excel import load_workbook | |
from decimal import Decimal | |
import tempfile | |
import os | |
def get_filepath(name): | |
fh, path = tempfile.mkstemp(prefix=name, suffix='.xlsx') |
OlderNewer