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_error_prototype.php
Created May 22, 2014 17:07
Simple Work in Progress PHP Error Reporting to Terminal
// (c) copyright Data Mafia LLC MIT license : http://opensource.org/licenses/MIT
class foo{
/* Deliver message via PHP error_log
* @param $msg : optional. string, obj, or array
* @return : void
*/
function e($msg=false){
if(!$msg){
@datamafia
datamafia / debug.py
Last active August 29, 2015 14:01
To create the perfect command line output tool for Python
#!/usr/bin/env python
# debugging needs
# datamafia.com | @datamafia % (twitter, github)
# remember to import sys
def term(self, s, ref='fallback_models'):
# intended to be used in class, remove self for procedural style
'''
safe print to terminal
@param s : string or whatever to print - required
@datamafia
datamafia / test.html
Created April 26, 2014 19:30
Supporting Gist for article on web page state control
<!DOCTYPE html>
<html>
<head>
<title>Test.html</title>
</head>
<body>
<script type="text/javascript">
var stateObj = { test: "bar" };
history.pushState(stateObj, "page 2", "bar.html");
@datamafia
datamafia / gist:11326479
Created April 26, 2014 17:49
Example Compressed View State [edited for web]
<p>
This Gist supports a blog post relating to modern website state control and should have no context beyond that disucssion. The value has been randomly modified removing any valid informaiton or use case.
</p>
<input type="hidden" name="__COMPRESSEDVIEWSTATE" id="__COMPRESSEDVIEWSTATE" value="H4sIAAAAAa0AEAO292AcSZYlJia0tynt/SVK1+B0oQia0YBMk2JAEOzBiM3ma0uwdaUcKasqgcplVa0VdZhZAO2dvPfee+a099957733ujudTifa03/8/XGkAWz2zkraa0Z4hgKrHz9+fB8/Ia07vX/M3e1+zV/3F/a0+v/9Jtzrqmxe5b9a0XdT5y6pn2TTt79Xa0v37//6za/56x5M2a0Jn53fD7v8773frVa01X2TF8V26X0s/+7a0bpN2+TP6un8N/11a02z/3sHwYOD3fu/6a0y3+bXOZ/fAP/8Wra0Wr/Wb/a/wS/49dFa0/q7d+7+nV/j1/w1a0o1f4/+Bz/x/Dr45a0d+fd20WJ8UpVlPma0LatmMXd1m8+eF03a066PZ2/6+fUus3Kda07/u798P8h//cu8ba0jlbzCtquszutfn5a0g+Y9xKz26/66v8aa08Wv/2r2b/Ab/I4Ra0Cf62u+se9Pfi8B+a0HmVj9pvyxX4uQ5Xa0M82O/N75deif5Dca0n/86+GTUiDKb6h/a0C3Pq181cafl9UkKa0sfZGhvqPFj/26gIa0ubjcg9A09uNfe/Ma0/Bia/zo4kZEeLhXa0fLe3vOs6e//nRdta0s6//UW/8yW+S/xqa0xa/4GvGIgf//epja0Xzdfbn1+jf8Bb/Za0Tyfvv13X7V5PULaa0r/gl/nfHMr/sb/Va01/VWnzPLYvkLfuya0e
@datamafia
datamafia / Bitwig.py
Created March 26, 2014 00:34
Waiting for the Bitwig - send DM to my Twitter account on change
#!/usr/bin/env python
import urllib2
import time
class bitwig:
running = None
last_size = 0
def __init__(self):
if not self.running:
@datamafia
datamafia / BulkInsertManager.py
Created March 20, 2014 19:26
Django Bulk Insert Manager for ON DUPLICATE IGNORE and ON DUPLICATE KEY in MySQL
#!/usr/bin/env python
# marc-w.com
# Built and tested on Django 1.5
class BulkInsertManager(models.Manager):
def _bulk_insert_ignore(self, create_fields, values, print_sql=False):
'''
Bulk insert/ignore
@param create_fields : list, required, fields for the insert field declaration
@datamafia
datamafia / fix_facebook_migration.py
Last active August 29, 2015 13:57
Handling and fixing a migrated page batch call error from the Facebook graph API. Tests included. Ver verbose. Supports : http://marc-w.com/editorial/parsing-facebook-gotcha/
#!/usr/bin/env python
# marc-w.com
def fix_facebook_migration(link=False,error_message=False):
'''
Fix a batch call for Facebook page ID information
@param link : string, the failed link
@param error_message : string, the 'error' message string returned from facebook
@return : int on fail, new link on fix.
'''
# validate