Skip to content

Instantly share code, notes, and snippets.

@miguelbermudez
miguelbermudez / git-aliases-export.sh
Last active November 27, 2023 14:05
Git Aliases from oh-my-zsh git plugin
#
# Aliases
# (sorted alphabetically)
#
# GIT #
alias g 'git'
alias ga 'git add'
@miguelbermudez
miguelbermudez / README.md
Created June 14, 2023 15:14 — forked from goliatone/README.md
Postgres TRIGGER to call NOTIFY with a JSON payload

This TRIGGER function calls PosgreSQL's NOTIFY command with a JSON payload. You can listen for these calls and then send the JSON payload to a message queue (like AMQP/RabbitMQ) or trigger other actions.

Create the trigger with notify_trigger.sql.

When declaring the trigger, supply the column names you want the JSON payload to contain as arguments to the function (see create_triggers.sql)

The payload returns a JSON object:

@miguelbermudez
miguelbermudez / .gitconfig
Last active September 9, 2022 00:50
my aliases from .gitconfig
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
lgb = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
lgf = log --graph --color --pretty=format:"%C(yellow)%H%C(green)%d%C(reset)%n%x20%cd%n%x20%cn%x20(%ce)%n%x20%s%n"
lga = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
log1 = log --pretty=oneline --abbrev-commit --decorate
log = log --pretty=format:\"%C(yellow)%h%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate
ll = log --pretty=format:\"%C(yellow)%h%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate --numstat
lds = log --pretty=format:\"%C(yellow)%h\\\\ %ad%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate --date=short
tree = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset) %C(auto)%d%C(reset)%x09%$
@miguelbermudez
miguelbermudez / snippet.js
Created August 8, 2011 21:33
RGB to HSL and RGB to HSV
/**
* From: http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
@miguelbermudez
miguelbermudez / imgUrlToBase64Str.clj
Last active July 13, 2021 12:18
Image URL to Base64 String in Clojure
;; REPL ONLY
;; Require clj-http https://github.com/dakrone/clj-http/
(require '[clj-http.client :as client])
;; Import Apache Common's Base64 encoder/decoder
(import (org.apache.commons.codec.binary Base64))
(def test-file
;Image Credit Metropolitan Museum of Art
(client/get "http://images.metmuseum.org/CRDImages/ma/web-large/DP241865.jpg" {:as :byte-array}))
@miguelbermudez
miguelbermudez / deps.edn
Created July 18, 2019 06:22 — forked from jmingtan/deps.edn
Clojure CLI setup with rebel-readline and cider middleware
{:aliases
{:dev {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.2"}
org.clojure/tools.nrepl {:mvn/version "0.2.12"}
cider/cider-nrepl {:mvn/version "0.17.0-SNAPSHOT"}}
:main-opts ["-m" "repl"]}}}
@miguelbermudez
miguelbermudez / redux-ish.clj
Created December 3, 2017 01:09 — forked from nhusher/redux-ish.clj
Redux with basically no effort in clojurescript, plus core.async to handle asynchronous actions
(ns reduxish.state-tools
(:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require [cljs.core.async.impl.protocols :refer [WritePort ReadPort]]
[cljs.core.async :refer [<!]]))
(defn channel?
"A predicate that determines if the provided thing is a core.async channel"
[ch]
(and (satisfies? WritePort ch) (satisfies? ReadPort ch)))
@miguelbermudez
miguelbermudez / snippets.js
Created October 16, 2017 15:04
Devtools Snippets
# add lodash
var el = document.createElement('script');
el.src = "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js";
el.type = "text/javascript";
document.head.appendChild(el);
@miguelbermudez
miguelbermudez / 00_destructuring.md
Created August 29, 2017 02:49 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

@miguelbermudez
miguelbermudez / win10-dev.md
Created June 3, 2017 05:18 — forked from wsargent/win10-dev.md
Windows Development Environment for Scala

Windows 10 Development Environment for Scala

This is a guide for Scala and Java development on Windows, using Windows Subsystem for Linux, although a bunch of it is applicable to a VirtualBox / Vagrant / Docker subsystem environment. This is not complete, but is intended to be as step by step as possible.

Sadly, much of this pertains to Git, GPG, SSH, and Windows all not working, rather than Windows Subsystem for Linux. There is no unified command line experience for native Windows still -- instead, there's a bunch of different conflicting programs which all bring along their own environment and need to be told about each other.

Harden Windows 10

Read the entire Decent Security guide, and follow the instructions, especially: