Skip to content

Instantly share code, notes, and snippets.

View datamafia's full-sized avatar
☠️
not here

" and 1=1 " datamafia

☠️
not here
  • At Desk
View GitHub Profile
@datamafia
datamafia / simple_allow_all.xml
Created May 23, 2019 15:55 — forked from philfreo/simple_allow_all.xml
AWS S3 CORS policy examples
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
<AllowedHeader>Content-*</AllowedHeader>
<AllowedHeader>Host</AllowedHeader>
</CORSRule>
import requests
import time
import json
token = ''
#Delete files older than this:
ts_to = int(time.time()) - 30 * 24 * 60 * 60
def list_files():
@datamafia
datamafia / aescrypt.py
Created January 6, 2016 03:11 — forked from SpotlightKid/aescrypt.py
Encrypt/decrypt files with symmetric AES cipher-block chaining (CBC) mode.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Encrypt/decrypt files with symmetric AES cipher-block chaining (CBC) mode.
Usage:
File Encryption:
aescrypt.py [-f] infile [outfile]
@datamafia
datamafia / 0_reuse_code.js
Created January 3, 2016 03:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@datamafia
datamafia / bobp-python.md
Created November 13, 2015 16:16 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
var scimoz = ko.views.manager.currentView.scimoz,
savedPos = scimoz.currentPos,
savedLinePos = scimoz.firstVisibleLine;
try {
scimoz.text = scimoz.text.replace(/\t/gm, " ");
scimoz.gotoPos(savedPos);
scimoz.lineScroll(0, savedLinePos-scimoz.firstVisibleLine);
} catch(e) {
return true;
<p>
My programming language of preference is python for the simple reason that I feel I write better code faster with it then I do with other languages. However also has a lot of nice tricks and idioms to do things well. And partly as a reminder to myself to use them, and partly because I thought this might be of general interest I have put together this collection of some of my favourite idioms. I am also putting this on <a href="https://gist.github.com/codefisher/9d7993ddbf404c505128">gist.github.com</a> so that anyone that wants to contribute there own things can, and I will try and keep this post up to date.
</p>
<h2>enumerate</h2>
<p>
A fairly common thing to do is loop over a list while also keeping track of what index we are up to. Now we could use a <code>count</code> variable, but python gives us a nicer syntax for this with the <code>enumerate()</code> function.
<script src="https://gist.github.com/codefisher/9d7993ddbf404c505128.js?file=enumerate.py"></script>