Skip to content

Instantly share code, notes, and snippets.

@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))
@wareya
wareya / actuallycompilemecab.sh
Last active April 16, 2018 22:45
compile mecab without autotools making everything unreasonably elaborate
#!sh
# On mingw, YOU NEED TO EDIT mecab.h to change DLL_EXPORT to MECAB_DLL_EXPORT or similar. on other platforms, you need to edit the first g++ line below to use DDLL_EXPORT instead (remove mconsole while you're at it)
cd src
MECAB_DEFAULT_RC="\"C:/Program Files/mecab/etc/mecabrc\""
DIC_VERSION="102"
g++ -O3 -m64 -mconsole -I.. -DDIC_VERSION=$DIC_VERSION -DMECAB_DEFAULT_RC="$MECAB_DEFAULT_RC" -DHAVE_CONFIG_H -Wfatal-errors -DMECAB_DLL_EXPORT learner.cpp tagger.cpp viterbi.cpp char_property.cpp dictionary_compiler.cpp feature_index.cpp learner_tagger.cpp nbest_generator.cpp tokenizer.cpp connector.cpp dictionary_generator.cpp iconv_utils.cpp param.cpp utils.cpp context_id.cpp dictionary_rewriter.cpp lbfgs.cpp string_buffer.cpp dictionary.cpp eval.cpp writer.cpp libmecab.cpp -shared -static -static-libgcc -static-libstdc++ -lpthread -liconv -o libmecab.dll
g++ -Os -fdata-sections -ffunction-sections -fwhole-program -Wl,--gc-sections -Wl,--strip-all -m64 -mconsole -I.. -DDIC_VERSION=$DIC_VERSION -DMECAB_DEFA
@wareya
wareya / rip.py
Last active March 31, 2018 02:23
narou scraper with persistent knowledge of updates (not fully tested) - use also: https://gist.github.com/wareya/4305e2f971a78c960402ac69f308128c
#!python
from bs4 import BeautifulSoup
import urllib
from urllib.parse import urljoin
import sys
import aiohttp
import asyncio
#!python
from bs4 import BeautifulSoup
import urllib
from urllib.parse import urljoin
import sys
def get_top_300(url):
r = urllib.request.urlopen(url)
data = r.read()