Skip to content

Instantly share code, notes, and snippets.

View schmidsi's full-sized avatar
🦩

Simon Emanuel Schmid schmidsi

🦩
View GitHub Profile
from django import template
import re
register = template.Library()
class_matcher = re.compile('(class="[^"]+)(")')
tag_matcher = re.compile(r'<([a-z0-9]+)([ >])')
def mark_current(navigation, current):
current_tokens = current.split('/')
@schmidsi
schmidsi / feincms_ajax.js
Created September 7, 2011 14:10
FeinCMS ajax client side
var ajax_links_selector = 'a.ajax';
var content_selector = '#content';
var first_call = true;
var navilevel_substring = 3; // how many chars from pathname are static (3 for languagecode like /de/)
/* needs jquery address loaded: http://www.asual.com/jquery/address/
*
* needs feincms to be ajax-enabled:
*
* feincms/views/base.py:
@schmidsi
schmidsi / jquery.getbgimage.js
Created October 10, 2011 18:32
getBgImage: Simple Jquery Plugin to get the dimensions or other attributes from a css background-image
// Inspired by http://stackoverflow.com/questions/5106243/how-do-i-get-background-image-size-in-jquery, a simple jquery plugin who does the task
$.fn.getBgImage = function(callback) {
var height = 0;
var path = $(this).css('background-image').replace('url', '').replace('(', '').replace(')', '').replace('"', '').replace('"', '');
var tempImg = $('<img />');
tempImg.hide(); //hide image
tempImg.bind('load', callback);
$('body').append(tempImg); // add to DOM before </body>
tempImg.attr('src', path);
@schmidsi
schmidsi / models.py
Created October 21, 2011 12:29
Custom 404, 500 Templates via FeinCMS
# imports
from django.conf import settings
from django.db.models import signals
from django.dispatch import receiver
from django.test.client import Client
# your other imports, config here
@receiver(signals.post_save, sender=Page)
def error_templates(sender, instance, created, raw, using, **kwargs):
@schmidsi
schmidsi / tumblr-template.html
Created January 30, 2012 13:11
Zur heiteren Mischung - Sourcecode
<html>
<head>
<title>{Title}</title>
<link rel="shortcut icon" href="{Favicon}">
<link rel="alternate" type="application/rss+xml" href="http://feeds.feedburner.com/zurheiterenmischung">
<!-- of course, we use the fancy open webfont LaneNarrow. generate your own: http://www.fontsquirrel.com/fontface/generator -->
<link rel="stylesheet" type="text/css" href="http://pushkinopen.s3.amazonaws.com/mixblog/media/fonts/stylesheet.css" >
<!-- to save a lot of time, we use the blueprint css framework: http://blueprintcss.org/ -->
@schmidsi
schmidsi / fabfile.py
Created March 6, 2012 17:07
Fabric Tools to Clone Django Projects
import os
from fabric.api import *
from urlparse import urlparse
@task
def clone(uri, local_name=None):
"""
@schmidsi
schmidsi / postgresql.sql
Created November 18, 2014 21:33
Postgresql refresh: Projects, Persons and Network Analysis
-- Aufgabe 1
\c postgres
DROP DATABASE IF EXISTS projects;
CREATE DATABASE projects encoding='UTF8';
\c projects
-- b) / c)
DROP TABLE IF EXISTS Person;
CREATE TABLE Person (
@schmidsi
schmidsi / script.js
Last active August 29, 2015 14:09
Facebook Invite All
var inputs = document.getElementsByClassName('_2aks');
for(var i=0; i<inputs.length;i++) {
inputs[i].click();
}
@schmidsi
schmidsi / gist:19a04cd8848e97ef5d48
Created December 18, 2014 14:26
gulp-sass-autoprefixer
gulp.task 'sass', ->
gulp.src(paths.sass)
.pipe sourcemaps.init()
.pipe sass
includePaths: [
'./node_modules'
'./bower_components'
]
errLogToConsole: true
onError: notify.onError('Stylus Error: <%= error.message %>')
@schmidsi
schmidsi / ClockIcon.jsx
Created August 4, 2016 15:13
A simple React SVG Clock Icon which can display a given time
// React imports
import React from 'react';
const Clock = (props) => {
const center = {
x: 15,
y: 15,
};
const lengths = {