Skip to content

Instantly share code, notes, and snippets.

View pluma's full-sized avatar
👋
Looking for projects

Alan Plum pluma

👋
Looking for projects
View GitHub Profile
import React from "react";
import { Link } from "react-router-dom";
import uuid from "uuid";
type Crumb = { id: string; url: string; title: string };
type Action =
| { type: "UPSERT"; payload: Crumb }
| { type: "REMOVE"; payload: { id: string } };
@pluma
pluma / express-windows-sso.js
Last active August 22, 2019 16:35
Example for an express app implementing Windows SSO (SPNEGO/GSSAPI)
"use strict";
const kerberos = require("kerberos");
const express = require("express");
const app = express();
// Make sure kerberos keytab is at /etc/krb5.keytab
// See https://github.com/mongodb-js/kerberos/blob/master/test/scripts/travis.sh
// for an example setup of a full kerberos dummy environment including a keytab
// If kerberos service name is HTTP/www.example.com@AD.EXAMPLE.COM
@pluma
pluma / profiles.json
Created July 17, 2019 14:07
Windows Terminal config with Night Owl theme and minor adjustments.
{
"globals": {
"alwaysShowTabs": true,
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"initialCols": 120,
"initialRows": 30,
"keybindings": [
{
"command": "closeTab",
"keys": ["ctrl+w"]
@pluma
pluma / Loader.tsx
Last active November 28, 2017 03:11
Component for handling async data fetching with redux?
import { Error, ErrorType } from "./Error";
import { Loading } from "./Loading";
import React from "react";
type LoaderProps = {
id: string;
error?: Object;
data: any;
isLoading: boolean;
@pluma
pluma / devrant.css
Last active November 15, 2017 12:38
Want DevRant in full-width on the desktop? Use this stylesheet to override the CSS.
@media (min-width: 880px) {
.interior-centered {
margin: 0;
width: auto;
}
.interior-content {
width: auto;
}
.body-col1 {
display: none;
@pluma
pluma / stringifyJsonml.js
Created November 12, 2017 00:49
Converting JSONML to XML (without sanity checks)
function isObject(obj) {
if (!obj) return false;
if (typeof obj !== "object") return false;
if (Array.isArray(obj)) return false;
return true;
}
function* stringifyElement(element, indentLevel, depth = 0) {
const indent =
typeof indentLevel === "string"
@pluma
pluma / jsonmlElement.js
Created November 12, 2017 00:47
Creating a DOM-like element tree from JSONML
function isObject(obj) {
if (!obj) return false;
if (typeof obj !== "object") return false;
if (Array.isArray(obj)) return false;
return true;
}
class Element {
constructor(tagName, attributes, ...children) {
this.tagName = tagName;
@pluma
pluma / hyper-stayalive.js
Created September 29, 2017 16:01
Prevent window from closing when last tab is closed (works great with autohide and visor)
'use strict';
const seen = new Set();
const $KNOWS_TO_HIDE = Symbol('knowsToHide');
exports.onWindow = window => {
if (window[$KNOWS_TO_HIDE]) return;
window[$KNOWS_TO_HIDE] = true;
window.rpc.on('hide', () => setTimeout(() => window.hide(), 0));
};
exports.middleware = store => next => action => {
switch (action.type) {
@pluma
pluma / autohide.js
Created September 29, 2017 15:58
Automatically hide Hyper.app on startup by running `HYPER_AUTOHIDE=1 hyper`
'use strict';
const $AUTO_HIDDEN = Symbol('autoHidden');
if (process.env.HYPER_AUTOHIDE) {
exports.onApp = app => {
if (app[$AUTO_HIDDEN]) return;
app[$AUTO_HIDDEN] = true;
const windows = app.getWindows();
for (const window of windows.values()) {
setTimeout(() => window.hide(), 500);
}
@pluma
pluma / arrutils.js
Created February 19, 2017 12:41
ES6 non-mutating array manipulation helpers
export const replace = (arr, index, value) => [
...arr.slice(0, index),
value,
...arr.slice(index + 1)
]
export const insert = (arr, index, value) => [
...arr.slice(0, index),
value,
...arr.slice(index)