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 / WhichCamera.cginc
Created October 11, 2019 05:09
Stashing this for safekeeping
bool isVR() {
// USING_STEREO_MATRICES
#if UNITY_SINGLE_PASS_STEREO
return true;
#else
return false;
#endif
}
bool isVRHandCamera() {
@hakanai
hakanai / AuthenticationLeakBugDemo.java
Created September 26, 2019 00:35
Demonstration of Java's HTTP client caching credentials when you don't want it
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.URL;
public class AuthenticationLeakBugDemo
{
public static void main(String[] args) throws Exception
{
// User 1
@hakanai
hakanai / han-unification.html
Created August 26, 2019 06:26
Quick test of differing renderings of the same Unicode character based on the language being rendered.
<html>
<head>
<title>Han Unification Test</title>
<style type="text/css">
* { font-family: 'Noto Serif CJK JP'; }
</style>
</head>
<body>
<ul>
<li>zh-CN: <span lang="zh-CN">次</span></li>
@hakanai
hakanai / Main.java
Created June 6, 2019 07:50
Small JxBrowser example for crash reproduction
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
@hakanai
hakanai / example.groovy
Created May 28, 2019 05:59
Reusing file sets in Gradle builds
def commonCrap = copySpec {
from('dir1') {
include '**/*.jar'
}
from('dir2') {
include '**/*.dll'
}
}
task copy1(type: Copy) {
@hakanai
hakanai / Jenkinsfile-fragment.groovy
Last active May 24, 2019 06:40
Is it possible to do _this_ in Jenkins pipeline?
pipeline {
// ...
stages {
// ...
customMatrix {
matrix [name: 'debian', prettyName: 'Debian'],
[name: 'ubuntu', prettyName: 'Ubuntu'],
[name: 'centos', prettyName: 'CentOS'],
[name: 'macos', prettyName: 'macOS'],
[name: 'windows', prettyName: 'Windows']
@hakanai
hakanai / TootsExporter.py
Last active April 29, 2019 11:07
Another Mastodon Toots Exporter in Python 3.
#!/usr/bin/env python3
#
# TootsExporter.py
# - Another Mastodon Toots Exporter in Python 3.
#
# Dependency:
# - pip(3) install "requests[socks]"
#
# License: MIT
@hakanai
hakanai / Converter.java
Created March 28, 2019 05:33
Example usage of Guava's `TypeToInstanceMap` for maps of non-trivial types
public interface Converter<T>
{
String toString(T thing);
T fromString(String string);
}
@hakanai
hakanai / DistanceFunctions.cginc
Created March 8, 2019 23:56
Signed distance function for an arc
// Distance from a point in 2D space to an arc starting at arc_r on the X axis
// and rotating through arc_theta in the positive direction.
float sdArc(float2 p, float arc_r, float arc_theta)
{
float p_theta = atan2(p.y, p.x);
if (p_theta < 0.0)
{
p_theta += UNITY_TWO_PI;
}
@hakanai
hakanai / MilitaryZones.asciidoc
Created November 13, 2018 00:34
Helpful guide to single-letter time zone abbreviations

A

Alpha Time

UTC+1

B

Bravo Time

UTC+2

C

Charlie Time

UTC+3

D

Delta Time

UTC+4

E

Echo Time

UTC+5

F

Foxtrot Time

UTC+6

G

Golf Time

UTC+7

H

Hotel Time

UTC+8

I

India Time

UTC+9