Skip to content

Instantly share code, notes, and snippets.

View joaofnds's full-sized avatar

João Fernandes joaofnds

View GitHub Profile
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 / 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"
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
@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);
@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 / 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)
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
)
@joaofnds
joaofnds / bookmark-duplicate-finder.html
Last active August 28, 2019 12:55
Small tool that helps to find out duplicates in a bookmark export file
<!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>
</head>
@joaofnds
joaofnds / helpers.js
Last active November 17, 2018 20:22
Simple js helpers (range, log, logFunc)
const fib =
n =>
n < 2
? 1
: fib(n - 1) + fib(n - 2)
const range =
(min, max) =>
Array(max - min + 1).fill().map((_, i) => i + min)
-- Drop while matches Char
dropInitialMatches :: Char -> String -> String
dropInitialMatches c xs = dropWhile (==c) xs
-- Drop preceding spaces
dropInitialSpaces :: String -> String
dropInitialSpaces xs = dropInitialMatches ' ' xs
-- Drop preceding linefeeds
dropInitialNewLines :: String -> String