Skip to content

Instantly share code, notes, and snippets.

# Regex to count paths with 4 slashes
(\/[^\/]*){4}
# Regex to count paths with starting text
\/issues(\/[^\/]*){3}
@robflaherty
robflaherty / word-frequency.py
Created April 23, 2019 15:40
Simple word frequency counter
import re
words = re.findall(r'\w+', open('term-list.csv').read().lower())
counts = Counter(words).most_common(500)
@robflaherty
robflaherty / gist:4d61c91ee1d771421c2b
Created October 14, 2015 14:14
Riveted Non-Bounce Example
riveted.init({
eventHandler: function(data) {
if (data == 10) {
ga('send', 'event', 'Non-Bounce', 'True');
}
}
});
@robflaherty
robflaherty / nginx-0765-installer.txt
Created February 19, 2010 00:39
Nginx 0.7.65 installer for Webfaction
-----BEGIN WEBFACTION INSTALL SCRIPT-----
#!/bin/env python2.4
"""
Nginx 0.7.65 Installer New
"autostart": not applicable
"extra info": Enter domain name for the nginx app
"""
{
"keywords": [
{
"text": "natural gas",
"relevance": 0.957925
},
{
"text": "natural gas meters",
"relevance": 0.832745
},
/*
* Inspired by (directly copied from) Mathias Bynens' optimized Google Analytics snippet
* http://mathiasbynens.be/notes/async-analytics-snippet
* Not fully tested, use at own risk!
*/
<script>
var clicky = { log: function(){ return; }, goal: function(){ return; }},
clicky_site_id = XXXXXX;
(function(d, t) {
@robflaherty
robflaherty / gist:7e06ea29c077ef33badf
Last active February 16, 2016 20:05
Remove annoying WordPress inline width on captions
// removes WordPress inline style width on captions
add_filter( 'img_caption_shortcode_width', '__return_zero' );
if (window.Notification) {
Notification.requestPermission(function() {
setTimeout(function(){
var n = new Notification('News Alert', {
'body' : 'S&P Surpasses 2000'
});
n.onclick = function() {
location.href = 'http://';
@robflaherty
robflaherty / gist:5388589
Created April 15, 2013 14:39
data attribute initializing boilerplate
(function($, window, undefined) {
"use strict";
var Plugin = function(element, options) {
this.element = element;
this.$element = $(element);
this.init();
};
@robflaherty
robflaherty / gist:2430219
Created April 20, 2012 16:42
sudo PATH stuff
sudo env PATH=$PATH dowhatever
Example:
sudo env PATH=$PATH npm uninstall -g less