Skip to content

Instantly share code, notes, and snippets.


Lucas Reta lucasreta

View GitHub Profile

Client-side GraphQL


Let's first analyze how to write the queries. I experimented the graphql_ppx with a few different features (nullable and non-nullable variables, fragments, convert response into record automatically). The type safety is very neat, both the input variables and the response have specific types (no Js.Json.t!), and the queries/mutations are validated against the schema! This makes it really easy to write queries, although I worry about integrating new versions of the schema since the repos are separated (we should probably re-fetch the schema as part of the CI).

As for the drawbacks, there are not many:

  • The ppx really messes up my language server sometimes.
  • I haven't tried a lot but I couldn't find easily a way to use refmt to format the queries.
  • I couldn't find anything about custom directives, the lack of which would prevents us from using some features from the GraphQL clients (for example, managing local state using Apollo's @client directive).
  • I haven't
View vanilla-spa-styles.css
* {
font-family: sans-serif;
body {
background-color: #eee;
header, main {
background-color: #fff;
border: 1px solid #ababab;
box-shadow: 1px 1px 0 rgba(0,0,0,.2);
View vanilla-spa-script.js
const useHash = true;
const apiUrl = '';
const routes = ['section-1', 'section-2'];
const content_box = document.getElementById("content_box");
function get(page) {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
data = JSON.parse(xhr.responseText);
View vanilla-spa-index.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Welcome | App Manual</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
lucasreta /
Created Dec 29, 2020 — forked from ygotthilf/
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out
cat jwtRS256.key
lucasreta /
Last active Dec 4, 2020
embeddable version of for medium article
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
weekday=`date +"%w"`
today=`date +%Y-%m-%d`
lucasreta / cligol.c
Created Dec 3, 2020
reduced version of cligol's main.c file for medium article
View cligol.c
#include "headers/config.h"
#include "headers/custom_string.h"
void compute (int neighbors[BOARD_HEIGHT][BOARD_WIDTH], int board[BOARD_HEIGHT][BOARD_WIDTH]);
void randomize (int board[BOARD_HEIGHT][BOARD_WIDTH]);
void clear () { printf ("\033[H\033[J"); }
void show (int board[BOARD_HEIGHT][BOARD_WIDTH]);

Small gist for a Stack Overflow question about simple PHP login flow.

  • Download all files into a directory
  • Create a database named logintest
  • Create a table as the one described in users.sql
  • Replace login credentials in mysqli() for your own (both in signup.php and login.php)
  • Start a local server in the directory where the files exist: php -S
  • Go to http://localhost:8888/signup.php and create a user
  • Go to http://localhost:8888/login.php and log in with email and password of created user
lucasreta /
Created Oct 16, 2020

Small gist to try and help answer a question in Stack Overflow.

Download the contents of the gist into a folder, open the terminal and navigate to said folder. Once inside the directory, run:

npx serve

This should start a local server in which the small Hello World application can be viewed.

lucasreta / index.html
Created Sep 22, 2020
working with Chart.JS
View index.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link href="" rel="stylesheet" />
<link href="" rel="stylesheet" />
<link href="" rel="stylesheet" type="text/css">
<title>Portfolio Review Overview</title>