Skip to content

Instantly share code, notes, and snippets.

View arialdomartini's full-sized avatar

Arialdo Martini arialdomartini

View GitHub Profile
@arialdomartini
arialdomartini / gist:d9015ef7f266c363e435
Last active August 29, 2015 14:14
one-time splash page
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www\.tuosito\.com [NC]
RewriteRule ^$ /splashpage.html [R]
public class GenericInvokerTest
{
[Test]
public void ShouldDynamicallProxyAGenericClass()
{
var sut = new Sut();
var injectableBehaviour = Substitute.For<IInjectableBehaviour>();
var wrapped = Wrapper<Sut>.Create(new Sut(), injectableBehaviour);
using System;
using MemoSpike.MemoizatorSpike;
namespace MemoSpike
{
using System;
using System.Collections.Generic;
namespace MemoizatorSpike
@arialdomartini
arialdomartini / memoize.cs
Created November 4, 2014 15:54
External memoization in C#, with an extension method, high-order function
static Func<A, R> Memoize<A, R>(this Func<A, R> function)
{
var cache = new Dictionary<A, R>();
return argument =>
{
R result;
if(!cache.TryGetValue(argument, out result))
{
r = function(argument);
cache.Add(argument, result);
namespace Nullity
{
class Program
{
static void Main(string[] args)
{
String nullity = null;
if (nullity == null)
{
var jr_track = {
country: 'tw',
id: 6775784,
uuid: 'twF00149141076fd0670',
};
var trackApplication = function() {
var jrta = document.createElement('script');
@arialdomartini
arialdomartini / gist:b0af26127c06522c3b16
Created October 9, 2014 07:15
How Java splits strings
package net.jobrapido.fo.api.v1.resources;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class SplitTest {
@Test
@arialdomartini
arialdomartini / Fibonacci
Created October 8, 2014 12:11
Tail recursive Fibonacci
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a1 := 0
a2 := 1
return func() int {
public static Integer LENGTH(final String string) {
if (StringUtils.isEmpty("")) {
if (StringUtils.isEmpty(string)) {
return 0;
} else {
return string.length();
}
} else if (StringUtils.isEmpty(string)) {
return 1;
}
@arialdomartini
arialdomartini / gist:a4193422d377a719d2d6
Created September 1, 2014 06:46
Étude 3-1: Pattern Matching in Elixir and Erlang
### Elixir
defmodule Geom do
def area(:rectangle, length, width) do
length * width
end
def area(:triangle, base, height) do
base * height / 2
end