Skip to content

Instantly share code, notes, and snippets.

@k0d
k0d / gist:1989086
Created March 6, 2012 21:35
CherryPy Redis Test
#!/usr/bin/env python
#encoding:UTF-8
import cherrypy
import redis
class Root(object):
redis = redis.StrictRedis(host='localhost', port=6379, db=0)
def counter(self):
@k0d
k0d / gist:2038259
Created March 14, 2012 18:02
USB Lamp for Artem
import usb.core
from binascii import unhexlify as hex2lamp
def set_color(color):
print 'Attempting to set color to %s' % color
colors = dict(red='ff0000', green='00ff00', blue='0000ff')
if color not in colors:
print 'Color %s not found' % color
return False
else:
@k0d
k0d / gist:2394453
Created April 15, 2012 19:37
htpasswd check
import crypt
def check(username, password):
data = f.read().split("\n")
for line in data:
if line.startswith(username + ':'):
foundUser = line
break
user, t, salt, hashed = foundUser.split('$')
return crypt.crypt(password, '$6$%s$' % salt) == '$6$%s$%s' % (salt, hashed)
@k0d
k0d / gist:3969926
Created October 28, 2012 21:12 — forked from norrs/gist:3969331
node nodename {
class { "dns::server":
master_zones => {
'zone1' => ['192.168.0.208','192.168.0.209', '192.168.105.225', '192.168.105.201'],
'zone2' => [],
'168.192.in-addr.arpa' => [],
},
}
}
/etc/puppet/hiera.yaml
---
:backends:
- yaml
:hierarchy:
- %{clientcert}
- %{environment}
- common
:yaml:
@k0d
k0d / class_abstract_writer.php
Last active December 29, 2015 17:09
Singletons, with Dependancy Injection and unit test support!
<?php
abstract class AbstractWriter implements Writer {
protected $counter = 0;
public function write( $file, $message ) {
$fp = fopen( $file, 'a' );
fwrite( $fp, $message . "\r\n" );
@k0d
k0d / TSNet.py
Created February 16, 2016 09:03
Code to find a TellStick Net and listen for events from it.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2016 Telldus Technologies AB. All rights reserved.
import socket, re, sys
UDPSock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
UDPSock.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
UDPSock.setblocking(1)

Keybase proof

I hereby claim:

  • I am k0d on github.
  • I am markolsson (https://keybase.io/markolsson) on keybase.
  • I have a public key whose fingerprint is 3869 0E64 0034 028F A47E A8BD 1008 538F A243 4963

To claim this, I am signing this object:

@k0d
k0d / foo.dts
Created March 25, 2020 16:37
dts macros
gpioc: gpio@40020800 {
compatible = "st,stm32-gpio";
gpio-controller;
#gpio-cells = < 0x2 >;
reg = < 0x40020800 0x400 >;
clocks = < &rcc 0x0 0x4 >;
label = "GPIOC";
phandle = < 0x9 >;
};
(gdb) help all
Command class: aliases
ni -- Step one instruction
rc -- Continue program being debugged but run it in reverse
rni -- Step backward one instruction
rsi -- Step backward exactly one instruction
si -- Step one instruction exactly
stepping -- Specify single-stepping behavior at a tracepoint