Skip to content

Instantly share code, notes, and snippets.

View chroto's full-sized avatar
🦍

Chris Proto chroto

🦍
View GitHub Profile
@chroto
chroto / all_aws_managed_policies.json
Created December 17, 2020 13:41 — forked from gene1wood/all_aws_managed_policies.json
A list of all AWS managed policies and they're policy documents as well as a short script to generate the list
This file has been truncated, but you can view the full file.
{
"APIGatewayServiceRolePolicy": {
"Arn": "arn:aws:iam::aws:policy/aws-service-role/APIGatewayServiceRolePolicy",
"AttachmentCount": 0,
"CreateDate": "2019-10-22T18:22:01+00:00",
"DefaultVersionId": "v6",
"Document": {
"Statement": [
{
@chroto
chroto / install.sh
Created March 4, 2020 17:36 — forked from mkubenka/install.sh
OpenVPN Access Server Letsencrypt
#!/bin/sh
apt-get -y install git bc
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
mkdir /etc/letsencrypt
var fs = require('fs');
// Lambda knows what region it's in but a local execution doesn't, so preload the SDK and set the region
// This will only work if the same variable name is used in the Lambda function file
var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
// validate arguments
if(process.argv.length < 4) {
@chroto
chroto / death.py
Created June 9, 2014 20:43
Behold I am Death, destroyer of worlds
def unpatch_models():
"""unpatch"""
if __backup == {}:
return
for module_to_unpatch in model_mods:
name = module_to_unpatch.__name__
for cls_name in vars(module_to_unpatch).get('__patchable__', []):
setattr(module_to_unpatch,
cls_name,
__backup[name][cls_name])
@chroto
chroto / .gitignore
Created December 3, 2012 23:54
Intro to crypto Week 1 Problem Sets
*.pyc
@chroto
chroto / sms_gateways.py
Created October 16, 2012 15:22
A tuple of tuples consisting of (SMS gateway, name of carrier)
SMS_GATEWAYS = (
(u'{number}@digitextdm.com', u'Digicel (Dominica)(Dominica)'),
(u'{number}@message.alltel.com', 'Alltel'),
(u'0{number}@smsmail.eplus.de', u'E-Plus(Germany)'),
(u'{number}@sms.edgewireless.com', u'Edge Wireless(USA)'),
(u'{number}@SMS.elementmobile.net', u'Element Mobile(USA)'),
(u'{number}@emtelworld.net', u'Emtel(Mauritius)'),
(u'{number}@echoemail.net', u'Esendex(UK)'),
(u'{number}@echoemail.net', u'Esendex(USA)'),
(u'{number}@esendex.net', u'Esendex(Spain)'),
@chroto
chroto / index.html
Created July 13, 2012 21:21
Django - detect MIME type
{% for file in mixed_files %}
<a href=""
{% if "image" in file|mimetype %}class="fancybox"{% endif %}
{% if "pdf" in file|mimetype %}rel="external"{% endif %}
>foo</a>
{% endfor %}
@chroto
chroto / gist:3107097
Created July 13, 2012 20:09
timedelta functions
def human_time(td):
"""
Return a more human readable version of a timedelta instance
"""
ret_str = ""
translate_tuple = [
"day",
"hour",
"minute",
"second"]
@chroto
chroto / gist:3107078
Created July 13, 2012 20:06
Find a dict key from its value
def reverse_dict_lookup(d, val):
"""
Performs a reverse lookup on a dictionary object, raising ValueError on
failure.
>>> reverse_dict_lookup({'a': 1, 'b': 2, 'c': 3}, 2)
'b'
>>> reverse_dict_lookup({}, 'a')
Traceback (most recent call last):
...
@chroto
chroto / bookstore.py
Created April 16, 2012 07:06
SA Bookstore
"""
# Bookstore
- Book => Images
- Book <=> Author
- Book <=> Genre
- Book -> Genre (Primary)