Skip to content

Instantly share code, notes, and snippets.

View Cynede's full-sized avatar
🕸️

ミーゼこちゃん Cynede

🕸️
View GitHub Profile
@VictorLaskin
VictorLaskin / aop.cpp
Last active November 17, 2021 12:28
C++11 functional decomposition - easy way to do AOP
// This is example from
// http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/
// by Victor Laskin
#include <iostream>
#include <functional>
#include <map>
#include <vector>
#include <memory>
#include <chrono>
@puffnfresh
puffnfresh / reornament.idr
Last active September 15, 2018 21:20
Algebraic Ornaments!
module reornament
-- Idris translation of Agda code:
-- https://gist.github.com/gallais/e507832abc6c91ac7cb9
-- Which follows Conor McBride's Ornaments paper:
-- https://personal.cis.strath.ac.uk/conor.mcbride/pub/OAAO/Ornament.pdf
ListAlg : Type -> Type -> Type
ListAlg A B = (B, A -> B -> B)
module Printf
%default total
data Format = FInt Format -- %d
| FString Format -- %s
| FOther Char Format -- [a-zA-Z0-9]
| FEnd --
format : List Char -> Format
@eulerfx
eulerfx / app.fsx
Created March 26, 2014 00:36
F# http service with HyperF
#load "HyperF.fsx"
open HyperF
open Route
let service =
[
Get("/resource/:id") => fun (req,ri) -> "hello world!" |> HttpRes.plainText
@jbtule
jbtule / build.fsx
Last active March 24, 2020 16:06
Crossplatform FSharp Makefile Bootstrapper
#!/bin/sh
#if run_with_bin_sh
# Doing this because arguments can't be used with /usr/bin/env on linux, just mac
exec fsharpi --define:mono_posix --exec $0 $*
#endif
(*
* Crossplatform FSharp Makefile Bootstrapper
* Apache licensed - Copyright 2014 Jay Tuley <[email protected]>
* v 2.0 https://gist.github.com/jbtule/9243729
@puffnfresh
puffnfresh / .zshrc
Created February 19, 2014 02:09
Put sandbox status in ZSH prompt
function cabal_sandbox_info() {
cabal_files=(*.cabal(N))
if [ $#cabal_files -gt 0 ]; then
if [ -f cabal.sandbox.config ]; then
echo "%{$fg[green]%}sandboxed%{$reset_color%}"
else
echo "%{$fg[red]%}not sandboxed%{$reset_color%}"
fi
fi
}
@Cynede
Cynede / gist:7673288
Last active December 29, 2015 12:49
(
(|x:|xx:|xxx:|||||{x(|xxx:|||{xxx()})}
) (|xx:|xxx:||||{xx(||{()})}));
@Cynede
Cynede / gist:7483104
Last active December 28, 2015 09:59
([](int x) { printf("HELLO A %d\n", x + 4); })(1);
([](int x) { printf("HELLO B"); })(1);
([]() { printf("HELLO C %d\n"); })();
([](float a) { printf("HELLO D %d\n"); })(2.0);
/* output :
HELLO A 5
HELLO A 5
HELLO C 5
HELLO D 5
use std::task;
use std::rt::io::timer::sleep;
///<Summary>
///Simple butterfly
///</Summary>
pub fn butterfly<U>(f: &fn() -> U) -> U {
let (port, chan) = stream();
do task::spawn_sched(task::SingleThreaded) {
print(" ");
/*
* Copyright (c) 2013, Daniel Park
* All rights reserved.
*
* Permission to modify and redistribute this software is granted to
* anyone provided the above copyright notice, this condition and the
* following disclaimer are retained.
*
* This software is provided "as is", without and express or implied
* warranty. In no event shall the author be liable for damages arising