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 / EvenMoreObjects.java
Last active October 31, 2018 04:20
I don't suppose there's a library like this out there somewhere already?
package magicutilities;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.ToIntFunction;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class EvenMoreObjects {
.../MimeWalker.java:128: warning: [OperatorPrecedence] Use grouping parenthesis to make the operator precedence explicit
(contentType.startsWith("application/octet-stream")) &&
^
(see https://errorprone.info/bugpattern/OperatorPrecedence)
Did you mean '((contentType.startsWith("application/octet-stream")) &&'?
.../MimeWalker.java:128: warning: [UnnecessaryParentheses] Unnecessary use of grouping parentheses
(contentType.startsWith("application/octet-stream")) &&
^
(see https://errorprone.info/bugpattern/UnnecessaryParentheses)
Did you mean 'contentType.startsWith("application/octet-stream") &&'?
@hakanai
hakanai / run-on-all-slaves-example.groovy
Created October 9, 2018 04:33
Example of running a command on all slaves
import hudson.util.RemotingDiagnostics
Jenkins.instance.slaves
.findAll { node -> node.labelString.contains('debian') } // not production-safe
.each { slave ->
println slave.name
def channel = slave.channel
if (channel != null) {
println RemotingDiagnostics.executeGroovy("""
@hakanai
hakanai / gist:23e9f2419d5ac3e587dabeee97fabb42
Created September 18, 2018 22:58
Issue where sometimes the container doesn't exit
$ docker run --volume "${PWD}:/home/tester/core" debianimage ps aux
Starting Xvfb...
Started Xvfb with PID 8
Running command: ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 3.0 0.0 21672 3256 ? Ss 08:57 0:00 /bin/bash /home/tester/run-wrapper ps aux
root 8 0.0 0.0 19424 876 ? R 08:57 0:00 Xvfb :1 -screen 0 1024x768x24
root 9 0.0 0.0 19104 2560 ? R 08:57 0:00 ps aux
Finished
Stopping Xvfb...
@hakanai
hakanai / blah.txt
Last active September 14, 2018 02:23
Some BMP format stuff
BMP file
{
42 4d - magic 'BM'
8e 00 00 00 - total file size
00 00 00 00 - application specific reserved stuff
8a 00 00 00 - offset to pixel array
DIB header (BITMAPV5HEADER)
{
7c 00 00 00 - DWORD biSize = 0x7c (bytes in header from here)
@hakanai
hakanai / blah.txt
Created September 14, 2018 00:02
Some PNG related stuff
00000000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 |.PNG........IHDR|
00000010 00 00 00 01 00 00 00 01 08 06 00 00 00 1f 15 c4 |................|
00000020 89 00 00 00 0d 49 44 41 54 78 da 63 98 f5 f9 7b |.....IDATx.c...{|
00000030 34 00 07 8f 02 e0 a7 82 a8 9a 00 00 00 00 49 45 |4.............IE|
00000040 4e 44 ae 42 60 82 |ND.B`.|
00000046
89 50 4e 47 0d 0a 1a 0a - magic
@hakanai
hakanai / TestIreland.java
Last active July 17, 2018 04:29
Welcome to in Ireland, the only country where the clock is turned _back_ for daylight saving time.
import java.util.Locale;
import com.ibm.icu.text.DateFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.TimeZone;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.junit.Test;
@hakanai
hakanai / clock.html
Created July 6, 2018 07:11
Attempt at improving @y23586's clock to use time zones properly. Supports less stuff overall, though.
<!doctype html>
<html>
<head>
<style type="text/css">
html, body {
height: 100%;
width: 100%;
padding: 0px;
margin: 0px;
@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;