Skip to content

Instantly share code, notes, and snippets.

View markddavidoff's full-sized avatar
🎯
Focusing on Work, Sorry Side Projects

Mark Davidoff markddavidoff

🎯
Focusing on Work, Sorry Side Projects
View GitHub Profile
@markddavidoff
markddavidoff / django-database-standalone.py
Created April 1, 2024 16:24 — forked from mw3i/django-database-standalone.py
Truly Standalone Django-ORM Wrapper
'''
Proof of Concept:
Django devs built an ORM that seems way more straightforward than many existing tools. This class lets you leverage the django-orm without any project settings or other aspects of a django setup.
There are probably weak points and functionality missing, but it seems like a relatively intuitive proof of concept
'''
import os
import django
from django.conf import settings
@markddavidoff
markddavidoff / gist:132ba2f069626f5dbc850f7f53d67c38
Created December 1, 2023 20:16
AbstractModelMeta a way to make django models abstract
class AbstractModelMeta(abc.ABCMeta, type(models.Model)):
"""
Set this as the metaclass to allow your abstract model to also be an ABC
ex:
```
class AbstractModelClass(models.Model, metaclass=AbstractModelMeta):
class Meta:
abstract = True
@abstractmethod
@markddavidoff
markddavidoff / gist:43cdae787afb90c13e04fb77329c01f8
Last active April 5, 2024 02:16
git shell plugins / functions / aliases
# warning these are hacky script thrown together with no care or understanding, so NO WARRANTY, USE AT YOUR OWN RISK
# you can install the git zsh plugin for more goodies, but these are some customized versions
# git zsh plugin: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/git/git.plugin.zsh
# also check out grecent
alias fetch='git fetch --all'
alias switch='git checkout'
alias switchb='gcb'
alias pull='ggpull'
alias branch='gcb'
@markddavidoff
markddavidoff / hmac_collision.py
Created May 14, 2021 03:00
hmac key collision
import hashlib
import hmac
string1 = 'plnlrtfpijpuhqylxbgqiiyipieyxvfsavzgxbbcfusqkozwpngsyejqlmjsytrmd'
string2 = 'eBkXQTfuBqp\'cTcar&g*'
key1 = hashlib.pbkdf2_hmac('sha1', string1.encode(), b'salt', 100000)
key2 = hashlib.pbkdf2_hmac('sha1', string2.encode(), b'salt', 100000)
hmac.new(key1, b"test", hashlib.sha256).hexdigest()
# '8122f91c70f4ac2205fc2039fc27bac3d54ccd91ee5ebf8d58fe13b406abd34a'
hmac.new(key2, b"test", hashlib.sha256).hexdigest()
@markddavidoff
markddavidoff / README.MD
Created August 22, 2019 00:03 — forked from nzec/README.MD
DeezLoader Offical Page

Deezloader Remix

(Recommended)

Available for macOS, Linux, Windows.

In the process of a rewrite. Final release will be v4.2.0. The repository might get DMCA' so, make Git Clones/Forks
You can compile yourself now to test for bugs (See rewrite branch in the Git repository)

@markddavidoff
markddavidoff / serverless-lambda-guide.md
Created August 16, 2019 16:57
Serverless Lambda Setup Instructions

Deploying to Lambda using serverless

This lambda uses serverless, a toolkit that makes building, deploying and maintaining serverless apps like this lambda painless. The instructions assume you're using AWS, if you're not, you'll have to tweak some things in serverless.yml to make it work with your provider

Setup serverless

Their getting started page is here, copy pasted for your convenience below (you'll also need to install npm first):

# Installing the serverless cli
@markddavidoff
markddavidoff / prepare-commit-msg
Last active April 16, 2021 05:06
Git Commit Hook to add branch name to commit
# commit hook to prepend the JIRA ticket from the branch name to the commit
# Installation for one repo:
# - copy this file into your git repo's .git/hooks folder
# - make sure its executable:
# chmod a+x repo-path/.git/hooks/prepare-commit-msg
# Installation for all new repos: (you'll still have to do the above for already cloned repos)
# - tell git where your global hooks live:
# git config --global init.templatedir '~/.git-templates'
# - mkdir -p ~/.git-templates/hooks
# - copy this file to ~/.git-templates/hooks
@markddavidoff
markddavidoff / slack-pagerduty-oncall.py
Last active September 25, 2024 14:27
Updates a Slack User Group with People that are on call in PagerDuty (updated for pagerduty v2 api and pull from env vars instead of KMS). Based on:https://gist.github.com/devdazed/473ab227c323fb01838f
"""
Lambda Func to update slack usergroup based on pagerduty rotation
From: https://gist.github.com/devdazed/473ab227c323fb01838f
NOTE: If you get a permission denied while setting the usergroup it is because there’s a workspace preference in slack
that limits who can manage user groups. At the time of writing it was restricted to owners and admins so i had to get
an owner to install the app. First i added them as a collaborator and then had them re-install the app, and got the new
auth token and added that to param store.
class TimestampField(serializers.DateTimeField):
def to_internal_value(self, value):
value = datetime.utcfromtimestamp(value)
return super(TimestampField, self).to_internal_value(value)
def to_representation(self, value):
if not value:
return value
return value.timestamp()
@markddavidoff
markddavidoff / slack-pagerduty-oncall.py
Created February 27, 2019 05:24 — forked from devdazed/slack-pagerduty-oncall.py
Updates a Slack User Group with People that are on call in PagerDuty
#!/usr/bin/env python
from __future__ import print_function
import json
import logging
from urllib2 import Request, urlopen, URLError, HTTPError
from base64 import b64decode