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 / python-superword.el
Last active August 22, 2017 06:48
Add superword mode to python-mode
;;
;; superword-mode is a minor mode that allows emacs
;; to treat a word separated by '_' as a single one
;; This might be useful for example when moving betwwen
;; words using 'Alt + F' or 'Alt + B' in python-mode
;;
(add-hook 'python-mode-hook
'(lambda ()
;; Enable superword mode, useful for “snake_case”.
@daviderestivo
daviderestivo / helm-ag.el
Created August 22, 2017 06:18
Replace helm grep with ag (The Silver Searcher)
;; Replace the default helm grep command with ag.
;; Requires "The Silver Searcher" (ag) to be installed.
;; On macOS use: 'brew install the_silver_searcher'
(when (executable-find "ag")
;; For helm to recognize correctly the matches we need to enable
;; line numbers and columns in its output, something the
;; --vimgrep option does.
(setq helm-grep-default-command "ag --vimgrep --nogroup --nocolor -z %p %f"
helm-grep-default-recurse-command "ag --vimgrep --nogroup --nocolor -z %p %f"))
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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.