Skip to content

Instantly share code, notes, and snippets.

@riobard
riobard / tcpdump.txt
Last active August 12, 2022 08:19
Poem lines broadcast by my ISP-provided fiber optical modem
# My ISP-provided fiber optical modem broadcasts a line of a poem every ten seconds. Here's the tcpdump of the complete poem.
# The optical modem is made by Shanghai Nokia-Bell Co.,Ltd and its model number is G-140W-UD. It's provided by my ISP, China Unicom in Shenzhen.
$ tcpdump -i vlan10 ether proto 0x8300
15:59:00.720301 00:00:00:00:00:12 (oui Ethernet) > Broadcast, ethertype Unknown (0x8300), length 72:
0x0000: 0000 0000 e4ea 8386 d93c 5468 6520 6461 .........<The.da
0x0010: 7920 4920 6c6f 7374 206d 7920 7665 7279 y.I.lost.my.very
0x0020: 2066 6972 7374 2074 6f6f 7468 2c00 0000 .first.tooth,...
0x0030: 0000 0000 0000 0000 0000 ..........
15:59:10.740778 00:00:00:00:00:12 (oui Ethernet) > Broadcast, ethertype Unknown (0x8300), length 72:
#!/bin/bash
# Encode a WAV to a finalized podcast MP3 with metadata, in the current directory
# Requires lame
# With Homebrew on Mac OS X: brew install lame
SHOW_AUTHOR="ATP"
EPISODE_NUMBER=104
EPISODE_TITLE="Minutiæ"
[peername]
proto = nacltai
proto_publickey = REMOTE_PUBKEY
proto_privatekey = LOCAL_PRIKEY
local = tuntap
local_interface = tunnel
peer = udp
peer_remoteaddr = REMOTE_IP
peer_remoteport = 8000
peer_localaddr = 0.0.0.0
# A xterm-256color based TERMINFO that adds the escape sequences for italic.
#
# Install:
#
# tic xterm-256color-italic.terminfo
#
# Usage:
#
# export TERM=xterm-256color-italic
#
def test(state):
' test if the state is final '
return all(d == 0 or d == 2 for d in state)
def next(state, cross=2):
' generate all possible moves from the current state '
for i, d in enumerate(state):
if d == 1:
l = left(state, i, cross)
@riobard
riobard / gist:3143441
Created July 19, 2012 12:14
Test gist.io

This is a section heading

foo bar spam!

another section heading

hello world!

@riobard
riobard / hack.sh
Created April 1, 2012 17:05 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@riobard
riobard / KochGen.java
Created March 20, 2012 05:35
Koch Snowflake Generator using Stack based on Linked List
/*
* common import used for drawing.
*/
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
@riobard
riobard / ZhihuDev.py
Created September 16, 2011 04:14 — forked from tlxue/ZhihuDev.py
ZhihuDev
#!/usr/bin/env python
class ZhihuDev(Developer) :
@property
def characteristics(self):
return set(["Teamwork", "Devoted", "Creative"])
@property
def skills(self) :
@riobard
riobard / factorial.scala
Created March 21, 2010 23:50
Scala 2.8 generic Numeric type
// Generic factorial function
// require Scala 2.8
def factorial[T](n: T)(implicit m: Numeric[T]): T = {
import m._
if (n == zero) one else n * factorial(n-one)
// this is not tail-optimized
// StackOverFlow for n > 26,800 BigInt on my JVM (1.6 OS X)
}