Skip to content

Instantly share code, notes, and snippets.

View joaofnds's full-sized avatar

João Fernandes joaofnds

View GitHub Profile
const customers = [
{ name: 'foo', orders: 4 },
{ name: 'bar', orders: 3 },
{ name: 'baz', orders: 2 },
{ name: 'qux', orders: 1 }
]
const arrayReducer = (arr, elem) => arr.concat(elem)
const tmap =
@joaofnds
joaofnds / heroku_clear_env.rb
Last active June 16, 2019 15:12
remove all heroku env variables except for database_url. Call it with `ruby heroku_clear_env.rb my-app`
require 'json'
app = ARGV[0]
envs_to_ignore = ['DATABASE_URL']
keys =
JSON.parse(`heroku config --app #{app} --json`)
.reduce('') do |memo, (key, _value)|
if envs_to_ignore.include? key
@joaofnds
joaofnds / copy_heroku_env.rb
Last active June 16, 2019 15:11
Copies heroku env from one app to another. Call it with `ruby copy_heroku_env.rb my-app-to-copy-from my-app-to-copy-to`
require 'json'
from_app, to_app = ARGV
envs_to_ignore = ['DATABASE_URL']
config =
JSON.parse(`heroku config --app #{from_app} --json`)
.reduce('') do |memo, (key, value)|
if envs_to_ignore.include? key
@joaofnds
joaofnds / alacritty theme switcher.md
Last active November 15, 2021 17:46
Easily switch between themes on alacritty

Please note that this is just for you to experiment with themes, your alacritty config will be overwritten without the comments, so I strongly recommend you to back up your file first and apply the theme yourself once you find out the one you like.

package main
import (
"fmt"
"math"
)
func main() {
memAddress := uint(26)

Keybase proof

I hereby claim:

  • I am joaofnds on github.
  • I am joaofnds (https://keybase.io/joaofnds) on keybase.
  • I have a public key whose fingerprint is 1D72 95B2 7D3B C292 068A 6533 064E 0BAC E988 9F9C

To claim this, I am signing this object:

@joaofnds
joaofnds / lscolors.sh
Created May 6, 2019 16:55
show all terminal colors
echo -en "\n + "
for i in {0..35}; do
printf "%2b " $i
done
printf "\n\n %3b " 0
for i in {0..15}; do
echo -en "\033[48;5;${i}m \033[m "
done
@joaofnds
joaofnds / pocket-export-parser.js
Created May 5, 2019 23:18
Gets links from pocket exported HTML file, organized by tags.
const pocketData = Array.from(document.querySelectorAll('a'))
.map(a => {
return {
name: a.innerText,
link: a.getAttribute('href'),
tags: a.getAttribute('tags').split(',').filter(t => t.length != 0)
}
})
.reduce((tags, entry) => {
if (entry.tags.length == 0) {
(0..7).each do |x|
(30..37).each do |y|
(40..47).each do |z|
print "\033[#{x};#{y};#{z}m\s\\033[#{x};#{y};#{z}m\s\033[0m"
end
print "\n"
end
end
@joaofnds
joaofnds / sub_gap.json
Last active February 27, 2022 18:35
pewds vs tseries sub count. pewds channel id is 1, tseries channel id is 2
[{"id":1,"sub_count":88848815,"channel_id":1,"inserted_at":"2019-03-11 14:43:08","updated_at":"2019-03-11 14:43:08"},{"id":2,"sub_count":88847413,"channel_id":2,"inserted_at":"2019-03-11 14:43:08","updated_at":"2019-03-11 14:43:08"},{"id":3,"sub_count":88849030,"channel_id":1,"inserted_at":"2019-03-11 14:44:08","updated_at":"2019-03-11 14:44:08"},{"id":4,"sub_count":88847624,"channel_id":2,"inserted_at":"2019-03-11 14:44:09","updated_at":"2019-03-11 14:44:09"},{"id":5,"sub_count":88849229,"channel_id":1,"inserted_at":"2019-03-11 14:45:09","updated_at":"2019-03-11 14:45:09"},{"id":6,"sub_count":88847827,"channel_id":2,"inserted_at":"2019-03-11 14:45:10","updated_at":"2019-03-11 14:45:10"},{"id":7,"sub_count":88849401,"channel_id":1,"inserted_at":"2019-03-11 14:46:11","updated_at":"2019-03-11 14:46:11"},{"id":8,"sub_count":88848099,"channel_id":2,"inserted_at":"2019-03-11 14:46:13","updated_at":"2019-03-11 14:46:13"},{"id":9,"sub_count":88849632,"channel_id":1,"inserted_at":"2019-03-11 14:47:13","updated_at":"2