Skip to content

Instantly share code, notes, and snippets.

@goliatone
goliatone / nodegit_load_ssh_key.js
Last active Dec 14, 2020 — forked from vital101/nodegit.js
NodeGit Clone Private with Token
View nodegit_load_ssh_key.js
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 Sep 15, 2020 — 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/
View index.js
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 Aug 30, 2020 — forked from azakordonets/generate_rsa_ssh_keys.go
Generate SSH RSA Private/Public Key pair with Golang
View generate_rsa_ssh_keys.go
// 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 Aug 16, 2020 — forked from stuart-warren/simple-gpg-enc.go
golang gpg/openpgp encryption/decryption example
View simple-gpg-enc.go
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"io/ioutil"
"log"
"os"
)
@goliatone
goliatone / gpg-encrypt.go
Created Aug 16, 2020 — forked from ayubmalik/gpg-encrypt.go
Golang encrypt file using GPG openpgp. Use standard go libs.
View gpg-encrypt.go
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 — forked from Hammer2900/download_multiple.py
Use asyncio and aiohttp to asynchronously download multiple files at once and handle the responses as they finish
View download_multiple.py
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.
View command-reloader.js
'use strict';
/**
* This plugin add hot command reload by watching
* file changes on any file under `./commands` and
* issuing a `reloadCommand` to the context.
* This
*/
module.exports.init = function(context, config) {
if (process.env.NODE_ENV !== 'development') return {};
@goliatone
goliatone / README.md
Last active Oct 31, 2019 — forked from colophonemes/create_triggers
Postgres TRIGGER to call NOTIFY with a JSON payload
View README.md

This TRIGGER function calls PosgreSQL's NOTIFY command with a JSON payload. You can listen for these calls and then send the JSON payload to a message queue (like AMQP/RabbitMQ) or trigger other actions.

Create the trigger with notify_trigger.sql.

When declaring the trigger, supply the column names you want the JSON payload to contain as arguments to the function (see create_triggers.sql)

The payload returns a JSON object:

@goliatone
goliatone / .block
Created Sep 24, 2019 — forked from rveciana/.block
RxJS and svelte
View .block
licence: mit
@goliatone
goliatone / README.md
Last active Oct 21, 2019 — forked from princejwesley/await-babel-repl.js
[Node REPL] Examples of node REPL #repl #nodejs #node
View README.md

Node.js REPL Examples

Different examples of Node.js REPLs

  • Top level async/await
  • Using custom VM
  • Using atocomplete, custom commands, histroy, etc