Skip to content

Instantly share code, notes, and snippets.

View fabriceleal's full-sized avatar
😫
meh

Fabrice Ferreira Leal fabriceleal

😫
meh
  • Leiria, Portugal
View GitHub Profile
@hirrolot
hirrolot / CoC.ml
Last active November 13, 2024 04:32
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@hirrolot
hirrolot / CoC.ml
Last active October 1, 2024 17:19
Barebones lambda cube in OCaml
(* The syntax of our calculus. Notice that types are represented in the same way
as terms, which is the essence of CoC. *)
type term =
| Var of string
| Appl of term * term
| Binder of binder * string * term * term
| Star
| Box
and binder = Lam | Pi
@fabriceleal
fabriceleal / gist:2e35d0b4b4f879930550
Created November 3, 2014 08:56
Call C pre processor without line markers in the output
gcc -E -P some.h > some.prep.h
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active September 12, 2024 16:16
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@fabriceleal
fabriceleal / gist:8286782
Created January 6, 2014 18:04
Apache as proxy
# From:
# http://stackoverflow.com/questions/17475587/setup-mod-proxy-on-apache-http-server
# http://www.forums.serverwatch.com/showthread.php?16887-mod_proxy-problem
# http://serverfault.com/questions/242650/setting-up-a-basic-mod-proxy-virtual-host
# http://stackoverflow.com/questions/14775248/apache-http-proxy-based-on-hostname
# http://stackoverflow.com/questions/1997001/setting-up-a-basic-web-proxy-in-apache
# http://ubuntuforums.org/showthread.php?t=983222
#
# put on httpdvhosts.conf
@SPY
SPY / andb_eq_orb.v
Last active January 1, 2016 22:38
(** **** Exercise: 2 stars (andb_eq_orb) *)
(** Prove the following theorem. (You may want to first prove a
subsidiary lemma or two.) *)
Lemma orb_always_true :
forall b,
orb true b = true.
Proof. reflexivity. Qed.
Lemma andb_always_false :
@fabriceleal
fabriceleal / gist:7803969
Last active February 22, 2024 09:21
Decent enough macro for exporting csvs from Excel.
' http://support.microsoft.com/kb/291296/en-us
' http://superuser.com/questions/130592/how-do-you-force-excel-to-quote-all-columns-of-a-csv-file
' - change integer to long indexing
' http://stackoverflow.com/questions/2524703/save-text-file-utf-8-encoded-with-vba
' - output utf8 content
Sub QuoteCommaExport()
' Dimension all variables.
Dim DestFile As String
Dim FileNum As Integer
@fabriceleal
fabriceleal / gist:7417279
Created November 11, 2013 17:49
Search for sql inserts without explicit columns.
grep -Eir "insert +into +[a-zA-Z0-9_]+ values" *
@fabriceleal
fabriceleal / gist:6994504
Created October 15, 2013 16:34
Find big files
find . -type f -size +10000k -exec ls -lh {} \;
@fabriceleal
fabriceleal / gist:6609675
Last active December 23, 2015 08:39
Get query parameters
function getParams() {
var parameters = location.search.substring(1).split('&'); // drop initial '?' and get array of 'key=value'
var obj = {};
for(var i=0; i < parameters.length; ++i){
// 0 with the key, 1 with the value
var keyvalue = parameters[i].split('=');
// this won't work well when we try to pass jsons as parameters.
obj[ decodeURIComponent(keyvalue[0]) ] = decodeURIComponent(keyvalue[1]);