Skip to content

Instantly share code, notes, and snippets.

View zeedunk's full-sized avatar

Zac Duncan zeedunk

  • Simple
  • Portland, OR
View GitHub Profile
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
//please pardon the MSTest.
namespace TestProject
{
[TestClass]
public class UnitTest
{
[TestMethod]
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Foo
{
[TestClass]
public class ReduceExamples
{
[TestMethod]
public void Aggregate_Is_A_Poorly_Named_Version_Of_Reduce()
require 'edgecase'
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#
#call restful URL in ruby.
require 'net/http'
Net::HTTP.start('localhost', '3000') { |http| puts http.get('/resource/and_args').body}
class ControllerTest < ActionController::TestCase
context 'on create' do
setup do
TheModel.stubs(:new).returns(@the_model)
@the_model.expects(:save)
post :create
end
class ControllerTest < ActionController::TestCase
context 'on create' do
setup do
@the_model = stub
TheModel.stubs(:new).returns(@the_model)
post :create
end
should 'save the new model' do
@zeedunk
zeedunk / gist:848570
Created March 1, 2011 03:35
fizzbuzz.erl
-module(fizzbuzz).
-include_lib("eunit/include/eunit.hrl").
-export([fizzbuzz/1]).
fizzbuzz([]) -> [];
fizzbuzz([X]) -> [fizzbuzzify(X)];
fizzbuzz([H|T]) -> fizzbuzz(T, [fizzbuzzify(H)]).
-module(fizzbuzz).
-export([fizzbuzz/1,fizzbuzzify/1]).
fizzbuzz(HighNum) -> lists:map(
fun (Num) ->
fizzbuzzify(Num, {Num rem 3, Num rem 5})
end, lists:seq(1, HighNum)).
fizzbuzzify(_Input,{0, 0})-> "fizzbuzz";
@zeedunk
zeedunk / chat_client.erl
Created March 1, 2011 23:23
copied and modified from prag programmers screencast
-module(chat_client).
-compile(export_all).
register_nickname(Nickname) ->
Pid = spawn(chat_client, handle_messages, [Nickname]),
message_router:register_nick(Nickname, Pid).
unregister_nickname(Nickname) ->
message_router:unregister_nick(Nickname).