Skip to content

Instantly share code, notes, and snippets.

@dariye
dariye / crypto.js
Last active August 21, 2018 01:05
Validate github webhook event
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')}`
}
@dariye
dariye / index.js
Last active August 21, 2018 01:06
Github webhook handler
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
@dariye
dariye / labeled.js
Last active August 21, 2018 01:14
Handler for 'labeled' event on a github issue
/**
* 'labeled' event handler
* @param {Object} payload Github event payload
*/
const { query } = require('../graphql')
const {
graphqlClient,
addProjectCard,
moveProjectCard,
baseVariables
@dariye
dariye / docker.md
Last active May 24, 2018 20:18
Running Docker locally
docker-machine start default

eval "$(docker-machine env default)"
@dariye
dariye / deploy_from_subfolder.md
Last active October 7, 2021 15:23
Deploying to Heroku from Subfolder

Context

What happens when you have a nested directory you want to deploy i.e

./root_dir/
|__sub_dir
|__..

Usage

@dariye
dariye / sc.js
Last active May 11, 2016 22:13
//Inspired by http://g-liu.com/blog/2013/08/tutorial-basic-carouselslideshow-with-javascript/
var SimpleCarousel = function(id, options){
this.id = id || 'slides'; // default id -> #slides
this.class = options.class || 'slide'; // default child class -> .slide
this.w = options.width;
this.h = options.height;
this.duration = options.duration || 4000; // default 4s
this.container = document.getElementById(this.id);
@dariye
dariye / gist:f46afcb481e659af31a5
Created February 28, 2016 20:42
update a forked repo
# source: http://stackoverflow.com/questions/7244321/how-to-update-a-github-forked-repository
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
@dariye
dariye / batcharge.py
Last active September 17, 2015 05:19 — forked from remy/batcharge.py
My zsh set up as of July 25, 2013
#!/usr/bin/env python
# saved to ~/bin/batcharge.py and from
# http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/#my-right-prompt-battery-capacity
#!/usr/bin/env python
# coding=UTF-8
import math, subprocess
p = subprocess.Popen(["ioreg", "-rc", "AppleSmartBattery"], stdout=subprocess.PIPE)
output = p.communicate()[0]
@dariye
dariye / devplylist.markdown
Last active August 29, 2015 14:01
music ---coder/gamer style

Music that Keeps you Typing and Thinking

On this very regular day,

I was just skimming the web as I infrequently do :) and came across this article by fast company. I just recently got serious about programming so I'm still in that early stage of easy distractions and child-like concentration spans. Well I've tried all sorts of music, maybe not all though, and none seem to work at keeping my mind at bay. Found a great playlist in the comment by LENA ELCHAMAA . Enjoy and maybe share your own playlists. I hope I can have a listen to all

Gist inspired by post fast company