Skip to content

Instantly share code, notes, and snippets.

View authorselection.js
// part of my admin.js. requires jquery. to use it, just call the function.
// got the idea from:
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();
View pomw-imagick.php
<?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)
View hyphenate.js
* 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
* 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 /
Created Nov 16, 2011
My Calibre recipe for
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at>'
Fetch Die Zeit.
from import BasicNewsRecipe
killercup /
Created Mar 16, 2012
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 / stathat.rb
Created Mar 16, 2012
Update Stathat from Rails in Background
View stathat.rb
# 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
system "curl -silent -d 'email=#{ezkey}&stat=#{stat}&#{type}=#{value}' '' > /dev/null &"
View extensions.rb
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.join(directory, content.strip)
to_markdown content.gsub('<%= path %>', permalink)
killercup / gist:2783854
Created May 24, 2012 — forked from mataspetrikas/gist:2300296
Check if element is visible in viewport and scroll if necessary
View gist:2783854
$.extend $.expr[":"],
inView: (a) ->
# cf.
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