This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Vector4 HSVToRGB(float hue, float saturation, float value, float alpha) | |
{ | |
Func<float, float> helper = (x) => | |
{ | |
float lowerBound = value * (1 - saturation); | |
float delta = value - lowerBound; | |
while (x < 0) x += 360; | |
x = x % 360; | |
return lowerBound + (float)((Math.Floor(x / 180) * value) + Math.Floor(((Math.Floor(x / 60) % 3) / 2)) * (x % 60) * (delta / 60F) * Math.Pow(-1, Math.Floor(x / 180))); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var rand = new Random(); | |
int success = 0; | |
for (int i = 0; i < 100000; ++i) | |
{ | |
var arr = Shuffle(new List<int> { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 }); | |
int sum = 0; | |
for (int j = 0; j < 3; ++j) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void PackRectanglesModify(List<PackedRectangle> rectangles) | |
{ | |
rectangles.Sort | |
( | |
Comparing.CreateComparer<PackedRectangle, double> | |
( | |
rect => rect.Rectangle.Size.X * rect.Rectangle.Size.Y | |
) | |
); | |
rectangles.Reverse(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type IRectangle = | |
abstract member X : double with get, set | |
abstract member Y : double with get, set | |
abstract member Width : double | |
abstract member Height : double | |
abstract member Id : int | |
type internal Spot(x: double, y: double, width: double, height: double) = | |
member this.x = x | |
member this.y = y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Form form; | |
private static Thread thread; | |
private static event Action showRequest; | |
public static void OpenForm() | |
{ | |
if (thread == null) | |
{ | |
thread = new Thread(() => | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Stop gif animations on escape | |
// @namespace http://github.com/johan/ | |
// @description Implements the "stop gif animations on hitting the escape key" feature that all browsers except Safari and Google Chrome have had since forever. Now also for Google Chrome! | |
// ==/UserScript== | |
document.addEventListener('keydown', freeze_gifs_on_escape, true); | |
function freeze_gifs_on_escape(e) { | |
if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Firefly2.Functional.RectanglePacking | |
type IRectangle = | |
abstract member X : double with get, set | |
abstract member Y : double with get, set | |
abstract member Width : double | |
abstract member Height : double | |
abstract member Id : int | |
type internal Spot(x: double, y: double, width: double, height: double) = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE PatternSynonyms #-} | |
module Reduction where | |
import Data.Maybe | |
import Function | |
pattern NumFrac n d = Number n :/: Number d | |
isConst :: Expression -> Bool | |
isConst (Number _) = True |
OlderNewer