Skip to content

Instantly share code, notes, and snippets.

View madzak's full-sized avatar

Zakaria Zajac madzak

View GitHub Profile
#!/usr/bin/env python
import sys, random, re, urllib, urllib2, json
def process_msg(line):
image_me = re.compile("(image|im)( me)? (.*)", re.IGNORECASE).match(line)
animate_me = re.compile("animate me (.*)", re.IGNORECASE).match(line)
if image_me:
return fetch_image(image_me.group(3))
elif animate_me:
class AdminHostingForm(forms.ModelForm):
total_users = ReadOnlyField()
def __init__(self, *args, **kwargs):
super(AdminHostingForm, self).__init__(*args, **kwargs)
instance = getattr(self, 'instance', None)
self.fields['account_manager'] = forms.ChoiceField(required=False)
try:
accountManagers = OeUsers("datalogicaccountmgr")
class ActUserForm(forms.ModelForm):
user_status = ReadOnlyField()
activation_date = ReadOnlyField()
def __init__(self, *args, **kwargs):
super(ActUserForm, self).__init__(*args, **kwargs)
instance = getattr(self, 'instance', None)
if instance and instance.id:
self.fields['user_status'].initial = instance.get_user_status_display()
@madzak
madzak / gist:1260246
Created October 3, 2011 21:03 — forked from sleekslush/gist:1260184
Client-side smash markup
<html>
<head>
<link rel="stylesheet/wesumo" type="text/css" href="http://meyerweb.com/eric/tools/css/reset/reset.css" />
<link rel="stylesheet/wesumo" type="text/css" href="http://a.fsdn.com/sd/classic.css?release_20110818.02" />
<script type="text/javascript" src="wesumo.debug.js?key=po0eYa_0R9W1QZ8Q7BGRiw&smash=css"></script>
</head>
<body>
<span id="message">Smash that shit</span>
<script type="text/wesumoscript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script>
<script type="text/wesumoscript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.js"></script>
class CompanyWorkNotesForm(forms.ModelForm):
class Meta:
model = CompanyWorkNotes
exclude = ('oe_id')
<h3>Work Notes</h3>
<form action="." method="post">
<table class="form">
{{ notesForm.as_table }}
</table>
<input name="notesForm" type="submit" value="Save Notes" />
{% csrf_token %}
</form>
class CompanyWorkNotes(models.Model):
class Meta:
managed=False
oe_id = models.IntegerField(primary_key=True)
notes = models.TextField()
def __init__(self, company_id):
request = OeWebRequest("notes", "4242")
data = request.getData()