Skip to content

Instantly share code, notes, and snippets.


Prasanna Swaminathan pswaminathan

View GitHub Profile
andrestc /
Last active Sep 4, 2018
Go std lib funcs/methods missing examples

About this

This list has the goal of helping developers interested in contributing to the Go language but are unsure of where to start. This was not generated manually so some functions and methods here may not require examples (maybe because they are too simple, e.g .String()) and some of these may only make sense in a package level example (which are not considered for this list yet). Use your best judgment and check the documentation before you open up a CL to add an example.

You should also search in gerrit for open CLs that are already adding examples.

I will try to keep this list as up to date as possible. If you find any mistakes, please comment below and I will try to fix it.

swankjesse / MoshiKotlinExample.kt
Created May 14, 2017
Demo how to use Moshi with Kotlin
View MoshiKotlinExample.kt
import com.squareup.moshi.Json
import com.squareup.moshi.KotlinJsonAdapterFactory
import com.squareup.moshi.Moshi
import com.squareup.moshi.Rfc3339DateJsonAdapter
import java.util.Date
val json = """
"url": "",
"id": 91393390,
jessfraz /
Created Oct 1, 2016
nginx go-get vanity urls
server {
location ~ ^/x/(.*) {
if ($args = "go-get=1") {
add_header Content-Type text/html;
return 200 '<meta name="go-import" content="$host/x/$1 git$1.git">';
return 302$1;
blha303 /
Last active May 3, 2018
Gets random comment from /r/gonewild, since they're pretty much all compliments. Warning: May contain sexual content
#!/usr/bin/env python3
import requests
from flask import *
import random
from apscheduler.schedulers.background import BackgroundScheduler
app = Flask(__name__)
scheduler = BackgroundScheduler()
url = ""
paragonie-scott /
Last active Aug 1, 2020
An Open Letter to Developers Everywhere (About Cryptography)
ygotthilf /
Last active Sep 28, 2020
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out
cat jwtRS256.key
ipmb / ratelimit.nginxconf
Last active Aug 26, 2020
Nginx reverse proxy with rate limiting
View ratelimit.nginxconf
upstream myapp {
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
listen 443 ssl spdy;
server_name _;


Let's imagine a very simple table

  id bigserial,
  name character varying
View dbmanager.go
// Use Case:
// Say you have a bunch of decoupled components which access the same set of databases.
// Since database/sql does connection pooling it makes sense for the components to share instances of *sql.DB
// This package lets you do that with minimal code changes.
package dbmanager
import (
blixt /
Created Aug 16, 2014
How to add CORS support to a Flask app in 9 lines of code
def add_cors_headers(response):
response.headers['Access-Control-Allow-Origin'] = '*'
if request.method == 'OPTIONS':
response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT'
headers = request.headers.get('Access-Control-Request-Headers')
if headers:
response.headers['Access-Control-Allow-Headers'] = headers
return response
You can’t perform that action at this time.