Skip to content

Instantly share code, notes, and snippets.

View ulrikdamm's full-sized avatar

Ulrik Flænø Damm ulrikdamm

  • Northplay
  • Denmark ✈️ Spain
View GitHub Profile
@ulrikdamm
ulrikdamm / EditPrefab.cs
Last active May 14, 2024 16:41
Unity editor script for better editing of prefabs. Put in Assets/Editor.
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
// Adds a "Edit Prefab" option in the Assets menu (or right clicking an asset in the project browser).
// This opens an empty scene with your prefab where you can edit it.
// Put this script in your project as Assets/Editor/EditPrefab.cs
public class EditPrefab {
static Object getPrefab(Object selection) {
enum Block {
case code(String)
case text(String)
case header(String)
}
enum PlaygroundElement {
case code(String)
case documentation([Block])
}
@ulrikdamm
ulrikdamm / gist:68c4f019abcc885247b5
Created November 2, 2014 12:55
Operations.swift
class Promise<T> {
var value : T? {
didSet {
if let value = value {
notifyListeners(value)
}
}
}
init(value : T? = nil) {
@ulrikdamm
ulrikdamm / gist:a9edb3516db7e9a13829
Created May 26, 2014 11:17
Xcide quicklook for UIColor
@interface UIColor (WBDebugExtensions)
@end
@implementation UIColor (DebugExtensions)
- (id)debugQuickLookObject {
UIGraphicsBeginImageContext(CGSizeMake(128, 128));
[self setFill];
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 128, 128)] fill];
@ulrikdamm
ulrikdamm / gist:8274171
Last active August 17, 2024 21:02
PMX 2.0 file format
# PMX 2.0 file format #
This is a description of the PMX file format. This is used for 3D models in Miku Miku Dance (MMD).
Since I couldn't find any English descriptions of the PMX file format, I've made this, which is translated from http://gulshan-i-raz.geo.jp/labs/2012/10/17/pmx-format1/. I haven't used this file format yet, so please don't ask me what everything means.
An English guide to the PMD file format, which preceeded PMX, can be found here: http://mikumikudance.wikia.com/wiki/MMD:Polygon_Model_Data.
If you want to learn more, there are some open source projects on GitHub which can read this format, so go take a look at them.
Note: fields with type text begins with an int (32 bit) with how many bytes of text the section is.
@ulrikdamm
ulrikdamm / gist:6249271
Last active December 21, 2015 04:28
Getting artwork for a audio file in Objective-C
NSURL *url = [NSURL URLWithString:songFileLocation];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
[asset loadValuesAsynchronouslyForKeys:@[ @"commonMetadata" ] completionHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
NSArray *artwork = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyArtwork keySpace:AVMetadataKeySpaceCommon];
NSImage *image = nil;
for (AVMetadataItem *item in artwork) {
if ([item.keySpace isEqualToString:AVMetadataKeySpaceID3]) {
@ulrikdamm
ulrikdamm / gol.dcpu16
Created April 7, 2012 09:32
Game of Life for DCPU
; My implementation of Conways' Game of Life for Notch's DCPU.
; Since screen sizes vary, please test it with this online emulator: http://mappum.github.com/DCPU-16/
; It takes about 80k cycles to do a screen update, so have patience :)
; Made by Ulrik F. Damm
set pc, main
:fillboard ; (a: from board, b: to board, x: width, y: height)
set i, 0
set j, 0