Skip to content

Instantly share code, notes, and snippets.

@apokalyptik
apokalyptik / uni.py
Last active December 25, 2015 19:49
#!/usr/bin/python
import re
import unicodedata
import codecs
import urllib2
if 2 == len( u'\U0001f4a9' ):
length_ucs2 = len
else:
@apokalyptik
apokalyptik / uni.py
Last active December 25, 2015 19:49
#!/usr/bin/python
import re
import unicodedata
lm = re.compile("^[0-9a-fA-F]")
s = u""
# http://www.unicode.org/Public/5.2.0/ucd/NamesList.txt
@apokalyptik
apokalyptik / gist:5952215
Created July 8, 2013 20:28
Super simple and informative exmple of using CGO
package main
// #include <ctype.h>
import "C"
import "log"
func main() {
for i := 32; i<126; i=i+1 {
log.Printf( "'%s' (%3d) isalpha: \t%d", string(byte(i)), i, C.isalpha(C.int(i)) )
}
@apokalyptik
apokalyptik / gist:5946350
Created July 8, 2013 05:10
Email me when it's more than 30% likely to rain soon... Pop it into cron once daily and forget. A simple and practical example of working with NOAA/weather.com DWML feeds in PHP
<?php
$email = "me@example.com";
// To find your weather feed....
// * Go here: http://forecast.weather.gov/MapClick.php?lat=37.7749295&lon=-122.41941550000001#.UdpHAj7714E
// * Search for your location (upper left side of the page as of 7/7/2013)
// * Click the orange "XML" button/link (on the right hand side, beneath the first map as of the same date)
$feed = 'http://forecast.weather.gov/MapClick.php?lat=39.01000&lon=-96.28&unit=0&lg=english&FcstType=dwml';