Skip to content

Instantly share code, notes, and snippets.

View TeMPOraL's full-sized avatar

Jacek Złydach TeMPOraL

View GitHub Profile
@TeMPOraL
TeMPOraL / stumpwmrc-part.lisp
Created October 24, 2018 05:34
.stumpwmrc - modeline with Dropbox and current org clock task
(defparameter *org-clock-current-task* "[N/A]")
(defparameter *dropbox-current-status* "[Dropbox current status here]")
;;; (...)
(defun current-dropbox ()
;; TODO colors
(first-line-only (run-external-program "dropbox" '("status"))))
;;; mode line
(setf *mode-line-timeout* 1)
@TeMPOraL
TeMPOraL / emacs-directory-server.el
Last active May 29, 2018 04:01
Quickly serving files and directories via HTTP, with Emacs!
(defvar my/file-server nil "Is the file server running? Holds an instance if so.")
(defalias 'my/send-directory-list 'ws-send-directory-list)
(defun my/ws-start (handlers port &optional log-buffer &rest network-args)
"Like `ws-start', but unbroken for Emacs 25+."
(let ((server (make-instance 'ws-server :handlers handlers :port port))
(log (when log-buffer (get-buffer-create log-buffer))))
(setf (process server)
(apply
@TeMPOraL
TeMPOraL / ad-hoc-hydras.el
Created May 11, 2018 05:41
Ad-hoc hydras for easier life
(defhydra hydra-host-os (:color teal :hint nil)
"
^Shell^ ^Other^
^^^^--------------------------------------
_e_: eshell _q_: quit
_E_: eshell here
_s_: shell command
_S_: shell command on region
_a_: async shell command
@TeMPOraL
TeMPOraL / stumpwm-multi-head.lisp
Created April 11, 2018 07:13
Some utilities for easier life with multiple heads in StumpWM.
(define-key *top-map* (kbd "s-f") "fselect") ; for faster access to select frame by number
;;; This is like fnext, but restricted to current head only.
(defun focus-next-frame-on-current-head (group)
"Focus next frame, limited to current head."
(let ((current-head (group-current-head group)))
(focus-frame-after group
(remove-if-not (lambda (frame)
(eql (frame-head group frame)
current-head))
@TeMPOraL
TeMPOraL / stream-to-emacs-buffer.lisp
Created April 6, 2018 09:51
Redirect a stream to Emacs buffer.
;;; Remember to set `slime-enable-evaluate-in-emacs' to t in Emacs.
;;; Also remember that it basically allows your Lisp to execute any code in your Emacs.
(defmacro with-output-to-emacs-buffer ((stream buffer-name) &body body)
`(let ((results (with-output-to-string (,stream)
,@body)))
(swank:eval-in-emacs `(with-current-buffer (get-buffer-create ,,buffer-name)
(erase-buffer)
(insert ,results)))))
;;; Use example:
@TeMPOraL
TeMPOraL / init-web-server.el
Created April 3, 2018 21:45
Serve files over HTTP directly from Emacs.
;;;; A webserver in Emacs, because why not.
;;;; Basically a fast replacement for serve_this in Fish.
(use-package web-server
:config
(defvar my/file-server nil "Is the file server running? Holds an instance if so.")
(defun my/ws-start (handlers port &optional log-buffer &rest network-args)
@TeMPOraL
TeMPOraL / stumpwm-volume.lisp
Created March 16, 2018 10:18
StumpWM volume control for PulseAudio
;;; Volume control
(defun current-volume-settings ()
"Return current volume settings as multiple values (`MUTEDP', `VOLUME-LEFT-%', `VOLUME-RIGHT-%')."
(let* ((raw-output (run-shell-command "pactl list sinks" t))
(raw-mute (nth-value 1 (cl-ppcre:scan-to-strings "Mute: ([a-z]+)" raw-output)))
(raw-volume (nth-value 1 (cl-ppcre:scan-to-strings "Volume: .+/\\s+(\\d+).+/.+/\\s+(\\d+).+/" raw-output)))
(mutedp (string= (svref raw-mute 0) "yes"))
(vol%-l (parse-integer (svref raw-volume 0)))
(vol%-r (parse-integer (svref raw-volume 1))))
@TeMPOraL
TeMPOraL / low-level.lisp
Created November 12, 2017 15:54
cl-sdl-ttf2 hacking; I'm not going to install _yet another_ gcc instance on my Windows machine just because people _have_ to grovel stuff -.-
(in-package :sdl2-ttf)
;;This file contains function definitions that could not be correctly wrapped by cl-autowrap (mainly due to no support for pass by value as of writing 6-22-2015)
(cffi:defcstruct (sdl-color)
(r :uint8)
(g :uint8)
(b :uint8)
(a :uint8))
@TeMPOraL
TeMPOraL / config.scm
Created November 4, 2017 20:20 — forked from mbakke/config.scm
GuixSD with custom kernel
(define-module (my packages)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages linux)
#:use-module (guix build-system trivial)
#:use-module (gnu)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix packages))
(define (linux-nonfree-urls version)
@TeMPOraL
TeMPOraL / emoji.ahk
Created October 4, 2017 13:37
Emoji Picker for Windows (via AutoHotkey)
#F2::
WinGetClass, class, A
Gui, Emojiwin: New, +ToolWindow , Emoji Picker (%class%)
Gui, Font, s12, Segoe UI
Gui, Add, Text,, Pick an emoji:
Gui, Add, Button, gEFacepalm, &1. 🤦 Facepalm
Gui, Add, Button, gEPizza, &2. 🍕 Pizza
Gui, Add, Button, gEParty, &3. 🎉 Party
Gui, Show
Return