Skip to content

Instantly share code, notes, and snippets.

View FZambia's full-sized avatar

Alexander Emelin FZambia

View GitHub Profile
@FZambia
FZambia / chi.go
Created February 21, 2024 11:20 — forked from alexaandru/chi.go
Chi-like syntactic sugar layer on top of stdlib http.ServeMux
// Chi-like syntactic sugar layer on top of stdlib http.ServeMux.
package main
import (
"net/http"
"slices"
)
type (
middleware func(http.Handler) http.Handler
@FZambia
FZambia / main.go
Last active August 15, 2023 04:36
Experimenting with QUIC and WebTransport in Go, see original post: https://centrifugal.github.io/centrifugo/blog/quic_web_transport/
package main
import (
"context"
"crypto/tls"
"encoding/binary"
"errors"
"io"
"log"
"net/url"
@FZambia
FZambia / pipeline.go
Created August 21, 2015 09:34
Go Concurrency Patterns: Pipelines and cancellation - final code from blog post as gist
package main
import (
"fmt"
"sync"
)
func gen(done <-chan struct{}, nums ...int) <-chan int {
out := make(chan int)
go func() {
@FZambia
FZambia / call_subprocess.py
Last active September 27, 2022 08:16
tornado subprocess call
from __future__ import print_function
from tornado.gen import Task, Return, coroutine
import tornado.process
import subprocess
from tornado.ioloop import IOLoop
STREAM = tornado.process.Subprocess.STREAM
@FZambia
FZambia / httperf_content
Created May 17, 2013 14:41
httperf POST with form data
/path/to/location/ method=POST contents="name=TEST&password=SECRET"
@FZambia
FZambia / fieldset_form.py
Created April 16, 2013 07:12
fieldset form for django
from django import forms
from django.forms.forms import BoundField
from django.utils.datastructures import SortedDict
class BoundFieldset(object):
def __init__(self, form, name, title, fields, is_fieldset):
self.form = form
self.name = name
@FZambia
FZambia / main.go
Last active December 12, 2021 18:33
Verify armored GPG signature using Go language
package main
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"golang.org/x/crypto/openpgp/armor"
@FZambia
FZambia / hardware.go
Last active November 22, 2021 18:39
Golang lshw output parser
package main
import (
"bytes"
"encoding/json"
"os/exec"
"gopkg.in/xmlpath.v2"
)
@FZambia
FZambia / reload_urlconf.py
Last active September 26, 2021 02:20
reload django urlconf
#python manage.py runserver --noreload
from django.conf.urls import patterns, include, url
from django.conf import settings
from django.http import HttpResponse
import sys
def reload_urls(request, urlconf=None):
if urlconf is None:
urlconf = settings.ROOT_URLCONF
@FZambia
FZambia / tornado_github_auth.py
Last active April 20, 2021 07:58
tornado github oauth
# coding: utf-8
#
# Copyright (c) Alexandr Emelin. BSD license.
# All rights reserved.
#
"""
class GithubAuthHandler(BaseHandler, auth.GithubMixin):
x_site_token = 'application'