Skip to content

Instantly share code, notes, and snippets.

@lanpai
lanpai / color_transfer.py
Created October 3, 2021 21:33
short numpy color transfer implementation for single channel images
import numpy as np
import cv2 as cv
def color_transfer(source, dest):
s_mean, s_std = cv.meanStdDev(source, mask=cv.inRange(source, 1, 254))
d_mean, d_std = cv.meanStdDev(dest, mask=cv.inRange(dest, 1, 254))
s_mean, s_std = np.hstack(s_mean)[0], np.hstack(s_std)[0]
d_mean, d_std = np.hstack(d_mean)[0], np.hstack(d_std)[0]
import java.util.ArrayList;
import java.util.Random;
class Neuron {
public double value;
public ArrayList<Double> weights;
}
class Layer {
public ArrayList<Neuron> neurons;
import pkg.*;
import java.util.ArrayList;
public class starter {
private static Rectangle add(ArrayList<Rectangle> list, Rectangle rect) { list.add(rect); return rect; }
public static void main(String args[]) {
ArrayList<Rectangle> list = new ArrayList<Rectangle>();
Text scroll = new Text(0, 130, "AMERICA YEAH");
scroll.draw();
for (int i = 0; i <= 120; i += 20) add(list, new Rectangle(0, i, 247, 10)).setColor(Color.RED);
add(list, new Rectangle(0, 0, 100, 70)).setColor(Color.BLUE);
@lanpai
lanpai / aggression_simulation.js
Created August 7, 2019 05:05
simulating the conflict between entities in an environment as shown in https://www.youtube.com/watch?v=YNMkADpvO4w
'use strict';
const PASSIVE_COUNT = 50;
const AGGRESS_COUNT = 50;
const FOOD_COUNT = 50;
const GAME_LOOPS = 50;
var entities = [];
for (let i = 0; i < PASSIVE_COUNT; i++) {
@lanpai
lanpai / screencap
Created July 25, 2019 09:12
Takes screen cap and uploads maybe
#! /bin/sh
FILE=$HOME/screenshots/`date +'%Y-%m-%d_%H-%M-%S'`.png
scrot $FILE
mpv $HOME/sounds/snap.mp3 ;
while getopts "u c" opt; do
case $opt in
u)
curl -F image=@$FILE "https://i.piyo.cafe/post.php" | xclip -selection c && mpv $HOME/sounds/bell.mp3
;;
@lanpai
lanpai / cmus_tree_by_album.patch
Created April 21, 2019 20:55
Patch for cmus which hackily enables album sorting over artist sorting in the tree view
diff --git a/comment.c b/comment.c
index 13ba7f0..4b3894d 100644
--- a/comment.c
+++ b/comment.c
@@ -60,7 +60,7 @@ int track_is_compilation(const struct keyval *comments)
int track_is_va_compilation(const struct keyval *comments)
{
- const char *c, *a, *aa;
+ /*const char *c, *a, *aa;