Skip to content

Instantly share code, notes, and snippets.

import csv
import math
# the files are encoded in gb but I converted them to utf-8
# csv reader wants newlines as ''
with open("CharFreq_inform.txt", newline = '', encoding = "utf-8") as unigrams:
fieldnames = ["index", "char", "freq"]
reader = csv.DictReader(unigrams, delimiter = '\t', fieldnames = fieldnames)
# skip the first six rows, including the header
for i in range(6):
// Example of a flawed graph for inserting nodes based on RPO ordering
// image
digraph {
0
3
4
19
21
22
23
@bluecookies
bluecookies / bisector.js
Created July 16, 2018 02:09
Quick and dirty L Shape bisector mockup for the Riddler
var handleSize = 5;
var width = 500, height = 500;
function init() {
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var shape = {x: 100, y: 300, X: 400, Y: 50, cornerX: 50, cornerY: 450};
var drag = {inner: false, outer: false};
canvas.addEventListener("mousedown", (e) => mouseDown(e, shape, drag), false);
@bluecookies
bluecookies / index.html
Last active July 14, 2018 11:19
Dice input method
<!DOCTYPE html>
<html>
<head>
<title>Text input</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/94/three.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/threex.keyboardstate/master/threex.keyboardstate.js"></script>
<script src="model.js"></script>
<script src="main.js"></script>
<style>
body {
@bluecookies
bluecookies / merge.sh
Created May 31, 2018 07:43
folder merger
if [ $# -ne 2 ]; then
echo "merge src patch"
exit 1
fi
num=$(ls -1q $1 | wc -l)
extra=$(ls -1q $2 | wc -l)
for x in $(seq 0 $((extra - 1))); do
@bluecookies
bluecookies / comic-walker.py
Last active August 22, 2022 10:08
working comic walker downloader as of 2018-03-22
from sys import argv
import requests
import json
import os
import itertools
endpoint_url = "https://ssl.seiga.nicovideo.jp"
OUT_DIR = "out"
# endpoint + "/api/v1/comicwalker/episodes/" + episode_id + "/frames"
@bluecookies
bluecookies / album.bat
Last active November 1, 2017 04:53
temp unpacker
@echo off
setlocal enabledelayedexpansion
for %%f in (Album/pri_l_*.unity3d) do @(
set id=%%~nf
unpack.py Album/%%f Processed/!id:~6!_large.png
)
for %%f in (Album/pri_s_*.unity3d) do @(
set id=%%~nf
unpack.py Album/%%f Processed/!id:~6!_small.png
)