Instantly share code, notes, and snippets.

View main.go
package main
import (
"context"
"database/sql"
"fmt"
"os"
_ "github.com/lib/pq"
)
View getPid.py
#!/usr/bin/env python3.5
import os
import subprocess
def getPid(name):
""" Get the process ID (pid) of a named process. """
ps = subprocess.run(["ps", "cax"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if ps.returncode == 0:
View certbot-renew.sh
# Let's Encrypt sends emails like this:
# Subject: Action required: Let's Encrypt certificate renewals
#
# Hello,
#
# **Action is required to prevent your Let's Encrypt certificate renewals from breaking.**
#
# Your Let’s Encrypt client used ACME TLS-SNI-01 domain validation to issue a certificate in the past 60 days.
#
View datetime-with-timezone.sql
drop table if exists t;
-- Create temporary table with local datetime and time zone.
create temporary table t (
id SERIAL primary key,
"datetime" timestamp without time zone not null default now(),
"zone" varchar(255) not null default 'Europe/Berlin'
);
-- Insert 262,800 generated rows.
View interface-slice.go
package main
import (
"fmt"
)
type Fooer interface {
Foo() string
}
View jwt-with-go.go
package main
import (
"errors"
"fmt"
"io/ioutil"
jwt "github.com/dgrijalva/jwt-go"
"github.com/satori/go.uuid"
)
View pom.xml
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.2</version>
</dependency>