Skip to content

Instantly share code, notes, and snippets.

@slifin
slifin / test.html
Last active August 29, 2015 14:18
observer pattern example
<!DOCTYPE html>
<html>
<head>
<title>Observer Pattern</title>
</head>
<body>
<div id="game-names"></div>
<script type="text/javascript">
function Observable(){
var that = {},
@swlaschin
swlaschin / ConstrainedTypesExamples.fsx
Last active May 26, 2024 20:19
Examples of creating constrained types in F#
// General hints on defining types with constraints or invariants
//
// Just as in C#, use a private constructor
// and expose "factory" methods that enforce the constraints
//
// In F#, only classes can have private constructors with public members.
//
// If you want to use the record and DU types, the whole type becomes
// private, which means that you also need to provide:
// * a constructor function ("create").
@Rayne
Rayne / F3PHPUnitTest.php
Created May 23, 2015 11:07
Basic FatFreeFramework/Base->mock() + PHPUnit example
<?php
class F3PHPUnitTest extends PHPUnit_Framework_TestCase {
public function test() {
$f3 = Base::instance();
// Don't write to STDOUT
$f3->set('QUIET', true);
$f3->route('GET /path', function(){ echo 'TEXT'; });
@GuyCarver
GuyCarver / tip.fsx
Last active July 4, 2018 09:45
F# version of tipcalculator.cs example for Continuous app
//
// Tip Calculator Example
//
// Calculates a tip and total given a bill amount
//
open System;
open Xamarin.Forms;
let clr1 = Color.FromRgb (150, 200, 190)
@reborg
reborg / rich-already-answered-that.md
Last active July 3, 2024 06:35
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@ericnormand
ericnormand / 00_script.clj
Last active May 18, 2024 08:30
Boilerplate for running Clojure as a shebang script
#!/bin/sh
#_(
#_DEPS is same format as deps.edn. Multiline is okay.
DEPS='
{:deps {clj-time {:mvn/version "0.14.2"}}}
'
#_You can put other options here
OPTS='
@pjstadig
pjstadig / transducers.md
Last active June 8, 2021 13:22
The secret feature of transducers that no one talks about!

The Pledge

One thing that always made me a little sad about transducers was how map lost its ability to iterate multiple collections in parallel. This is actually my favorite feature of map. For example:

(map + (range 5) (range 5 10))
=> (5 7 9 11 13)

One somewhat practical use of this is if you want to compare two sequences, pairwise, using a comparator. Though I wish that every? took multiple collections, this is an adequate substitute:

@andy-thomason
andy-thomason / Genomics_A_Programmers_Guide.md
Created May 14, 2019 13:32
Genomics a programmers introduction

Genomics - A programmer's guide.

Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.

https://www.genomicsplc.com

@yogthos
yogthos / clojure-beginner.md
Last active July 1, 2024 09:43
Clojure beginner resources

Introductory resources

@lispyclouds
lispyclouds / monads.clj
Last active May 17, 2020 02:37
Monads, simple made easier
; A simple demo of monadic composition of side effects
; Program to take 3 nubers as input and print their sum.
(defn read-and-add!
[prev]
(print "Enter a number: ")
(+ prev (do (flush)
(Integer/parseInt (read-line)))))
(defn bind