Skip to content

Instantly share code, notes, and snippets.

@wareya
wareya / regression.rs
Last active September 24, 2018 03:28
unoptimized multiple regression in rust
use std::vec::Vec;
use std::fs::File;
use std::io::Read;
use std::result::Result;
fn get_data() -> Result<Vec<Vec<f64>>, std::io::Error>
{
let mut file = File::open("info.txt")?;
let mut text = String::new();
file.read_to_string(&mut text)?;
#!python
# -*- coding: utf-8 -*-
from collections import OrderedDict
import json
import sys
from io import open
import re
entries = json.load(open("zero-shinjirin.json", encoding="utf-8"), object_pairs_hook=OrderedDict)
@wareya
wareya / dump.py
Created May 30, 2018 04:36
kanjivg -> json, images (no stroke order/groups)
#!python
mypath = "M26.75,23.5c1.48-0.24,3.35-0.52,5.49-0.84C46.03,20.62,63,17.75,74,17.25c4-0.18,6.09,0.97,5.5,4.75C76.25,42.75,77.25,71.75,92,87.75c6.95,7.54,5.75,1,6-5.5"
commands = "MmZzLlHhVvCcSsQqTtAaBb";
rules = [
["comma", r"^(,)(.*)"],
["number", r"^([+\-]?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+))(.*)"],
@wareya
wareya / bezier.html
Created May 30, 2018 02:13
complex canvas bezier drawing example
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="436" height="436" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
// from kanjivg, see kanjivg's license
@wareya
wareya / keep me off reddit.js
Last active June 5, 2018 13:33
greasemonkey script that keeps me off reddit
// ==UserScript==
// @name Block Reddit
// @version 1
// @grant none
// @include http://*.reddit.com/*
// @include https://*.reddit.com/*
// @run-at document-start
// ==/UserScript==
async function delete_page()
@wareya
wareya / rijndael.py
Created May 13, 2018 02:13
from the comments on https://gist.github.com/jeetsukumaran/1291836 edited to use lists instead of strings
# from the comments on https://gist.github.com/jeetsukumaran/1291836 edited to use lists instead of strings
import copy
class Rijndael(object):
@classmethod
def create(cls):
if hasattr(cls, "RIJNDAEL_CREATED"):
return
# [keysize][block_size]
@wareya
wareya / gist:1cddf8627ff496b13d6ac906b8909f2f
Last active June 17, 2018 01:56
Google Fonts preview override (gs script)
// ==UserScript==
// @name Google Fonts preview override
// @version 1
// @grant unsafeWindow
// @include https://fonts.google.com/*
// ==/UserScript==
function overwrite(e, text)
{
@wareya
wareya / notwfc.py
Created May 1, 2018 11:39
it's not wavefunction collapse
#!/usr/bin/env python
from math import ceil, sqrt
from PIL import Image
import gc
import sys
from time import time
@wareya
wareya / notwavefunctioncollapse.py
Created April 30, 2018 14:02
it's not wave function collapse
#!/usr/bin/env python
from math import ceil, sqrt
from PIL import Image
import gc
import sys
from time import time
@wareya
wareya / main.cpp
Created April 27, 2018 07:49
primitive sprite-only 2d renderer in software that presents with gl
#include <GL/gl3w.h>
#include <GLFW/glfw3.h>
#include <stdio.h>
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_PNG
#include "include/stb_image.h"
#define max(X,Y) (((X)>(Y))?(X):(Y))