Skip to content

Instantly share code, notes, and snippets.

@puentesarrin
puentesarrin / xxd.py
Created September 15, 2013 02:15
Basic xxd command using Python
# -*- coding: utf-8 -*-
import os.path
import string
import sys
def print_buf(counter, buf):
buf2 = [('%02x' % ord(i)) for i in buf]
print '{0}: {1:<39} {2}'.format(('%07x' % (counter * 16)),
' '.join([''.join(buf2[i:i + 2]) for i in range(0, len(buf2), 2)]),
@puentesarrin
puentesarrin / FileSplitter.py
Last active February 16, 2021 05:19 — forked from msharp/FileSplitter.py
python script to split a (large) file into multiple (smaller) files with specified number of lines
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
class FileSplitter(object):
def __init__(self):
self.parse_args(sys.argv)
@puentesarrin
puentesarrin / index.html
Created April 5, 2013 18:14
TornadoMail demo using a tornado.template.Loader.
<html>
<head>
<title>TornadoMail Demo</title>
</head>
<body>
<form method="post" action="/">
<input type="text" name="subject"/>
<input type="text" name="email"/>
<input type="submit" value="Send message"/>
</form>
diff --git a/ad_codes/models/__init__.py b/ad_codes/models/__init__.py
index 5abedab..75bc44f 100644
--- a/ad_codes/models/__init__.py
+++ b/ad_codes/models/__init__.py
@@ -20,12 +20,12 @@ class AdCodesFields(object):
tablet = fields.StringField()
amp = fields.StringField()
ia = fields.StringField()
+ display = fields.BooleanField(default=False)
@puentesarrin
puentesarrin / demo.conf
Created April 1, 2013 18:16
Tornado, auto reloading/parsing options when config file is modified.
greeting = 'Hello, World'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import raven
CURRENT = os.path.dirname(__file__)
sys.path.insert(0, os.path.realpath(os.path.join(CURRENT, '..', '..')))
sys.path.insert(1, os.path.realpath(os.path.join(CURRENT, '..', '..', 'rebelmouse')))
@puentesarrin
puentesarrin / ez_setup.py.diff
Created April 25, 2016 18:30
Setuptools quickfix :)
➜ ~ diff ez_setup.py ez_setup.py.edited
331c331
< url = download_base + zip_name
---
> url = 'https://pypi.python.org/packages/86/ee/622e83b0dbede6d48891ed209fa5ca83fcc485f9b6696cf56796eda40806/{}'.format(zip_name)
@puentesarrin
puentesarrin / gist:8290754
Created January 6, 2014 22:13
Python alternative installation
$ cd /usr/local/src
$ wget http://www.python.org/ftp/python/3.4.0/Python-3.4.0b2.tgz
$ tar -xzf Python-3.4.0b2.tgz Python-3.4.0b2
$ cd Python-3.4.0b2
$ ./configure --enable-shared --prefix=/usr/local
$ make
$ make altinstall
$ python3.4
@puentesarrin
puentesarrin / bonzo_sample.py
Created August 26, 2013 02:21
Bonzo sample
import tornado.ioloop
import email
from bonzo.smtpserver import SMTPServer
def receive_message(message):
print "New received message: "
print "From: " + message['from']
print "Subject: " + message['subject']
# -*- coding: utf-8 *-*
import logging
import motor
import pymongo
from mongolog.handlers import MongoHandler
from tornado import ioloop, options, web
from tornado.options import options as opts