Skip to content

Instantly share code, notes, and snippets.

"""
Example MQLogHandler to emit log messages to an IronIO Queue
"""
import sys
import json
import logging
from iron_mq import *
logging.basicConfig(level=logging.INFO,
import os
import sys
import csv
path = os.path.normpath(os.path.join(os.getcwd(), '..'))
sys.path.append(path)
path = os.path.normpath(os.path.join(os.getcwd(), '..','possync'))
sys.path.append(path)
from django.core.management import setup_environ
@jtallieu
jtallieu / VEND: mkVoidJs.py
Created August 15, 2014 17:43
Python script using the POSSync python VendAPI to generate javascript that can be used in a Firebug console tol void a large number of orders for a specific register https://github.com/xoho/vendhq-api-python
"""
This script will generate the necessary Javascript
to void CLOSED orders from a specific Register. The javascript
is intended to run in a Firebug console.
Nahnay Software, LLC
Makers of www.pos-sync.com
Authors:
------------
@jtallieu
jtallieu / _void.js
Last active August 29, 2015 14:05
This file is intended to be used as a template for https://gist.github.com/jtallieu/e6a209a436465d0743e4 VEND: mkVoidJs.py. This JS gist expects a list of order id's
var void_order = function(index){
if (index < ids.length){
var id = ids[index];
console.log("(" + index + ") voiding order " + id);
$.ajax({
type: "POST",
url: "/register_sale/void",
data: {id:id, return:null},
success: function(data, stat, xhr){
console.log("Success " + xhr.status);
@jtallieu
jtallieu / void_orders.js
Created August 15, 2014 17:49
Generated js to void closed Vend orders.
var ids=["3b0e6b85-b0dc-2556-30e6-5b8f67d166b8","7deef2c5-c2c1-95d1-f17e-9c83e5f8169b"];
var void_order = function(index){
if (index < ids.length){
var id = ids[index];
console.log("(" + index + ") voiding order " + id);
$.ajax({
type: "POST",
url: "/register_sale/void",
data: {id:id, return:null},
@jtallieu
jtallieu / masquerade.py
Created October 15, 2014 12:50
Django Middleware that supports masquerading as another user without authentication. Requires views that will set the _masq_user session variable.
from django.contrib import auth
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import SimpleLazyObject
def get_user(request):
if request.session.has_key("_masq_user"):
return request.session["_masq_user"]
if not hasattr(request, '_cached_user'):
request._cached_user = auth.get_user(request)
@jtallieu
jtallieu / view.py
Created October 15, 2014 12:53
Using the django masquerade.py middleware
@user_passes_test(lambda u: u.is_superuser)
def view_as_user(request, id):
"""
Allows a priveledged user to view the website as another without
logging in as that user
"""
log.info("Finding user %s" % id)
try:
user = User.objects.get(pk=id)
import requests
import datetime
import calendar
import json
token = "------------"
project_id= "--------------"
iron_host = "worker-aws-us-east-1.iron.io/2/projects/%s" % project_id
import dhashpy
_dhash = None
_host = None
_port = None
class DHash(object):
"""Wrap the dhashpy to make the simple things simpler"""
def __init__(self, dhash):
@jtallieu
jtallieu / pyscreen_sample_5.py
Last active September 9, 2016 20:11
Eagle Eye Networks Inc :: Python screening - Debug I
"""
::Eagle Eye Networks Inc.:::
::Python screening::
The following script is purposley written poorly.
Fix the 'magic' function.
"""
def magic(X, additional=[]):