Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / tracker_blocking.rb
Last active July 27, 2023 14:19
Current list of spy pixels named'n'shamed in HEY, as of April 23, 2020
module Entry::TrackerBlocking
extend ActiveSupport::Concern
included do
has_many :blocked_trackers
end
email_service_blockers = {
"ActiveCampaign" => /lt\.php(.*)?l\=open/,
"AWeber" => "openrate.aweber.com",
@alphapapa
alphapapa / magit.sh
Last active April 5, 2020 10:18
Run a standalone Magit editor!
# Please see the script's new home: https://github.com/alphapapa/magit.sh
@lilactown
lilactown / promises.re
Last active August 20, 2022 07:56
Notes on using JavaScript Promises in ReasonML/BuckleScript
/**
* Making promises
*/
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok"));
/* Simpler promise creation for static values */
Js.Promise.resolve("easy");
Js.Promise.reject(Invalid_argument("too easy"));
@Drup
Drup / sat_micro.ml
Last active June 15, 2020 17:17
SAT-MICRO, a Sat solver in 60 lines of code
(* Code extracted from:
SAT-MICRO: petit mais costaud !
by Sylvain Conchon, Johannes Kanig, Stéphane Lescuyer
*)
module type VARIABLES = sig
type t
val compare : t -> t -> int
end

Recovering deleted files in Ubuntu with ext4 filesystem

Recently, I deleted some files by mistake in a Ubuntu machine with an ext4 fs. These notes document the steps I took to get them back.

Important

  • this procedure assumes that the partition that contained the deleted files is different from the root partition, as that was the scenario with which I had to deal (deleted files were in my home dir). The procedure needs that the partition that contained the files is unmounted, so if the deleted files were in the root partition, the process would be a bit different (e.g. storing the fs journal in a USB stick, using a live CD/USB to boot and issue the commands, etc.)
  • if something is not clear, you need more information, etc. check the sources below

With that out the way, let's begin.

#require "lambda-term";;
let prompt = LTerm_text.(eval [B_fg (LTerm_style.green); S "# "]);;
UTop.prompt := fst (React.S.create prompt);;
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//
@takscape
takscape / gist:df9925d0f18b2942feb2
Created September 13, 2014 02:52
Parsing with Sedlex and BatParserCo
#!/usr/bin/env ocamlscript
Ocaml.ocamlflags := ["-g"; "-thread"];
Ocaml.use_camlp4 := false;
Ocaml.packs := ["batteries"; "sedlex"]
--
open Batteries
(* Sedlex lexer definitions *)
type token =
| Number of int
@sakalajuraj
sakalajuraj / squid.conf
Last active August 1, 2020 00:48
Logstash filter for squid log
# Content of the file /etc/logstash/conf.d/squid.conf
# Squid logs MAC address of the source host
# Logs are sending by syslog-ng raw without standard log headers
input {
tcp {
host => "xxx.xxx.xxx.xxx"
port => xxxx
type => SQUID
tags => [SQUID]
@NicolasT
NicolasT / nel.ml
Last active May 28, 2019 18:48
Playing with OCaml GADTs
type z
type 'a s
(* Sadly enough, without kind restrictions, this still allows nonsense types like *)
type nonsense = int s
(* GHC 7.6 supports this (lifting types to kinds & kind constraints) ;-) *)
type (_, _) llist =
| Nil : (z, 'a) llist
| Cons : ('a * ('l, 'a) llist) -> ('l s, 'a) llist