Skip to content

Instantly share code, notes, and snippets.

View outlook-mixed-encoding-subject-bug.eml
Date: Thu, 01 Jan 1970 00:00:00 +0000 (UTC)
From: ABC <abc@example.com>
To: XYZ <xyz@example.com>
Subject:
=?UTF-8?Q?=E7=BB=9F=E4=B8=80=E7=A0=81?=
=?UTF-8?Q?=E5=8F=98=E6=88=90=E4=B9=B1=E7=A0=81?=
=?us-ascii?Q?_removing_this_part_fixes_the_mojibake?=
MIME-Version: 1.0
Content-Type: text/plain;
View 姓名_parser.js
// https://web.archive.org/web/20160920191749/http://zhaoren.idtag.cn/samename/searchName!pmbyrepeatlist.htm
const 姓名 = [...document.querySelectorAll('li p')]
.map(x => x.textContent.trim().match(/^\d+\.(.+)$/))
.filter(Boolean)
.map(x => x[1])
const = [...new Set(姓名.map(x => x[0]))].join('')
const = [...new Set(姓名.flatMap(x => [...x.slice(1)]))].join('')
View highlightify.js
// ==UserScript==
// @name Highlightify
// @namespace https://github.com/lionel-rowe/
// @version 0.4
// @description Highlightify Stack Exchange
// @author @lionel-rowe
// @match https://meta.stackexchange.com/*
// @grant none
// ==/UserScript==
/* global StackExchange */
@lionel-rowe
lionel-rowe / prepare-commit-msg.sh
Last active Jun 17, 2019 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
View prepare-commit-msg.sh
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
# curl <link_to_raw> > .git/hooks/prepare-commit-msg && chmod u+x .git/hooks/prepare-commit-msg
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
@lionel-rowe
lionel-rowe / QueryParams.js
Last active Apr 30, 2019
QueryParams - super-simple query string parser with comma-delimited arrays
View QueryParams.js
const QueryParams = {};
QueryParams.options = {
usePlusSigns: false, // per RFC 1866 application/x-www-form-urlencoded; otherwise use "%20" for space
keyMustReturnArray: key => key.endsWith('_arr') // for URI-decoded keys that return `true` for this function, coerce the value to an array even if it contains no commas
};
const decode = str => {
if (QueryParams.options.usePlusSigns) {
str = str.replace(/\+/g, '%20');
View spamfilter_v2.js
/*
Concepts covered:
concept | syntax
---------------------------------|--------------------------
testing for a match | test
replacing matches | replace
...with a string | replace(re, '...')
...with a function | replace(re, m => ...)
View spamfilter.js
const alphabetMap = {
a: 'a@4', b: 'b8', c: 'c{\\[(', d: 'd', e: 'e3', f: 'f', g: 'g69', h: 'h',
i: 'i|', j: 'j', k: 'k', l: 'l', m: 'm', n: 'n', o: 'o0', p: 'p', q: 'q',
r: 'r', s: 's5', t: 't7', u: 'u', v: 'v', w: 'w', x: 'x', y: 'y', z: 'z2'
};
const makeRegex = str => {
const inner = str.split('').map(char => {
const chars = alphabetMap[char];
@lionel-rowe
lionel-rowe / insaneOptions.js
Last active Mar 3, 2019
insane options for use with marked and highlightjs
View insaneOptions.js
const insaneOptions = {
allowedAttributes: {
a: ['href', 'name', 'target', 'rel', 'title'],
img: ['src', 'alt', 'title'],
input: ['type', 'checked', 'disabled'],
code: ['class'],
span: ['class'],
th: ['align'],
tr: ['align']
},
View get-stories-commented.js
/*
source: https://github.com/zeit/now-examples/blob/3f609858904e7dafbd016a255de325a936cf240f/nextjs-news/lib/get-stories.js
The actual functionality isn't anything special - it just gets data about news
stories for a typical hacker-news-clone demo app.
What I like is how this really short snippet shows off so many really nice
features of modern JavaScript. This is the snippet I'd show to rebut someone
claiming "JavaScript is a poorly-designed language created by Brendan Eich in
10 days".
@lionel-rowe
lionel-rowe / linux-terminal.md
Last active Oct 17, 2018
Useful terminal commands/shortcuts (Linux::Ubuntu)
View linux-terminal.md

Useful terminal commands and shortcuts (Linux::Ubuntu)

Commands

  • sudo apt-get install <pkg name> install package
  • sudo apt-get remove <pkg name> remove package
  • apt list | grep <txt to search> search currently installed packages
  • xkill kill an unresponsive window w. mouse
  • touch to create file, mkdir to create dir
  • rm to delete file, rmdir to delete dir