Skip to content

Instantly share code, notes, and snippets.

import java.io._
import Main.file
import scala.collection.mutable
import scala.util.Random
object Main extends App {
val randomFileName = "random.txt"
#ifndef __TIMER_GUARD__
#define __TIMER_GUARD__
class TimeGuard {
private:
unsigned long lastUpdated = 0;
unsigned long interval;
public:
static Color biasedColor(Color color, float offset){
float value = (color.r + color.g + color.b) / 3.0;
float newValue = value+2.0*((float)random(0,10000)/10000.0)*offset-offset;
float valueRatio = newValue / value;
int R = (int)((float)color.r * valueRatio);
int G = (int)((float)color.g * valueRatio);
int B = (int)((float)color.b * valueRatio);
return Color(R,G,B);
}
@zallesov
zallesov / Types Zoo
Created February 17, 2024 22:19
Code snippet for medium article
import { DateTime } from 'luxon';
import { z } from 'zod';
/**
* Replace type V1 with type V2.
*/
type Replace<T, V1, V2> = T extends V1 ? V2 : never;
/**
* Replace all fields of type V1 with fields of type V2.