Skip to content

Instantly share code, notes, and snippets.

View johnwilson's full-sized avatar

John Wilson johnwilson

  • Infinite Blue Technologies
  • GH
View GitHub Profile
@johnwilson
johnwilson / json_indexer.py
Last active August 29, 2015 13:56
Quick indexing of JSON data for storage in 'SQL' or 'NoSQL' database
# This Python file uses the following encoding: utf-8
import json
from types import NoneType
def type_to_string(typ):
"""Return a custom Type name for python Type
:param typ: The python Type
:type typ: type.
:raises: TypeError
#!/bin/bash
set -e
cd /tmp
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-2.2.tar.gz
tar -xzf setuptools-2.2.tar.gz
cd setuptools-2.2
sudo jython27 setup.py install --prefix=/opt/jython27
@johnwilson
johnwilson / gpg-import-and-export-instructions.md
Created January 12, 2018 09:28 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@johnwilson
johnwilson / remove-plugin.js
Created March 21, 2018 18:30
Remove JQuery Plugin from DOM element
/*-----------------------------------------------------------
| Original author:
| * http://ub4.underblob.com/remove-jquery-plugin-instance/
------------------------------------------------------------*/
var destroyPlugin = function($elem, eventNamespace) {
// check if plugin has a namespace
var isInstantiated = !! $.data($elem.get(0));
if (isInstantiated) {
@johnwilson
johnwilson / simple-pagination.js
Created May 2, 2018 13:17 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
/**
* Sample of serverside generation of Highcharts using an extension to jsdom in node.js.
*
* Usage:
* npm install [email protected] && npm install highcharts
* node highcharts-jsdom
*/
/* eslint-env node */
/* eslint no-console: 0 */
/**
* Sample of serverside generation of Highcharts using an extension to jsdom in node.js.
*
* Usage:
* npm install jsdom
* npm install highcharts
* node highcharts-jsdom
*/
/* eslint-env node */
@johnwilson
johnwilson / setup-avahi.sh
Created May 14, 2018 10:46 — forked from davisford/setup-avahi.sh
Setup avahi-daemon on Ubuntu for so you can reach hostname `ubuntu.local` from host OS
sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan
@johnwilson
johnwilson / fix.wkhtmltopdf.odoo.snippetbucket.erp.open.source.seo.sh
Created November 8, 2018 10:44 — forked from tejastank/fix.wkhtmltopdf.odoo.snippetbucket.erp.open.source.seo.sh
Wkhtmltopdf failed (error code: -6). Message: The switch --header-spacing, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.QXcbConnection: Could not connect to display. # https:/…
# https://www.snippetbucket.com/
# ODOO ERP Django PHP Android AngularJS implementation and customization.
# Most Simple and Quick Way:
cd /opt/
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
tar vxf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
cp wkhtmltox/bin/wk* /usr/local/bin/
And you can confirm with:
@johnwilson
johnwilson / flynn-online-net-install.sh
Created November 30, 2019 15:18
Install Flynn PaaS on Online.net bare metal server
#!/usr/bin/env bash
#===========================================================
#
# Run this command:
#
# sudo SERVERS="Space separated list of IPs" bash install.sh
#
#===========================================================