Skip to content

Instantly share code, notes, and snippets.

View joaofnds's full-sized avatar

João Fernandes joaofnds

View GitHub Profile
@joaofnds
joaofnds / mac-gems.log
Last active September 16, 2019 11:56
Gems that come pre-installed in macOS Mojave
bigdecimal (1.2.8)
CFPropertyList (2.2.8)
did_you_mean (1.0.0)
io-console (0.4.5)
json (1.8.3.1)
libxml-ruby (2.9.0)
minitest (5.8.5)
net-telnet (0.1.1)
nokogiri (1.5.6)
power_assert (0.2.6)
@joaofnds
joaofnds / show-date-in-user-locale.js
Last active November 21, 2018 21:08
A simple example of how to show dates in user locale
const SERVER_URL = "https://donamaid.herokuapp.com";
const fetchServer = async (path, opts = {}) =>
(await fetch(`${SERVER_URL}/${path}`, opts)).json();
const createServerAPI = token => ({
get: (path, opts = {}) => {
return fetchServer(path, {
method: "GET",
headers: {
@joaofnds
joaofnds / api-class.js
Last active November 21, 2018 21:11
Example of an API class that helps with server communication
const SERVER_URL = "https://donamaid.herokuapp.com";
class API {
constructor() {
this.token = null;
this.currentUser = null;
this.defaultParams = this.defaultParams.bind(this);
this.fetchJSON = this.fetchJSON.bind(this);
this.authenticate = this.authenticate.bind(this);
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
@joaofnds
joaofnds / calendar-viewer.html
Last active December 21, 2018 04:34
Simple page that displays first 10 events on a given user schedule
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<link
rel="stylesheet"
href="https://unpkg.com/fullcalendar@alpha/dist/fullcalendar.min.css"
import fetch from "node-fetch";
import cheerio from "cheerio";
const TRACKING_NUMBER = "";
(async () => {
const content = await getTrackingResponse();
const $ = cheerio.load(content, {
normalizeWhitespace: true,
decodeEntities: false
@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
(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 / 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) {
@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