Skip to content

Instantly share code, notes, and snippets.

View mtbkeith's full-sized avatar

Keith Reynolds mtbkeith

View GitHub Profile
@mtbkeith
mtbkeith / multiple_ssh_setting.md
Created March 17, 2022 05:24 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@mtbkeith
mtbkeith / grant_database.py
Created January 20, 2022 23:31
Grant DB permissions from Django permission group
from django.contrib.auth.models import Group as AuthGroup, Permission
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Grant db permissions"
def handle(self, *args, **options):
self.grant_database_permissions('dj_group', 'db_group')
@mtbkeith
mtbkeith / compare_schemas.py
Last active April 17, 2020 06:42
sql alchemy compare two table schemas
from sqlalchemy import text, MetaData, Table, inspect
from sqlalchemy.engine import (
reflection,
)
def foo():
# check to see if the two schemas are the same
inspector = inspect(engine)
schemas = inspector.get_schema_names()
@mtbkeith
mtbkeith / redshift_alter_sortkey.sql
Created February 29, 2020 03:37
change a redshift sortkey without coping the table
-- redshift
alter table hospital_events alter sortkey (key, visit_id);
alter table notes alter sortkey (key, visit_id);
@mtbkeith
mtbkeith / django_login_reset_axes.py
Created February 13, 2020 16:08
reset django axes on login
from django.conf import settings
from django.contrib import auth
from django.utils.deprecation import MiddlewareMixin
from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
from axes.utils import reset
@receiver(user_logged_in)
def post_login(sender, user, request, **kwargs):
""" Reset django axes for this user now that they have logged in """
#!/bin/bash
# Decrypt GPG files in current directory
# Files created with gpg --armor --output <out enc file> --symmetric --cipher-algo AES256 <in clear file>
read -s -p "Enter Password: " pw
echo -ne "\033[0K\r"
for infile in *.gpg;
do
outfile=${infile%.gpg}
@mtbkeith
mtbkeith / aws-lambda
Last active December 4, 2018 20:29
serverless comparison
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.ListObjectsV2Result;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.S3ObjectSummary;
@mtbkeith
mtbkeith / crap.swift
Created November 18, 2018 17:14
stupidity of swift evolution
// old swift
let data = string.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
// new swift
let data = string.data(using: String.Encoding.utf8, allowLossyConversion: true)
Process: Sourcetree [8884]
Path: /Applications/SourceTree.app/Contents/MacOS/Sourcetree
Identifier: com.torusknot.SourceTreeNotMAS
Version: 2.7.3 (169)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Sourcetree [8884]
User ID: 501
Date/Time: 2018-06-05 14:20:53.287 -0600
@mtbkeith
mtbkeith / loggingMarkerBug_loggingMarker (1).iml
Last active February 20, 2018 08:00
Bug when using child markers and filtering for parent
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>