Skip to content

Instantly share code, notes, and snippets.

View websocketserver.py
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 / 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 AppController.mm, Info.plist, etc.
View UpdateXcodeProject.cs
/* **************************************************************************
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 / IncrementBuildVersion.cs
Created Sep 8, 2012
Unity3d: Post-process script that increments revision number of iPhone and Android builds.
View IncrementBuildVersion.cs
/* **************************************************************************
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 / 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
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
#if UNITY_EDITOR
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(), gameObject.name),
"Cancel");
@darktable
darktable / PostBuildLog.cs
Created Aug 29, 2012
Unity3D: Post-process script that includes a build.log file containing the build summary in the output directory. Based on a method in BuildManager.
View PostBuildLog.cs
/* **************************************************************************
Copyright 2012 Calvin Rien
(http://the.darktable.com)
Derived from a method in BuildManager, part of
VoxelBoy's Unite 2012 Advanced Editor Scripting Talk.
(http://bit.ly/EditorScripting)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@darktable
darktable / PostprocessBuildPlayer.cs
Created Jul 24, 2012
Unity3D: C# replacement for the python version of PostprocessBuildPlayer
View PostprocessBuildPlayer.cs
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) {
@darktable
darktable / ProjectAssetPostprocessor.cs
Created Apr 20, 2012 — forked from hoesing/ProjectAssetPostprocessor.cs
Unity asset pre/postprocessor for applying asset defaults by path.
View ProjectAssetPostprocessor.cs
// Drop this script in the Editor directory in your project (creating the Editor directory if it's not there yet)
// Then re-import the assets in the directories covered by this script (right click and reimport)
//
// I would replace my path checking with the path checking from this gist:
// https://gist.github.com/1842177
//
// The texture settings for icons might want to use some of his settings combined with mine as well
using UnityEngine;
@darktable
darktable / SavWav.cs
Created Apr 6, 2012
Unity3D: script to save an AudioClip as a .wav file.
View SavWav.cs
// Copyright (c) 2012 Calvin Rien
// http://the.darktable.com
//
// This software is provided 'as-is', without any express or implied warranty. In
// no event will the authors be held liable for any damages arising from the use
// of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
@darktable
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;
You can’t perform that action at this time.