This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
# references: | |
# Learning by doing: Writing your own traceroute in 8 easy steps (Ksplice Blog) | |
# https://blogs.oracle.com/ksplice/entry/learning_by_doing_writing_your | |
import sys | |
import socket | |
def traceroute(dest_addr, max_hops=30, timeout=0.2): | |
proto_icmp = socket.getprotobyname('icmp') | |
proto_udp = socket.getprotobyname('udp') |
#!/usr/bin/env python | |
"""Simple server using epoll.""" | |
from __future__ import print_function | |
from contextlib import contextmanager | |
import socket | |
import select | |
class KeyifyList(object): | |
def __init__(self, inner, key): | |
self.inner = inner | |
self.key = key | |
def __len__(self): | |
return len(self.inner) | |
def __getitem__(self, k): | |
return self.key(self.inner[k]) |
#include <assert.h> | |
#include <netinet/ip.h> | |
#include <stdio.h> | |
#include <sys/socket.h> | |
#include <sys/types.h> | |
void test_setsockopt() | |
{ | |
int priority = 6; |
copy/delete word under cursor in Vim | |
yw / byw | |
Assuming that the cursor is at the first character of the word simply do this in command mode: | |
yw | |
y is for yank and w is for word. | |
Other ways of doing the same thing which are not as efficient: | |
vey | |
the v starts visual select mode. e tells vim to move to end of word. y yanks or copies the word. to delete replace y with x. |
#!/bin/bash | |
echo -n "loading ipv4 packet filter... " | |
### clear tables | |
iptables --flush | |
iptables --delete-chain | |
iptables --table mangle --flush | |
iptables --table mangle --delete-chain |
''' | |
Basic tail command implementation | |
Usage: | |
tail.py filename numlines | |
''' | |
import sys | |
import linecache |
type T struct { | |
A int | |
B string | |
} | |
t := T{23, "skidoo"} | |
s := reflect.ValueOf(&t).Elem() | |
typeOfT := s.Type() | |
for i := 0; i < s.NumField(); i++ { |
def walk(top, topdown=True, onerror=None, followlinks=False): | |
"""Directory tree generator. | |
For each directory in the directory tree rooted at top (including top | |
itself, but excluding '.' and '..'), yields a 3-tuple | |
dirpath, dirnames, filenames | |
dirpath is a string, the path to the directory. dirnames is a list of | |
the names of the subdirectories in dirpath (excluding '.' and '..'). |