Skip to content

Instantly share code, notes, and snippets.

View vbuaraujo's full-sized avatar

Vítor De Araújo vbuaraujo

View GitHub Profile
// SmallLisp: a simple Lisp-like language shell implemented in C++.
#include <iostream>
#include <sstream>
#include <memory>
#include <map>
#include <list>
#include <cctype>
#include <exception>
#!/bin/bash
# vpnsetup.sh - Set up a L2TP VPN on Debian/Ubuntu systems.
# Written by Vítor De Araújo <https://elmord.org/>.
# Version 1.2, 2018-08-23.
# Location where the VPN control script will be installed.
VPNCTL_SCRIPT=/usr/local/bin/vpn
# Am I bash?
@vbuaraujo
vbuaraujo / unfix.user.js
Last active March 29, 2018 02:45
Yet another attempt at getting rid of "position: fixed" toolbars
// ==UserScript==
// @name Unfix all toolbars!
// @version 1
// @grant none
// ==/UserScript==
function unfix(el) {
if (["fixed", "sticky"].indexOf(window.getComputedStyle(el).position) >= 0) {
if (el.offsetWidth >= document.documentElement.clientWidth) {
console.log("Unfix element:", el);
@vbuaraujo
vbuaraujo / block-comments.el
Last active March 15, 2018 15:37 — forked from anonymous/block-comments.el
Auto-insert " * " in block comments in Emacs
(defun elmord-block-comment-auto-prefix ()
(when (eq last-command-event ?\n)
(let* ((last-comment-start
(save-excursion (search-backward "/*" nil t)))
(last-comment-end
(save-excursion (search-backward "*/" last-comment-start t))))
(when (and last-comment-start (not last-comment-end))
(insert "* ")
(indent-for-tab-command)))))
(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 ...)]
@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
@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 / 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 / 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)
(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)