Skip to content

Instantly share code, notes, and snippets.

View jpoehnelt's full-sized avatar
🏠
Working from home

Justin Poehnelt jpoehnelt

🏠
Working from home
View GitHub Profile
@lukeramsden
lukeramsden / midString.sql
Created June 24, 2020 08:01
PL/pgSQL implementation of a LexoRank-style lexicographical rank generator function
-- https://stackoverflow.com/questions/38923376/return-a-new-string-that-sorts-between-two-given-strings
create or replace function app_public.mid_string(prev text, next text) returns text as $$
declare
v_p int;
v_n int;
v_pos int := 0;
v_str text;
begin
LOOP -- find leftmost non-matching character
v_p := CASE WHEN v_pos < char_length(prev) THEN ascii(substring(prev from v_pos + 1)) ELSE 96 END;
#!/bin/bash -ex
rm -rf ~/.glide/cache
export GOPATH=$( mktemp -d )
PKG=client-go-example
PKG_PATH=$GOPATH/src/$PKG
function cleanup {
@xrstf
xrstf / letsencrypt.md
Last active April 18, 2023 05:01
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@understar
understar / png2tiff.py
Created July 24, 2014 14:00
GDAL project TIANDITUSICHUAN tile png to wgs84 geotiff
import gdal, osr
import numpy as np
levelsdetail = {18:(262144, 131072, 256),
17:(131072, 65536, 256)
}
def lat_lon2index(lat, lon, level): # top left corner
width = levelsdetail[level][0]
height = levelsdetail[level][1]
@jgoux
jgoux / app.js
Created April 15, 2014 14:53
Ionic / AngularJS service wrapper for Web SQL API / SQLite-Cordova-Plugin
angular.module('myApp', ['ionic', 'myApp.services', 'myApp.controllers'])
.run(function(DB) {
DB.init();
});
@iamnewton
iamnewton / bash-colors.md
Last active May 27, 2024 23:36
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@mikevansnell
mikevansnell / invite.js
Last active October 22, 2018 21:04
Parse.com cloudcode sample that enables one user to invite another user, and immediately returns the new user object so that you can do something with it (e.g. start associating objects with it).
// in invite.js module:
exports.inviteUser = function(creatingUser,email,tempPass,response)
{
"use strict";
if (!tempPass) {
tempPass = genRandomPass();
}
var user = new Parse.User();
user.set ("username", email);
@crccheck
crccheck / README.md
Last active March 2, 2024 16:39
Python Packaging

What the Hell? -- A Journey Through the Nine Circles of Python Packing

Writing a setup.py

map

I am no Virgil, but having stumbled my way through Python packaging a few times already, I'm documenting the things I learn as I go here.

To help me learn, I took a survey of the top 15 Python packages on Github along with 12 other commonly referenced packages. I thought... if there are any best