Skip to content

Instantly share code, notes, and snippets.

@goliatone
goliatone / taskfile.template
Last active February 8, 2023 03:11
Taskfile template
#!/bin/bash
# Check for -debug flag
if [[ $* == *-debug* ]]; then
set -x
fi
# If we have a .taskenv file load it as source
if [ -f .taskenv ]; then
# shellcheck disable=SC1091
@goliatone
goliatone / query_builder.go
Created October 16, 2022 18:48 — forked from paragtokopedia/query_builder.go
Query Builder
package query_builder
import (
"strings"
"strconv"
"html/template"
"fmt"
)
type DynamicQueryBuilder string
@goliatone
goliatone / base64_to_uuid.sql
Created March 29, 2022 21:52
[Snowflake base64 to UUID] #sql #snowflake Snowflake function to encode a base64 encoded UUID as a string formatted UUID
DROP FUNCTION _BASE64_UUID(VARCHAR);
CREATE OR REPLACE FUNCTION _BASE64_UUID(INPUT VARCHAR)
RETURNS varchar
LANGUAGE javascript
strict
AS
$$
try {
var stmt = snowflake.createStatement({
sqlText: `SELECT TO_VARCHAR(TRY_BASE64_DECODE_BINARY(?), 'HEX');`,
@goliatone
goliatone / github-proxy-client.js
Created March 15, 2022 17:51 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@goliatone
goliatone / pad.js
Created October 16, 2015 15:25
JavaScript pad
/**
*
* Javascript string pad
* http://www.webtoolkit.info/
*
**/
var STR_PAD_LEFT = 1;
var STR_PAD_RIGHT = 2;
var STR_PAD_BOTH = 3;
@goliatone
goliatone / postgres-pivot.md
Created November 9, 2021 22:50 — forked from ryanguill/postgres-pivot.md
Example of postgres pivot using jsonb_object_agg for variable columns in output. To play with this yourself in an online repl, click here: http://dbfiddle.uk/?rdbms=postgres_9.6&fiddle=5dbbf7eadf0ed92f8d6a49fc5be8f3f2
/*
================================================================================
Pivot example with variable number of columns in the output.
================================================================================

example data is straight forward, imagine a table with a customer identifier, an invoice date and an amount.
*/

DROP TABLE IF EXISTS invoice;
@goliatone
goliatone / main.go
Created October 16, 2021 04:26 — forked from mickelsonm/main.go
Golang AES Encryption/Decryption example. See running example: http://play.golang.org/p/5G-IUlYqQV
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"errors"
"io"
"log"
@goliatone
goliatone / Docker_Deploy.md
Created May 12, 2016 16:25 — forked from bradbergeron-us/Docker_Deploy.md
Deploying a Docker Registry

Deploying a registry server

This section explains how to deploy a Docker Registry either privately for your own company or publicly for other users. For example, your company may require a private registry to support your continuous integration (CI) system as it builds new releases or test servers. Alternatively, your company may have a large number of products or services with images you wish to serve in a branded manner.

Docker's public registry maintains a default registry image to assist you in the deployment process. This registry image is sufficient for running local tests but is insufficient for production. For production you should configure and build your own custom registry image from the docker/distribution code.

Note: The examples on this page were written and tested using Ubuntu 14.04. If you are running Docker in a different OS, you may need to "translate" the commands to meet the requirements of your own environment.

###Simple example with the official image In this section, you cre

@goliatone
goliatone / aes-256-gcm.go
Last active September 2, 2021 00:52 — forked from tinti/aes-256-gcm.go
[golang aes-256-gcm] Example script using AES-256 in golang #go #crypto
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/hex"
"flag"
"fmt"
"io"
@goliatone
goliatone / sqlite_to_json.sql
Created August 9, 2021 21:05 — forked from akehrer/sqlite_to_json.sql
SQLite Results as JSON using the SQLite JSON1 extension
-- When SQLite is compiled with the JSON1 extensions it provides builtin tools
-- for manipulating JSON data stored in the database.
-- This is a gist showing SQLite return query data as a JSON object.
-- https://www.sqlite.org/json1.html
-- An example table with some data
CREATE TABLE users (
id INTEGER PRIMARY KEY NOT NULL,
full_name TEXT NOT NULL,
email TEXT NOT NULL,