Skip to content

Instantly share code, notes, and snippets.

@lovasoa
lovasoa / count.js
Last active August 29, 2015 14:05
Count nodes in a page in javascript
// This beautiful oneliner is a recursive function that counts the nodes in a given node
// It uses the ES6 "=>" notation for anonymous functions
var count = (node) => 1 + Array.prototype.slice.apply(node.childNodes).reduce((p,q) => count(q)+p, 0);
// Count the number of nodes in the current document
count(document);
@marcelosomers
marcelosomers / git-php-webhook.php
Last active January 28, 2023 19:07
A basic webhook for deploying updates to repos on Github to your local server
<?php
/**
* This script is for easily deploying updates to Github repos to your local server. It will automatically git clone or
* git pull in your repo directory every time an update is pushed to your $BRANCH (configured below).
*
* Read more about how to use this script at http://behindcompanies.com/2014/01/a-simple-script-for-deploying-code-with-githubs-webhooks/
*
* INSTRUCTIONS:
* 1. Edit the variables below
* 2. Upload this script to your server somewhere it can be publicly accessed