Skip to content

Instantly share code, notes, and snippets.

View frankitox's full-sized avatar

Franco Biasin frankitox

  • Rosario, Argentina
  • 15:43 (UTC -03:00)
View GitHub Profile
@frankitox
frankitox / xmonad.hs
Last active November 8, 2023 15:36
For anyone looking to map the workspaces 1-9 to use shortcuts in a grid (1, 2, 3 | q, w, e | a, s, d)
import XMonad (def, modMask, mod4Mask, xK_q, xK_w, xK_e, xK_a, xK_s, xK_d, borderWidth, layoutHook)
import XMonad.Main (xmonad)
import XMonad.Layout.Grid
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Util.PureX (defile, greedyView)
-- https://hoogle.haskell.org/
winKey = mod4Mask
@frankitox
frankitox / shell-exit-on-error.clj
Created January 11, 2021 01:27
Monad-like helpers to run spire's shell commands emulating `-e` (exit on error)
(require '[spire.module.shell :refer [shell]])
;; >>= :: m a -> (a -> m b) -> m b
(defn >>= [{:keys [result out-lines] :as prev} f]
(if (= result :ok)
(f out-lines)
prev))
;; return :: a -> m a
(defn return [cmd]
@frankitox
frankitox / with-file.clj
Created January 9, 2021 00:33
Helper to clean generated files
(require '[clojure.java.io :as io])
(defmacro with-file
"bindings => [name init ...]
Evaluates body in a try expression with names bound to the values
of the inits, and a finally clause that calls (io/delete-file name) on each
name in reverse order."
[bindings & body]
(#'clojure.core/assert-args
(vector? bindings) "a vector for its binding"
(defn all-settled [promises]
(js/Promise.
(fn [resFn _]
(let [state (atom {:resolutions (vec (repeat (count promises) nil))
:counter 0})
process (fn [idx type]
(fn [val]
(swap! state
(fn [{:keys [resolutions counter]}]
{:resolutions (assoc resolutions idx
(defn get-file-splits
[size-in-bytes mb-per-split]
(let [num-parts (Math/ceil (/ size-in-bytes mb-per-split))]
(map
(fn [part-num]
{::part-number (inc part-num)
::start-pos (if (zero? part-num)
0
(inc (* part-num mb-per-split)))
::max-bytes-to-transfer mb-per-split})
(defn get-file-splits
[size-in-bytes mb-per-split]
(let [num-parts (Math/ceil (/ size-in-bytes mb-per-split))]
(map
(fn [part-num]
{::part-number (inc part-num)
::start-pos (if (zero? part-num)
0
(inc (* part-num mb-per-split)))
::max-bytes-to-transfer mb-per-split})
Order
Fetching
fetched -> List
fetching-error -> List
List
resend-confirmation -> ResendingConfirmation
download -> Downloading
refund -> ConfirmRefund
ResendingConfirmation
resend-confirmation -> ResendConfirmationSuccess
FTPs
Fetching
fetch-success -> List
fetch-failure -> List
# Only state where main layout controls are enabled
List
new-ftp -> Creating FTP
delete-ftp -> Sure delete FTP
test-ftp -> Sure test FTP
Creating FTP
@frankitox
frankitox / tag-buckets.clj
Last active December 12, 2019 19:20
Tag all your S3 buckets without loosing previous tags
#!/usr/bin/env bb
;; Run it using [babashka](https://github.com/borkdude/babashka)
;; > bb -f tag-buckets.clj
;; Related info: https://stackoverflow.com/questions/52645443/how-to-add-tags-to-an-s3-bucket-without-deleting-the-existing-tags-using-boto3
(defn parse [str]
(json/parse-string str true))
(defn print [data]
@frankitox
frankitox / c.vim
Last active June 19, 2019 01:05
cVim config
set noautofocus
map m* setMark
map <A-p> pinTab
map <C-h> previousTab
map <C-l> nextTab
map <C-j> scrollFullPageDown
map <C-k> scrollFullPageUp
map $ lastTab
" Open new tab with current URL
map T :tabnew @%<CR>