Skip to content

Instantly share code, notes, and snippets.

@thomasdarimont
thomasdarimont / app.py
Last active January 8, 2024 03:21
Example for a simple Python flask webapp that uses Authlib to act as an OpenID Connect client for Keycloak
import json
import os
import certifi
import requests
from authlib.oauth2.rfc6749 import OAuth2Token
from flask import Flask, url_for, session
from flask import render_template, redirect
from authlib.integrations.flask_client import OAuth, token_update
@jclosure
jclosure / sample.org.gpg
Created October 21, 2020 17:49
Org-file header to be automatically encrypted/decrypted
HeadlineTime
Total time0:00
@hjertnes
hjertnes / doom.txt
Created April 6, 2018 08:28
Doom Emacs Cheatsheet
SPC
SPC: find file
, switch buffer
. browse files
: MX
; EX
< switch buffer
` eval
u universal arg
x pop up scratch
@pmarreck
pmarreck / migrations_in_console_cheatsheet.exs
Created September 25, 2017 16:47
How to run Ecto migrations in Elixir/Phoenix from an `iex -S mix` or production console
# How to run Ecto migrations from IEx console... Examples
# preliminaries assumed in the following code, change to fit your environment:
alias YourAppName.Repo
your_app_name_as_atom = :mpnetwork
downto_version = 20170724182558
# Down:
Ecto.Migrator.run(Repo, "priv/repo/migrations/", :down, [to: downto_version])
from abc import abstractmethod
from itertools import chain, imap
from typing import Any, Iterable
from typing import Callable, Generic, List
from typing import TypeVar
A = TypeVar('A')
B = TypeVar('B')
C = TypeVar('C')
@ulve
ulve / remoteobserver.sh
Created February 2, 2016 20:19
Connect to remote phoenix node with observer
# On the phoenix node
# if production mode
MIX_ENV=prod PORT=4001 elixir --name phoenix@127.0.0.1 --cookie 123 --erl "-kernel inet_dist_listen_min 9001 inet_dist_listen_m 9001" -pa _build/prod/consolidated -S mix phoenix.server
# if debug mode
elixir --name phoenix@127.0.0.1 --cookie 123 --erl "-kernel inet_dist_listen_min 9001 inet_dist_listen_m 9001" -S mix phoenix.server
# On the observing node
# Terminal 1, start SSH tunnel
ssh -N -L 9001:localhost:9001 -L 4369:localhost:4369 pi@192.168.1.31
@EdwardBetts
EdwardBetts / pprint_color.py
Last active March 19, 2024 18:17
Python pprint with color syntax highlighting for the console
from pprint import pformat
from typing import Any
from pygments import highlight
from pygments.formatters import Terminal256Formatter
from pygments.lexers import PythonLexer
def pprint_color(obj: Any) -> None:
"""Pretty-print in color."""
@vsouza
vsouza / .bashrc
Last active April 9, 2024 05:27
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
(defn force-login [app]
(fn [req]
(println "force-login: ****** " req "******")
(if (or (= "/login" (:uri req)) (:user (:session req)))
(app req)
(resp/redirect "/login"))))
@subfuzion
subfuzion / global-gitignore.md
Last active April 21, 2024 10:06
Global gitignore

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file:

  • Create a file called .gitignore in your home directory and add any filepath patterns you want to ignore.
  • Tell git where your global gitignore file is.

Note: The specific name and path you choose aren't important as long as you configure git to find it, as shown below. You could substitute .config/git/ignore for .gitignore in your home directory, if you prefer.