Skip to content

Instantly share code, notes, and snippets.

🔮
~*~*sorcery*~*~

Philip Diaz lambdahands

🔮
~*~*sorcery*~*~
  • Chicago
Block or report user

Report or block lambdahands

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lambdahands
lambdahands / core.cljs
Created Nov 5, 2013
Using bound vars as argument to `to-attr` in macro produces no results. Not sure what mistake I'm making.
View core.cljs
(ns my-project.core
(:require-macros [my-project.macros :refer [style-el]]))
(defn create-el [kind]
(. js/document (createElement (name kind))))
(let [div (create-el :div)]
;; Works as expected
(style-el div :width "50%")
View gist:e3d981f8d33e0ce1a5fe
import Data.Text (split, pack, unpack)
splitStr :: Char -> String -> [String]
splitStr c str = map unpack $ split (== c) (pack str)
@lambdahands
lambdahands / transfer.sh
Created Sep 30, 2014
Little script to encrypt + upload and download + decrypt files. Uses gpg and http://transfer.sh
View transfer.sh
#!/bin/bash
transfer() {
echo $(gpg -ac --cipher-algo AES256 --sign --force-mdc < $1) | curl http://transfer.sh/$1 -T -
}
recover() {
curl $1 | gpg -ad
}
alias transfer=transfer
View nse.factor
# A side effect-less Factor operation.
[ ] call
@lambdahands
lambdahands / cta.js
Created Dec 9, 2014
flow-type + immutable-js
View cta.js
/* @flow */
var T = require('immutable');
type Branch = T.List<string>
type TrainLine = T.Map<string, Branch>
type CTAMap = T.Map<string, TrainLine>
/*
* Representation of Chicago's train stops and branches
@lambdahands
lambdahands / objectAlgebras.ml
Last active Nov 6, 2015
Object Algebras in OCaml
View objectAlgebras.ml
(*
* An OCaml implementation of object algebras, inspired from this article by Oleksandr Manzyuk:
* https://oleksandrmanzyuk.wordpress.com/2014/06/18/from-object-algebras-to-finally-tagless-interpreters-2/
*)
module ObjectAlgebras = struct
(* We technically don't need these interfaces;
* added here to compare between the Java implementation *)
type 'a expAlg = < lit : int -> 'a; add : 'a -> 'a -> 'a >
type 'a mulAlg = < mul : 'a -> 'a -> 'a >
@lambdahands
lambdahands / finalTagless.ml
Last active Aug 2, 2018
Final Tagless in OCaml
View finalTagless.ml
(*
* An OCaml implementation of final tagless, inspired from this article by Oleksandr Manzyuk:
* https://oleksandrmanzyuk.wordpress.com/2014/06/18/from-object-algebras-to-finally-tagless-interpreters-2/
*)
module FinalTagless = struct
type eval = { eval : int }
type view = { view : string }
module type ExpT = sig
View mapv.ml
module ListExtra = struct
open Core.Std
(*- Maps a function to each "column" in a list of "rows".
mapv [[1;2;3]; [3;4;5]] ~f:(List.fold ~init:0 ~f:(+));;
- : int list = [4; 6; 8]
*)
let mapv ls ~f = let open List in
let cmp x y = if length x = length y then 0
@lambdahands
lambdahands / _readme.md
Created Sep 28, 2015
FlowType and CSS Modules
View _readme.md

Huh?

So basically FlowType doesn't know about CSS Modules, a really handy way of dealing with the plagues of CSS in codebases (global variables and dependency wackiness mainly).

What WebPack allows us to do is "require" CSS files and use their class names:

import styles from "my_styles.css";
import React from "react";
@lambdahands
lambdahands / error.clj
Last active Dec 20, 2016
Datomic Client Errors
View error.clj
(require '[clojure.core.async :refer [<!!]]
'[datomic.client :as client])
; Connection config incomplete for brevity
(def conn (<!! (client/connect {:db-name "mydb"})))
(<!! (client/pull (client/db conn) {:selector [:db/doc]}))
; Produces data as error message.
; Value on path [:datomic.client/http-error :cause] is a spec explaination:
{:cognitect.anomalies/category :cognitect.anomalies/incorrect
You can’t perform that action at this time.