Skip to content

Instantly share code, notes, and snippets.

@jamesabruce
jamesabruce / detect.py
Created August 19, 2015 11:53
OpenHAB on Raspberry Pi Tutorial: Detect User Presence via Bluetooth, report to RESTful OpenHAB interface
#!/usr/bin/python
import bluetooth
import time
import requests
from requests.exceptions import ConnectionError
payload =''
while True:

Today on the Internet we were discussing some code one of us had written. He said that although his function would silently categorize the array [3, 7, 0] as having adjacent duplicate elements, that is not a bug, because no array in the program's input will contain 0. It said so right in his problem statement, which none of us had read.

I totally sympathize with this stance. It is the same thing as how when you ask something on Stack Overflow, almost no matter what it is, one of the top-voted answers will be, you shouldn't be asking that because you should be doing this other thing instead, which always turns out to be something sensible enough under ordinary circumstances, but hopelessly inappropriate for your actual situation. The main cost of asking a question therefore turns out to be convincing every stranger on the entire Internet that the question really is what you meant to ask, and that you are competent to ask it.

It reminds me of a situation at my house. I find that when I put something in

@ramsey
ramsey / freenode-channel-setup
Created September 17, 2014 19:22
Base Freenode Channel Setup
Join the channel you want to register. Make sure you're an op (either the first to join, or someone who is an op there sets you to +o).
/join #newchannel
/msg chanserv register #newchannel
/msg chanserv set #newchannel mlock +cnt-s
/msg chanserv set #newchannel guard on
/msg chanserv set #newchannel secure on
/msg chanserv set #newchannel topiclock on
/msg chanserv set #newchannel keeptopic on
/msg chanserv set #newchannel url http://example.org/

Oh no
I have gotten a bad cashew
but I can stick it out
no it is too awful
I have to spit out the whole mouthful
that was so awful
I have to write a poem about it

@bernd
bernd / collectd-redis.conf
Created April 2, 2012 08:23
collectd redis metrics in ruby
LoadPlugin exec
<Plugin exec>
Exec "nobody:nogroup" "/path/to/collectd-redis.rb" "127.0.0.1" "6379"
</Plugin>
@bldewolf
bldewolf / tracetosmoke.pl
Created June 10, 2011 19:31
traceroute output to smokeping config converter
#!/usr/bin/perl
use strict;
use warnings;
my @s;
my $hop = 0;
while(<>) {
chomp;
tmpdir=tmp
if [ -d "$tmpdir" ]; then
rm -rf $tmpdir
fi
mkdir $tmpdir
height=2592
width=10
n=0
for f in *.jpg
do