Skip to content

Instantly share code, notes, and snippets.

@thalesmg
thalesmg / haskell-records.md
Created December 7, 2017 23:36 — forked from mtesseract/haskell-records.md
Working around Haskell's namespace problem for records

The Problem

Defining records in Haskell causes accessor functions for the record's fields to be defined. There is no seperate namespace for these accessor functions.

The Goal

Be able to

  • use records in Haskell, which share field names.
  • use lenses for accessing these fields
@thalesmg
thalesmg / gist:1730c67efddf06b83fe25d3a9a85390f
Created June 1, 2018 19:43 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@thalesmg
thalesmg / 0-README.md
Created August 26, 2018 23:43 — forked from abhijeetchopra/0-README.md
Creating automatic scheduled backup copies of your Google Sheets using Google Apps Script

How to "Schedule Automatic Backups" of your Google Sheets

This tutorial demonstrates how to use Google Apps Script to:

  • Create copies of the Google Sheet in the desired destination folder automatically at set intervals.

  • Append the time stamp with each backup file's name.

  • Adjust time trigger for backing up every day/hour/minute.

@thalesmg
thalesmg / reflect.py
Created September 4, 2018 18:53 — forked from 1kastner/reflect.py
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from http.server import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@thalesmg
thalesmg / Intro.md
Created November 16, 2019 19:17 — forked from chrisdone/Intro.md
Statically checked overloaded strings

Statically checked overloaded strings

This gist demonstrates a trick I came up with which is defining IsString for Q (TExp a), where a is lift-able. This allows you to write $$("...") and have the string parsed at compile-time.

This offers a light-weight way to enforce compile-time constraints. It's basically OverloadedStrings with static checks.

This trick works already in existing (old) GHCs.

@thalesmg
thalesmg / Optics Cheatsheet.md
Created January 12, 2020 21:27 — forked from ChrisPenner/Optics Cheatsheet.md
Optics Cheatsheet
@thalesmg
thalesmg / gist:f759f79c32efeaff655582904885cb2c
Created November 2, 2020 22:22 — forked from sebfisch/gist:2235780
Laymans explanation of delimited continuations with examples of using them for exception handling and nondeterministic programming.

Delimited Continuations

Delimited continuations manipulate the control flow of programs. Similar to control structures like conditionals or loops they allow to deviate from a sequential flow of control.

We use exception handling as another example for control flow manipulation and later show how to implement it using delimited continuations. Finally, we show that nondeterminism can also be expressed using delimited continuations.

Exception Handling

@thalesmg
thalesmg / world-building-with-tom-harding.md
Created February 7, 2021 21:14 — forked from sjsyrek/world-building-with-tom-harding.md
World-Building in Haskell with Tom Harding
@thalesmg
thalesmg / shell.nix
Created July 21, 2021 20:18
elixir 1.12 e erlang 24 phoenix derivation
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
elixir_1_12 = { mkDerivation }:
mkDerivation rec {
version = "1.12.0";
sha256 = "00dc3szjn2k552jp7n1c98kjab6wac9d49v2gr43pf3yzcyv8mk1";
minimumOTPVersion = "24";