Skip to content

Instantly share code, notes, and snippets.

View tremby's full-sized avatar

Bart Nagel tremby

View GitHub Profile
@tremby
tremby / huetemp.py
Created January 27, 2018 22:21
Sync Philips Hue light temperature with redshift
#!/usr/bin/env python
from __future__ import print_function
import phue
import re
import subprocess
import sys
import logging
@tremby
tremby / closest_named_colour.py
Last active June 10, 2022 06:47 — forked from scholich/closest_named_color.py
Get the closest named color to a hex or triple RGB value from the XKCD color naming survey, see http://xkcd.com/color/rgb/.
#!/usr/bin/env python
"""Get closest named colour according to XKCD's colour naming survey
`http://xkcd.com/color/rgb/`.
rgb.txt from `http://xkcd.com/color/rgb.txt` must reside alongside this script.
Exceptions are made for true black and true white: these are omitted from the
searched colours. "black" and "white" are returned only if the queried colour is
true black or true white.
@tremby
tremby / mirrored-tile.lua
Created April 9, 2017 07:56
Awesomewm layout mirroring awful.layout.suit.tile.right
---------------------------------------------------------------------------
--- Mirrored "left" tile layout for awful
--
-- This is the same as awful's awful.layout.suit.tile.left but with the
-- secondary columns' order reversed.
--
-- With two columns, awful.layout.suit.tile.left has
--
-- +-----+-----+-----------+
-- | | | |
@tremby
tremby / webpack.config.babel.js
Created December 20, 2016 23:12
Example webpack configuration
import autoprefixer from 'autoprefixer';
import mqpacker from 'css-mqpacker';
import path from 'path';
import webpack from 'webpack';
let srcDir = path.join(__dirname, 'src');
let globalStylesDir = path.join(srcDir, 'scss');
let config = {
context: srcDir,
@tremby
tremby / Dvorak-LCD.kbd.json
Last active November 17, 2016 01:09 — forked from quince/Dvorak-option_.kbd.json
Dvorak LCD
[
{
"backcolor": "#ffffff",
"name": "Dvorak LCD",
"author": "Bart Nagel",
"background": {
"name": "Maple orange",
"style": "background-image: url('/bg/wood/maple-orange.jpg');"
},
"switchMount": "alps",
@tremby
tremby / seekable_url.py
Created September 3, 2016 07:48
Seekable or non-seekable (depending on HTTP server capabilities) file object from URL
import requests
class SeekableURL(object):
def __init__(self, url):
self._url = url
self._pointer = 0
self._filesize = None
self._is_seekable = None
self._got_stats = False
self._stream = None
@tremby
tremby / 00 command sequece
Last active April 16, 2016 20:16 — forked from myitcv/00 command sequece
Gitlab frozen mailroom diagnostics
# Step 01
# per https://gitlab.com/gitlab-org/gitlab-ce/issues/13357#note_4857268
gdb
attach <PID>
redirect_stdout
eval("puts Kernel.caller.join(\"\\n\")")
# Step 02
gdb
attach <PID>
@tremby
tremby / WrapArray.php
Last active March 9, 2016 08:43
Twig filter to make sure a variable is an array
<?php
namespace Tremby\Twig\Extension;
use Twig_Extension;
use Twig_SimpleFilter;
/**
* Filter to leave a variable alone if it's array,
* pass an empty array if the variable was missing,
* and wrap anything else in an array.
@tremby
tremby / output.txt
Last active April 24, 2018 00:25
Twig.js bug breaking case
test2layout.twig 1 [foo] [bar]
test2page.twig 1 [foo] []
test2.twig 1 [foo] [] [baz]
test2template.twig 1 [] [] [baz]
test2.twig 2 [] [] [baz]
test2template.twig 2 [] [] [baz]
test2.twig 3 [foo] [] [baz]
test2page.twig 2 [foo] []
test2layout.twig 2 [foo] [bar]
@tremby
tremby / jquery.classregex.js
Last active December 24, 2015 13:19
Jquery plugins to remove classes from elements by regex and to test if at least one element has a class by regex (same behaviour as .hasClass)
$.fn.removeClassRegex = function(regex) {
return this.removeClass(function(index, classes) {
return classes.split(/\s+/).filter(function(c) {
return regex.test(c);
}).join(' ')
});
};
$.fn.hasClassRegex = function(regex) {
var has = false;
this.each(function() {