Skip to content

Instantly share code, notes, and snippets.

View motoki317's full-sized avatar
🏠
Working from home

motoki317 motoki317

🏠
Working from home
View GitHub Profile
@motoki317
motoki317 / main.js
Last active September 19, 2021 14:22
Quine-McCluskey Algorithm in JavaScript
const product = (s1, s2) => s1.flatMap(elt1 => s2.map(elt2 => [...elt1, ...elt2]));
const power = (s, p) => new Array(p).fill(s).reduce(product, [[]]);
const bool = [[0], [1]];
const and = (...x) => {const base = (x, y) => x * y; return x.reduce(base, 1)};
const or = (...x) => {const base = (x, y) => x + y - x * y; return x.reduce(base, 0)};
const xor = (...x) => {const base = (x, y) => x + y - 2 * x * y; return x.reduce(base, 0)};
const nand = (...x) => 1 - and(...x);
const dual_func = f => (...x) => (v => v === '*' ? '*' : 1 - v)(f(...x.map(t => 1 - t)));
# from traq-message-indexer messages cache
SELECT c.name AS "channel_name", u.name AS "related_user_name", COUNT(*) AS "messages_count" FROM message m
# restrict to times messages
INNER JOIN channel c ON m.channel_id = c.id
INNER JOIN user u ON m.user_id = u.id
# drop own messages in their own times
WHERE u.name != c.name
# drop bot relations
AND NOT u.bot
GROUP BY m.channel_id, m.user_id
@motoki317
motoki317 / main.go
Last active March 13, 2021 12:07
Mandelbrot Set
package main
import (
"fmt"
"github.com/lucasb-eyer/go-colorful"
"github.com/schollz/progressbar/v3"
"image"
"image/color"
"image/png"
"math"