This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Form(web.form.Form, object): | |
def __init__(self, name, *inputs, **kw): | |
super(Form, self).__init__(*inputs, **kw) | |
self.name = name | |
def save_state(self): | |
session.forms[self.name] = dict( | |
notes = dict((i.name, i.note) for i in self.inputs if i.note ), | |
values = dict((i.name, i.get_value()) for i in self.inputs ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from web.db import DB, SQLQuery, register_database | |
class SphinxDB(DB): | |
def __init__(self, **keywords): | |
import MySQLdb as db | |
if 'pw' in keywords: | |
keywords['passwd'] = keywords['pw'] | |
del keywords['pw'] | |
if 'charset' not in keywords: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import web | |
import json | |
from restful_controller import RESTfulController | |
urls = ( | |
r'/resources(?:/(?P<resource_id>[0-9]+))?', | |
'ResourceController', | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d = web.input(page_id=None, sizes=[]) | |
File "/home/edzohogusava/lib/python2.7/web/webapi.py", line 330, in input | |
out = rawinput(_method) | |
File "/home/edzohogusava/lib/python2.7/web/webapi.py", line 303, in rawinput | |
a = cgi.FieldStorage(fp=fp, environ=e, keep_blank_values=1) | |
File "/usr/local/lib/python2.7/cgi.py", line 508, in __init__ | |
self.read_multi(environ, keep_blank_values, strict_parsing) | |
File "/usr/local/lib/python2.7/cgi.py", line 637, in read_multi | |
environ, keep_blank_values, strict_parsing) | |
File "/usr/local/lib/python2.7/cgi.py", line 510, in __init__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AwesomeObject = function() { | |
this.init() | |
}; | |
AwesomeObject.prototype = { | |
init: function() { | |
_.bindAll(this, 'onSuccess', 'onError', 'onComplete') | |
// or | |
this.onSuccess = $.proxy(this.onSuccess, this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: require(['twitter'], function (twitter) { twitter.load() }) | |
define(function() { | |
var twitter = { | |
load: executeWhenReady('load') | |
} | |
// Return wrapped function that will | |
// be executed only when twttr is ready | |
function executeWhenReady (funcName) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Script to convert png files to RGBA color space | |
# Requires Pillow (pip install Pillow) | |
# | |
import os | |
import fnmatch | |
from PIL import Image | |
for root, dirnames, filenames in os.walk('sprites'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function() { | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | |
window.ga('create', 'UA-XXXXXXXX-X') | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This mixin is used to ease workaround explained in this article | |
// http://n12v.com/css-retina-and-physical-pixels/ | |
// Creates linear gradient for specified border | |
@function border-gradient($side, $color: currentColor, $width: 0.5px) { | |
@if $side == top { | |
@return linear-gradient(180deg, $color, $color 50%, transparent 50%) top left / 100% #{$width * 2} no-repeat; | |
} @else if $side == bottom { | |
@return linear-gradient(0, $color, $color 50%, transparent 50%) bottom right / 100% #{$width * 2} no-repeat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<!-- load combined svg file (with symbols) into body--> | |
<script> | |
(function (doc) { | |
var scripts = doc.getElementsByTagName('script') | |
var script = scripts[scripts.length - 1] | |
var xhr = new XMLHttpRequest() | |
xhr.onload = function () { |
OlderNewer