This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if application "Google Chrome" is running then | |
tell application "Google Chrome" to make new window with properties {mode:"incognito"} | |
else | |
do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito" | |
end if | |
tell application "Google Chrome" to activate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
size=1024 # MB | |
mount_point=$HOME/tmp | |
name=$(basename "$mount_point") | |
usage() { | |
echo "usage: $(basename "$0") [mount | umount | remount | check | orphan]" \ | |
"(default: mount)" >&2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This program has two feature. | |
# | |
# 1. Create a disk image on RAM. | |
# 2. Mount that disk image. | |
# | |
# Usage: | |
# $0 <dir> <size> | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////// | |
////ATTACH EVENT LISTENER | |
///////////////// | |
function attachEventListener(eventTarget, eventType, eventHandler) { | |
if (eventTarget.addEventListener) { | |
eventTarget.addEventListener(eventType, eventHandler, false); | |
} else if (eventTarget.attachEvent) { | |
eventType = "on" + eventType; | |
eventTarget.attachEvent(eventType, eventHandler); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from: | |
// http://stackoverflow.com/a/2490876 | |
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent | |
// prototype.js | |
// https://gist.github.com/heyi/a76167229038b4718a50 | |
// and etc | |
(function(){ | |
var sendEvent = document.createEvent ? function(name, target) { | |
/* WARNING: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Text.Printf (printf) | |
----------------------------------------------------------------------------------------- | |
{-| Datatype for all the objects -} | |
data Object t = | |
Object { getA :: Int -- common fields for all the objects | |
, setA :: Int -> Object t -- setter example | |
, action1 :: IO () -- generally speaking, action is just a regular object field | |
, objectType :: t | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies, StandaloneDeriving #-} | |
{- anti-pattern warning -} | |
{- | |
Say, we need to "inherit" some behavior from another object. | |
Say, we also need to be able to customize overloaded actions, | |
preserving the ability of using the original action. | |
This is the one of the approaches. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Text.Printf (printf) | |
----------------------------------------------------------------------------- | |
{- interface: -} | |
data BaseObject = BaseObject { baseObjectA :: Int } -- the top-level object | |
class WithInheritedActions a where | |
-- inherited actions: | |
action1 :: a -> IO () | |
--action2 :: a -> Foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************************************** | |
Copyright (C) 2008 RadixPro/Jan Kampherbeek (http://radixpro.org). | |
This program is free software; you can redistribute it and/or | |
modify it under the terms of both the GNU General Public License (GPL). | |
You should also adhere to the terms of the Swiss Ephemerice | |
License (SEPL). | |
The GPL is published by the Free Software Foundation; either version 3 | |
of the License, or (at your option) any later version is effective. | |
The SEPL (Swiss Ephemeris License) is published by AstroDienst; either |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A newforms widget and field to allow multiple file uploads. | |
Created by Edward Dale (www.scompt.com) | |
Released into the Public Domain | |
""" | |
from django.utils.encoding import force_unicode | |
from django.utils.datastructures import MultiValueDict | |
from django.utils.translation import ugettext |