Skip to content

Instantly share code, notes, and snippets.

View x5lcfd's full-sized avatar
:octocat:
coding.

x5lcfd x5lcfd

:octocat:
coding.
View GitHub Profile
@x5lcfd
x5lcfd / w3g_format.txt
Last active October 17, 2016 02:04 — forked from stattrak-dragonlore/w3g_format.txt
War3 Replay File Format
*******************************************************************************
* WarCraft III Replay file format description *
* *
* document version: 1.18 *
* document date : 2007-06-26 *
* document authors: blue, nagger *
* *
* For more informtion about w3g file format, please visit: *
* http://w3g.deepnode.de *
* *
#!/usr/bin/perl
$f = $ARGV[0];
$pagestart = 0;
$charstart = 0;
$kernstart = 0;
$s = "<?xml version=\"1.0\"?>\n<font>\n";
open(F, $f);
@x5lcfd
x5lcfd / freetype_test.cpp
Created April 21, 2016 14:01
FreeType Render UTF8 string
/* Compile & Run:
clang++ -std=c++11 -fsanitize=address `freetype-config --cflags` `icu-config --cflags | sed -e 's/-std=c99//g' | sed -e 's/-O2//g'` -o freetype_test freetype_test.cpp `freetype-config --libs` `icu-config --ldflags` -lopencv_core -lopencv_highgui && ASAN_OPTIONS="detect_leaks=1" ./freetype_test
*/
// Change the following to suit your need.
static const char *FONT_FILE = "/usr/share/fonts/truetype/wqy/wqy-microhei.ttc";
static const char *STR = u8"哈哈abcdefghijklmnopqrstuvwxyz1234567890";
static const int PIXEL_SIZE = 32, COLOR_BLUE = 255, COLOR_GREEN = 255, COLOR_RED = 0;
#include <cstdio>
@x5lcfd
x5lcfd / SkeletonGraphic.cs
Created May 24, 2016 06:04 — forked from pharan/SkeletonGraphic.cs
SkeletonGraphic is a self-contained UnityEngine.UI.Graphic version of Spine's SkeletonAnimation component.
/******************************************************************************
* Spine Runtimes Software License
* Version 2.3
*
* Copyright (c) 2013-2015, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to use, install, execute and perform the Spine
* Runtimes Software (the "Software") and derivative works solely for personal
@x5lcfd
x5lcfd / gist:68a8fefc666a4f2d63a7e50c5424e453
Created June 1, 2016 02:31 — forked from BastienClement/gist:b34f14dd93381498a7a1
The CASC (Content Addressable Storage Container) Filesystem
---------------------------------------------------------------------
| The CASC (Content Addressable Storage Container) Filesystem |
| Warlords of Draenor Alpha, Build 6.0.1.18125 |
| Written April 14th, 2014 by Caali |
| Version 1.2 |
---------------------------------------------------------------------
Distribution and reproduction of this specification are allowed without
limitation, as long as it is not altered. Quotation in other works is
freely allowed, as long as the source and author of the quote are stated.
@x5lcfd
x5lcfd / latency.txt
Created February 1, 2017 03:17 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@x5lcfd
x5lcfd / gist:97b9002cf3218cb6a0d242a44945582e
Created July 23, 2017 16:25 — forked from ChickenProp/gist:3194723
The Liang-Barsky algorithm for line-rectangle collisions

The Liang-Barsky algorithm is a cheap way to find the intersection points between a line segment and an axis-aligned rectangle. It's a simple algorithm, but the resources I was pointed to didn't have particularly good explanations, so I tried to write a better one.

Consider a rectangle defined by x_min ≤ x ≤ x_max and y_min ≤ y ≤ y_max, and a line segment from (x_0, y_0) to (x_0 + Δ_x, y_0 + Δ_y). We'll be assuming at least one of Δ_x and Δ_y is nonzero.

Image depicting the situation

(I'm working with Flash, so I'll be using the convention that y increases as you go down.)

We want to distinguish between the following cases:

@x5lcfd
x5lcfd / lua-uuid.lua
Created October 20, 2017 08:24 — forked from jrus/lua-uuid.lua
quick lua implementation of "random" UUID
local random = math.random
local function uuid()
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
return string.format('%x', v)
end)
end
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
/// <summary>
/// A base class for creating editors that decorate Unity's built-in editor types.
/// </summary>
public abstract class DecoratorEditor : Editor
@x5lcfd
x5lcfd / SimpleHTTPServerWithUpload.py
Created August 6, 2018 12:13 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""