Skip to content

Instantly share code, notes, and snippets.

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
#!/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
}
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
//////////////////
////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 {
@ruthenium
ruthenium / event.js
Last active August 29, 2015 14:03
Send event in pure js
// 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:
@ruthenium
ruthenium / dummyInheritance.hs
Created June 10, 2014 19:43
Inheritance and overloading using data Object and w\o typeclasses
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
}
@ruthenium
ruthenium / super.hs
Created June 4, 2014 19:34
Inheritance and overloading with 'super' action
{-# 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.
@ruthenium
ruthenium / simpleInheritance.hs
Created June 4, 2014 19:33
Simple Inheritance and overloading using typeclasses in haskell
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
@ruthenium
ruthenium / sweph.cs
Created April 13, 2013 14:56
Swiss Ephemeris wrapper taken from RadixPro engine source code.
/***************************************************************************
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
"""
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