Skip to content

Instantly share code, notes, and snippets.

🥑
ArangoDB

Alan Plum pluma

🥑
ArangoDB
Block or report user

Report or block pluma

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pluma
pluma / profiles.json
Created Jul 17, 2019
Windows Terminal config with Night Owl theme and minor adjustments.
View profiles.json
{
"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 Nov 28, 2017
Component for handling async data fetching with redux?
View Loader.tsx
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 Nov 15, 2017
Want DevRant in full-width on the desktop? Use this stylesheet to override the CSS.
View devrant.css
@media (min-width: 880px) {
.interior-centered {
margin: 0;
width: auto;
}
.interior-content {
width: auto;
}
.body-col1 {
display: none;
@pluma
pluma / stringifyJsonml.js
Created Nov 12, 2017
Converting JSONML to XML (without sanity checks)
View stringifyJsonml.js
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 Nov 12, 2017
Creating a DOM-like element tree from JSONML
View jsonmlElement.js
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 Sep 29, 2017
Prevent window from closing when last tab is closed (works great with autohide and visor)
View hyper-stayalive.js
'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 Sep 29, 2017
Automatically hide Hyper.app on startup by running `HYPER_AUTOHIDE=1 hyper`
View autohide.js
'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 Feb 19, 2017
ES6 non-mutating array manipulation helpers
View arrutils.js
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)
View xunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="/hello" timestamp="2016-11-23T15:32:04.685Z" tests="31" errors="0" failures="6" skip="1" time="66">
<testcase classname="global" name="is global" time="0"/>
<testcase classname="An error" name="is an error" time="0">
<failure type="Error" message="banana">
Error: banana
at Context.&lt;anonymous> (/home/pluma/projects/arango/_local/3.1.devel/arango-apps/_db/_system/hello/APP/test/queries.js:12:11)
at Function.global.DEFINE_MODULE.exports.nextTick [as immediately] (./js/common/bootstrap/modules/process.js:26:5)
</failure>
</testcase>
View cancellable.js
/*global assert*/
class CancellationError extends Error {}
CancellationError.prototype.name = 'CancellationError'
function deferred () {
let _resolve, _reject
const promise = new Promise((resolve, reject) => {
_resolve = resolve
_reject = reject
})
You can’t perform that action at this time.