Skip to content

Instantly share code, notes, and snippets.

@iurisilvio
iurisilvio / 1.patch
Created January 8, 2014 13:10
A simple openpyxl profiler to optimized reader
--- a/openpyxl/reader/iter_worksheet.py Thu Jan 02 23:46:28 2014 +0100
+++ b/openpyxl/reader/iter_worksheet.py Tue Jan 07 22:26:45 2014 +0100
@@ -254,6 +254,7 @@
data_type = Cell.TYPE_FORMULA
value = "=" + formula
yield RawCell(row, column_str, coord, value, data_type, style_id, None)
+ element.clear()
@iurisilvio
iurisilvio / admin.py
Last active December 15, 2015 21:49
Flask-SuperAdmin with basic authentication
'''
This code is an example of Flask-SuperAdmin app with basic authentication. Use it for anything you like.
Based on this snippet: http://flask.pocoo.org/snippets/8/
'''
import flask
from flask.ext.superadmin import Admin, expose, AdminIndexView as _AdminIndexView
from flask.ext.superadmin.model import ModelAdmin as _ModelAdmin
from flask.ext.sqlalchemy import SQLAlchemy
diff --git a/django-emailmgr/emailmgr/urls.py b/www.freedomsponsors.org/djangoproject/emailmgr/urls.py
index 31f7a00..eada324 100644
--- a/django-emailmgr/emailmgr/urls.py
+++ b/www.freedomsponsors.org/djangoproject/emailmgr/urls.py
@@ -6,34 +6,34 @@ from views import email_add, email_list, email_delete, \
#add an email to a User account
urlpatterns = patterns('',
- url(
- r'^email/add/$',
@iurisilvio
iurisilvio / registration.diff
Last active December 14, 2015 10:18
www.freedomsponsors.org django-registration diff
diff --git a/djangoproject/registration/auth_urls.py b/djangoproject/registration/auth_urls.py
index 9bb1bc3..da93a3f 100644
--- a/djangoproject/registration/auth_urls.py
+++ b/djangoproject/registration/auth_urls.py
@@ -27,6 +27,13 @@ from django.conf.urls.defaults import *
from django.contrib.auth import views as auth_views
+# from registration.forms import MailerPasswordResetForm
+from django.conf import settings
// ~/.ejtp/console/idents.json
{
"[\"local\",null,\"mitzi\"]": {
"encryptor": [
"rsa",
"-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQDAZQNip0GPxFZsyxcgIgyvuPTHsruu66DBsESG5/Pfbcye3g4W\nwfg+dBP3IfUnLB4QXGzK42BAd57fCBXOtalSOkFoze/C2q74gYFBMvIPbEfef8yQ\n83uoNkYAFBVp6yNlT51IQ2mY19KpqoyxMZftxwdtImthE5UG1knZE64sIwIDAQAB\nAoGAIGjjyRqj0LQiWvFbU+5odLGTipBxTWYkDnzDDnbEfj7g2WJOvUavqtWjB16R\nDahA6ECpkwP6kuGTwb567fdsLkLApwwqAtpjcu96lJpbRC1nq1zZjwNB+ywssqfV\nV3R2/rgIEE6hsWS1wBHufJeqBZtlkeUp/VEx/uopyuR/WgECQQDJOaFSutj1q1dt\nNO23Q6w3Ie4uMQ59rWeRxXA5+KjDZCxrizzo/Bew5ZysJzHB2n8QQ15WJ7gTSjwJ\nMQdl/7SJAkEA9MQG/6JivkhUNh45xMYqnMHuutyIeGE17QndSfknU+8CX9UBLjsL\nw1QU+llJ3iYfMPEDaydn0HJ8+iinyyAISwJAe7Z2vEorwT5KTdXQoG92nZ66tKNs\naVAG8NQWH04FU7tuo9/C3uq+Ff/UxvKB4NDYdcM1aHqa7SEir/P4vHjtIQJAFKc9\n1/BB2MCNqoteYIZALj4HAOl+8nlxbXD5pTZK5UAzuRZmJRqCYZcEtiM2onIhC6Yq\nna4Tink+pnUrw24OhQJBAIjujQS5qwOf2p5yOqU3UYsBv7PS8IitmYFARTlcYh1G\nrmcIPHRtkxIwNuFxy3ZRRPEDGFa82id5QHUJT8sJbqY=\n-----END RSA PRIVATE KEY----
@iurisilvio
iurisilvio / gist:4579043
Created January 20, 2013 14:26
Using bottle.ResourceManager to serve static files with `bottle.static_file`
import os
import bottle
# consider root folder with:
# path1/file1.txt
# path2/file2.txt
# path3/file3.txt
rm = bottle.ResourceManager()
@iurisilvio
iurisilvio / gist:4024082
Created November 6, 2012 11:15
Use pdfcrowd url to pdf to create server side pdfs
import requests
response = requests.get('http://pdfcrowd.com/url_to_pdf/?pdf_name=google.pdf',
headers={'Referer': 'http://www.google.com'})
filename = response.headers['content-disposition'].split('"')[1]
with file(filename, 'w+b') as f:
f.write(response.content)
@iurisilvio
iurisilvio / main.py
Created September 6, 2012 10:52
bottle wsgilog with hooks
$ python main.py
Bottle server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.
wsgilog.log: Thu, 06 Sep 2012 07:50:38 INFO Before request to GET /hello/bottle
wsgilog.log: Thu, 06 Sep 2012 07:50:38 INFO After request to GET /hello/bottle
iurisilvio - - [06/Sep/2012 07:50:38] "GET /hello/bottle HTTP/1.1" 200 20
iurisilvio - - [06/Sep/2012 07:50:38] "GET /favicon.ico HTTP/1.1" 404 742
@iurisilvio
iurisilvio / gist:2895930
Created June 8, 2012 14:34
Redirect with StripPathMiddleware
# Untested example of permanent redirect to strip trailing slash
# It is better than internal strip the trailing slash because of SEO problems
# Based on StripPathMiddleware recipe: http://bottlepy.org/docs/dev/recipes.html#ignore-trailing-slashes
# Some pointer: http://www.adrianworlddesign.com/Knowledge-Base/seo/Watch-out-for/Trailing-slashes
class StripPathMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, e, h):
bottle.redirect(e['PATH_INFO'].rstrip('/'), code=301)
@iurisilvio
iurisilvio / gist:2703710
Created May 15, 2012 17:55
Generating App_WebReferences from command line
# RTFM SvcUtil.exe
"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Bin/SvcUtil.exe" //noconfig "//n:*,MyNamespace" //o:some/path/app_Code/WebServiceClientSoap.cs http://www.somedomain.com/service.asmx