Skip to content

Instantly share code, notes, and snippets.

@jcarley
jcarley / json.py
Created September 16, 2022 18:10 — forked from ergoithz/json.py
python json datetime encoder
import json
import datetime
import dateutil.parser
class JSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, datetime.datetime):
return {
'type': 'datetime',
'data': obj.isoformat()
@jcarley
jcarley / install_tmux.sh
Created April 22, 2022 17:14 — forked from tknhs/install_tmux.sh
for Amazon Linux 2
LIBEVENT_VERSION="2.1.12-stable"
TMUX_VERSION="3.2a"
sudo yum install -y gcc kernel-devel make ncurses-devel openssl-devel
curl -LOk https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz
tar -xf libevent-${LIBEVENT_VERSION}.tar.gz
cd libevent-${LIBEVENT_VERSION}
./configure --prefix=/usr/local
make -j4
@jcarley
jcarley / .ideavimrc
Created January 6, 2022 20:34
JetBrains IDE IdeaVim .ideavimrc.
set gdefault
set hlsearch
set ignorecase
set iskeyword
set incsearch
set number
set clipboard+=unnamed
set relativenumber
set showmode
set smartcase
@jcarley
jcarley / s3_heroku_rails_01_direct_upload_controller.rb
Created November 30, 2021 17:14 — forked from elliott-king/s3_heroku_rails_01_direct_upload_controller.rb
Creates a URL for an Active Storage direct upload
class DirectUploadController < ApplicationController
def create
response = generate_direct_upload(blob_params)
render json: response
end
private
def blob_params
params.require(:file).permit(:filename, :byte_size, :checksum, :content_type, metadata: {})
@jcarley
jcarley / rails http status codes
Created October 22, 2021 18:10 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
service salt-minion stop
rm -f /etc/salt/pki/minion/minion_master.pub
echo "master: salt" > /etc/salt/minion
service salt-minion start
@jcarley
jcarley / assume-role-policy.json
Created February 28, 2018 15:00 — forked from clstokes/assume-role-policy.json
Example: Terraform IAM Role
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
@jcarley
jcarley / generate_docker_cert.sh
Created January 19, 2018 13:34 — forked from bradrydzewski/generate_docker_cert.sh
Generate trusted CA certificates for running Docker with HTTPS
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
# See http://docs.docker.com/articles/https/
#
# To start the Docker Daemon:
#
# sudo docker -d \
@jcarley
jcarley / le-install.sh
Created January 17, 2018 17:59 — forked from hisnameisjimmy/le-install.sh
Unifi Controller one-shot install script for Ubuntu 16.04 with Lets Encrypt
#!/bin/sh
#
# This script stands on the shoulders of giants.
#
# It is written and tested for Ubuntu 16.04 on Digital Ocean using a 1GB droplet.
# Anything less than 1GB of memory may cause issues with anything memory intensive
# like imports/exports.
#
# It does the following:
# 1) Opens the appropriate ports for Unifi, SSH, Web/SSL traffic via iptables
@jcarley
jcarley / .babelrc
Created August 10, 2017 21:14 — forked from fdietz/.babelrc
Phoenix Framework Webpack Integration (replacing Brunch)
{
"presets": ["es2015", "react", "babel-preset-stage-0"]
}