Skip to content

Instantly share code, notes, and snippets.

View ralphbean's full-sized avatar

Ralph Bean ralphbean

  • Red Hat, Inc
  • Rochester, NY
View GitHub Profile
@ralphbean
ralphbean / martha.py
Created December 13, 2011 19:20
Overzealous decoration
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Decorating every function in a module """
import types
def some_command():
""" This command will knock your socks off! """
print "Hello",
try:
from lockfile import LockFile
except ImportError:
from lockfile import FileLock as LockFile
@ralphbean
ralphbean / scanner.py
Created January 31, 2012 21:45
Scann0r
#!/usr/bin/env python
""" This is a python script for Paul! """
import os
for base_dir, sub_dirs, files in os.walk(os.getcwd()):
for filename in files:
print base_dir + "/" + filename
@ralphbean
ralphbean / root.py
Created February 9, 2012 13:28
Additional methods to controller/root.py
# Add these imports near the top of the file
from sqlalchemy import desc
from datetime import datetime, timedelta
import random
# Add this function OUTSIDE of the RootController
def log_message(msg):
model.DBSession.add(model.Message(msg=msg))
@ralphbean
ralphbean / stuff.py
Created February 9, 2012 13:31
tg2app/model/stuff.py
# -*- coding: utf-8 -*-
"""My Login Modules stuff."""
from sqlalchemy import *
from sqlalchemy.orm import mapper, relation
from sqlalchemy import Table, ForeignKey, Column
from sqlalchemy.types import Integer, Unicode, DateTime
#from sqlalchemy.orm import relation, backref
from datetime import datetime
@ralphbean
ralphbean / waiting.js
Created February 9, 2012 13:34
tg2app/public/js/waiting.js
(function() {
var globals, poll;
globals = typeof exports !== "undefined" && exports !== null ? exports : this;
globals.polling_interval = 3000;
poll = function() {
var last, name, toks;
toks = window.location.href.split('/');
@ralphbean
ralphbean / waiting.mak
Created February 9, 2012 13:37
tg2app/templates/waiting.mak
<%inherit file="local:templates.master"/>
<script type="text/javascript" src="/js/waiting.js"></script>
<div id="users" class="running_list">
<h2>Logged in users</h2>
<ul>
% for user in users:
<li>${user['name']}</li>
% endfor
</ul>
@ralphbean
ralphbean / auth-fb.js
Created February 9, 2012 13:41
tg2app/public/js/auth-fb.js
(function() {
var act_on_login, check_auth, force_login, globals;
globals = typeof exports !== "undefined" && exports !== null ? exports : this;
globals.appID = "Your APP Id";
globals.logged_in_callback = function(obj) {
console.log(obj);
if (obj.error != null) {
@ralphbean
ralphbean / auth-faked.js
Created February 9, 2012 13:42
tg2app/public/js/auth-faked.js
(function() {
var check_auth, globals;
globals = typeof exports !== "undefined" && exports !== null ? exports : this;
globals.logged_in_callback = function(user) {
return window.location = '/do_login?' + $.param({
name: user.name,
access_token: globals.access_token
});
@ralphbean
ralphbean / master.mak
Created February 9, 2012 14:03
tg2app/templates/master.mak
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
${self.meta()}
<title>${self.title()}</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
% if tmpl_context.in_production:
<script type="text/javascript" src="${tg.url('/js/auth-fb.js')}"></script>
% else: