Skip to content

Instantly share code, notes, and snippets.

// WAY 1 - Instantiating an anonymous function
var MySingleton = new (new MyClass(args));
// WAY 2 - Using an instance manager
var getMySingleton = (function(options) {
function MyClass(args) {}
var singleton;
return function(args) {
return singleton ? singleton : singleton = new MyClass(args);
// WAY 1 - Instantiating an anonymous function
var MySingleton = new (new MyClass(args));
// WAY 2 - Using an instance manager
var getMySingleton = (function(options) {
function MyClass(args) {}
var singleton;
return function(args) {
return singleton ? singleton : singleton = new MyClass(args);
-- PF.WrapSelectionWithFolder.applescript
--
-- Created by Peter Geil on 05.12.09.
-- Copyright 2009 Peter Geil. All rights reserved.
registerWithGrowl()
var NamespaceManager = new function() {
// Used to store dependencies; Two Arrays because there are
// probably multiple dependencies on the same classes
var memberIds = [],
callbacks = [];
// Used to store ALL loaded classes
var loaded = [];
var repeat = 500;
// Using Crockford's Module Pattern
console.profile("Crockford's Module Pattern");
var arrObjLit = [],
iObjLit = repeat;
while (iObjLit--) {
(function() {
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
@peta
peta / Vendor prefixed property
Created September 25, 2010 16:01
After you triggered the snippet, just type the desired property in its generic form and it will be mirrored into vendor prefixed properties for Mozilla Gecko, Webkit, Opera and Internet Explorer.
${1:}: ${2:};
-moz-${1/\s.*//}: $2;
-webkit-${1/\s.*//}: $2;
-o-${1/\s.*//}: $2;
-ms-${1/\s.*//}: $2;$3
@peta
peta / fm4-grabber.sh
Created March 12, 2011 00:04
Tool for batch downloading FM4 podcasts
#!/usr/bin/env bash
# Author: Peter Geil -- @pbyte
# Version: 0.1
# Description: Tool for batch downloading <http://fm4.orf.at> podcasts.
DIRECTORY=$(cd `dirname $0` && pwd)
if [ $(($#)) -gt 0 ]; then
URL=$1
@peta
peta / sniff_file.sh
Created May 13, 2011 11:46
Sniff type of files by scanning their contents
#!/usr/bin/env sh
# A simple one-liner
find . -depth 1 -type f -name "*.pdf" -exec file {} \;
@peta
peta / ftat-mousehover5k.jquery.js
Created July 15, 2011 22:22
Filmtipps.at Mousehover5000
/**
*
* Filmtipps.at Mouseover5000(tm)
*
* Author: Peter Geil
* Created: 15.07.11
* License: to kill
* Description: When hovering a movie entry, the corresponding film poster will
* be highlighted and vice versa. The code is written for the document/markup model
* Filmtipps.at is using right now (15.07.11)and might break when they change it. My intention