Skip to content

Instantly share code, notes, and snippets.

View ricardoaguiar's full-sized avatar
🎯
Focusing

ricardo ricardoaguiar

🎯
Focusing
View GitHub Profile
@ricardoaguiar
ricardoaguiar / git-branches-by-commit-date.sh
Created January 25, 2024 09:27 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@ricardoaguiar
ricardoaguiar / getLocalIP.js
Created July 26, 2023 05:58 — forked from hectorguo/getLocalIP.js
Get local IP address through Javascript
/**
* Get Local IP Address
*
* @returns Promise Object
*
* getLocalIP().then((ipAddr) => {
* console.log(ipAddr); // 192.168.0.122
* });
*/
function getLocalIP() {
@ricardoaguiar
ricardoaguiar / .zshrc
Created July 20, 2023 10:05 — forked from dwchiang/.zshrc
gcloud with zsh
# The next line updates PATH for the Google Cloud SDK.
source /Users/dwchiang/google-cloud-sdk/path.zsh.inc
# The next line enables zsh completion for gcloud.
source /Users/dwchiang/google-cloud-sdk/completion.zsh.inc
@ricardoaguiar
ricardoaguiar / levenshtein.js
Created February 8, 2023 07:21 — forked from andrei-m/levenshtein.js
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
@ricardoaguiar
ricardoaguiar / _config.scss
Created December 2, 2022 15:01 — forked from michsch/_config.scss
Font size configuration with Sass (SCSS)
/* font size & line height in px */
$font-size-body-px: 14;
$line-height-px: 21;
/* calculate font-size (in %) and line-height (in em) */
$font-size-body: pc($font-size-body-px, 16);
$line-height: em($line-height-px, $font-size-body-px);
@ricardoaguiar
ricardoaguiar / multiple-git-clone.md
Created September 24, 2022 09:49 — forked from benizar/multiple-git-clone.md
Ubuntu post-installation script for cloning multiple git repositories.

multiple-git-clone.sh

Every time I install Ubuntu on a different computer, I need to clone again the same git repositories. This is why I use this bash script.

Usage

It clones the list of repositories to a convenient working directory in the home folder. I use the /home/git folder.

Arguments are lists of git repositories. One repo per line, one file per list. See the example:

@ricardoaguiar
ricardoaguiar / update-repos.fish
Created September 24, 2022 09:46 — forked from phette23/update-repos.fish
Shell script to run `git pull` inside all subdirectories which are git repositories. I keep a number of projects in a folder & this helps me avoid manually updating each.
#!/usr/bin/env fish
# similar script in Fish
# still under construction, need to quiet `git status` more effectively
function update -d 'Update git repo'
git stash --quiet
git pull
git stash apply --quiet
end
@ricardoaguiar
ricardoaguiar / root em with pixel fallback with scss
Created September 8, 2022 19:58 — forked from pavenuto/root em with pixel fallback with scss
Note: the font-size: 62.5% thing on the html element is for switching to base 10 for the ease of calculations (default 16px * 62.5 / 100 = 10). From there, it’s easy to say 1.3rem + 13px.
.font-size($pxValue){
@remValue: (@pxValue / 10);
font-size: ~"@{pxValue}px";
font-size: ~"@{remValue}rem";
}
html { font-size: 62.5%; }
.my-element {
.font-size(13px);
@ricardoaguiar
ricardoaguiar / astro.config.mjs
Created September 8, 2022 17:10 — forked from jaames/astro.config.mjs
Injecting global SCSS variables in Astro (https://astro.build), using additionalData and a path alias
import { fileURLToPath } from 'url';
import path, { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default {
// all the usual config goes here...
@ricardoaguiar
ricardoaguiar / countries.json
Created January 25, 2022 18:13 — forked from tiagodealmeida/countries.json
List of countries with country code, name, currency code, population, capital and continent name in JSON format
{
"countries": {
"country": [
{
"countryCode": "AD",
"countryName": "Andorra",
"currencyCode": "EUR",
"population": "84000",
"capital": "Andorra la Vella",
"continentName": "Europe"