Skip to content

Instantly share code, notes, and snippets.

View igorjs's full-sized avatar
🦝
Building Raccoon Lang

igor.js igorjs

🦝
Building Raccoon Lang
View GitHub Profile
@igorjs
igorjs / git-branch-protection.md
Created October 28, 2022 06:26 — forked from edudobay/git-branch-protection.md
Command-line script for protecting/unprotecting branches in a GitHub repository

(To be improved)

Requirements

  • httpie (which provides the http command) — pip install httpie

Setup

  • Save the git-branch-protection.sh as git-branch-protection somewhere in your path (something like ~/bin or ~/.local/bin if you already use it)
  • Generate a GitHub token and save it as ~/.config/github_token.
@igorjs
igorjs / ci-yarn-install.md
Created October 24, 2022 13:45 — forked from belgattitude/ci-yarn-install.md
Composite github action to improve CI time with yarn 3+ / node-modules linker.

Not using yarn ? see the corresponding pnpm action gist

Why

While @setup/node has a built-in cache parameter for popular package managers, it discards the cache on every lock file update. This composite action allows to run install with (almost always) warm cache. Depending on repo usage, that might reduces the monthly ci-time and decrease the carbon emissions. See also actions/setup-node#325.

Bench

Based on the nextjs-monorepo-example. A cold cache install on the ci is more than 2 minutes. With warmed cache: 1 minute. Crafted from benchmarks results in https://gist.github.com/belgattitude/0ecd26155b47e7be1be6163ecfbb0f0b. Depending on repo (renovatebot...), the slight complexity increase in ci setup might worth it.

@igorjs
igorjs / pipe.js
Created October 14, 2021 09:38
JS utility functions
/**
* Example:
*
* const multiply20 = (price) => price * 20;
* const divide100 = (price) => price / 100;
* const normalizePrice = (price) => price.toFixed(2);
* const addPrefix = (price) => '$' + String(price);
*
* const getDiscount = pipe(multiply20, divide100, normalizePrice, addPrefix);
*
/**
* DISCLAIMER:
* This Utility is in a Work in Progress state.
* The ideia is to encrypt the sensitive data in the Frontend to prevent XSS data stealing.
*
* @author Igor Santos <[email protected]>
*
* @see https://www.npmjs.com/package/crypto-js
*/
import CryptoJS from 'crypto-js';
const fs = require('fs');
const path = require('path');
let getContent = (path) => {
const data = fs.readFileSync(path, 'utf8');
return JSON.parse(data);
}
let safeResolve = (base, target) => {
const targetPath = '.' + path.posix.normalize('/' + target);
image: dnxsolutions/musketeers:1.1.1-ecr
services:
- docker:18.03.1-ce-dind # needs to match gitlab runner version
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
AWS_DEFAULT_REGION: ap-southeast-2
AWS_HOSTED_ZONE: dev.cloud.example.com.au
@igorjs
igorjs / btc-e.js
Created January 10, 2021 08:26 — forked from carlos8f/btc-e.js
btc-e trading api
/**
* BTC-e JavaScript Trading API
* https://btc-e.com/api/documentation
*
* Author: jsCoin
* BTC : 151vumzopVBZMV9CtswFiumQBbEHcULPnG
* LTC : Laoq3qsLvQFCnnbfcFGpQyjy5kcK58bpen
*
* Dependencies:
* jQuery - http://jquery.com/
@igorjs
igorjs / Satoshi_Nakamoto.asc
Created January 10, 2021 08:10 — forked from carlos8f/Satoshi_Nakamoto.asc
Satoshi Nakamoto's PGP key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.7 (MingW32)
mQGiBEkJ+qcRBADKDTcZlYDRtP1Q7/ShuzBJzUh9hoVVowogf2W07U6G9BqKW24r
piOxYmErjMFfvNtozNk+33cd/sq3gi05O1IMmZzg2rbF4ne5t3iplXnNuzNh+j+6
VxxA16GPhBRprvnng8r9GYALLUpo9Xk17KE429YYKFgVvtTPtEGUlpO1EwCg7FmW
dBbRp4mn5GfxQNT1hzp9WgkD/3pZ0cB5m4enzfylOHXmRfJKBMF02ZDnsY1GqeHv
/LjkhCusTp2qz4thLycYOFKGmAddpVnMsE/TYZLgpsxjrJsrEPNSdoXk3IgEStow
mXjTfr9xNOrB20Qk0ZOO1mipOWMgse4PmIu02X24OapWtyhdHsX3oBLcwDdke8aE
gAh8A/sHlK7fL1Bi8rFzx6hb+2yIlD/fazMBVZUe0r2uo7ldqEz5+GeEiBFignd5
@igorjs
igorjs / simple-promise-retry.js
Created January 8, 2021 05:28 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);