Skip to content

Instantly share code, notes, and snippets.

darktable /
Created Mar 22, 2011
GAE: Script that will download a list of models from remote app engine server and insert them into the local dev_appserver.
import time
import os
import logging
import sys
from subprocess import call, PIPE
import time, os, logging
MODEL_CLASSES = ['list','of','models','to','backup']
email = ''
darktable /
Created May 14, 2011
GAE: Detectmobilebrowser function from function-ized to make it more standalone.
# Ported by Matt Sullivan
import re
reg_b = re.compile(r"android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", re.I|re.M)
reg_v = re.compile(r"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea
darktable / AutoSaveAssets.cs
Created Nov 16, 2011
Unity3D: Somewhat Hacky Method for Auto Saving Assets in Unity.
View AutoSaveAssets.cs
//#define VERBOSE
/* ***************************************************************************
Copyright 2011 Calvin Rien
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
darktable / IconPostprocessor.cs
Created Feb 16, 2012
Unity3D: Editor script to prevent images added to Assets/Platform from being compressed. (Requires Unity Pro?)
View IconPostprocessor.cs
using System.IO;
using UnityEditor;
using UnityEngine;
public class IconPostprocessor : AssetPostprocessor {
void OnPreprocessTexture () {
if (assetPath.ToLower().StartsWith(Path.Combine("assets", "platform"))) {
var ti = (TextureImporter) assetImporter;
darktable / GUIMerge.cs
Created Mar 29, 2012
Unity3D: Script to merge multiple GUISkins into a single GUISkin with multiple custom styles.
View GUIMerge.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class GUIMerge : MonoBehaviour {
public GUISkin primary;
public GUISkin[] skins;
import struct
import SocketServer
from base64 import b64encode
from hashlib import sha1
from mimetools import Message
from StringIO import StringIO
# import threading
class WebSocketsHandler(SocketServer.StreamRequestHandler):
darktable / minijsonjsdemo.js
Created Aug 30, 2012
Unity3D: Example of using MiniJSON in UnityScript (JavaScript).
View minijsonjsdemo.js
#pragma strict
import MiniJSON;
import System.Collections.Generic;
function Start () {
var jsonString = "{ \"array\": [1.44,2,3], " +
"\"object\": {\"key1\":\"value1\", \"key2\":256}, " +
"\"string\": \"The quick brown fox \\\"jumps\\\" over the lazy dog \", " +
"\"unicode\": \"\\u3041 Men\\u00fa sesi\\u00f3n\", " +
"\"int\": 65536, " +
darktable / SingleComponentCheck.cs
Created Aug 30, 2012
Unity3D: Snippet that prevents adding a component multiple times to a GameObject in the Unity Editor.
View SingleComponentCheck.cs
void SingleComponentCheck() {
var components = gameObject.GetComponents(this.GetType());
foreach (var component in components) {
if (component == this) continue;
UnityEditor.EditorUtility.DisplayDialog("Can't add the same component multiple times!",
string.Format("The component {0} can't be added because {1} already contains the same component.", this.GetType(),,
darktable / UpdateXcodeProject.cs
Created Oct 5, 2012
Unity3D: Post-process script that copies the xcode build output to another directory. Used for updating a heavily modified Xcode project without stomping on changes to, Info.plist, etc.
View UpdateXcodeProject.cs
/* **************************************************************************
Copyright 2012 Calvin Rien
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
darktable / CodeProfiler.cs
Created Mar 14, 2012
Unity3D: Tweaked version of @robotduck's CodeProfiler script.
View CodeProfiler.cs
// You can switch to a regular Update() loop
// if you comment out this line. (makes debugging easier)
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using UnityEngine;
using Debug = UnityEngine.Debug;