Skip to content

Instantly share code, notes, and snippets.

View ties's full-sized avatar

Ties de Kock ties

  • The Netherlands
View GitHub Profile
from pynetgear import Netgear
import operator
import collections
import argparse
import os
"""
A simple plugin to have wlan stats in Munin
The plugin has sensible defaults. If you have different settings,
#
# Simple upstart script for homeassistant.
# **Make sure the OS uses upstart to run services**
# (you might need to install that separately)
#
# cat /etc/init/homeassistant.conf
start on runlevel [2345]
stop on runlevel [016]
# add your own directory here (!)
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name [host].dev;
root /Users/[docroot];
index index.html index.htm;
location / {
import sys
"""
A debug tool for use with ipython/ipdb.
With this tool you can save local variables to the interactive session
which you are working from.
Source: <unknown>
"""
from flask.views import MethodView
from flask import jsonify
class JSONMethodView(MethodView):
"""
A view that returns json objects
The view calls self.dispatch_[method] and
returns the result using jsonify
"""
/*
* This PoC script uses the [node-sensortag](https://github.com/sandeepmistry/node-sensortag)
* library
*
* Status: "it works, but drains the sensortag in a month"
*/
var MAGNETOMETER_PERIOD = 1000;
var SensorTag = require('sensortag');
@ties
ties / 00_intro.md
Last active February 29, 2016 11:10

I ran into cpython issue #24931.

The _asdict() function of my namedtuple subclasses returned empty
dictionaries. My subclass implicitly created an instance dictionary (c.f. empty __slots__). This broke the Python 3.4 version of _asdict.

When you see the source of the namedtuple that is implemented it becomes clear why this happens.

freeDimensions(data, usedKeys) {
// list[][map]
const usedKeySet = Set(usedKeys)
// Take the entries of which the key has not been seen
const unusedEntries = data.flatMap(v => v.entrySeq().filter(kv => !usedKeySet.contains(kv[0])))
// Group these entries by key, then create a set of their values
const unusedMap = unusedEntries.groupBy(kv => kv[0]).map(v => Set(v.map(kv => kv[1])))
// Return the elements with more than one entry
return unusedMap.filter(v => v.count() > 1)
}
"""
<?php
$admin_user = "pr0_adm1n";
$admin_pw = clean_hash("0e408306536730731920197920342119");
function clean_hash($hash) {
return preg_replace("/[^0-9a-f]/","",$hash);
}
"""
http://fivethirtyeight.com/features/should-you-pay-250-to-play-this-casino-game/
Suppose a casino invents a new game that you must pay $250 to play. The game
works like this:
The casino draws random numbers between 0 and 1, from a uniform distribution. It
adds them together until their sum is greater than 1, at which time it stops
drawing new numbers. You get a payout of $100 each time a new number is drawn.
"""