Skip to content

Instantly share code, notes, and snippets.

00:00:00.000 [INFO] [sway/main.c:346] Sway version 1.5-e5913f81 (Apr 24 2021, branch 'HEAD')
00:00:00.003 [INFO] [sway/main.c:154] Linux splurge 5.11.15-300.fc34.x86_64 #1 SMP Fri Apr 16 13:41:48 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
00:00:00.003 [INFO] [sway/main.c:170] Contents of /etc/os-release:
00:00:00.003 [INFO] [sway/main.c:154] NAME=Fedora
00:00:00.003 [INFO] [sway/main.c:154] VERSION="34 (Workstation Edition)"
00:00:00.003 [INFO] [sway/main.c:154] ID=fedora
00:00:00.003 [INFO] [sway/main.c:154] VERSION_ID=34
00:00:00.003 [INFO] [sway/main.c:154] VERSION_CODENAME=""
00:00:00.003 [INFO] [sway/main.c:154] PLATFORM_ID="platform:f34"
00:00:00.003 [INFO] [sway/main.c:154] PRETTY_NAME="Fedora 34 (Workstation Edition)"
@keis
keis / coro.py
Created April 14, 2014 08:27
asyncio examples
import asyncio
@asyncio.coroutine
def waiting(r):
print("hello from waiting -", r)
yield from asyncio.sleep(2)
print("bye from waiting -", r)
return r
@keis
keis / logreport.js
Created December 4, 2013 11:47
extend mocha dot reporter with log4js capture
var log4js = require('log4js'),
Base = require('mocha/lib/reporters/base'),
Dot = require('mocha/lib/reporters/dot'),
diff = require('diff'),
ms = require('mocha/lib/ms'),
color = Base.color;
function LogReport(runner) {
var captured = [],
layout = log4js.layouts.colouredLayout;
var fs = require('fs'),
esprima = require('esprima'),
escodegen = require('escodegen'),
uglify = require('uglifyjs'),
_ = require('underscore');
function findScope(tree, key) {
var q = [],
scope,
node;
@keis
keis / loopback.js
Created October 7, 2013 12:42
loopback glue for log4js
var log4js = require('log4js'),
sentinel = {};
function loopbackAppender() {
return function (loggingEvent) {
var logger = log4js.getLogger(loggingEvent.categoryName),
isRemote = !!loggingEvent.remoteAddress,
hasLooped = loggingEvent._loopback !== sentinel;
if (hasLooped && isRemote) {
@keis
keis / yielding
Created September 18, 2013 21:31
try to figure out how often we yield for IO / other callbacks
function yielding() {
var stop = false,
stamp = (new Date()).getTime(),
count = 0,
clear;
function tick() {
if (!stop) {
count++;
clear = setImmediate(tick);
@keis
keis / bcproto
Created June 4, 2013 05:44
construct description of bitcoin block https://en.bitcoin.it/wiki/Protocol_specification
'''Description of bitcoin binary protocol fragments'''
from construct import (Construct, ConstructError, Struct, Bytes, Array,
ULInt8, ULInt16, ULInt32, ULInt64)
class VarInt(Construct):
def __init__(self, name):
Construct.__init__(self, name)
@keis
keis / screenshot.py
Created March 1, 2013 11:29
some screenshot stuff for selenium I ended up not using
'''screenshot utilities for selenium
Let's you work with screenshots of specific elements as PIL images.
>>> el = driver.find_element_by_css_selecto('#logotype')
>>> img = screenshot.element(driver, el)
>>> ref = Image.open('reference.png')
>>> screenshot.compare(ref, img)
True
'''

smoke

A concise Publish/Subscribe utility module. It supports both free-form signal names and a stricter style where signals are declared first. You can also mix them.

usage

@keis
keis / multigource
Created July 20, 2011 20:36
multi repo gource
#!/usr/bin/env bash
# Generates gource video (h.264) out of multiple repositories.
# Pass the repositories in command line arguments.
# Example:
# <this.sh> /path/to/repo1 /path/to/repo2
i=0
for repo in $*; do
# 1. Generate a Gource custom log files for each repo. This can be facilitated by the --output-custom-log FILE option of Gource as of 0.29:
logfile="$(mktemp /tmp/gource.XXXXXX)"