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>
<?
// 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{
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 April 11, 2016 20:00
Every Cobra Motor model and KV I could Find on http://innov8tivedesigns.com/
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 April 3, 2016 22:07
3 April NPR Sunday Puzzle Solution Kata
# 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',
@datamafia
datamafia / shopify_helper.py
Created February 23, 2016 20:19
Shopify API helper
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 January 27, 2016 02:37
Looking for element in tuple inside list via len() as a boolean. Too cool to forget.
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 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