Skip to content

Instantly share code, notes, and snippets.

View joaofnds's full-sized avatar

João Fernandes joaofnds

View GitHub Profile
<html>
<head>
<script src="https://unpkg.com/keycloak-js@14.0.0/dist/keycloak.js"></script>
</head>
<body>
<div>
<button onclick="keycloak.login()">Login</button>
<button onclick="keycloak.login({ action: 'UPDATE_PASSWORD' })">Update Password</button>
<button onclick="keycloak.logout()">Logout</button>
@joaofnds
joaofnds / frequency_ditribution.clj
Last active March 30, 2021 11:43
babashka script to generate a frequency distribution table
(ns script
(:require [clojure.pprint :as pprint]))
(def sequence (sort (map #(Float/parseFloat %) *command-line-args*)))
(def n (count sequence))
(def k (int (Math/ceil (Math/sqrt n))))
(def es (apply min sequence))
(def ei (apply max sequence))
(def i (/ (- ei es) k))
(def classes (map #(+ es (* i %)) (range k)))

Introduction

Ruby on Rails is the framework of choice for web apps at Shopify. It is an opinionated stack for quick and easy development of apps that need standard persistence with relational databases, an HTTP server, and HTML views.

By design, Rails does not define conventions for structuring business logic and domain-specific code, leaving developers to define their own architecture and best practices for a sustainable codebase.

This file has been truncated, but you can view the full file.
1588419345.803051 server started (54961): version 3.1a, socket /private/tmp/tmux-501/test, protocol 8
1588419345.803079 on Darwin 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64; libevent 2.1.10-stable (select)
1588419345.803193 yylex_token: bind
1588419345.803206 yylex_token: -N
1588419345.803213 yylex_token: Send the prefix key
1588419345.803218 yylex_token: C-b
1588419345.803223 yylex_token: send-prefix
1588419345.803239 cmd_parse_build_commands: 0 bind
1588419345.803246 cmd_parse_build_commands: argv[0]=-N
1588419345.803251 cmd_parse_build_commands: argv[1]=Send the prefix key
@joaofnds
joaofnds / dump_request.go
Created February 2, 2020 22:36
A simple server that responds with the raw HTTP request
package main
import (
"context"
"log"
"net/http"
"net/http/httputil"
"os"
"os/signal"
"syscall"
@joaofnds
joaofnds / reduce-map-filter.js
Last active March 5, 2021 16:40
reduce, map and filter one-liners. Just because.
const reduce = reducer => memo => ([first, ...rest]) =>
first ? reduce(reducer)(reducer(first)(memo))(rest) : memo
const map = f => arr =>
reduce(mapReducer(f))([])(arr)
const filter = f => arr =>
reduce(filterReducer(f))([])(arr)
const mapReducer = f => element => memo =>
git clone https://github.com/eulerto/wal2json -b master --single-branch \
&& cd wal2json \
&& git checkout d2b7fef021c46e0d429f2c1768de361069e58696 \
&& make && make install \
&& cd .. \
&& rm -rf wal2json
@joaofnds
joaofnds / pipe.lisp
Last active October 20, 2019 14:30
Naive implementation of a "pipe" macro (does *not* support lambdas)
(defmacro -> (args &body forms)
(flet ((ensure-list (arg) (if (listp arg) arg (list arg))))
(reduce
(lambda (args f)
(ensure-list
(case (type-of f)
(function (apply f args))
(symbol (apply f args))
(cons (apply (car f) (append (cdr f) args))))))
forms
@joaofnds
joaofnds / notable-export.js
Last active September 24, 2019 03:41
Export notable files to a filetree structure using the first encountered tag
const fs = require("fs");
const path = require("path");
const { promisify } = require("util");
const matter = require("gray-matter"); // required since notable use it to encode
const glob = promisify(require("glob"));
const mkdir = promisify(fs.mkdir);
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
@joaofnds
joaofnds / mac-home.log
Created September 16, 2019 11:57
output of `ls -al` from a fresh macos install
total 24
drwxr-xr-x+ 15 joaofnds staff 480 Sep 14 23:56 .
drwxr-xr-x 5 root admin 160 Sep 14 23:52 ..
-r-------- 1 joaofnds staff 7 Sep 14 23:52 .CFUserTextEncoding
-rw-r--r--@ 1 joaofnds staff 6148 Sep 14 23:55 .DS_Store
drwx------ 2 joaofnds staff 64 Sep 14 23:55 .Trash
-rw------- 1 joaofnds staff 0 Sep 14 23:56 .bash_history
drwx------ 11 joaofnds staff 352 Sep 15 00:25 .bash_sessions
drwx------@ 8 joaofnds staff 256 Sep 15 00:25 Desktop
drwx------@ 16 joaofnds staff 512 Sep 15 00:12 Documents