Skip to content

Instantly share code, notes, and snippets.

View B-Interactive's full-sized avatar

David Armstrong B-Interactive

View GitHub Profile
@B-Interactive
B-Interactive / pm2
Created November 3, 2022 07:10 — forked from PieterScheffers/pm2
node.js pm2 startup script for FreeBSD
#!/bin/sh
# PM2 Startup script
# Source: https://0x0a14.de/pm2-startup-script-for-freebsd/
# Made by: Johannes Tonn
#
# Download this file
# cd /usr/local/etc/rc.d && fetch https://gist.github.com/457769f2090c6b69cd9d
#
# Make the file executable with:
@B-Interactive
B-Interactive / MergeAlpha.hx
Created January 31, 2016 11:29
A HaXe method for applying a decimal (0 to 1) alpha to a 32bit ARGB hexadecimal colour, returning the recalculated 32bit ARGB hexadecimal value.
/**
* Merges a hexidecimal colour with a 0-1 alpha value and returns a new hexidecimal colour.
*
* @param Input ARGB colour that alpha will be applied to. Eg: 0xFFFFFFFF (32bit ARGB).
* @param Alpha value will be applied to colour. 0 (fully transparent) to 1 (fully opaque).
* @return Returns a new ARGB hexidecimal incorporating alpha.
*/
public static function mergeAlpha(colour:Int, alpha:Float):Int
{
// Bitwise hex extraction.
@B-Interactive
B-Interactive / BlendColours.hx
Last active January 31, 2016 11:21
A HaXe method for blending two 32bit hexadecimal ARGB colours together. It's important that the input values are ARGB, not just RGB values. For example: 0xFFFFFFFF (32bit ARGB), not just 0xFFFFFF (24bit RGB). Credit to Mark Ransom (https://stackoverflow.com/a/1944193/2178791) and Michael Baczynski (http://lab.polygonal.de/?p=81).
/**
* Merges two 32bit hexadecimal colours, and returns the result.
*
* @param First hexadecimal ARGB colour.
* @param Second hexadecimal ARGB colour.
* @return Returns the two colours blended as a hexadecimal ARGB value.
*/
public static function blendColours(colourA:Int, colourB:Int):Int
{
// Bitwise hex extraction...