Skip to content

Instantly share code, notes, and snippets.

@glowinthedark
glowinthedark / generate_directory_index_caddystyle.py
Last active February 16, 2024 21:58
Generate directory index (recurse subfolders with `-r` or `--recursive`). Use `-h` or `--help` for all options ❗️superseded by https://github.com/glowinthedark/index-html-generator
#!/usr/bin/env python3
# NOTE: this script is deprecated;
# maintained version with SVG icons: https://github.com/glowinthedark/index-html-generator/
# ---
# Copyright 2020 glowinthedark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@maestre3d
maestre3d / sse.go
Created July 25, 2020 17:15
Server Sent Events (SSE) broker written in Go
package sse
import (
"encoding/json"
"fmt"
"github.com/alexandria-oss/core"
"github.com/go-kit/kit/log"
"net/http"
"sync"
)
@mstoykov
mstoykov / aws_k6.js
Last active February 26, 2022 06:33
k6 compatible awsv4 library
/* eslint-__ENV node */
/* eslint no-use-before-define: [0, "nofunc"] */
"use strict";
// sources of inspiration:
// https://web-identity-federation-playground.s3.amazonaws.com/js/sigv4.js
// http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
var crypto = require("k6/crypto");
function createCanonicalRequest(
@luizbafilho
luizbafilho / perf_overview.md
Last active September 18, 2019 12:55
Performance overview from K6

k6 performance overview

In order to get a general idea of how k6 is performing, and to see if there are any low-hanging fruit in terms of optimizations we could do, I did a series of tests running k6 against a local server, testing different changes to the k6 code base.

Local environment

macOS High Sierra 10.13.13
MacBook Pro(Retina, 15-inch, Mid 2014)
Processor: 2,2Ghz Intel Core i7
Memory: 16GB 1600MHz DDR3
@trlkly
trlkly / grant-none-shim.js
Last active May 7, 2021 21:44
Updated Greasemonkey "@grant none" compatibility shim.
/*
Forked from https://gist.github.com/arantius/3123124
The MIT License (MIT)
Copyright (c) 2014 Anthony Lieuallen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@imiric
imiric / gpg2qr.sh
Last active April 1, 2019 19:00 — forked from joostrijneveld/gpg2qrcodes.sh
Producing printable QR codes for persistent storage of GPG private keys
#!/bin/bash
# Main credit goes to joostrijneveld on github:
# Ref: https://gist.github.com/joostrijneveld/59ab61faa21910c8434c
# adopted to "I want to have a pdf with a textual AND QR key to directly
# print it and put it in the bank safe" needs by Jan Stuehler,
# 2015-10-05.
if [ $# -lt 2 ]
then
echo "Please specify [Key ID] and an arbitrary [Name]"
@toddmotto
toddmotto / consoleLoge.js
Last active August 29, 2015 13:57
console.loge(), many log, much console
window.console.loge = function (msg) {
var gifs = ['wink','shake-space','peepers','prizza','hat','gradient','fat','rainbow','sunglasses','derp','shake'],
wow = ['', 'wow! ', 'amaze! ', 'dazzle! '],
adjs = ['so', 'such', 'many', 'much', 'very'],
randomizr = function (a) { return a[Math.floor(Math.random() * a.length)];},
message = '%c ' + randomizr(wow) + randomizr(adjs) + ' ' + typeof msg + ': ',
css = 'background: url(http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-' + randomizr(gifs) + '-212.gif) no-repeat 0 0; background-size: 80px 80px; font-family: \'Comic Sans MS\', cursive; text-shadow: 0 1px 1px rgba(0,0,0,1); font-size: 14px; padding: 25px; line-height: 70px; color: #fff; font-weight: 100;';
console.log.apply(console, typeof msg === 'object' ? [message, css, msg] : [message += msg, css]);
};
@cpatulea
cpatulea / gist:7394412
Created November 10, 2013 05:59
Find Python string literals that should probably be Unicode
#!/usr/bin/python
import ast, _ast, os
for root, dirs, files in os.walk('.'):
for name in files:
if name.endswith('.py'):
full = os.path.join(root, name)
t = ast.parse(open(full).read())
for n in ast.walk(t):
if isinstance(n, _ast.Str) and not isinstance(n.s, unicode):
@jbenet
jbenet / simple-git-branching-model.md
Last active June 17, 2024 14:53
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@tobiasmcnulty
tobiasmcnulty / generate_factories.py
Last active October 27, 2020 15:12
Django management command to generate factory-boy boilerplate factory definitions for all the models in a given app. The code is not intended to be usable right off the bat, it just provides a few sane defaults based on the structure of your models.
from django.core.management.base import BaseCommand, CommandError
from django.db.models import get_models, get_app, fields
from django.db.models.fields import related
class Command(BaseCommand):
help = """Generate factory-boy factories for the given app"""
def handle(self, *args, **options):
assert len(args) == 1, 'Must specify app name as first and only argument'