Skip to content

Instantly share code, notes, and snippets.

apokalyptik

Block or report user

Report or block apokalyptik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@apokalyptik
apokalyptik / gist:5946350
Created Jul 8, 2013
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
View gist:5946350
<?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';
@apokalyptik
apokalyptik / gist:5952215
Created Jul 8, 2013
Super simple and informative exmple of using CGO
View gist:5952215
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)) )
}
View uni.py
#!/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
View uni.py
#!/usr/bin/python
import re
import unicodedata
import codecs
import urllib2
if 2 == len( u'\U0001f4a9' ):
length_ucs2 = len
else:
View req-to-local.sh
#!/bin/bash
#
# Please note: This script is likely very brittle...
#
ORIGIN=$1
OUT_DIR=$2
if [ "$2" == "" ] || [ "$1" == "" ]; then echo "Please specify origin requirements file and output directory"; exit 4; fi
@apokalyptik
apokalyptik / test.go
Created Jun 18, 2014
Patricia VS Quicktrie
View test.go
package main
import (
"crypto/rand"
"log"
"net/http"
_ "net/http/pprof"
"github.com/apokalyptik/quicktrie"
"gopkg.in/tchap/go-patricia.v1/patricia"
@apokalyptik
apokalyptik / sockchat.go
Created Jun 18, 2014
Simple chat server in go
View sockchat.go
package main
import (
"log"
"net/http"
"code.google.com/p/go.net/websocket"
)
type register struct {
View keybase.md

Keybase proof

I hereby claim:

  • I am apokalyptik on github.
  • I am apokalyptik (https://keybase.io/apokalyptik) on keybase.
  • I have a public key whose fingerprint is 8832 E456 A26F 1E55 CBD7 32BD ED63 D6A0 9A85 639A

To claim this, I am signing this object:

View string-slice-flag.go
type Foo struct {
value []string
}
func (f *Foo) String() string {
return ""
}
func (f *Foo) Set(s string) error {
f.value = append(f.value, s)
@apokalyptik
apokalyptik / decrypt.go
Created Sep 1, 2014
Go RSA private key decryption example. Compatible with data encrypted via http://us3.php.net/openssl_public_encrypt
View decrypt.go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"flag"
"fmt"
"io/ioutil"
You can’t perform that action at this time.