Skip to content

Instantly share code, notes, and snippets.

@error454
error454 / sketchfab-oculus.js
Created January 8, 2015 03:19
Greasemonkey script to replace Sketchfab model links with dk1/dk2 links
// ==UserScript==
// @name Sketchfab Oculus-izer
// @namespace https://sketchfab.com/
// @description Replace all model links with dk1/dk2 links
// @include https://sketchfab.com/*
// ==/UserScript==
// DK1 users change this to false
var bIsUsingDK2 = true;
var dk1String = '/embed?oculus=1'
@error454
error454 / wav2RGB.py
Created December 6, 2014 23:38
wav2RGB
# http://codingmess.blogspot.com/2009/05/conversion-of-wavelength-in-nanometers.html
def wav2RGB(wavelength):
w = int(wavelength)
# colour
if w >= 380 and w < 440:
R = -(w - 440.) / (440. - 350.)
G = 0.0
B = 1.0
elif w >= 440 and w < 490:
@error454
error454 / w2rgb.py
Created December 6, 2014 23:35
Wavelength to RGB
#!/usr/bin/env python
# vim:set ft=python fileencoding=utf-8 sr et ts=4 sw=4 : See help 'modeline'
# From http://www.noah.org/wiki/Wavelength_to_RGB_in_Python
'''
== A few notes about color ==
Color Wavelength(nm) Frequency(THz)
Red 620-750 484-400
Orange 590-620 508-484
@error454
error454 / copyengine.bat
Last active August 29, 2015 14:09
Package Unreal Engine 4 Editor and ignore debug files.
@echo off
set SOURCE=C:\projects\UnrealEngine
set DESTINATION=C:\projects\perforce\UnrealEngine
REM Samples
xcopy /e /f /r /h /i %SOURCE%\Samples %DESTINATION%\Samples
REM Templates
xcopy /e /f /r /h /i %SOURCE%\Templates %DESTINATION%\Templates
@error454
error454 / gist:6b94c46d1f7512ffe5ee
Last active May 14, 2020 22:17
Convert RGB to CIE Color Space
import math
# This is based on original code from http://stackoverflow.com/a/22649803
def EnhanceColor(normalized):
if normalized > 0.04045:
return math.pow( (normalized + 0.055) / (1.0 + 0.055), 2.4)
else:
return normalized / 12.92
def RGBtoXY(r, g, b):
@error454
error454 / gist:e4e9c2f7620374baf283
Created September 19, 2014 10:07
Shiva Code File Count
--
-- Put at the root of your project and run
--
lfs = require "lfs"
function findAllAI ( )
local t = {}
count = 1
for file in lfs.dir('./Resources/AIModels') do
local sName, sExt = getFileNameAndExtension ( file )
@error454
error454 / gist:0943cf7899c20f5f2b48
Created September 19, 2014 08:39
Delete JPGs that don't have a matching raw file
lfs = require "lfs"
local sPath = 'D:/temp photos/'
function hasExtension ( sFilename, sExt )
if sFilename then
return string.match ( string.lower ( sFilename ), "." .. string.lower( sExt ) ) ~= nil
end
return false
end
local ex,ey,ez = object.getTranslation ( hEnemy,object.kGlobalSpace )
local ox,oy,oz = object.getTranslation ( o,object.kGlobalSpace )
-- vector pointing at the enemy
local dx,dy,dz = math.vectorSubtract ( ex,ey,ez,ox,oy,oz )
-- distance between enemy and object
local dist = math.vectorLength ( dx,dy,dz )
-- vector pointing at enemy with length of half the distance
@error454
error454 / gist:4d4b15086c772c3f1bda
Created July 29, 2014 18:18
Local Space to Global Space
-- I have cube whose origin is in the center of the cube.
-- I want to place a joint on the end face of the cube, the +Z end.
-- --------------
-- | |
-- | |<--- Joint here
-- | |
-- --------------
--
-- I know that the width of the box is boxLength, so the localspace coordinate that gives me the
-- end of the box is 0, 0, boxLength * 0.5 (remember that the origin is in the center)
@error454
error454 / achievementconvert.lua
Created May 2, 2014 23:52
Steam Achievement Image Converter
-- Author: Zachary Burke
-- License: MIT
--
-- Steam Achievement Image Converter
--
-- /-----------\ ----> Color JPG
-- (Color PNG) ----> |This script|
-- \-----------/ ----> Grayscale JPG
--
-- Each Steam Achievement requires two 64x64 JPG files. One image for the unachieved state and the