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 / sexy_or.py
Created October 23, 2015 15:05
Use of "or" in conjunction with update for setting variables
d = dict()
d['a'] = 1
d.update(
{
'a': 2
}
)
print d
@datamafia
datamafia / timestamp.py
Created August 4, 2015 21:57
Shortest Possible Path to Unix Epoch Time in seconds
import calendar
from time import gmtime
print calendar.timegm(gmtime())
###################################
# Follow Me on Twitter @datamafia #
###################################
@datamafia
datamafia / buffer_multi_profile.py
Created April 3, 2015 18:18
Prototype for posting to multiple BufferApp profile ids
"""because the instructions were not clear to me, if I missed
something or this does not work drop a comment and I will fix.
After figuring this out I just wanted to put the solution
somewhere. Code pulled from working project."""
from __future__ import print_function
import os, urllib, url
buffer_base_url = 'https://api.bufferapp.com'
@datamafia
datamafia / ex.js
Last active November 18, 2015 21:54
Simple OOP reference for simple functionality across languages.
// class w/construct
var happy = function (msg) {
this.message = msg;
};
// method
happy.prototype.hello = function(){
console.log('hi');
console.log(this.message)
}
@datamafia
datamafia / config.cfg
Last active August 29, 2015 14:17
MVP Proto for *.cfg reading (Python 2.7)
[section]
key=value
otherKey=otherValue
@datamafia
datamafia / url_validation.py
Created March 24, 2015 01:03
Highly compliant Python URL validator
"""Check the validity of URL for maximum compliance, return "ready to
use" url address (with http:// as needed) on success
Abstract: Be dry. URL verification is a persistent need, this iteration
has been very handy for website use, such as profile creation and seems
to have a near total compliance with the changing URL schemas.
No code is prefect, olease let me know if you find error or have a proposed
patch.
@datamafia
datamafia / snippet.liquid
Created March 22, 2015 02:10
Shopify Snippets and similar items I don't feel like looking up again.
<!-- List tags for product -->
{% if product.tags.size > 0 %}
<div><span class="mellow" >tags:</span>
{% for tag in product.tags %}
<a href="/collections/all/{{ tag | replace: ' ','-' }}">{{ tag }}</a>
{% endfor %}
</div>
{% endif %}
@datamafia
datamafia / worpress_dev.php
Created March 5, 2015 16:26
Wordpress development script for previews
<?php
/*
Install this in your theme header.php as the first statement
(next line right after the <?php opening tag)
Change $magic_word to what ever variable you want to use,
default is "preview"
To use this, go to yoursite.com?preview and a session will
be created and access to the site will last as long as the
@datamafia
datamafia / mini_subclass.py
Created February 22, 2015 18:37
Minimal proto for subclass in Python (social media)
#!/usr/bin/env python
class A(object):
var = 'A'
def __init__(self):
self.test()
def test(self):
print 'Class A: '+self.var
@datamafia
datamafia / repr_and_haphazard.py
Created February 13, 2015 15:34
# Fast and haphazard introduction to repr in Python supports #twitter
#!/usr/bin/env python
# Fast and haphazard introduction
# to repr in Python
g = 'x'
print(g) # x
# reprESENTATION is if... (terminal)
print(repr(g)) # 'x'
repr = 'y'