Skip to content

Instantly share code, notes, and snippets.

View vbuaraujo's full-sized avatar

Vítor De Araújo vbuaraujo

View GitHub Profile
(use-modules (srfi srfi-1))
(define valid-tlds '(".com" ".org" ".net")) ;; ...
(define (valid-email? email)
(any (lambda (tld) (string-suffix? tld email)) valid-tlds))
(define-syntax >>
(syntax-rules ()
[(>> val1 (fun args ...))
(fun val1 args ...)]
[(>> val1 val2 rest ...)
(>> (>> val1 val2) rest ...)]))
;; Examples.
(format #t "~s\n"
@vbuaraujo
vbuaraujo / extended-if.scm
Last active April 15, 2017 01:16
Extended 'if' syntax, allowing 'else' and 'elif' clauses
(define-module (elmord extended-if)
#:export (if*))
(define-syntax if*
(syntax-rules (else elif)
;; Subsume the standard 'if'.
[(if* condition form1) (if condition form1)]
[(if* condition form1 form2) (if condition form1 form2)]
;; If more forms present, use extra syntax.
[(if* condition forms ...)
@vbuaraujo
vbuaraujo / fixed.css
Created September 15, 2017 20:13
Fixed-font white-on-black user style
/* AGENT_SHEET */
@-moz-document url-prefix(http://), url-prefix(https://), url-prefix(file://),
url-prefix(about:sessionrestore), url-prefix(about:newtab)
{
* {
color: #C0C0C0 !important; /*white !important;*/
background: black !important;
font-family: Fixed, monospace !important;
font-size: 18px !important; /* force everything to use the same size */
/*font-size: 14px !important; force everything to use the same size */
(import (scheme base)
(scheme write))
(define *update-methods* (list '*update-methods*))
(define-record-type <method> (make-method predicate action) method?
(predicate method-predicate)
(action method-action))
(define (make-generic name)
@vbuaraujo
vbuaraujo / init-exwm.el
Last active March 3, 2018 19:02
My EXWM init file
;;;; init-exwm.el -*- lexical-binding: t; -*-
(require 'exwm)
;; (require 'exwm-config)
;; Commented out because I'm using stalonetray instead of the EXWM tray.
;; (require 'exwm-systemtray)
;; (exwm-systemtray-enable)
;; (exwm-config-default)
@vbuaraujo
vbuaraujo / emacs-notifications.py
Created October 29, 2017 20:05
Pass on desktop notifications to Emacs
#!/usr/bin/python
# Pass on desktop notifications to Emacs.
# Based on https://askubuntu.com/questions/89279/listening-to-incoming-libnotify-notifications-using-dbus/451402#451402
import glib
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from subprocess import call
# [dbus.String(u'theapp'), dbus.UInt32(0L), dbus.String(u'icon'), dbus.String(u'summary'), dbus.String(u'body'), dbus.Array([], signature=dbus.Signature('s')), dbus.Dictionary({dbus.String(u'category'): dbus.String(u'category', variant_level=1), dbus.String(u'urgency'): dbus.Byte(0, variant_level=1)}, signature=dbus.Signature('sv')), dbus.Int32(-1)]
@vbuaraujo
vbuaraujo / search.el
Created December 11, 2017 16:19
Chanege behavior od Emacs search
;;;; Search.
;; Automatically wrapping I-search.
;; https://stackoverflow.com/questions/285660/automatically-wrapping-i-search
;; TODO: Still not perfect: does not distinguish overwrapped I-search anymore.
(defadvice isearch-search (after isearch-no-fail activate)
(unless isearch-success
;; Avoid recursive loop
(ad-disable-advice 'isearch-search 'after 'isearch-no-fail)
(ad-activate 'isearch-search) ;; ad-activate to reflect the above change
@vbuaraujo
vbuaraujo / webserver.sh
Created January 5, 2018 16:55
Webserver with netcat
#!/bin/bash
main() {
if [[ $INSIDE_NETCAT ]]; then
serve_request
else
export INSIDE_NETCAT=1
while :; do
netcat -q 0 -v -l -p 9000 -c "$0"
done
(define-syntax switch
(syntax-rules (default)
[(switch expr clauses ...)
(let ([result expr])
(%handle-switch-clauses result clauses ...))]))
(define-syntax %handle-switch-clauses
(syntax-rules (default)
[(_ result) 'Nada™]
[(_ result (default forms ...)) (begin forms ...)]