Skip to content

Instantly share code, notes, and snippets.

☯️
Be

Paul Dariye pauldariye

☯️
Be
Block or report user

Report or block pauldariye

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
View theme.ts
import { darken, parseToHsl, hsl, getLuminance } from "polished";
const addAliases = (arr: (string | number)[], aliases: string[]) =>
aliases.forEach((key, i) =>
Object.defineProperty(arr, key, {
enumerable: false,
get() {
return this[i];
}
})
);
View folder-structure.md

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
View micro-db-server.js
const { json, send } = require('micro')
module.exports = async (req, res) => {
return send(res, 200, req.url)
}
@pauldariye
pauldariye / micro-proxy.js
Created Sep 7, 2018
micro-proxy.js programmatic usage
View micro-proxy.js
const createProxy = require('micro-proxy')
const services = require('./services')
const {port} = require('./config').server
const server = createProxy(Object.values(services)
.map(service => service[process.env.NODE_ENV]))
server.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
@pauldariye
pauldariye / github.js
Last active Aug 21, 2018
GitHub api clients and utility methods
View github.js
const async = require('async')
const Github = require('github-api')
const { GraphQLClient } = require('graphql-request')
const { query, mutation } = require('../graphql')
const config = require('../config')
const { token, repo, owner } = config.github
const issues = new Github({ token }).getIssues(`${owner}/${repo}`)
const graphqlClient = new GraphQLClient('https://api.github.com/graphql', {
headers: { Authorization: `bearer ${token}`, }
@pauldariye
pauldariye / crypto.js
Last active Aug 21, 2018
Validate github webhook event
View crypto.js
const crypto = require('crypto')
/**
* Sign request body using secret and HTTP request body
* @param {string} key Secret key
* @param {body} body HTTP request body
* @returns {string} Generate hash code
*/
function signRequestBody (key, body) {
return `sha1=${crypto.createHmac('sha1', key).update(body, 'utf-8').digest('hex')}`
}
@pauldariye
pauldariye / index.js
Last active Aug 21, 2018
Github webhook handler
View index.js
const { json, send, text } = require('micro')
const micro = require('micro')
const config = require('../config')
const actions = require('../actions')
const { signRequestBody } = require('../lib/crypto')
/**
* Main request handler
* @param {Object} req HTTP request object
* @param {Object} res HTTP response object
* @returns {Object} Updated server response object
@pauldariye
pauldariye / labeled.js
Last active Aug 21, 2018
Handler for 'labeled' event on a github issue
View labeled.js
/**
* 'labeled' event handler
* @param {Object} payload Github event payload
*/
const { query } = require('../graphql')
const {
graphqlClient,
addProjectCard,
moveProjectCard,
baseVariables
You can’t perform that action at this time.