Skip to content

Instantly share code, notes, and snippets.

View serbrech's full-sized avatar
🤙
Working from home

Stéphane Erbrech serbrech

🤙
Working from home
View GitHub Profile
public interface IIssueDataFetcher
{
void Fetch(Action<IssueData> callback);
IIssueDataFetcher WithId(int id);
IIssueDataFetcher IncludeContainers();
IIssueDataFetcher IncludeContainerStatuses();
IIssueDataFetcher IncludeContainerCategories();
IIssueDataFetcher IncludeAll();
}
@serbrech
serbrech / rubykoans triangle.rb
Created April 5, 2011 18:55
My ruby koans triangle implementation. Is there a "rubyer" way to write this?
def guard(a, b, c)
if a < 0 || b < 0 || c < 0
raise TriangleError, "a triangle should not have a side with a negative value."
end
if a == 0 && b == 0 && c == 0
raise TriangleError, "A triangle should not have all its side equal to 0."
end
if (a + b) <= c || (b + c) <= a || (a + c) <= b
raise TriangleError, "Any two sides of a triangle should add up to more than the third side."
end
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
def triple?(dice, val)
dice.count {|die| die == val} >= 3
end
def get_triple_bonus(dice)
return 0 if dice.empty?
return 350 if triple? dice, 5
return 700 if triple? dice, 1
@serbrech
serbrech / TestBase.cs
Created August 21, 2011 18:42
Silverlight MSTest TestBase
public class TestBase
{
private Exception _exception;
[TestInitialize]
public void TestInitialize()
{
try
{
Initialize();
@serbrech
serbrech / KeyGestureCommandTrigger.cs
Created August 31, 2011 12:30
KeyGestureBehavior
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using PagePlanner.Windows.Controls.TriggerActions;
namespace PagePlanner.Windows.Controls.Behaviours.KeyGestures
{
@serbrech
serbrech / app.rb
Created November 6, 2011 15:48
facebook canvas sinatra by heroku
require "sinatra"
require "mogli"
enable :sessions
set :raise_errors, false
set :show_exceptions, false
# Scope defines what permissions that we are asking the user to grant.
# In this example, we are asking for the ability to publish stories
# about using the app, access to what the user likes, and to be able
@serbrech
serbrech / factories.rb
Created November 13, 2011 16:01
sequence of hash with factory_girl
Factory.sequence :writer_hash do |n|
{
"id" => "#{n}",
"name" => "name#{n}",
"article" => {
"id" => "#{n}",
"title" => "post title #{n}"
}
}
end
@serbrech
serbrech / whereis.ps1
Created March 9, 2012 12:13
powershell whereis first draft
function get-path{
$env:path -split';'
}
function whereis
{
$argument = $cmd, [string]$arguments = $args;
foreach ($item in get-path){
foreach ($thing in gci $item -ErrorAction silentlycontinue){
if($thing.Name.StartsWith($cmd + ".")){
@serbrech
serbrech / hack.sh
Created April 2, 2012 09:17 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@serbrech
serbrech / init.sh
Created April 25, 2012 18:37
This is how I bootstrap my envoironment. It's a small shellscript that will open a new tab and run the command past as argument to it.
#!/bin/sh
# Credits goes to http://stackoverflow.com/questions/1589114/opening-a-new-terminal-tab-in-osxsnow-leopard-with-the-opening-terminal-window#answer-7911097
# I just slightly modified it to take an argument.
new_tab() {
pwd=`pwd`
osascript -e "tell application \"Terminal\"" \
-e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
-e "do script \"cd $pwd; clear; $1;\" in front window" \