Skip to content

Instantly share code, notes, and snippets.

@cblavier
cblavier / app.js
Created January 9, 2021 10:55
Responsive Phoenix LiveView
const Hooks = { ViewportResizeHooks}
const connectLiveSocket = () => {
const csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute('content')
const liveSocket = new LiveSocket('/my_app/live', Socket, {
params: {
_csrf_token: csrfToken,
viewport: {
width: window.innerWidth,
height: window.innerHeight
@Qqwy
Qqwy / Example.ex
Created July 11, 2020 21:51
Elixir 'safe macro override' example implementation
defmodule Example do
use OverrideExample1
use OverrideExample2
@a 1
@b 2
end
# Prints at compile-time:
#
# yaay: {:a, [line: 4], [1]}
# wooh: {:a, [line: 4, context: OverrideExample2], [1]}
#!/usr/bin/env bash
CIPHERS='ALL:eNULL'
DELAY=${2:-0.1}
SERVER=${1:?usage: $0 <host:port> [delay, default is ${DELAY}s] [ciphers, default is ${CIPHERS}]}
MAXLEN=$(openssl ciphers "$CIPHERS" | sed -e 's/:/\n/g' | awk '{ if ( length > L ) { L=length} }END{ print L}')
echo Using $(openssl version).
declare -A TLSMAP=( [tls1_1]=cipher [tls1_2]=cipher [tls1_3]=ciphersuites )
@sdondley
sdondley / tmux split-window subcommand.md
Last active May 24, 2024 01:31
Super Guide to the split-window tmux Subcommand (and Beyond)

Super Guide to the split-window tmux Subcommand (and Beyond)

Guide overview

tmux, like other great software, is deceptive. On the one hand, it's fairly easy to get set up and start using right away. On the other hand, it's difficult to take advantage of tmux's adanced power features without spending some quality alone time with the manual. But the problem with manuals is that they aren't geared toward beginners. They are geared toward helping seasoned developers and computer enthusiasts quickly obtain the

@mdonkers
mdonkers / server.py
Last active May 23, 2024 00:16
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@wilhelmy
wilhelmy / dirlist.xslt
Last active June 5, 2023 10:44
make nginx dirlistings look like lighttpd's through the magic of xslt-transforming xml dirlistings. I don't even.
<?xml version="1.0"?>
<!--
dirlist.xslt - transform nginx's into lighttpd look-alike dirlistings
I'm currently switching over completely from lighttpd to nginx. If you come
up with a prettier stylesheet or other improvements, please tell me :)
-->
<!--
Copyright (c) 2016 by Moritz Wilhelmy <mw@barfooze.de>
@gudmundur
gudmundur / Gruntfile.js
Last active December 16, 2015 20:48
Gruntfile for re-running xelatex on any .tex change.
module.exports = function(grunt) {
grunt.initConfig({
watch: {
latex: {
files: ['**/*.tex'],
tasks: ['exec:xelatex']
}
},
exec: {
@cslarsen
cslarsen / free-body.mp
Created January 7, 2012 10:40
Free body diagram with frictional forces made in MetaPost
% MetaPost free body diagram with frictional forces
%
% Placed in the public domain by the author; Christian Stigen Larsen
% 2011-10-07
%
% To render:
% $ mptopdf free-body.mp
%
beginfig(1)