Skip to content

Instantly share code, notes, and snippets.

@gerardolima
gerardolima / github_bitbucket_multiple_ssh_keys.md
Created March 12, 2024 14:49 — forked from yinzara/github_bitbucket_multiple_ssh_keys.md
Managing SSH keys and repo cloning using multiple accounts on GitHub and BitBucket

Why Multiple SSH keys?

There are numerous reasons you may need to use multiple SSH keys for accessing GitHub and BitBucket

You may use the same computer for work and personal development and need to separate your work.

When acting as a consultant, it is common to have multiple GitHub and/or BitBucket accounts depending on which client you may be working for.

You may have different projects you're working on where you would like to segregate your access.

@gerardolima
gerardolima / github_bitbucket_multiple_ssh_keys.md
Created March 12, 2024 14:49 — forked from yinzara/github_bitbucket_multiple_ssh_keys.md
Managing SSH keys and repo cloning using multiple accounts on GitHub and BitBucket

Why Multiple SSH keys?

There are numerous reasons you may need to use multiple SSH keys for accessing GitHub and BitBucket

You may use the same computer for work and personal development and need to separate your work.

When acting as a consultant, it is common to have multiple GitHub and/or BitBucket accounts depending on which client you may be working for.

You may have different projects you're working on where you would like to segregate your access.

@gerardolima
gerardolima / main.go
Created September 19, 2021 15:41
The Computer Language Benchmarks Game - GO - binary-tree
// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// Go implementation of binary-trees, based on the reference implementation
// gcc #3, on Go #8 (which is based on Rust #4) as the following links, below:
// - https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/binarytrees-gcc-3.html
// - https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/binarytrees-go-8.html
// - https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/binarytrees-rust-4.html
//
// Comments aim to be analogous as those in the reference implementation and are
@gerardolima
gerardolima / ping-url.sh
Created August 25, 2021 10:29
Repeatedly calls URL and waits WAIT seconds
#! /bin/bash
URL=$1
WAIT=${2:-60}
if [[ $URL != http* ]] ;
then
echo 'Repeatedly calls URL and waits WAIT seconds (default = 60)'
echo 'usage example:'
echo '$ ./ping-url.sh https://google.com 2'
@gerardolima
gerardolima / many-promises-with-max-concurrent-limit.js.js
Created May 13, 2021 15:08
This Gist demonstrates how to keep control a maximum of concurrent promises using standard NodeJs Promises.
const CONCURRENT_LIMIT = 3
const workUnits = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
/** Returns a Promise that resolves after `milliseconds` */
const sleep = (milliseconds = 1) => new Promise((resolve) => setTimeout(resolve, milliseconds))
/** Placeholder for any business-related async function */
const worker = async (id) => {
console.log(`working on ${id}`)
@gerardolima
gerardolima / package.md
Created December 14, 2020 10:43
npm scripts for TDD

The following npm scripts lint:tdd and test:tdd run the tests and lint for files that are new of differ from their correspondent on the branch develop. These rely on the git utility and uses command line tools usually found on *UX systems.

{
  "scripts": {
    "lint:tdd": "NODE_PATH=./src nodemon --exec 'git diff develop --diff-filter=d --name-only | grep \"ts$\" | tr \"\\n\" \" \" | xargs eslint --ext .ts --fix'",
    "test:tdd": "NODE_PATH=./src nodemon --exec 'git diff develop --diff-filter=d --name-only | grep \"ts$\" | tr \"\\n\" \" \" | xargs lab --sourcemaps'",
 },

Keybase proof

I hereby claim:

  • I am gerardolima on github.
  • I am gbln (https://keybase.io/gbln) on keybase.
  • I have a public key ASDLFavVVAWxyCElI5i_NHOcOqFTPS2ZG-EF-j86adARIwo

To claim this, I am signing this object:

@gerardolima
gerardolima / f_weekdiff.sql
Last active October 8, 2019 09:18
Difference between 2 dates, in week boundaries, for MySql
delimiter //
CREATE FUNCTION f_weekdiff(expr1 DATETIME, expr2 DATETIME)
RETURNS INTEGER
COMMENT 'Returns the number of week boundaries between expr1 and expr2. Example: f_weekdiff(\'2019-10-07\', \'2019-09-30\'); == 1'
DETERMINISTIC
LANGUAGE SQL
BEGIN
SET expr1 = ADDDATE(expr1, -1 * WEEKDAY(expr1)); -- "moves" expr1 to the beggining of its week
SET expr2 = ADDDATE(expr2, -1 * WEEKDAY(expr2)); -- "moves" expr2 to the beggining of its week
@gerardolima
gerardolima / docker-mysql.md
Created July 17, 2019 14:02 — forked from s1moe2/docker-mysql.md
Local Docker MySQL (5.7) server setup

Local Docker MySQL server setup

  • Pull latest MySQL docker image

docker pull mysql:5.7

  • Create a directory to mount volumes and persist container data

mkdir $HOME/docker/volumes/mysql5.7

  • Start the thing

docker run --rm --name mysql5.7-docker -e MYSQL_ROOT_PASSWORD=mypassword -d -p 127.0.0.1:3306:3306 -v $HOME/docker/volumes/mysql5.7:/var/lib/mysql mysql:5.7

#!/bin/bash
set $GIT_USER_NAME = "yout-user-name-here"
set $GIT_USER_EMAIL = "your-email-here"
# minimal
# -------
sudo apt-get install neovim curl
# vscode - https://code.visualstudio.com/docs/setup/linux