Skip to content

Instantly share code, notes, and snippets.

@jasco
jasco / serve.js
Created July 13, 2015 18:42
TLS enabled deployd (https/ssl/tls)
var fs = require('fs');
var https = require('https');
var deployd = require('deployd');
var express = require('express');
var socketIO = require('socket.io');
var dbhost = process.env.MONGODB_TCP_ADDR;
var dbport = process.env.MONGODB_TCP_PORT;
var dbname = process.env.MONGODB_DB_NAME || 'dbname';
var dbuser = process.env.MONGODB_USERNAME;
@jasco
jasco / FlaskApacheAuth.md
Created October 15, 2015 18:25
Using Flask auth to authorize access to apache static resources

Using Apache auth with Flask user authentication

Flask supported user authentication combined with direct apache basic authentication for static files

Flask Auth

The flask-security module uses flask-login to authenticate users and stores a token identifying the user in a session cookie encrypted using an application secret the prevents forgery. Additional modules can be used to store session

@jasco
jasco / README.md
Last active March 30, 2017 05:12
Configurable python decorators

Decorator class using decorator called methods to configure

Allow the behavior of a decorator to be modified by other decorators.

@mod_b
@mod_a
@base_decorator
def myfunc(): pass

In contrast to a more typical

@jasco
jasco / .gitconfig
Created April 7, 2017 21:39
Git Config
[user]
name = {name}
email = {email}
[diff]
tool = kdiff3
[core]
autocrlf = input
editor = /usr/local/bin/vim
[alias]
# Short status, one line per file
@jasco
jasco / migrator.sh
Last active July 14, 2017 08:24 — forked from vigneshwaranr/migrator.sh
Script to convert SQLITE dumps into PostgreSQL compatible dumps
#! /bin/sh
usage_error () {
echo 'Usage: sh migrator.sh <path to sqlite_to_postgres.py> <path to sqlite db file> <an empty dir to output dump files>'
echo
echo 'Example:'
echo '>sh migrator.sh sqlite_to_postgres.py ~/reviewboard.db /tmp/dumps'
echo
echo 'Tested on:'
echo 'Python 2.7.3'
@jasco
jasco / README.md
Created October 17, 2017 08:30
ARM Debian Config for Kyocera FS-4020DN

Kyocera FS-4020DN Laser Printer Config

Install CUPS

sudo apt update && apt dist-upgrade
sudo apt install cups openprinting-ppds

Add user to printer group

sudo usermod -a -G lpadmin $USER
@jasco
jasco / five_minutes.yml
Last active June 3, 2019 04:18 — forked from ryane/five_minutes.yml
[Ansible Ubuntu First Boot Security Tighening] five_minutes.yml #ubuntu #ansible
---
# Ansible script for first-boot tightening up Ubuntu security
# Reference blog https://ryaneschinger.com/blog/securing-a-server-with-ansible/
- hosts: all
vars:
UBUNTU_COMMON_ROOT_PASSWORD: 'xxxxx'
UBUNTU_COMMON_DEPLOY_PASSWORD: 'xxxxx'
UBUNTU_COMMON_LOGWATCH_EMAIL: user@example.com
ubuntu_common_deploy_user_name: deploy
@jasco
jasco / 99_facetimehd
Last active February 27, 2020 01:09
ubuntu facetimehd kernel module build
#!/bin/bash
set -e
# References
# - https://github.com/patjak/bcwc_pcie/wiki/Get-Started#get-started-on-ubuntu
# - https://gist.github.com/Stono/990ea9f0b3c41606c292f00382d421bf
git clone https://github.com/patjak/bcwc_pcie.git /tmp/bcwc_pcie
cd /tmp/bcwc_pcie
git clone https://github.com/patjak/facetimehd-firmware.git
@jasco
jasco / download_fetched_response.js
Last active April 2, 2020 07:48
Browser download from fetched data
// Most samples used createObjectURL which gave errors suggesting no longer supported by the browser.
// This implementation encodes as a base64 string and saves as an octet-stream.
// Adapted from https://stackoverflow.com/a/38384008 and https://stackoverflow.com/a/11562550
function download(filename, arrayBuffer) {
const element = document.createElement('a');
const base64String = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer)));
element.setAttribute('href', 'data:application/octet-stream;base64,' + base64String);
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
@jasco
jasco / SPPachabelCanon.rb
Last active June 12, 2020 08:24 — forked from rbnpi/SPPachabelCanon.rb
Sonic Pi Pachabel's Canon for Flute, Clarinet and Trombone sample based voices. This version runs on RPi
# Pachebel Canon for Sonic Pi, played by Flute, Clarinet and Trombone sample based voices
# coded by Robin Newman, March 2015
# modified to work with SonicPi 3.2.2 (min unknown)
# score from www.freegigmusic.com (version for flute oboe and clarinet)
# samples download at http://r.newman.ch/rpi/Pachabel.zip
use_debug false
samples_dir='/home/pi/samples/Pachabel' #adjust location as necessary
# first deal with selecting and setting up the samples
inst0=samples_dir + '/flute_ds5.wav'