Skip to content

Instantly share code, notes, and snippets.

View frankitox's full-sized avatar

Franco Biasin frankitox

  • Rosario, Argentina
View GitHub Profile
@frankitox
frankitox / addEventListener.js
Last active August 29, 2015 13:56
Cross-Browser event attach handler
// Crossbrowser event attacher.
var addEventListener = function (elem, evento, handler) {
console.assert(elem.addEventListener || elem.attachEvent, "Can't find an event handler.");
if (elem.addEventListener) {
elem.addEventListener(evento, function (e) {
if (handler.call(elem, e) === false)
e.preventDefault();
});
} else if (elem.attachEvent) {
elem.attachEvent('on' + evento, function (e) {

Static/dynamic, strong/weak typing.

You have discovered a soft spot in the terminology that amateurs use to talk about programming languages. Don't use the terms "strong" and "weak" typing, because they don't have a universally agreed on technical meaning. By contrast, static typing means that programs are checked before being executed, and a program might be rejected before it starts. Dynamic typing means that the types of values are checked during

@frankitox
frankitox / prepare-commit-msg
Last active February 19, 2020 15:11
Git hook to prepend Jira ticket code.
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD | grep -Po '[A-Z]{4}-[0-9]{4,5}')
BRANCH_NAME="${BRANCH_NAME##*/}"
@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>
@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]
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
Order
Fetching
fetched -> List
fetching-error -> List
List
resend-confirmation -> ResendingConfirmation
download -> Downloading
refund -> ConfirmRefund
ResendingConfirmation
resend-confirmation -> ResendConfirmationSuccess
(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})
(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