Skip to content

Instantly share code, notes, and snippets.

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

Igor J. S. igorjs

🦝
Building Raccoon Lang
View GitHub Profile
@igorjs
igorjs / change-codec.md
Created February 1, 2023 01:47 — forked from dvf/change-codec.md
Enable High Quality mode on your headphones (Updated for macOS Catalina)

If you're using a high-end bluetooth headset on your Macbook Pro it's likely your mac is using an audio codec which favors battery efficiency over high quality. This results in a drastic degradation of sound, the SBC codec is the likely culprit, read more about it here.

Find out what codec you're using

  1. Play a song on your headphones
  2. Option (⌥) click the Bluetooth button at the top of your screen Inspect the Bluetooth Coded
  3. If you're using AAC or aptX, you can stop here—those are the highest quality codecs.

Change your codec to AAC or aptX

/**
* Calculate the distance between two points on Earth using the Haversine formula
* @param Point1 { lat: number; lng: number } - The first point
* @param Point2 { lat: number; lng: number } - The second point
* @returns Distance in metres
*/
function calcDistanceInMetresBetweenTwoPoints(Point1, Point2) {
const EARTH_RADIUS_METERS = 6371000; // Earth's radius in meters
// Convert degrees to radians
@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/