Skip to content

Instantly share code, notes, and snippets.

@thieux
thieux / swift-getting-started.md
Created November 1, 2017 14:05
Swift Getting Started

Swift Getting Started on Linux

wget https://swift.org/builds/swift-4.0-release/ubuntu1604/swift-4.0-RELEASE/swift-4.0-RELEASE-ubuntu16.04.tar.gz
tar xvzf swift-4.0-RELEASE-ubuntu16.04.tar.gz
export PATH="$PATH:~/Applications/swift-4.0-RELEASE-ubuntu16.04/usr/bin/"
apt-get install curl
apt-get install clang
@thieux
thieux / expected-username.xml
Created September 25, 2017 09:25
Unit test in XSLT
<?xml version="1.0"?>
<root>
<name username="JS1">John</name>
<name username="MI1">Morka</name>
</root>
@thieux
thieux / state-interaction.md
Last active August 9, 2017 09:15
State versus interaction - design strategies & tests

Pattern

The input (that feeds a function) can be implemented in 2 ways: controlled by the caller or by the callee.

The outputs (that is provided by a function) can be implemented in 2 ways: exposed to the caller or by message.

Input as parameter

The function's caller controls the input.

@thieux
thieux / generate_word.clj
Last active May 31, 2017 22:31
Quick&dirty POC of a markov chain in Clojure to generate city names that sound french
(ns generate-word.core-test
(:require [clojure.test :refer :all]
[generate-word.core :refer :all]
[clojure.string :as str]))
(def cities1 ["ABBAYE" "ABBAYE ST-JEAN" "ABBE FOURE" "ABBE HUCHET" "ABBE LORIN" "ABBE PIERRE LEROY" "ABBE POUSSIN" "ABLETTE" "ABREUVOIR" "ACACIAS" "ACADIENS" "ACHILLE" "AIGUILLE" "AJONCS" "ALAUX" "ALBATROS" "ALBERT" "ALBERT 1er" "ALCYON" "ALET"])
(def cities ["ABBAYE" "ABBAYE ST-JEAN" "ABBE FOURE" "ABBE HUCHET" "ABBE LORIN" "ABBE PIERRE LEROY" "ABBE POUSSIN" "ABLETTE" "ABREUVOIR" "ACACIAS" "ACADIENS" "ACHILLE" "AIGUILLE" "AJONCS" "ALAUX" "ALBATROS" "ALBERT" "ALBERT 1er" "ALCYON" "ALET" "ALGER" "ALLENDE" "ALSACE" "AMANDIERS" "AMARYLLIS" "AMAZONE" "AMIRAL EPRON" "AMIRAL LEVERGER" "AMIRAL MAGON" "AMIRAL PROTET" "AMITIE" "AMOUREUX" "ANCIENS COMBATTANTS" "ANCIENS D'INDOCHINE" "ANDROMEDE" "ANEMONES" "ANJOU" "ANTILLES" "APPOLINE" "ARABIE" "ARCHERS" "ARGENTEUIL" "ARGONAUTES" "ARGONNE" "ARKANSAS" "ARONDEL" "ARROMANCHES" "ARTILLEURS" "ARTIMON" "ARTOIS" "ASFELD" "ASTROL

Dynamic Composite

  1. Implement a DSL with many operation like concatenate, every, and, or, etc.

Here is some usages.

With the following object:

@FunctionalInterface
@thieux
thieux / pythagorean_triples.clj
Last active May 24, 2017 17:52
A brute force approach to the pythagorean triples problem in Clojure
(let [max 100]
(take 100
(for [a (range 1 max)
b (range 1 max)
c (range 1 max)
:when (= (+ (* a a) (* b b)) (* c c))]
[a b c])))
@thieux
thieux / pythagore-triple.py
Last active May 24, 2017 12:24
A brute force approach to generate pythagorean triples in Python 3
MAX = 100
pythagorean_triples = [(a, b, c) for a in range(2, MAX) for b in range(2, MAX) for c in range(2, MAX) if a*a + b*b == c*c]
print(pythagorean_triples)
(ns anonymous-letter.core-test
(:require [clojure.test :refer :all]
[anonymous-letter.core :refer :all]))
(defn decrement-dict [word dictionary]
(conj dictionary
[word
(dec (let [count (get dictionary word)]
(if (nil? count) 0 count)))]))

Random Code Generator

(defn generate-name []
  (case (rand-int 3)
    0 "agastopia"
    1 "bibble"
    2 "cabotage"))