Skip to content

Instantly share code, notes, and snippets.

Avatar

Santiago Saavedra ssaavedra

View GitHub Profile
@ssaavedra
ssaavedra / operator.hs
Created Nov 7, 2016
Haskell and higher-order polymorphism. Intuitionstic logic and type theory.
View operator.hs
{-# LANGUAGE RankNTypes #-}
module Operator
where
(***) f g (x1, x2) = (f x1, g x2)
f :: [a] -> [a]
f = snd . splitAt 1
type GType a = ([a], [a])
@ssaavedra
ssaavedra / roswell.spec
Last active Sep 8, 2016
roswell specfile
View roswell.spec
Name: roswell
Version: 0.0.6.65
Summary: A lisp installer and launcher for major environments that just work
Release: 1%{?dist}
License: MIT
URL: https://github.com/roswell/roswell/
Source0: https://github.com/roswell/roswell/archive/v%{version}.tar.gz
Group: Development/Tools
BuildRequires: libcurl-devel
@ssaavedra
ssaavedra / 5_cpu_percent
Created Sep 5, 2016
Get the CPU usage as a percentage. Great for use inside byobu/tmux, but can be used standalone.
View 5_cpu_percent
#!/bin/bash
#
# 5_cpu_percent: get the global CPU usage as a percentage
#
# Copyright (C) 2016 Santiago Saavedra
#
# Authors: Santiago Saavedra <santiagosaavedra@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
View detect-raspis.py
#!/usr/bin/env python3
# -*- coding: utf-8; -*-
# Author: Santiago Saavedra <ssaavedra@gpul.org>
# License: MIT
# Description:
# This script detects raspberries and sorts them by last-seen time.
# It also tries to inspect whether they still have their default
# password set.
# We found it specially interesting in IoT Hackathons and the like
# for participants to easily spot theirs (and actively remember
@ssaavedra
ssaavedra / 57-add-emoji-support.conf
Created Jun 19, 2016
Add Emoji to Linux Fontconfig
View 57-add-emoji-support.conf
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!--
EmojiOne Color SVGinOT Font
Author: Santiago Saavedra <ssaavedra@gpul.org>
License: CC0
Year: 2016
Install:
View minexample-correct.lisp
(defpackage :mypackage
(:use)
(:export :let))
(defpackage :mypackage.impl
(:use :cl))
(in-package :mypackage.impl)
(defmacro mypackage:let (a)
@ssaavedra
ssaavedra / tco.lisp
Created Mar 30, 2016
Improve TCO handling on Common Lisp easy cases
View tco.lisp
(defpackage :ssaavedra.tco
(:documentation
"Implements some silly optimizations for improved Tail Call
Optimization (TCO) so that when defining a function or a lambda ending
in a `case' or an `if' the enclosing frame can be removed.")
(:use :common-lisp)
(:export :tco-body :case-tco :defun-tco))
(in-package :ssaavedra.tco)
(defun tco-test ()
View .gitignore
*~
*.swp
*.fasl
*.FASL
*.lisp-temp
View run-why3.sh
#!/bin/sh
# Author: Santiago Saavedra <s.saavedra@fdi.ucm.es>
# License: MIT
#
# Usage:
# 1. Set up Vagrant and VirtualBox
# 2. Download this file:
# curl https://gist.githubusercontent.com/ssaavedra/1ffa0a6f4b51cee04703/raw/run-why3.sh > run-why3.sh
# (or)
# wget https://gist.githubusercontent.com/ssaavedra/1ffa0a6f4b51cee04703/raw/run-why3.sh
@ssaavedra
ssaavedra / org-clock-back.el
Last active Oct 1, 2018
Convert orgmode clocktable time to numbers
View org-clock-back.el
;; Receive time as a string like "9d 11:28"
;; Outputs the number of minutes in that
;; The regex works with and without days.
;; MIT License
(defun my-minutes-in-org-time (time)
(let ((re "\\(\\([0-9]+\\)d \\)?\\([0-9]+\\):\\([0-9]+\\)")
(values '(2 3 4)))
(save-match-data
(catch 'exit
(if (not (string-match re time))