Skip to content

Instantly share code, notes, and snippets.

@FLamparski
FLamparski / WikiWordFrequency.ipynb
Last active August 13, 2016 13:15
One of the many ways to get word counts in wiki articles
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@FLamparski
FLamparski / mwcleanerfromhell.ipynb
Created August 14, 2016 19:20
A function that tries to convert a Wikipedia article to plain text using mwparserfromhell.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@FLamparski
FLamparski / logger.js
Created September 9, 2016 10:24
Console logging for any site
(function () {
document.body.innerHTML += '<div id="log"></div>';
document.head.innerHTML += '<style>#log{position:fixed;bottom:0;right:0;left:0;height:150px;font:12px monospace;background-color:rgba(0,0,0,.6);color:#eee;overflow-y:auto}#log .log-message .log-ts{opacity:.6}#log .log-message.severity-info{background-color:#add8e6;color:#fff}#log .log-message.severity-warn{background-color:#ff0;color:#222}#log .log-message.severity-error{background-color:pink;color:#e00}</style>';
if (!console) {
console = {};
}
var old = console.log;
var logger = document.getElementById('log');
console.log = function (message) {
if (typeof message == 'object') {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>DOM performance test</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@FLamparski
FLamparski / dna.txt
Created October 12, 2016 17:36
evolving towards ken bone
3 1000 232 5 2 0.9356521479540434 111 170 17 188 63 197 201 154 227 0.13464087134528213 7 184 174 86 191 67 182 73 215 0.2194653171728026 84 47 71 78 151 106 242 179 97 0.001 108 78 154 168 57 93 146 116 63 0.001 145 8 88 87 106 22 239 139 119 0.5865357490610987 197 106 191 32 147 30 253 53 109 0.5205563096431599 116 75 98 200 49 182 134 69 46 0.001 145 111 148 152 155 150 252 2 181 0.9968319506177736 6 2 0 187 118 141 177 204 198 0.001 36 84 125 112 58 58 149 1 126 0.9999882310628767 194 0 0 2 8 192 4 2 229 0.9659037288383411 197 198 200 0 128 19 120 1 237 0.9928429808717291 198 199 200 23 126 49 133 2 245 0.9918611477500882 38 194 0 0 196 1 238 4 217 0.04750376251015209 101 139 12 188 103 196 48 72 123 0.001 114 36 96 53 160 122 98 218 75 0.001 29 126 191 137 127 183 20 184 132 0.001 187 30 179 60 86 188 21 1 68 0.9677728118246786 200 199 200 0 6 24 148 214 48 0.9625386140412341 192 13 68 151 50 90 243 76 173 0.001 54 185 97 181 97 70 59 254 84 0.001 27 28 125 87 154 193 59 3 26 0.7728665120767301 198 6 189
@FLamparski
FLamparski / SetOfLists.java
Created December 11, 2016 22:10
I may have just written an abomination
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Scanner;
public class SetOfLists {
private static
<COLL_INNER extends Collection<Integer>, COLL_OUTER extends Collection<COLL_INNER>>
COLL_OUTER collectionOfCollections(Scanner in, Class<COLL_OUTER> OuterCollection, Class<COLL_INNER> InnerCollection)
throws InstantiationException, IllegalAccessException {
@FLamparski
FLamparski / Column.java
Created January 13, 2017 23:44
BadORM - how easy can it be to write an "ORM"?
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target(FIELD)
public @interface Column {
String name();
@FLamparski
FLamparski / hack_shlex.php
Created January 27, 2017 15:48
Hacky way to use shlex.split in PHP
<?php
/**
* Hacks around the fact that there isn't a good shell-style argument lexer
* for PHP by using the Python one.
* One argument: the line to parse as a shell line.
* Returns: An array such that:
* 'foo --bar baz\ foo "/bar/foo man/quux"' → ['foo', '--bar', 'baz foo', '/bar/foo man/quux']
* Caveat: no error handling. Depends on /usr/bin/python3 being python. It's horrible.
*/
function hack_shlex($str) {
@FLamparski
FLamparski / notes.md
Last active April 2, 2017 11:41
I'm playing with the language Pony. Here's me trying (badly) to figure out reference capabilities.

Pony reference capabilities!

These specify what I can do with an object. They are specified on object level but can be used on variable level to constrain objects passed to stuff.

iso Isolated!

I own the thing. It is my thing. I am free

@FLamparski
FLamparski / package.json
Created June 26, 2017 11:12
Hey, add this to your package.json to generate a self-signed cert for each project, then use it with webpack-dev-server https server!
"scripts": {
"serve-dev-secure": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --progress --https --cert certs/cert.pem --key certs/key.pem",
"make-certs": "mkdir -p certs && openssl req -x509 -newkey rsa:4096 -keyout certs/key.pem -out certs/cert.pem -days 365 -nodes -subj '/CN=localhost'"
}