Skip to content

Instantly share code, notes, and snippets.

@dyoo
dyoo / letsencrypt-GAE.md
Created July 16, 2017 22:48
Set up HTTPS for Google App Engine using Let's Encrypt

Copied from https://www.jeffgodwyll.com/posts/2016/letsencrypt

Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. Let’s Encrypt is a service provided by the Internet Security Research Group (ISRG)

About Let's Encrypt

This post won't go into details as to what Let's Encrypt is about. We should probably read the FAQs if we want to learn more.

Until the Google App Engine Team fully automate the process of using Let's Encrypt on Google App Engine or even provide some sort of API to handle certs, we'll probably have to find ways of either automating the process just a little bit or stick to some other easier cert authority.

@dyoo
dyoo / cantor_pairing.go
Last active October 27, 2021 19:20
Cantor pairing function
// http://en.wikipedia.org/wiki/Pairing_function
package main
import (
"fmt"
"math"
)
func InvertedCantorPairing(z int) (int, int) {
w := int(math.Floor((math.Sqrt(float64(8*z+1)) - 1) / 2))
// The curse of a programmer; if you read articles with data,
// you continuously fight the temptation to write a program to
// play with that data. In this case, I failed.
package main
import (
"fmt"
"math"
)
@dyoo
dyoo / .emacs
Created September 22, 2013 04:16
My current .emacs on my Mac OS X laptop
;; These are the settings I'm using for Emacs on my Mac laptop.
;; Turn off the splash screen.
(setq inhibit-splash-screen t)
;; Set the Command key to work like meta.
;; http://superuser.com/questions/297259/set-emacs-meta-key-to-be-the-mac-key
(setq mac-option-key-is-meta nil
mac-command-key-is-meta t
@dyoo
dyoo / count_t_words_2.go
Last active December 22, 2015 02:59
A second version of the program in https://gist.github.com/dyoo/6407562. Make simple things more complicated! :P
package main
// A question from reading Barry Schwartz's "The Paradox of Choice".
//
// How many English words start with "t"?
//
// How many English words have "t" as the third letter?
import (
"bufio"
@dyoo
dyoo / count_t_words_1.go
Last active December 22, 2015 02:59
More play with Go. A question from reading Barry Schwartz's "The Paradox of Choice": how many English words start with 't', and how many have 't' as the third letter?
package main
// A question from reading Barry Schwartz's "The Paradox of Choice".
//
// How many English words start with "t"?
//
// How many English words have "t" as the third letter?
import (
"bufio"
@dyoo
dyoo / sort_func.go
Created August 11, 2013 20:28
More play with Go; sorting with a comparison function. It's interesting to note that we have to do type conversions that we wouldn't have to do if we were to go along the grain of the sort.Sort() function.
package main
import (
"fmt"
"sort"
)
type ComparableSlice struct {
elts []interface{}
cmp func(interface{}, interface{}) bool
@dyoo
dyoo / sort.go
Created July 25, 2013 19:59
A few notes on how to use Go's sort, and observation on how the language features interact.
// A little bit of play with Go's sorting routines, coupled with
// type system stuff.
// Let's say that we'd like to sort a list of numbers in reverse
// order. (and pretend that we know about sort.Sort(), but neglected
// to read about sort.Reverse(). Let's start this off:
package main
import (
@dyoo
dyoo / linecount.go
Created July 24, 2013 21:06
Playing around with more go stuff; line counting utility
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
)
@dyoo
dyoo / crawl.go
Created July 23, 2013 18:29
My somewhat convoluted approach to the web crawler exercise in the Tour of Go http://tour.golang.org/#70. Uses ideas from http://soniacodes.wordpress.com/2011/10/09/a-tour-of-go-69-exercise-web-crawler/ with regards to how to serialize access to the map, and Rob Pike's Go Currurency Pattern's talk http://www.youtube.com/watch?v=f6kdp27TYZs with …
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
Fetch(url string) (body string, urls []string, err error)