Skip to content

Instantly share code, notes, and snippets.

Avatar
✌️

David Pelayo davidpelayo

✌️
View GitHub Profile
@davidpelayo
davidpelayo / zapier-http-digest-multipart-async-example.js
Created Aug 5, 2020
Zapier Node/JS step performing HTTP Digest Auth + Multipart/form-data example
View zapier-http-digest-multipart-async-example.js
// Kudos for this repo: https://github.com/simme/node-http-digest-client
// Original `node-http-digest-client` license: Copyright (c) 2012, Simon Ljungberg <hi@iamsim.me>
// Adapted by @ddpelayo / github.com/davidpelayo / davidpelayo.com - to Modern Javascript
const HTTPDigest = function () {
const crypto = require('crypto');
let http = require('http');
const HTTPDigest = function (username, password, https) {
this.nc = 0;
this.username = username;
@davidpelayo
davidpelayo / what forces layout-reflow.md
Last active Jul 10, 2018
What forces layout-reflow
View what forces layout-reflow.md

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@davidpelayo
davidpelayo / github-pr-toggle-files-bookmarklet.js
Created May 28, 2018
Toggle all files details within a PR
View github-pr-toggle-files-bookmarklet.js
javascript:(function(){var files = document.querySelectorAll('.js-details-target'); for(var i = 0; i<files.length; i++) {files[i].click();}})();
@davidpelayo
davidpelayo / agnoster.zsh-theme
Created Nov 29, 2017 — forked from elijahmanor/agnoster.zsh-theme
Custom Agnoster Zsh Theme to Add Node & Npm Versions
View agnoster.zsh-theme
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
@davidpelayo
davidpelayo / git-delete-merged-script.sh
Created Jun 12, 2017
Delete local and remote branches which have been merged with your current base branch, avoiding to delete master and a branch name
View git-delete-merged-script.sh
#!/bin/bash
#
# With execute permissions of this bash file.
# Checkout on master branch
# Replace <custom_branch> by the branch you want to avoid to be removed (in case any) - for instance: development / staging
# Run:
# - ./git-delete-merged-script.sh -h --- print help
# - ./git-delete-merged-script.sh -r origin --- to delete remote branches based on remote: origin
# - ./git-delete-merged-script.sh -l origin --- to delete local branches based on remote: origin
@davidpelayo
davidpelayo / git-delete-merged-script.sh
Created Jun 12, 2017
Delete local and remote branches which have been merged with your current base branch, avoiding to delete master and a branch name
View git-delete-merged-script.sh
#!/bin/bash
#
# With execute permissions of this bash file.
# Checkout on master branch
# Replace <custom_branch> by the branch you want to avoid to be removed (in case any) - for instance: development / staging
# Run:
# - ./git-delete-merged-script.sh -h --- print help
# - ./git-delete-merged-script.sh -r origin --- to delete remote branches based on remote: origin
# - ./git-delete-merged-script.sh -l origin --- to delete local branches based on remote: origin
@davidpelayo
davidpelayo / mbox-to-csv.py
Created Mar 3, 2016
Simple mbox parser to csv in Python
View mbox-to-csv.py
import mailbox
import csv
writer = csv.writer(open("mbox-output.csv", "wb"))
for message in mailbox.mbox('file.mbox/mbox'):
writer.writerow([message['message-id'], message['subject'], message['from']])
@davidpelayo
davidpelayo / jobsGeneratorGivenForks.groovy
Last active Sep 22, 2015
Jobs generator based on forks of a certain github repo
View jobsGeneratorGivenForks.groovy
//thanks to https://gist.github.com/joshareed/5706061
import groovy.json.JsonSlurper
def owner = "<owner>"
def project = "<project>"
// curl -k -u <user>:<token> -X GET https://api.github.com/repos/<owner>/<repo>/forks > forks.txt
def fetch(addr, params = [:]) {
@davidpelayo
davidpelayo / GithubClient.groovy
Last active Sep 22, 2015 — forked from kyleboon/GithubClient.groovy
Simple Github API client using Groovy RESTClient
View GithubClient.groovy
/**
* Simple Github API client that supports basic auth.
*/
class GithubClient {
String username
String password
String owner
String repository
String fetchFileContents(String filePath) {
@davidpelayo
davidpelayo / GithubClient.groovy
Last active Sep 22, 2015 — forked from joshareed/GithubClient.groovy
Fetch list of issues from Github and draft an email
View GithubClient.groovy
//#!/usr/bin/env groovy
import groovy.json.JsonSlurper
import java.text.SimpleDateFormat
// fetches a Github API URL and parses the result as JSON
def fetch(addr, params = [:]) {
def auth = "<personal api token>"
def json = new JsonSlurper()
return json.parse(addr.toURL().newReader(requestProperties: ["Authorization": "token ${auth}".toString(), "Accept": "application/json"]))
You can’t perform that action at this time.