Skip to content

Instantly share code, notes, and snippets.

// part of my admin.js. requires jquery. to use it, just call the function.
// got the idea from: http://www.mahner.org/weblog/spass-mit-newforms-admin-automatische-felder/
function authorselection() {
/* If there is an author field, and it is set to a user, hide the selection
* and let the user have to click on "change" to change it. This takes one
* decision to make form the user, but keeps functionality.
*/
if (!($("div#content-main select[name='author'] option[@selected]").text() == "---------")) {
// $("div#content-main select[name='author']").hide();
<?php // $thumburl ist die URL des Bildes bei Flickr (1024er Version normalerweise)
$thumburl = get_post_meta($post->ID, 'thumbnail', true);
// Aus $thumbname und $upload_path setzt sich der absolute Pfad der Datei zusammen
$thumbname = "thumbnails/".$post->ID."-800.jpg";
$upload_path = ABSPATH.get_option("upload_path");
// Sofern es die Datei noch nicht gibt, erstellen wir sie mal eben
if(!file_exists($upload_path."/".$thumbname)) {
// Datei von Flickr temporär laden
def quer(zahl):
qsumme = 0
for einer in str(zahl):
qsumme = qsumme + int(einer)
if len(str(qsumme)) > 1:
qsumme = quer(qsumme)
return qsumme
zahl = 4242
quersumme = quer(zahl)
/*!
* Hyphenator 2.4.0 - client side hyphenation for webbrowsers
* Copyright (C) 2009 Mathias Nater, Zürich (mathias at mnn dot ch)
* Project and Source hosted on http://code.google.com/p/hyphenator/
*
* This JavaScript code is free software: you can redistribute
* it and/or modify it under the terms of the GNU Lesser
* General Public License (GNU LGPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
@killercup
killercup / zeit_online.recipe.py
Created November 16, 2011 10:56
My Calibre recipe for zeit.de
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
Fetch Die Zeit.
'''
from calibre.web.feeds.news import BasicNewsRecipe
@killercup
killercup / README.md
Created March 16, 2012 11:03
Unicorn, RVM Wrapper, Init.d

You have your Rails Apps with specific Gemsets in RVM.

The following commands creates a wrapped unicorn_rails bin. Be sure to replace the variables and that you have unicorn in your bundle.

rvmsudo rvm wrapper [RUBY VERSION]@[GEMSET] [GEMSET] unicorn_rails

Now you have a /usr/local/rvm/bin/[GEMSET]_unicorn_rails I will refer to [GEMSET]_unicorn_rails as [WRAPPED_NAME]

@killercup
killercup / stathat.rb
Created March 16, 2012 11:12
Update Stathat from Rails in Background
# config/initializers/stathat.rb
if Rails.env.production?
ezkey = # SET ME!
server = # SET ME!
def stathat(ezkey, stat, value, type)
# This is probably the most insane code you have ever seen
# http://ragefac.es/53
system "curl -silent -d 'email=#{ezkey}&stat=#{stat}&#{type}=#{value}' 'http://api.stathat.com/ez' > /dev/null &"
@killercup
killercup / extensions.rb
Created March 28, 2012 19:33
Extensions for Bonsai, http://tinytree.info/
module Bonsai
class Page
def markdown(content)
# Render the markdown file with the name `content`
# that is in the folder of the current page.
# Also replace `<%= path %>` with the page's directory path.
content = File.read File.join(directory, content.strip)
to_markdown content.gsub('<%= path %>', permalink)
end
@killercup
killercup / gist:2783854
Created May 24, 2012 19:56 — forked from mataspetrikas/gist:2300296
Check if element is visible in viewport and scroll if necessary
$.extend $.expr[":"],
inView: (a) ->
# cf. http://remysharp.com/2009/01/26/element-in-view-event-plugin/#comment-127058
st = (document.documentElement.scrollTop or document.body.scrollTop)
ot = $(a).offset().top
wh = (if (window.innerHeight and window.innerHeight < $(window).height()) then window.innerHeight else $(window).height())
ot > st and ($(a).height() + ot) < (st + wh)
$.fn.scroll_if_necessary = ->
if this.length && not @is(":inView")
String.prototype.capitalize = ->
@charAt(0).toUpperCase() + @slice(1)
parse_shit_to_date = (shit) ->
# shit in form of "2012-05-23"
parts = shit.match(/(\d+)/g)
new Date(parts[0], parts[1]-1, parts[2])
jQuery(document).ready ($) ->
return unless $("body.admin_dashboard").length