Skip to content

Instantly share code, notes, and snippets.

@david-sanabria
david-sanabria / pg_base62_encode.sql
Last active March 28, 2024 11:08
Base62 Encode/Decode functions for PostgreSQL.
/*
* This script will create base62_encode() and base62_decode() in the current schema of a postgresql database.
* Give it a star if you find it useful.
*/
CREATE OR REPLACE FUNCTION base62_encode( long_number bigint )
RETURNS text
AS $BODY$
/*
* base62_encode()
@nat-n
nat-n / Recipe-bundling-fonts-with-headless-chrome.md
Last active February 28, 2024 19:23
How to build a fontconfig bundle for adding arbitrary fonts to headless chrome independent of the OS. This is specifically useful for deploying headless chrome to AWS lambda where it is necessary to include fonts for rendering CJK (Chinese, Japanese, Korean) characters into the deployed bundle.

Building fontconfig

Start up a lambda-like docker container:

docker run -i -t -v /tmp:/var/task lambci/lambda:build /bin/bash

Install some dependencies inside the container:

yum install gperf freetype-devel libxml2-devel git libtool -y

easy_install pip

@creack
creack / main.go
Created January 7, 2018 17:30 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"strconv"
@merkushin
merkushin / mysql_uuid.sql
Last active October 15, 2023 14:06
MySQL UUID v5 Stored Functions
DROP FUNCTION IF EXISTS uuid_from_bin;
DROP FUNCTION IF EXISTS uuid_to_bin;
DROP FUNCTION IF EXISTS uuid_v5;
DROP FUNCTION IF EXISTS uuid_v4;
DELIMITER //
CREATE FUNCTION uuid_from_bin(b BINARY(16))
RETURNS CHAR(36)
BEGIN
@devinodaniel
devinodaniel / gist:8f9b8a4f31573f428f29ec0e884e6673
Created November 21, 2017 20:18
Generate SSH RSA Private/Public Key pair with Golang
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"golang.org/x/crypto/ssh"
package main
import "fmt"
// WithPrefix
type prefixOption struct{}
func WithPrefix() interface {
GetOption
@PurpleBooth
PurpleBooth / Dockerfile
Last active March 21, 2024 09:33
Create a static binary in go and put it in a from scratch docker container
FROM golang:1.9
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
@levelsio
levelsio / btc-eth-dca-buy.php
Last active January 6, 2023 22:04
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
@tj
tj / snippets.coffee
Last active September 1, 2018 19:01
Atom snippets for Go
'.source.go':
'Options':
'prefix': 'options'
'body': '''
// Option function.
type Option func(*$1)
// New with the given options.
func New(options ...Option) *$1 {
@dopey
dopey / main.go
Last active April 13, 2024 08:07 — forked from denisbrodbeck/main.go
How to generate secure random strings in golang with crypto/rand.
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
"io"
"math/big"
)