Skip to content

Instantly share code, notes, and snippets.

@jasco
jasco / DialogFragAnim_snippet.java
Created October 5, 2014 00:26
DialogFragment enter/exit animations
// example courtesy of http://adilatwork.blogspot.com/2012/11/android-dialogfragment-enter-and-exit.html
// file location: src/main/java/com/example/
@Override
public void onStart() {
super.onStart();
// safety check
if (getDialog() == null) {
return;
@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 April 18, 2024 18:07
Workaround for SqlAlchemy Alembic Migrations

Dialect specific migration with Alembic

DDL

Certain SQL dialect specific SQL including triggers and stored procedures are not abstracted away by SqlAlchemy. In those cases SqlAlchemy provides a DDL interface that can be connected to events that conditionally trigger the appropriate dialect specific code.

ddl = sqlalchemy.DDL(custom_pg_trigger)

@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 / 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 / get_etag.pl
Last active May 26, 2022 20:46
Apache Use Stored MD5 as ETAG
#!/usr/bin/perl
use strict;
$| = 1; # Turn off I/O buffering
sub sanitize {
my $fname = $_[0];
$fname =~ s#[^-_a-zA-Z0-9./]*##g;
$fname =~ s#/\.\.+/##g;
@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