Skip to content

Instantly share code, notes, and snippets.

View leggsimon's full-sized avatar
🙃

Simon Legg leggsimon

🙃
View GitHub Profile
export const log = (...args) => console.log(...args);
# from https://apple.stackexchange.com/a/267261
function show_italics {
echo "xterm-256color|xterm with 256 colors and italic,\n sitm=\E[3m, ritm=\E[23m,\n use=xterm-256color," >> xterm-256color.terminfo.txt
tic -o ~/.terminfo xterm-256color.terminfo.txt
rm xterm-256color.terminfo.txt
}
# set up gitcommit message styling https://shime.sh/git-commit-message-syntax-highlighting-in-vim
function add_gitcommit_message_styling {
mkdir -p ~/.vim/after/syntax/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WFWorkflowActions</key>
<array>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.count</string>
<key>WFWorkflowActionParameters</key>
const post = (userId) => {
// First check the user exists
return getUser(userId)
.then(user => {
// Ok, so the user aleady exists
// do some logic
// Lets try and delete them
return deleteUser(userId)
const querystring = require('querystring');
const qs = querystring.parse('doom=bar')
console.log(qs)
// console.log(`QS: ${qs}`) <-- This blows up
// console.log('QS: ' + qs) <-- So does this
qs.toString = function() {
return JSON.stringify(this)
const toBool = str => {
if (!str) {
return false
}
return str === 'true'
? true
: str === 'false'
? false
: true
@leggsimon
leggsimon / index.js
Created March 25, 2018 19:00
Bot blocker
// mad codez
@leggsimon
leggsimon / propsal.md
Created January 27, 2018 18:33
ECMAScript Proposal - Question Mark character to be allowed in IdentifierNames

ECMAScript Proposal - Question Mark character to be allowed in IdentifierNames

Outline

My proposal is for the Question Mark (?) character to be allowed in an IdentifierName.

Acording to the current ES5 spec

This standard specifies specific character additions: The dollar sign ($) and the underscore (_) are permitted anywhere in an IdentifierName.

Currently I can't think of any reason why this couldn't be ammended in a future version.

@leggsimon
leggsimon / find-obsolete.js
Last active March 27, 2017 00:26
A shell script that finds files in a specified directory and returns the instances it is used within another directory. Used to find files that weren't ever required in another file in a repository
#!/usr/bin/env node
const shell = require('child_process');
const path = require('path')
if (process.argv.length <= 3) {
console.log(`Usage: ${__filename} path/to/directory/with/needles path/to/haystack`);
process.exit(-1);
}
#!/usr/bin/env node
console.log('\x1b[1m','Please wait for linting to run...','\x1b[0m');
console.log('You can','\x1b[1m','skip','\x1b[0m','the precommit hook by running "git commit -n" instead','\x1b[1m', "but beware!",'\x1b[0m');
require('child_process').exec(
'make verify',
function (error, stdout) {
console.log(stdout && 'stdout: ' + stdout);
if (error !== null) {