Skip to content

Instantly share code, notes, and snippets.

View aoberoi's full-sized avatar
👷‍♂️
Under construction

Ankur Oberoi aoberoi

👷‍♂️
Under construction
View GitHub Profile
@aoberoi
aoberoi / README.md
Last active June 2, 2023 02:18
How macOS treats Spaces with multiple displays

How macOS treats Spaces with multiple displays

👷‍♀️ Under construction... 🚜

TL;DR: Leave the first space on your monitor empty forever and just have a second space. The empty first space on the monitor will merge with the first space on the laptop when you unplug the monitor. The 2nd through Nth spaces on the external monitor will move onto the laptop with thier windows. When you plug the monitor back in, the 2nd through Nth spaces will move back to the monitor as expected.

@aoberoi
aoberoi / example-listener-middleware.js
Last active September 1, 2020 17:27
example of a bolt listener middleware that catches errors in view submission handlers and pushes a view
import { App } from '@slack/bolt';
const app = new App(...);
// a listener middleware.
// could easily be shared. can be refactored into a global middleware too.
function pushViewOnErrors(errorViewTemplate) {
return async function _pushViewOnErrors({ body, client, logger, ack, next }) => {
try {
await next();
const { createServer } = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const { createEventAdapter } = require('@slack/events-api');
const { createMessageAdapter } = require('@slack/interactive-messages');
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET;
const port = process.env.PORT || 3000;
const slackEvents = createEventAdapter(slackSigningSecret);
const slackInteractions = createMessageAdapter(slackSigningSecret);

An exploration of ideas for the API and implementation of the next generation RTMClient in Python

Multiprocessing agnostic

At a minimum, the RTMClient must provide a means for application developers to bring their own multiprocessing opinions and implementaitons.

The simplest implementation an app developer might use is exactly what we've recommended every developer use in the current version of the package: an infinite loop that polls for new data in the main thread of a single process.

@aoberoi
aoberoi / README.md
Last active January 15, 2019 18:53
Working out an API proposal for Slapp v4

Slapp v4 Proposal

This proposal expresses a design that leans towards solving problems with middleware. This is motivated by the need to support migratability from Hubot, deliver extensibility in the framework, and to lay the ground work for a plugin API in the future.

Please add feedback Does this feel unintuitive? Complicated? Are there use cases that you beleive should be easy hard to implement using this API? Please comment below.

There are some wrinkles that still need to be ironed out. These are noted below where they come up.

@aoberoi
aoberoi / projects-change-column-with-touch.md
Last active November 2, 2018 19:45
A couple papercuts I'd like to see addressed in GitHub

What

Create an affordance in the GitHub Projects UI for users on touch-based interfaces to change the column of a card.

Why

Users can already drag and drop new cards into a project using a touch-based interface. But once that card is in a specific column, there's no way to move it to another. This feels maddening, because I'm forced to question whether I am too stupid to see something that should be obvious. I realize that adding drag events would be complicated, because dragging on both the X and Y axes are already bound to panning/scrolling the columns on the board. But, there's a flyout menu ... on each card, that seems like it could accomodate an additional "Move card to..." item, or something like that. This could also benefit users with accessibility

const http = require('http');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const { WebClient } = require('@slack/client');
const { createMessageAdapter } = require('@slack/interactive-messages');
const slack = new WebClient(process.env.SLACK_ACCESS_TOKEN);
const slackInteractions = createMessageAdapter(process.env.SLACK_SIGNING_SECRET);
// define dispatch table OR import it from somewhere else
// const commands = require('./commands/live/somewhere');
const commands = {
first: (foo, bar) => { /* ... */ },
second: (baz) => { /* ... */ },
help: (commandName) => { /* ... */ }
};
function usingDispatch(commandName, ...args) {
const command = commands[commandName] || commands.help;
import Duplexify = require("duplexify");
new Duplexify();
new Duplexify(writable);
new Duplexify(undefined, readable);
new Duplexify(undefined, undefined, opts);
new Duplexify(writable, readable);
new Duplexify(undefined, readable, opts);
new Duplexify(writable, undefined, opts);
new Duplexify(writable, readable, opts);
@aoberoi
aoberoi / enumerable_props.md
Last active December 30, 2017 22:31
JavaScript objects as key-value pairs or dictionaries

Cheatsheet for JavaScript objects as key-value pairs (object literals)

In many JavaScript programs, plain objects are used as a hash map, a dictionary, or as a simple set of key-value pairs. JavaScript properties can be a little tricky, so this cheatsheet maps out options for accessing those enumerable properties. Non-enumerable properties are usually not interesting in this usage (this includes methods, constructor, etc).

Own Properties Own & Prototype Properties
Exists? x.propertyIsEnumerable(name) Requires walking up the prototype chain