Skip to content

Instantly share code, notes, and snippets.

@deadghost
deadghost / flac_to_ogg
Created March 29, 2023 09:02
Converts flac files in dir to opus audio
#!/bin/bash
for filename in ./*.flac; do
ffmpeg -i "$filename" -vn -c:a libopus -b:a 128k -vbr on -compression_level 10 -frame_duration 60 -application audio "${filename%.*}.ogg";
done
@deadghost
deadghost / flac_to_mp3
Created March 29, 2023 07:59
Converts all .flac in current directory to .mp3
#!/bin/bash
for filename in ./*.flac; do
ffmpeg -i "$filename" -codec:a libmp3lame -q:a 0 -b:a 320k -compression_level 9 -id3v2_version 3 -write_id3v1 1 "${filename%.*}.mp3";
done
{:state-code :CA
:primary-type :closed-primary
:state-name "California"
:primary-registration-deadline "Mon, Feb 17"
:primary-date "Tue, March 3"
:primary-comment "Californians must register as democrat or undeclared to vote
for Yang!"}
@deadghost
deadghost / counter.cljs
Created July 30, 2017 01:33
reagent re-render counter example
(defonce app-state (reagent/atom {:foo 0 :bar 0}))
(defn show-count [r]
[:div "Count is" (str @r)])
(defn counted [ratom]
(let [render-count (reagent/atom 0)]
(fn [ratom]
(let [{:keys [foo bar]} @ratom]
(swap! render-count inc)
(defvar current-date-time-format "%a %b %d %H:%M:%S %Z %Y"
"Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")
(defvar current-time-format "%a %H:%M:%S"
"Format of date to insert with `insert-current-time' func.
Note the weekly scope of the command's precision.")
(defun insert-current-date-time ()
"insert the current date and time into current buffer.
(global-company-mode)
(define-key company-active-map [tab] 'company-select-next)
(define-key company-active-map (kbd "<backtab>") 'company-select-previous)
@deadghost
deadghost / if-macro.clj
Created November 29, 2016 08:04
Lisp macro example - writing if in terms of cond
(defmacro if-macro [pred truth-body false-body]
(cond
pred truth-body
:else false-body))
(defn if-fn [pred truth-body false-body]
(cond
pred truth-body
:else false-body))
@deadghost
deadghost / magic.clj
Last active November 10, 2016 15:21
Library that I wish existed for clojure HTML templating
;; Library that I wish existed for HTML templating
(def base-html
[:html
[:head]
[:body
[:div {:id "id-name"}]]])
(def index-page
"Wishful Thinking."
(add-hook 'evil-mode-hook
(lambda ()
(local-set-key (kbd "M-j") 'evil-next-line)
(local-set-key (kbd "M-k") 'evil-previous-line)))
@deadghost
deadghost / gist:dcf51ddcc7e4b0bfd09e
Last active August 29, 2015 14:13
Set up emacs for common lisp
Install SBCL. In ubuntu this would be $ sudo apt-get install sbcl
Install emacs. In ubuntu this would be $ sudo apt-get install emacs
Put the following as your ~/.emacs file:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Dependencies ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'cl) ; Enable Common Lisp functions(Does not actually use CL)
(defalias 'get-alist 'assoc-default) ; get-alist is gone