Skip to content

Instantly share code, notes, and snippets.

View gilles-leblanc's full-sized avatar

Gilles Leblanc gilles-leblanc

View GitHub Profile
@gilles-leblanc
gilles-leblanc / dabblet.css
Created April 13, 2013 00:56
Strings and numbers conversions
/** Strings and numbers conversions
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@gilles-leblanc
gilles-leblanc / dabblet.css
Created April 13, 2013 01:11
Undefined and exceptions
/** Undefined and exceptions
* Trying out code while reading JavaScript docs on MDN
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@gilles-leblanc
gilles-leblanc / dabblet.css
Created April 13, 2013 01:29
No block scope and variable hoisting
/** No block scope and variable hoisting
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
/** Functions
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@gilles-leblanc
gilles-leblanc / dabblet.css
Created April 13, 2013 17:53
Variable hoisting 2
/** Variable hoisting 2
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@gilles-leblanc
gilles-leblanc / stub.rb
Last active December 20, 2015 22:09
Simple test to check behaviour of stubs defined with allow.
require_relative 'test_bidon'
describe TestBidon do
context 'when using stubs' do
before :each do
@exp = double('exp')
allow(@exp).to receive(:name).and_return('Gilles')
end
it 'is actually called' do
// Explicitly typed variable
let blog_post_count: int = 0;
@gilles-leblanc
gilles-leblanc / AssertExtension.cs
Created January 26, 2014 20:47
A better alternative than using the ExpectedException attribute for catching exceptions in C#.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestUtilities
{
public static class AssertExtension
{
public static T Throws<T>(Action expressionUnderTest, string exceptionMessage = "Expected exception has not been thrown by target of invocation.") where T : Exception
{
try
@gilles-leblanc
gilles-leblanc / gist:e07cf10af136c41f37e7
Last active August 29, 2015 14:02
Rust: expressions
// expressions.rs
fn main() {
let a = {
let inner = 2;
inner * inner
};
println!("a = {}", a);
let b = {
@gilles-leblanc
gilles-leblanc / gist:e1faed3c7b7008a9d116
Last active August 29, 2015 14:02
Rust: expressions 2
let a = {
let inner = 2;
inner * inner
};
println!("a = {}", a);
let b = {
let inner = 2;
inner * inner;