Skip to content

Instantly share code, notes, and snippets.

View storborg's full-sized avatar

Scott Torborg storborg

View GitHub Profile
from sqlalchemy import MetaData, Column
from sqlalchemy.types import Integer, String
from sqlalchemy.orm import create_session, composite
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.mutable import MutableComposite
metadata = MetaData('sqlite://')
Base = declarative_base(metadata=metadata)
"""
Baidu is the shit. They made a super-awesome SimCity style map. To see it, go
to http://maps.baidu.com and zoom in on Beijing, then click the alternate modal
button in the top center of the maps area.
Once you're down marveling in the awesomeness you will surely be inspired to
make a giant wall-sized mural with the tiles.
Use this.
"""
$ python polymorphic_trick.py
2011-01-26 17:28:06,918 INFO sqlalchemy.engine.base.Engine.0x...5a90 PRAGMA table_info("employees")
2011-01-26 17:28:06,918 INFO sqlalchemy.engine.base.Engine.0x...5a90 ()
2011-01-26 17:28:06,919 INFO sqlalchemy.engine.base.Engine.0x...5a90 PRAGMA table_info("developers")
2011-01-26 17:28:06,919 INFO sqlalchemy.engine.base.Engine.0x...5a90 ()
2011-01-26 17:28:06,919 INFO sqlalchemy.engine.base.Engine.0x...5a90
CREATE TABLE employees (
id INTEGER NOT NULL,
name VARCHAR(50),
discriminator VARCHAR(50),
from sqlalchemy import MetaData, Column, ForeignKey, types, create_engine, orm
from sqlalchemy.ext.declarative import declarative_base, declared_attr
engine = create_engine('sqlite://')
sm = orm.sessionmaker(bind=engine)
metadata = MetaData()
metadata.bind = engine
Base = declarative_base(metadata=metadata)
import asyncore
import asynchat
import socket
class TalkHandler(asynchat.async_chat):
def __init__(self, server, conn, name):
asynchat.async_chat.__init__(self, conn)
self.name = name
self.server = server
<?php
/**
* Queue:
* Manages the flow to the web servers on high traffic event sales
* by placing customers into a line and then redirecting them to the
* web app serves as space is opened for trans processing
*
* @author Marc Urbaitel <[email protected]>
* @copyright In Ticketing
*/
/*
I found this on a customer site (for example) customersite.com. Looks like Google Analytics tracking code right?
<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://customersite.com" : "http://www.customersite.com"); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); var test = unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"); </script> <script type="text/javascript"> try{ var pageTracker = _gat._getTracker("UA-xxxxxx-x"); pageTracker._trackPageview(); } catch(err) {}</script>
Somehow my customer had been tricked into changing: "https://" : "http://" to: "https://customersite.com" : "http://www.customersite.com"
This makes the JavaScript called from http://www.customersite.comgoogle-analytics.com which then redirects to dxwebhost.com/l.js for the JavaScript. It looks like JavaScript file then uses a CSS vulnerability to lo
"""
Plot climb rate (in vertical ft/min) against grade. Break it up in 10-point
chunks?
"""
from datetime import datetime
from xml.dom.minidom import parse
def grouper(n, iterable):
"""
Demonstration of a filtering issue that was introduced in sqlalchemy r6748.
In the post-r6748 behavior, the filter param False is not processed before being
passed to the DBAPI. E.g. this is echoed:
SELECT foos.id AS foos_id, foos.data AS foos_data FROM foos WHERE foos.data = ?
(False,)
Instead of this (pre-r6748):
diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py
index e126fe6..1862449 100644
--- a/lib/sqlalchemy/ext/associationproxy.py
+++ b/lib/sqlalchemy/ext/associationproxy.py
@@ -266,6 +266,33 @@ class AssociationProxy(object):
'no proxy_bulk_set supplied for custom '
'collection_class implementation')
+ def _proxy_filter_operator(name):
+ def _wrapped_operator(self, object):