Skip to content

Instantly share code, notes, and snippets.

View passy's full-sized avatar
😷
Wear a mask.

Pascal Hartig passy

😷
Wear a mask.
View GitHub Profile
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
from flask import Module, request, redirect, url_for, render_template, abort
from formalchemy import FieldSet
from example import db
from example import Service, User, Forum, Category, Topic, Post
mod = Module(__name__)
models = {
@rozza
rozza / django_jinja.py
Created July 12, 2010 09:49
Django 1.2 and Jinja2 loader
"""
Using Jinja2 with Django 1.2
Based on: http://djangosnippets.org/snippets/2063/
To use:
* Add this template loader to settings: `TEMPLATE_LOADERS`
* Add template dirs to settings: `JINJA2_TEMPLATE_DIRS`
If in template debug mode - we fire the template rendered signal, which allows
debugging the context with the debug toolbar. Viewing source currently doesnt
/*
* def.js: Simple Ruby-style inheritance for JavaScript
*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(global) {
__super__ = function(){
var caller = __super__.caller;
@jashkenas
jashkenas / minified-single-line-bookmarket.js
Created October 27, 2010 19:06
Handy Bookmarklet to recursively reload all CSS stylesheets for each frame in the page.
(function(){function f(b){b=b||window;for(var g=b.document.getElementsByTagName("link"),a=0,d=g.length;a<d;a++){var e=g[a],c=e.href;if(c&&/stylesheet/i.test(e.rel)){c=c.replace(/(&|%5C?)forceReload=\d+/,"");var h="forceReload="+(new Date).valueOf();e.href=c+(c.indexOf("?")>=0?"&":"?")+h}}a=0;for(d=b.frames.length;a<d;a++)f(b.frames[a])}f()})();
@dchaplinsky
dchaplinsky / _pagination.html
Created November 12, 2010 10:25
Port of django_pagination package to make it works with jinja2
{% macro render_pagination(pages) -%}
{% if pages.is_paginated %}
<div class="pagination">
{% if pages.page_obj.has_previous() %}
<a href="?page={{ pages.page_obj.previous_page_number() }}{{ pages.getvars }}{{ pages.hashtag }}" class="prev">&lsaquo;&lsaquo; previous</a>
{% else %}
<span class="disabled prev">&lsaquo;&lsaquo; previous</span>
{% endif %}
{% for page in pages.pages %}
{% if page %}
@klipstein
klipstein / b64field.py
Created November 22, 2010 12:25
Base64 file handling for django-tastypie
import base64
import os
from tastypie.fields import FileField
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64FileField(FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
It uses base64 for en-/decoding the contents of the file.
Usage:
@leegao
leegao / Swap.c
Created January 19, 2011 22:45
C is fucking crazy.
#include <stdio.h>
void(*swap)() = (void(*)()) "\x8b\x44\x24\x04\x8b\x5c\x24\x08\x8b\x00\x8b\x1b\x31\xc3\x31\xd8\x31\xc3\x8b\x4c\x24\x04\x89\x01\x8b\x4c\x24\x08\x89\x19\xc3"
"Oh, there you are Mr. Insanity...";
int main(){ // works on GCC 3+4
int a = 37, b = 13;
swap(&a, &b);
printf("%d%d",a,b);
}
@rduplain
rduplain / README.rst
Created February 13, 2011 05:21
Demonstrate use of fixture with Flask-SQLAlchemy and Flask-Testing.

Demonstrate use of fixture with Flask-SQLAlchemy and Flask-Testing. February 13, 2011 Ron DuPlain <ron.duplain@gmail.com>

Post any feedback to: flask@librelist.org

Get this gist:

git clone git://gist.github.com/824472.git Flask-SQLAlchemy-Fixture
cd Flask-SQLAlchemy-Fixture
@romannurik
romannurik / DashboardLayout.java
Created March 23, 2011 05:06
A custom Android layout class that arranges children in a grid-like manner, optimizing for even horizontal and vertical whitespace.
/*
* ATTENTION:
*
* This layout is now maintained in the `iosched' code.google.com project:
*
* http://code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/ui/widget/DashboardLayout.java
*
*/
/*