Skip to content

Instantly share code, notes, and snippets.

@6r1d
6r1d / background.js
Last active June 20, 2021 01:23
A tiny TTS interface
chrome.runtime.onInstalled.addListener(function() {
chrome.contextMenus.create({
"title": 'Read "%s"',
"contexts": ["selection"],
"id": "ReadTTS"
});
})
let readText = function(info) {
console.log({
trending on artstation | 110
HDR | 110
vray | 104
CGI | 97
DSLR | 71
hyperrealistic | 66
unreal engine | 47
VFX | 45
light transport sharpening | 40
transparent | 31

Recently, I needed SVG smoothing code. I looked at a demo here by netsi1964 and all credits to the code go to him: I only want to trim the code down for the later use.

Note: it is limited to smoothing PATH elements which uses only the L and M line types. Something you can generate with:

function points_to_z(points) {
    z = ""
    z += `M ${points[0][0]} ${points[0][1]} `
 points.slice(1).forEach(function(point) {
// A fork of https://www.shadertoy.com/view/MtX3Ws
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// Created by S. Guillitte 2015
float zoom=1.5;
vec2 cmul( vec2 a, vec2 b ) { return vec2( a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x ); }
vec2 csqr( vec2 a ) { return vec2( a.x*a.x - a.y*a.y, 2.*a.x*a.y ); }
@6r1d
6r1d / Makefile
Last active January 17, 2021 02:44
Libsoundio + Polyphony
CFLAGS = -Wall -std=gnu11
LDFLAGS = -lm -lsoundio
all:
$(CC) $(CFLAGS) *.c -o main $(LDFLAGS)
@6r1d
6r1d / conf
Created December 18, 2020 12:40
Lighttpd config file for Emscripten
# Lighttpd configuration I am using with Emscripten.
#
# Probably there is a better solution
# and I am doing everything wrong.
#
# Start with:
# lighttpd -D -f lighttpd.conf
server.modules += ( "mod_setenv" )
@6r1d
6r1d / split_midi.py
Last active June 10, 2020 14:54
A test music21 program to split a MIDI file into melodies.
"""
This program breaks a MIDI file to a number of melodies.
"""
from os import getcwd, listdir
from os.path import join as path_join, splitext, abspath
from music21 import midi, stream, instrument, key, meter, note, tempo
from pathlib import Path
INPUT_DIR = abspath(path_join(getcwd(), "in"))
@6r1d
6r1d / all.lua
Last active June 2, 2020 08:09
Lite font update experiment
-- style.lua
-- First, I tried altering `style.lua` to add `fscale` attribute and a function to update style.
style.set_font = function()
style.padding = { x = common.round(14 * style.fscale), y = common.round(7 * style.fscale) }
style.divider_size = common.round(1 * style.fscale)
style.scrollbar_size = common.round(4 * style.fscale)
style.caret_width = common.round(2 * style.fscale)
style.tab_width = common.round(170 * style.fscale)
style.font = renderer.font.load(EXEDIR .. "/data/fonts/font.ttf", 14 * style.fscale)
style.big_font = renderer.font.load(EXEDIR .. "/data/fonts/font.ttf", 34 * style.fscale)
@6r1d
6r1d / gist:7443641
Created November 13, 2013 04:20
Centered pagination cases
case (position - radius > first_page && position + radius <= last_page):
pages = range_gen(position - radius, position + radius + 1, position);
break;
// - page is located near the left corner
case (position >= first_page && position <= first_page + radius):
pages = range_gen(first_page, first_page + (radius * 2) + 1, position);
break;
// - page is located near the right corner
case (position >= last_page - radius && position <= last_page):
pages = range_gen(last_page - (radius * 2), last_page + 1, position);
@6r1d
6r1d / gist:7407790
Created November 11, 2013 04:18
Pagination debug
Backbone.View.extend({
// root view DOM-element
tagName: "div",
// events for root view DOM-element
events: {
"click .go_back": "back",
"click .go_forward": "forward",
"click .active a": "fire",