Skip to content

Instantly share code, notes, and snippets.

@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,
@goliatone
goliatone / README.md
Created July 27, 2021 01:36 — forked from bruth/README.md
SQLite update hook example in Go

SQLite Update Hook Example

This is an example usage of registering an update_hook to a SQLite connection. The motivation for exploring this feature is to test out various implementations of data monitoring interfaces.

A few notable properties of the implementation:

  • The hook must be registered on the connection being used which requires clients to manually integrate this code.
  • Each INSERT and UPDATE operation requires a subsequent SELECT to get the row data.
  • When registering the hook, increasing the bufsize under heavy workloads will improve throughput, but the SQLite library is single-threaded by design.
@goliatone
goliatone / ffmpeg.md
Created April 24, 2021 22:27 — forked from steven2358/ffmpeg.md
FFmpeg cheat sheet
@goliatone
goliatone / poller.go
Created April 22, 2021 02:16 — forked from nhocki/poller.go
Simple task scheduling with Redis & Go. Similar to Sidekiq's `perform_in` and `perform_at`.
// poller.go
package main
import (
"fmt"
"os"
"os/signal"
"time"
@goliatone
goliatone / nodegit_load_ssh_key.js
Last active December 14, 2020 18:31 — forked from vital101/nodegit.js
NodeGit Clone Private with Token
var url = "git@github.com:nodegit/test.git";
var opts = {
fetchOpts: {
callbacks: {
certificateCheck: () => 0,
credentials: function(url, userName) {
return NodeGit.Credential.sshKeyNew(
userName,
sshPublicKeyPath,
sshPrivateKeyPath,
@goliatone
goliatone / index.js
Created September 15, 2020 21:08 — forked from JamesChevalier/index.js
Get the bounding box of a GeoJSON object, regardless of how many polygons it contains. The core of this is from http://mikefowler.me/2014/06/10/drawing-geojson-in-a-canvas/
function getBoundingBox(data) {
var bounds = {}, coordinates, point, latitude, longitude;
// Loop through each "feature"
for (var i = 0; i < data.features.length; i++) {
coordinates = data.features[i].geometry.coordinates;
if(coordinates.length === 1){
// It's only a single Polygon
// For each individual coordinate in this feature's coordinates...
@goliatone
goliatone / generate_rsa_ssh_keys.go
Last active October 16, 2023 07:34 — forked from azakordonets/generate_rsa_ssh_keys.go
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"
@goliatone
goliatone / simple-gpg-enc.go
Created August 16, 2020 07:42 — forked from stuart-warren/simple-gpg-enc.go
golang gpg/openpgp encryption/decryption example
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"io/ioutil"
"log"
"os"
)
@goliatone
goliatone / gpg-encrypt.go
Created August 16, 2020 07:42 — forked from ayubmalik/gpg-encrypt.go
Golang encrypt file using GPG openpgp. Use standard go libs.
package main
/**
Example hack to encrypt a file using a GPG encryption key. Works with GPG v2.x.
The encrypted file e.g. /tmp/data.txt.gpg can then be decrypted using the standard command
gpg /tmp/data.txt.gpg
Assumes you have **created** an encryption key and exported armored version.
You have to read the armored key directly as Go cannot read pubring.kbx (yet).
@goliatone
goliatone / download_multiple.py
Created May 19, 2020 05:07 — forked from Hammer2900/download_multiple.py
Use asyncio and aiohttp to asynchronously download multiple files at once and handle the responses as they finish
import asyncio
from contextlib import closing
import aiohttp
async def download_file(session: aiohttp.ClientSession, url: str):
async with session.get(url) as response:
assert response.status == 200
# For large files use response.content.read(chunk_size) instead.