Skip to content

Instantly share code, notes, and snippets.

☠️
Always down for Django!

Marc datamafia

☠️
Always down for Django!
Block or report user

Report or block datamafia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@datamafia
datamafia / simple_allow_all.xml
Created May 23, 2019 — forked from philfreo/simple_allow_all.xml
AWS S3 CORS policy examples
View simple_allow_all.xml
<?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>
View cutsom_appl.php
<?
// Session may not be started on this script, if not init session
if (!session_id()) {
session_start();
}
// double check, once for the key, again that the result is an int larger than 0 (as WP will follow the AI rule in the DB)
if (array_key_exists('some_custom_var', $_SESSION) and $_SESSION['some_custom_var'] > 0){
echo 'User is valid with id:'.$_SESSION['some_custom_var'];
}else{
View slack_delete.py
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 / cobra.txt
Created Apr 11, 2016
Every Cobra Motor model and KV I could Find on http://innov8tivedesigns.com/
View cobra.txt
Cobra CM-2204/28 Multirotor Motor, Kv=2300
Cobra C-2202/70 Brushless Motor, Kv=1530
Cobra C-2203/28 Brushless Motor, Kv=2800, E36-F1S
Cobra C-2203/34 Brushless Motor, Kv=2300
Cobra C-2203/46 Brushless Motor, Kv=1720
@datamafia
datamafia / five_letter_words.py
Created Apr 3, 2016
3 April NPR Sunday Puzzle Solution Kata
View five_letter_words.py
# source http://www.bestwordlist.com/5letterwords.txt
WORDS = [
'AAHED', 'AALII', 'AARGH', 'AARTI', 'ABACA', 'ABACI', 'ABACK', 'ABACS', 'ABAFT', 'ABAKA', 'ABAMP',
'ABAND', 'ABASE', 'ABASH', 'ABASK', 'ABATE', 'ABAYA', 'ABBAS', 'ABBED', 'ABBES', 'ABBEY', 'ABBOT',
'ABCEE', 'ABEAM', 'ABEAR', 'ABELE', 'ABETS', 'ABHOR', 'ABIDE', 'ABIES', 'ABLED', 'ABLER', 'ABLES',
'ABLET', 'ABLOW', 'ABMHO', 'ABODE', 'ABOHM', 'ABOIL', 'ABOMA', 'ABOON', 'ABORD', 'ABORE', 'ABORT',
'ABOUT', 'ABOVE', 'ABRAM', 'ABRAY', 'ABRIM', 'ABRIN', 'ABRIS', 'ABSEY', 'ABSIT', 'ABUNA', 'ABUNE',
'ABUSE', 'ABUTS', 'ABUZZ', 'ABYES', 'ABYSM', 'ABYSS', 'ACAIS', 'ACARI', 'ACCAS', 'ACCOY', 'ACERB',
'ACERS', 'ACETA', 'ACHED', 'ACHES', 'ACHOO', 'ACIDS', 'ACIDY', 'ACING', 'ACINI', 'ACKEE', 'ACKER',
'ACMES', 'ACMIC', 'ACNED', 'ACNES', 'ACOCK', 'ACOLD', 'ACORN', 'ACRED', 'ACRES', 'ACRID', 'ACTED',
View shopify_helper.py
def prepare_for_api(str_json):
"""
Prepare a json string API use by escaping double quotes and removing \n new line breaks
:param str_json: string
:return: string
Note: Use pattern is to wrap data at the last possible moment to avoid extra escaping.
"""
str_json = re.sub(' +', ' ', str_json) # kills multi whitespace
str_json = str_json.replace('\n', '') # kill new line breaks caused by triple quoted raw strings
str_json = str_json.replace('"', '\\"') # address double quotes
@datamafia
datamafia / list_tup_lokky.py
Created Jan 27, 2016
Looking for element in tuple inside list via len() as a boolean. Too cool to forget.
View list_tup_lokky.py
t = [
('a', 'b'),
('c', 'd')
]
if len([item[1] for item in t if item[0] == 'a']):
print 'yes'
else:
print 'no'
# yes
if len([item[1] for item in t if item[0] == 'e']):
@datamafia
datamafia / aescrypt.py
Created Jan 6, 2016 — forked from SpotlightKid/aescrypt.py
Encrypt/decrypt files with symmetric AES cipher-block chaining (CBC) mode.
View aescrypt.py
#!/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 Jan 3, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 Nov 13, 2015 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.
View bobp-python.md

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
You can’t perform that action at this time.