Skip to content

Instantly share code, notes, and snippets.

View karlhorky's full-sized avatar

Karl Horky karlhorky

View GitHub Profile
@karlhorky
karlhorky / package.json
Last active April 12, 2018 15:03
Yarn: Set options conditionally based on value of positional argument
{
"scripts": {
"cli": "bash -c 'node -r @babel/register src/cli.js $1 $([[ $1 =~ login|logout ]] && echo \"--identity ../local-dev/cli_id_rsa\" || echo \"\")' -- "
}
}
@karlhorky
karlhorky / 1.js
Last active April 6, 2018 05:25
Asynchronous Configuration in Node.js
import {setPath} from './2';
(async () => {
await setPath();
// Could also do dynamic import() here with https://github.com/airbnb/babel-plugin-dynamic-import-node
require('./3');
})();
@karlhorky
karlhorky / in-browser-notepad
Last active February 23, 2018 10:17
In-browser notepad URL
# Enter this in the browser address bar to get a simple page where text can be added:
data:text/html,<html contenteditable>
@karlhorky
karlhorky / signature.scpt
Last active April 28, 2023 17:16
Add HTML Signature to Outlook 2016 on macOS without Attachment Bug
#!/usr/bin/osascript
-- To fix error with Outlook 2016 HTML signature images showing up as attachments
-- Ref: http://mydesignpad.com/how-to-create-an-attractive-html-email-signature-for-microsoft-outlook-2016-for-mac/#comment-36065
-- To use, add your signature name (under `name`) and signature (under `content`) and paste and run this code in Script Editor
tell application id "com.microsoft.Outlook"
make new signature with properties {name:"Google Signature", content:"<table><tr><td><img src='https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png' width='120' height='44'></td></tr></table>"}
end tell
@karlhorky
karlhorky / convert-markdown-references-to-inline.md
Created July 24, 2017 09:41
Regular expression: Change Markdown reference links to inline

This regex will allow search and replace to change Markdown links using references (matching ][...] pattern) to inline links.

It will leave the document otherwise untouched.

Search:

\]\[([^\]]+)\]([\s\S]+\1\]: (http.+))$
@karlhorky
karlhorky / webpack-dev-server-show-all-modules.js
Created April 17, 2017 21:49
Show all hidden modules in webpack-dev-server output
const WebpackDevServer = require('webpack-dev-server');
const webpackOptions = require('../config/webpack/webpack.dev');
const compiler = webpack(webpackOptions);
const devServer = new WebpackDevServer(compiler, {
quiet: false, // Turn on logging (false is the default)
stats: {
maxModules: Infinity, // Does the same thing as --display-modules webpack command line option (shows all hidden modules)
},
{
profile:false,
module:{
loaders:[
{
test:[
Function:shouldBeHandledByLoader
],
loader:'react-hot'
},
@karlhorky
karlhorky / request-local-storage-singleton.js
Created February 16, 2017 10:39
request-local-storage global singleton
// Before
module.exports = {
getNamespace: getNamespace,
getCountNamespaces: getCountNamespaces,
startRequest: startRequest,
bind: bind,
patch: patch
};
// After (singleton in global namespace)
@karlhorky
karlhorky / react-server-route-groups.js
Last active February 13, 2017 16:58
react-server route groups (for translated path fragments)
// Beware! Not tested.
// open source library: `react-server-route-groups`
// - function to generate routes based on array of things (in our case, translations)
export default function ({groups, pages}) {
return groups.reduce((acc, group) => {
return {
// All previous routes
...acc,