Skip to content

Instantly share code, notes, and snippets.

@darktable
darktable / backup_helper.py
Created March 22, 2011 20:45
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 = 'admin@email.com'
@darktable
darktable / detectmobilebrowser.py
Created May 14, 2011 21:50
GAE: Detectmobilebrowser function from detectmobilebrowser.com function-ized to make it more standalone.
# Ported by Matt Sullivan http://sullerton.com/2011/03/django-mobile-browser-detection-middleware/
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
darktable / AutoSaveAssets.cs
Created November 16, 2011 00:12
Unity3D: Somewhat Hacky Method for Auto Saving Assets in Unity.
//#define VERBOSE
/* ***************************************************************************
Copyright 2011 Calvin Rien
(http://the.darktable.com)
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
http://www.apache.org/licenses/LICENSE-2.0
@darktable
darktable / IconPostprocessor.cs
Created February 16, 2012 05:00
Unity3D: Editor script to prevent images added to Assets/Platform from being compressed. (Requires Unity Pro?)
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
darktable / GUIMerge.cs
Created March 29, 2012 18:58
Unity3D: Script to merge multiple GUISkins into a single GUISkin with multiple custom styles.
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
darktable / minijsonjsdemo.js
Created August 30, 2012 21:54
Unity3D: Example of using MiniJSON in UnityScript (JavaScript).
#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
darktable / UpdateXcodeProject.cs
Created October 5, 2012 16:57
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 AppController.mm, Info.plist, etc.
/* **************************************************************************
Copyright 2012 Calvin Rien
(http://the.darktable.com)
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
http://www.apache.org/licenses/LICENSE-2.0
@darktable
darktable / CodeProfiler.cs
Created March 14, 2012 04:02
Unity3D: Tweaked version of @robotduck's CodeProfiler script.
// You can switch to a regular Update() loop
// if you comment out this line. (makes debugging easier)
#define COROUTINE
//
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using UnityEngine;
using Debug = UnityEngine.Debug;
@darktable
darktable / PostprocessBuildPlayer.cs
Created July 24, 2012 22:11
Unity3D: C# replacement for the python version of PostprocessBuildPlayer
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEditor.Callbacks;
using System.IO;
public class PostprocessBuildPlayer : ScriptableObject {
[PostProcessBuild]
static void OnPostprocessBuildPlayer(BuildTarget target, string buildPath) {