Skip to content

Instantly share code, notes, and snippets.

View cgt's full-sized avatar

Christoffer Gamrath cgt

  • Denmark
View GitHub Profile
@cgt
cgt / gt.sh
Last active August 29, 2015 13:59
gt bash func
function gt(){
case "$1" in
cwb)
cd $GOPATH/src/cwb
;;
go)
cd $GOPATH/src
;;
mwc)
cd $GOPATH/src/cgt.name/pkg/go-mwclient
@cgt
cgt / keybase.md
Created October 25, 2014 09:39
keybase.md

Keybase proof

I hereby claim:

  • I am cgt on github.
  • I am cgt (https://keybase.io/cgt) on keybase.
  • I have a public key whose fingerprint is F310 8436 FF27 DB19 B2FB 1EF1 95CD 6B2C 0655 BE69

To claim this, I am signing this object:

cgt@lpc1:~$ http cgt.name/pkg/go-mwclient
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Thu, 19 Feb 2015 15:18:46 GMT
Last-Modified: Sun, 08 Feb 2015 13:16:35 GMT
Server: nginx
Transfer-Encoding: chunked
Vary: Accept-Encoding
@cgt
cgt / fib.py
Last active August 29, 2015 14:16
O(n) recursive fib
cache = {1: 1, 2: 1}
def fib(n: int) -> int:
assert n > 0
if n in cache:
return cache[n]
else:
m = fib(n-1) + fib(n-2)
cache[n] = m
return m
@cgt
cgt / lp.py
Created March 16, 2015 10:10
longest palindrome
#!/usr/bin/env python3
def lp(x, i=None, j=None, cache={}):
if i is None or j is None:
i = 0
j = len(x)-1
if (i, j) in cache.keys():
return cache[(i, j)]
@cgt
cgt / churchchecker.py
Created March 19, 2015 20:31
Church infobox URL length report generator
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
An incomplete sample script.
This is not a complete bot; rather, it is a template from which simple
bots can be made. You can rename it to mybot.py, then edit it in
whatever way you want.
The following parameters are supported:
@cgt
cgt / calcDiag.py
Created January 25, 2012 10:02
Calculate the number of diagonals in a polygon
#/usr/bin/env python
from sys import argv
def calcDiagonals(n):
'''Calculates how many diagonals there can be in a polygon.'''
return n*(n-3)/2
if __name__ == '__main__':
print calcDiagonals(int(argv[1]))
@cgt
cgt / webtest.go
Created July 1, 2012 19:53
A simple web test app in Go
package main
import (
"fmt"
"log"
"net/http"
)
const (
pHeader = "<!DOCTYPE html><html><body>"
@cgt
cgt / nethttpsleep.go
Created August 22, 2012 17:41
nethttpsleep
package main
import (
"fmt"
"net/http"
"time"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Greetings!")
package main
import (
"log"
"os"
"os/exec"
)
func main() {
fpath := os.TempDir() + "/thetemporaryfile.txt"