Skip to content

Instantly share code, notes, and snippets.

View hakanai's full-sized avatar
⚔️
Battling i16n demons

Hakanai hakanai

⚔️
Battling i16n demons
View GitHub Profile
@hakanai
hakanai / ThickGlass.cginc
Created June 30, 2018 07:17
Quick implementation of the first step documented in http://prideout.net/blog/?p=51
#include "UnityCG.cginc"
fixed4 _Color;
float _DepthScale;
float _Sigma;
struct VertexInput
{
float3 objectPos : POSITION;
@hakanai
hakanai / aabb-ray-intersect.cginc
Last active June 17, 2018 12:54
AABB-Ray intersect returning which side was hit (wrong logic)
uint faceIndexFromDirection(float3 worldViewPos, float3 worldViewDir)
{
//todo carry these from the source
float3 objectViewPos = mul(unity_WorldToObject, float4(worldViewPos, 1)).xyz;
float3 objectViewDir = mul(unity_WorldToObject, float4(worldViewDir, 0)).xyz;
fixed3 directionSign = sign(objectViewDir);
float3 directionInverse = 1.0 / objectViewDir;
float3 xHit = (-directionSign.x - objectViewPos.x) * directionInverse.x * objectViewDir;
@hakanai
hakanai / apfs_allocation.txt
Created June 15, 2018 00:26
APFS allocation examples
For a 256-block image: (I see the same for 246-block images)
1 block for main (current checkpoint's) container superblock
8 blocks for previous checkpoints and container superblocks
52 blocks for space manager and related objects
16 blocks for future expansion?
6 blocks for allocation info file blocks
------
83
@hakanai
hakanai / acls.txt
Last active June 13, 2018 23:15
APFS XAttr com.apple.system.Security
APFS XAttr com.apple.system.Security
====================================
Original command I ran:
chmod +a 'group:staff allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit' file
Resulting xattr:
@hakanai
hakanai / VideoUpdater.cs
Created June 2, 2018 03:00
VRC_SyncVideoPlayer updater script that runs in Unity. Currently very tied to loading my own database from YAML and updating a video player and a separate component with a list of videos in it, but modify as you wish.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.Video;
using VRCSDK2;
using YamlDotNet.RepresentationModel;
@hakanai
hakanai / 8dot3-checksum.c
Last active May 24, 2018 01:39
Checksum used by Windows when generating 8.3 filenames. Dredged out of a now-deleted article which can only be found on the Wayback Machine. https://web.archive.org/web/20150610125659/https://usn.pw/blog/gen/2015/06/09/filenames/
/* A checksum calculator for Windows 8.3 filenames.
* The relevant post can be found at http://usn.pw/blog/cs/2015/06/09/filenames/
* Written by Thomas Galvin. */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
uint16_t chksum(wchar_t * name)
@hakanai
hakanai / 8dot3-checksum.c
Created May 24, 2018 01:27
Checksum used by Windows when generating 8.3 filenames. Dredged out of a now-deleted article which can only be found on the Wayback Machine.
/* A checksum calculator for Windows 8.3 filenames.
* The relevant post can be found at http://usn.pw/blog/cs/2015/06/09/filenames/
* Written by Thomas Galvin. */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
uint16_t chksum(wchar_t * name)
@hakanai
hakanai / decoded.txt
Created May 3, 2018 01:23
Message on the wall in Big Sister's
This is an automated message generated by Big Brother,
Mom... Dad, this is my last message to you... I love you both... But you leave me no choice, you took away my pride, happiness... What do you expect me to do?
When the new child is born I shall take way everything you love...
@hakanai
hakanai / Some APFS file attribute structures.txt
Created April 4, 2018 05:08
Some APFS file attribute structures
Some directory:
01 00 00 00 00 00 00 00 parent node ID
02 00 00 00 00 00 00 00 our node ID
12 13 b0 25 44 1a 22 15 time created
29 28 23 65 45 1a 22 15 time modified
29 28 23 65 45 1a 22 15 time changed
12 13 b0 25 44 1a 22 15 time accessed
00 80 00 00 00 00 00 00 0x8000 = flags
@hakanai
hakanai / fbx.ksy
Created March 12, 2018 09:02
Non-working Kaitai Struct definition for FBX format
meta:
id: fbx
title: FBX 3D model interchange format
file-extension: fbx
encoding: UTF-8
endian: le
license: WTFPL
seq:
- id: header