Skip to content

Instantly share code, notes, and snippets.

View nickserv's full-sized avatar

Nicky McCurdy nickserv

View GitHub Profile
@nickserv
nickserv / README.md
Last active January 28, 2017 14:45
Convert an outline of cards in a Trello board to Org syntax.

Convert an outline of cards in a Trello board to Org syntax.

This is designed for importing Trello boards that represent outlined cards into Org. If you want to import Trello cards as TODOs or sync them between Trello and Org, use org-trello.

  1. Install the latest stable version of Node.
  2. Set the following environment variables:
  3. node trello_outline_to_org.js
@nickserv
nickserv / a1z26.js
Last active February 23, 2017 00:28
A1Z26 cipher decoder for Gravity Falls S1E14
var cipher = '14-5-24-20 21-16: "6-15-15-20-2-15-20 20-23-15: 7-18-21-14-11-12-5 \'19 7-18-5-22-5-14-7-5"'
var letterOffset = 97
function indexToLetter (index) {
return String.fromCharCode(letterOffset + Number(index) - 1)
}
// next up: "footbot two: grunkle 's grevenge"
console.log(cipher.replace(/\d+/g, indexToLetter).replace(/-/g, ''))
@nickserv
nickserv / README.md
Last active April 6, 2017 23:00
add-hooks macro for Emacs: Set many hooks at once, without duplicating hook or function names.
@nickserv
nickserv / function_invocation.js
Created June 18, 2017 21:55 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
@nickserv
nickserv / tsconfig.json
Created January 9, 2018 07:06
TypeScript config for checking JavaScript projects
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true
},
"exclude": "node_modules"
}
@nickserv
nickserv / .el
Created February 19, 2018 01:09
Emacs timed macro
(defmacro timed (&rest body)
"Executes BODY and prints a message of the time elapsed."
`(progn
(setq timed-start (float-time))
,(macroexp-progn body)
(setq timed-end (float-time))
(message "%f" (float-time (time-subtract timed-end timed-start)))))
@nickserv
nickserv / reboot-minus-normalize.css
Last active March 5, 2018 19:43
This is what Bootstrap 4.0.0's Reboot looks like with all the Normalize styles removed. For educational purposes only, just use Reboot if you like these styles.
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
-ms-overflow-style: scrollbar;
-webkit-tap-highlight-color: transparent;
@nickserv
nickserv / index.js
Created May 7, 2018 06:39
Find insecure GitHub Pages repositories
// Set $GITHUB_TOKEN to a personal access token with repo access
const fetch = require('node-fetch')
const parse = require('parse-link-header')
async function getPages(url = 'https://api.github.com/user/repos?type=owner') {
const response = await fetch(url, {
headers: {
Authorization:
'Basic ' + Buffer.from(process.env.GITHUB_TOKEN).toString('base64')
@nickserv
nickserv / index.js
Created September 8, 2018 19:58
Cartesian product
const cartesianProduct = (...arrays) =>
arrays.reduce(
(accumulator, array) =>
accumulator.flatMap(accumulatorItem =>
array.map(arrayItem => accumulatorItem.concat(arrayItem))
),
[[]]
);
const getPositions = chatLog => {
return chatLog.map((message, i) => {
const previous = chatLog[i - 1];
const next = chatLog[i + 1];
const messageIsJoinOrExit = message.messageType === "JOIN_OR_EXIT";
let previousIsJoinOrExit;
let nextIsJoinOrExit;
let previousIsFromSameUserAsMessage;
let nextIsfromSameUserAsMessage;