Skip to content

Instantly share code, notes, and snippets.

@senevoldsen
senevoldsen / Insignia\New_Khazikstan.hpp
Last active December 11, 2019 14:46
Mission compatible insignias
class New_Khazikstan {
displayName = "New Khazikstan";
author = "Rather not say";
texture = "Insignia\New_Khazikstan.paa"; // File not included in gist
textureVehicle = "Insignia\New_Khazikstan.paa"; // File not included in gist.
};
#define SPRITZ_N 256
#define SPRITZ_N_FLOOR_HALF 128
#define SPRITZ_D 16
#define SPRITZ_I_S 0
#define SPRITZ_I_I 1
#define SPRITZ_I_J 2
#define SPRITZ_I_K 3
#define SPRITZ_I_Z 4
#define SPRITZ_I_A 5
#define SPRITZ_I_W 6
@senevoldsen
senevoldsen / acorn_prg.sqf
Created August 27, 2019 15:34
Acorn random number generator
// 2**21 leaving more than enough for safe integer addition
#define MF_ACORN_M 2097152
#define MF_ACORN_M_RECIP 4.76837158203125e-07
// Higher better and slower, but keep max 20
#define MF_ACORN_DEFAULT_K 6
// This should be 0 < y0 < M, and relative prime wrt. to M meaning just odd since M is power of two.
#define MF_ACORN_DEF_Y0 682777
MF_ACORN_TEST_K = [1406504, 41542, 1738859, 883892, 220285, 2090629, 398606, 996019, 1191661, 1076927, 1344894, 411434, 1380805, 1099101, 820216, 1442075, 1593105, 1145902, 38279, 1782955];
MF_ACORN_TEST_K resize MF_ACORN_DEFAULT_K;
@senevoldsen
senevoldsen / timeit.bat
Created July 22, 2019 10:24
timeit - windows
@echo off
powershell -Command "Measure-Command { %* | Out-Default}"
@senevoldsen
senevoldsen / approx.py
Last active May 16, 2019 07:54
Float approximation
class Approx(object):
"""
Represents an approximate floating point number. Will compare equal
to any float-convertible type that are within 'tolerance' difference.
>>> 10.0 == Approx(10.0)
True
>>> 10.0 == Approx(10.0001)
False
@senevoldsen
senevoldsen / script.cs
Created April 7, 2019 00:05
Space Engineer - Full Haul Detection
/***
(Mining) Capacity Exceeded Indicator.
When the percentage of used volume becomes too high for selected
cargo containers it will toggle indicators, for example a light.
======================================
Put the following texts in "Custom Data" to configure the
ragel
@senevoldsen
senevoldsen / vector.js
Created May 13, 2018 14:28
ES6 basic vector module (mostly 2D functionality) that is Array compatible.
function radToDeg(x) {
return x * 180 / Math.PI;
}
function degToRad(x) {
return x * Math.PI / 180;
}
export class Vector extends Array {
@senevoldsen
senevoldsen / datetime.sqf
Last active November 5, 2017 13:07
Strftime for SQF
/*
Copyright 2017 Muzzleflash
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OT
@senevoldsen
senevoldsen / gist:b233ce4f77e835eb7529
Created May 3, 2015 16:38
Global hotkeys for YouTube media player in Firefox.
Local Const $kTitleForYoutubeTab = "[REGEXPTITLE:(?i)(.*YouTube - Mozilla Firefox.*)]"
Local Const $kTitleForFirefox = "[REGEXPTITLE:(?i)(.*Mozilla Firefox.*)]"
Local Const $kKeyPlayPause = "k"
Local Const $kKeyNext = "+n"
Local Const $kKeyPrev = "+p"
HotKeySet("{MEDIA_PLAY_PAUSE}", "PlayPause")
HotKeySet("{MEDIA_NEXT}", "NextTrack")
HotKeySet("{MEDIA_PREV}", "PrevTrack")