Skip to content

Instantly share code, notes, and snippets.

@tmarthal
tmarthal / com.user.disable-rcd.plist
Created May 24, 2026 16:54 — forked from pythoninthegrass/com.user.disable-rcd.plist
Disable Apple Music (née iTunes) from launching via media keys
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.disable-rcd</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>unload</string>
@tmarthal
tmarthal / aes_encryption.py
Last active October 16, 2024 11:42
PyCrypto AES256 Encoding with Initialization Vectors Matching Spring Security
class AesCrypt256:
#Based on https://gist.github.com/pfote/5099161
BLOCK_SIZE = 16
# To use the null/x00 byte array for the IV
default_initialization_vector = False
def __init__(self, default_initialization_vector=False):
self.default_initialization_vector = default_initialization_vector
@tmarthal
tmarthal / deploy-django.md
Last active April 27, 2024 15:50 — forked from rmiyazaki6499/deploy-django.md
Deploying a Production ready Django app on AWS

Deploying a Production ready Django app on AWS

In this tutorial, I will be going over to how to deploy a Django app from start to finish using AWS and EC2. Recently, my partner Tu and I launched our app Hygge Homes (a vacation home rental app for searching and booking vacation homes based off Airbnb) and we wanted to share with other developers some of the lessons we learned along the way.

Following this tutorial, you will have an application that has:

  • An AWS EC2 server configured to host your application
  • SSL-certification with Certbot
  • A custom domain name
  • Continuous deployment with Github Actions/SSM Agent
# -*- coding: utf-8 -*-
from airflow.operators.http_operator import SimpleHttpOperator
from airflow.operators.postgres_operator import PostgresOperator
from airflow.operators.dummy_operator import DummyOperator
from airflow.hooks.postgres_hook import PostgresHook
from airflow.models import Variable, DAG
from datetime import date, datetime, timedelta
@tmarthal
tmarthal / task-dag-creation.py
Created February 23, 2017 01:31
DAG Creation from within a PythonOperator task DOES NOT WORK
# -*- coding: utf-8 -*-
from airflow.operators.http_operator import SimpleHttpOperator
from airflow.operators.postgres_operator import PostgresOperator
from airflow.operators.subdag_operator import SubDagOperator
from airflow.operators.sensors import SqlSensor
from airflow.hooks.postgres_hook import PostgresHook
from airflow.operators.python_operator import PythonOperator
from airflow.models import Variable, DAG
# "given an array of integers and a number n, partition the array into
# n pieces so that their sums are as equal as possible"
import itertools
import numpy as np
import sys
def powerset(input:list) -> list:
# returns a list of tuple lists of all of the permutations of elements
# [1,2,3] -> [[(1, 2, 3)], [(1,), (2, 3)], [(1,), (2,), (3,)], [(1,), (3,), (2,)],
@tmarthal
tmarthal / AESBytesEncryptor-2.java
Last active May 12, 2017 06:55
Spring Security AES Encryption Setup/Usage Blog Code
byte[] iv = this.ivGenerator.generateKey();
byte[] encrypted = doFinal(this.encryptor, bytes);
return this.ivGenerator != NULL_IV_GENERATOR ? concatenate(iv, encrypted) : encrypted;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import binascii
# PyCryptodome, NOT pycrypto
from Crypto.Cipher import AES
from Crypto.Protocol.KDF import PBKDF2
class AesCrypt256:
#Based on https://gist.github.com/pfote/5099161
BLOCK_SIZE = 16
def pkcs5_pad(self,s):
"""
@tmarthal
tmarthal / crontab
Created October 26, 2013 21:20 — forked from tovbinm/crontab
# Nginx - logrotate & upload to S3
0 0 * * * /usr/sbin/logrotate /etc/logrotate.d/nginx
15 0 * * * s3cmd put /var/log/nginx/access.log-`date +"\%Y\%m\%d"`.gz s3://$LOGS_BUCKET_NAME/nginx-access/`date +"dt=\%Y\%m\%d"`/`hostname -s`.access.log-`date +"\%Y\%m\%d"`.gz