Skip to content

Instantly share code, notes, and snippets.

$ telnet twitter.com 80
Trying 128.121.146.100...
Connected to twitter.com.
Escape character is '^]'.
GET /statuses/friends.xml HTTP/1.0
Authorization: Basic REDACTED
User-Agent: Blah
# response works and is returned here
-module(my_calc).
-export([my_calc/2]).
%% My Erlang representation of:
%% http://math.andrej.com/2009/04/09/pythons-lambda-is-broken/
my_calc([], _) ->
[];
my_calc(L, N) ->
[H + N || H <- L].
def parse_date(date):
"""parse out non-standard date format used by Twitter
Usage: parse_date("Sun Jul 13 12:44:07 +0000 2008")
>>> datetime.datetime(2008, 06, 13, 12, 44, 07)
"""
date_regex = re.compile(r"""
^
(?P<day_name>[a-zA-Z]+)
\s+
<form action="" method="post">
<fieldset>
<legend>Personal details</legend>
<!-- name etc here -->
</fieldset>
<fieldset>
<legend>Date of birth</legend>
<label for="day">Day</label>
<select name="day" id="day"><!-- options here --></select>
<label for="month">Month</label>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import random
sys.path.insert( 0, os.path.join( os.path.dirname( __file__ ) ) )
from jinja2 import Template, Environment, FileSystemLoader
env = Environment( loader=FileSystemLoader( '.', encoding='utf-8' ) )
def iso8601_to_datetime(iso_date):
"""Converts an ISO-8601 date string to a Python datetime.
We ignore microseconds for the moment as datetime only takes milliseconds.
Usage: >>> iso8601_to_datetime('2009-04-24T15:48:26,000000Z')
datetime.datetime(2009, 04, 24, 15, 48, 26)
"""
rx = re.compile(r'^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}),?(.*)$')
matches = rx.match(iso_date)
if matches:
<?
session_start();
define('HPSURL',"https://psp.transactium.com/hpservices/ws/hpws.v1100.asmx");
include('utils.php');
/* AMEND FOLLOWING SECTION WITH PAYMENT DETAILS */
$hp=new CTransactiumHPP("--USERNAME--","--PASSWORD--");
$params=array(
'Amount'=>0, ///payment amount
'Curr'=>"EUR"; ///payment currency
# -*- coding: utf-8 -*-
"""
djangojinja2
~~~~~~~~~~~~
Adds support for Jinja2 to Django.
Configuration variables:
======================= =============================================
#!/bin/sh
FOO="Hello, world"
`exec erl -kernel bar "${FOO}"`
;; This gets around Emacs 23.1 for OS X clobbering the Alt key on a UK keyboard
(global-set-key (kbd "M-3") 'insert-hash)
(defun insert-hash ()
(interactive)
(insert "#"))