Skip to content

Instantly share code, notes, and snippets.

View andresanches's full-sized avatar

Andre Sanches andresanches

  • San Francisco Bay Area
View GitHub Profile
package com.turo.security.authorization.spicedb;
import com.authzed.api.v1.Core.ObjectReference;
import com.authzed.api.v1.Core.Relationship;
import com.authzed.api.v1.Core.RelationshipUpdate;
import com.authzed.api.v1.Core.RelationshipUpdate.Operation;
import com.authzed.api.v1.Core.SubjectReference;
import com.authzed.api.v1.PermissionService.CheckPermissionRequest;
import com.authzed.api.v1.PermissionService.CheckPermissionResponse;
import com.authzed.api.v1.PermissionService.Consistency;
@andresanches
andresanches / esp8266_garage_door.ino
Last active April 4, 2021 05:10
Arduino sketch for the garage door opener
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
String wifi_ssid = "ADD WIFI SSID HERE";
String wifi_password = "ADD WIFI PASSWORD HERE";
ESP8266WebServer server(80);
// Function prototypes
void connectWifi();
@andresanches
andresanches / .vimrc
Last active February 5, 2022 20:57
Default settings for vim
set nu
set softtabstop=2
set tabstop=2
set shiftwidth=2
set expandtab
set ignorecase
set hlsearch
set showtabline=2
set smartindent
syntax on
@andresanches
andresanches / monads-explained.md
Last active November 30, 2020 00:59
Monads explained

Extracted from the highest voted answer, by JacquesB, on https://stackoverflow.com/questions/44965/what-is-a-monad

First: The term monad is a bit vacuous if you are not a mathematician. An alternative term is computation builder which is a bit more descriptive of what they are actually useful for.

They are a pattern for chaining operations. It looks a bit like method chaining in object-oriented languages, but the mechanism is slightly different.

The pattern is mostly used in functional languages (especial Haskell uses them pervasively) but can be used in any language which support higher-order functions (that is, functions which can take other functions as arguments).

Arrays in JavaScript support the pattern, so let’s use that as the first example.

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
#set-option -g prefix M-b
setw -g mode-keys vi
setw -g mouse on
set -g pane-border-status top
set-option -g history-limit 5000
bind-key -T prefix C-s setw synchronize-pane
bind t command-prompt -p "(rename-pane)" -I "#T" "select-pane -T '%%'"
set -g base-index 1
# Emulate scrolling by sending up and down keys if these commands are running in the pane
@andresanches
andresanches / update-godaddy-dns.bash
Last active February 5, 2022 22:10
update-godaddy-dns.bash
#! /usr/bin/env bash
#
# Usage: update-godaddy-dns.sh "api_key" "api_secret" "domain_domain" "domain_name" "log_file"
# Note: log_file defaults to /var/log/update-godaddy-dns.log if not provided
set -e
set -o pipefail
log_file="/var/log/update-godaddy-dns.log"