Skip to content

Instantly share code, notes, and snippets.

View daviderestivo's full-sized avatar
🎧
Focusing

Davide Restivo daviderestivo

🎧
Focusing
View GitHub Profile
@daviderestivo
daviderestivo / _reader-macros.md
Created March 11, 2023 16:18 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@daviderestivo
daviderestivo / boost-low-pri-macOS.sh
Created September 25, 2022 10:10 — forked from mayankk2308/boost-low-pri-macOS.sh
Boost Low-Priority Tasks on macOS
# Useful for improving Time Machine backup prep. times, Mac App Store install speeds, etc.
sudo sysctl debug.lowpri_throttle_enabled=0
# To restore defaults
sudo sysctl debug.lowpri_throttle_enabled=1
@daviderestivo
daviderestivo / how-to-enable-notes-export-from-kobo.md
Created September 25, 2022 10:09 — forked from samuelsmal/how-to-enable-notes-export-from-kobo.md
how to export notes and highlights from kobo

steps

  1. connect kobo to your device
  2. open a file browser
  3. navigate to the hidden folder .kobo/Kobo
  4. open the file Kobo eReader.conf
  5. navigate to the section [FeatureSettings]
  6. add the line ExportHighlights=true and save
  7. disconnect the device
  8. now you can long press on a book and export the note file into a .txt file which will be saved alongside your books. to get it connect your ereader.
@daviderestivo
daviderestivo / deep-binding.lisp
Created January 3, 2022 21:55 — forked from nyuichi/dee-binding.lisp
deep binding vs shallow binding
;;;; **deep binding**
;;; look up
(cdr (assq 'the-symbol *the-stack*))
;;; funcall
; wind...
(loop for arg in args
@daviderestivo
daviderestivo / helm-search-doc-ag.el
Created January 23, 2021 07:41
Helm search function
(defun helm-search-doc-ag ()
"Search for a keyword in the Documents folder using ag"
(interactive)
(helm-do-ag "~/Documents"))
(global-set-key (kbd "<f5>") 'helm-search-doc-ag)
@daviderestivo
daviderestivo / magit_unpushed_recent_unfold.el
Created September 15, 2018 20:28
Expand "unpushed to upstream or recent" magit section
;; Expand "unpushed to upstream or recent" magit section
(push (cons [unpushed status] 'show) magit-section-initial-visibility-alist)
@daviderestivo
daviderestivo / elisp26-condvars.el
Last active July 14, 2018 15:07
Emacs 26 - Threads and conditional variables example
;; Unset var1
(setq var1 nil)
;; Create a mutex and an associated conditional variable
(setq mut1 (make-mutex "mut1"))
(setq cond-var1 (make-condition-variable mut1 "cond-var1"))
;; Read and set functions used by r1 and s1 threads
(defun read-global-var1 ()
(with-mutex mut1
@daviderestivo
daviderestivo / eshell-prompt.el
Last active July 21, 2019 20:38
Eshell prompt
(defun galactic-emacs-eshell-prompt ()
"Customize eshell prompt.
This function requires `all-the-icons' package to be installed
(https://github.com/domtronn/all-the-icons.el)."
(if (display-graphic-p)
(setq galactic-emacs-header-bg "#282C34")
;; The background used when Emacs runs in a terminal
(setq galactic-emacs-header-bg "black"))
;; In order to set the eshell prompt correctly we need to
@daviderestivo
daviderestivo / How_to_install_an_old_version_of_a_brew_formula.txt
Last active September 30, 2017 20:05
How to install an old version of a brew formula
```
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
git log --oneline imagemagick@6.rb
7fbfe5b80 imagemagick@6: update 6.9.9-15 bottle.
e350b9b9b imagemagick@6 6.9.9-15
1b98748c9 imagemagick@6: update 6.9.9-14 bottle.
3075a3186 imagemagick@6: update 6.9.9-14 bottle.
c52c493a1 imagemagick@6 6.9.9-14
a03627c39 imagemagick@6: update 6.9.9-12 bottle.
@daviderestivo
daviderestivo / drestivo-org-download-method.el
Created August 30, 2017 12:07
This is an helper function for org-download. It creates an \"./image\" folder within the same directory of the org file. Images are separated inside that image folder by additional folders one per org file.
(defun drestivo/org-download-method (link)
"This is an helper function for org-download.
It creates an \"./image\" folder within the same directory of the org file.
Images are separated inside that image folder by additional folders one per
org file.
More info can be found here: https://github.com/abo-abo/org-download/issues/40.
See the commit message for an example:
https://github.com/abo-abo/org-download/commit/137c3d2aa083283a3fc853f9ecbbc03039bf397b"
(let ((filename
(file-name-nondirectory