This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[... document.querySelectorAll(".file td")] | |
.map(td => | |
td.firstChild | |
? td.firstChild.textContent | |
= td.firstChild.textContent | |
.replace( | |
/^(\t+)/, | |
(match, p1) => | |
" ".repeat(4).repeat(p1.length)) | |
: "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeUnique(prev, current, index) { | |
return (index === 1 | |
? [prev].concat(prev !== current ? current : []) // handle when first two items are identical | |
: (prev.indexOf(current) > -1 | |
? prev | |
: (prev.push(current), prev))) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getJaccardSimilarity(item, otherItem) { | |
function makeUnique(prev, current, index) { | |
return (index === 1 | |
? [prev].concat(prev !== current ? current : []) // handle when first two items are identical | |
: (prev.indexOf(current) > -1 | |
? prev | |
: (prev.push(current), prev))) | |
} | |
const union = [].concat(item.split(/\s+/)).concat(otherItem.split(/\s+/)).reduce(makeUnique); | |
const otherUnique = otherItem.split(/\s+/).reduce(makeUnique); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Minimal implementation of the TAR file format. | |
* Reference: | |
* https://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5 | |
*/ | |
export class Tar { | |
private data: Map<string, Blob> = new Map(); | |
/** Add a file to the archive. | |
* @param {string} fileName - file name (including directory structure) | |
* @param {Blob} contents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name removeappreference | |
// @namespace numen | |
// @include https://www.youtube.com/* | |
// @include https://youtube.com/* | |
// @include http://www.youtube.com/* | |
// @include http://youtube.com/* | |
// @include https://m.youtube.com/* | |
// @include http://m.youtube.com/* | |
// @version 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(new MutationObserver(function (mutation) { // create a mutationobserver for checking any new nodes added to the chats | |
mutation.forEach(function (m) { // each mutation shall be iterated. | |
for (var node of m.addedNodes) { // each item may contain the added nodes | |
message = node.textContent; | |
if (( message.substr(0, 4) == 'jscr') && confirm("evaluate?")) { // if message matches some conditions | |
// do stuff with the message | |
console.log(message.substr(4, 40)); | |
} | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Result of some quick night-coding, so don't expect much. | |
There should be a show.db sqlite3 database with a schema like | |
in line 22. | |
If there isn't a new one is created with helloworld as a default password. | |
New passwords can be created, they are stored as sha1() hashes. | |
One can create a new link on show.php?mode=admin; the file names are paths on the web server. | |
The links are going to look like this: show.php?session=SESSION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Multi_key> <colon> <parenright> : "☺" # Compose : ) | |
<Multi_key> <minus> <less> : "←" U2190 # Compose - < | |
<Multi_key> <minus> <greater> : "→" U2192 # Compose -> | |
<Multi_key> <o> <o> : "…" U2026 # Compose | |
<Multi_key> <asterisk> <asterisk> : "★" | |
<Multi_key> <asciitilde> <asciitilde> : "≈" U2248 | |
<Multi_key> <s> <n> <o> : "☃" # Snowman! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# make a quick overview of the pictures in a folder | |
# I'm using this for Amazon S3, to have preview of the items I have in Deep Glacier | |
# create an empty folder: index/ | |
# make folder: index/thumbnails | |
# generate thumbnails for files | |
# generate index.html | |
# - generate metadata.js | |
# - add thumbnails | |
# - add metadata (todo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def donothingDecorator(f): | |
""" Make a function returning some string return it prepended with the string's length. """ | |
def wrapper(*args, **kwargs): | |
#print("ogwell") | |
returnvalue = str(f(*args, **kwargs)) | |
return str(len(returnvalue)) + " " + returnvalue | |
return wrapper |