Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
jaytaylor / dbhelper.py
Created March 13, 2012 18:12
Python Database Helper
import MySQLdb
##
# @author Jay Taylor [@jtaylor]
# @date 2010-11-15
#
# @description This is a basic database helper script which will setup the connection.
#
# @requirements The MySQLdb package must be installed, i.e. `sudo easy_install MySQLdb`
#
@jaytaylor
jaytaylor / zfs-on-oracle-linux-7.md
Last active April 6, 2022 06:18 — forked from RulerOf/zfs-on-oracle-linux-7.md
Installing ZFS on Linux on Oracle Linux 7

Installing ZFS on Linux on Oracle Linux 7

We're going to add ZFS support to our Oracle Linux installation. We'll just add the ZFS on Linux Repo, verify the binary signature from GitHub, install the files, ensure the driver loads properly, and verify that it's functional. We'll save things like array creation for another document.

This is mostly a transcription of the process from the CentOS/RHEL ZoL installation manual.

Install the repo file

Add the ZFSonLinux repo and verify the fingerprint.

Note — manual fingerprint verification is atypical but we'll do it anyway just for kicks.

@jaytaylor
jaytaylor / camel_case_to_snake_case.py
Created September 6, 2012 21:41
Convert camel-case to snake-case in python.
#!/usr/bin/env python
"""
Convert camel-case to snake-case in python.
e.g.: CamelCase -> snake_case
Relevant StackOverflow question: http://stackoverflow.com/a/1176023/293064
"""
@jaytaylor
jaytaylor / yaml2json.py
Created August 9, 2018 22:01
Python one-liner to convert YAML to JSON
python -c 'import json, sys, yaml ; y = yaml.safe_load(sys.stdin.read()) ; print(json.dumps(y))'
@jaytaylor
jaytaylor / zstd.md
Last active January 11, 2022 18:04
How to use zstd for fast as hell compression

HOW TO: zstd

Why?

Way faster than bzip2, it's basically streaming compression with comparable compression levels.

Compress

tar -cvf - foo | zstd -f --no-progress -o foo.tar.zst
@jaytaylor
jaytaylor / aws-ec2-ubuntu-16.04-xenial-latest-ami-id-finder.sh
Last active December 22, 2021 09:17
AWS EC2 AMI-ID finder for Ubuntu 16.04 Xenial.
#!/usr/bin/env bash
##
# Description
#
# AWS EC2 AMI-ID finder for Ubuntu 16.04 Xenial.
#
set -o errexit
set -o pipefail
@jaytaylor
jaytaylor / install-go.sh
Last active November 15, 2021 21:53
Golang Linux installer configurator
#!/usr/bin/env bash
##
# @description Golang Linux installer.
#
# Example usage:
#
# VERSION=1.17.3 sudo -E bash install-go.sh
#
# @date 2021-02-18
@jaytaylor
jaytaylor / log4j2.properties
Created January 26, 2018 23:36
Elasticsearch log4j2.properties file for hybrid console + disk-based logging, with rotation and expiration.
status = error
dest = err
name = PopertiesConfig
property.logDir = /var/log/elasticsearch
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
@jaytaylor
jaytaylor / EnvHacker.scala
Created August 21, 2014 02:41
Setting environment variables in Scala JVM
trait EnvHacker {
/**
* Portable method for setting env vars on both *nix and Windows.
* @see http://stackoverflow.com/a/7201825/293064
*/
def setEnv(newEnv: Map[String, String]): Unit = {
try {
val processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment")
val theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment")
theEnvironmentField.setAccessible(true)
@jaytaylor
jaytaylor / thrift-configure-mac-osx-20170504.md
Last active August 14, 2020 07:07
Thrift compilation advice for mac OS-X, particular ./configure QT errors and openssl errors.