Skip to content

Instantly share code, notes, and snippets.

View 8bitDesigner's full-sized avatar

Paul Sweeney 8bitDesigner

  • Cisco Meraki
  • Los Angeles
View GitHub Profile
@8bitDesigner
8bitDesigner / 1_loader.md
Last active December 19, 2015 07:49
Simple evented ready state delegator, for cases where you don't have access to anything better.

Set up

<!-- Add this to your Rails app's body tag -->
<body data-controller="<%= request[:controller] %>" data-action="<%= request[:action] %>">

Usage

@8bitDesigner
8bitDesigner / burnThem.js
Last active December 19, 2015 05:19
Find and log every DOMNode on the page which isn't using Proxima Nova as its font-family
// Find and log every DOMNode on the page which isn't using Proxima Nova
// as its font-family
function isHeretic(node) { return (window.getComputedStyle(node).fontFamily.indexOf('proxima-nova') < 0) }
function isVisible(node) { return (window.getComputedStyle(node).display !== 'none') }
function log(node) { console.log(node, window.getComputedStyle(node).fontFamily) }
function toArray(domlist) { return Array.prototype.slice.call(domlist) }
toArray(document.querySelectorAll('#fs-main-content *')).filter(isHeretic).filter(isVisible).forEach(log)
@8bitDesigner
8bitDesigner / 1.md
Last active January 2, 2025 20:52
Git post-merge hook which, when you run `git merge` or `git pull` will then `bundle` if the project's Gemfile changed, or `npm install` if the project's package.json changed.Inspired and based off of https://gist.github.com/bumi/5706550

Make bundleing and npm installing easy

This repo has some handy handy hooks to run bundle or npm install whenever you:

  • git checkout a new branch with a different Gemfile or package.json
  • git pull a change to Gemfile or package.json

How can I has this!!?

  1. git clone https://gist.github.com/5869846.git hooks &amp;&amp; cd hooks &amp;&amp; chmod +x install
@8bitDesigner
8bitDesigner / uneff.sh
Created May 23, 2013 00:17
When your homebrew certfiles get all effed
cert_file="$( openssl version -d | awk -F'"' '{print $2}' )/cert.pem"
mkdir -p "${cert_file%/*}"
security find-certificate -a -p /Library/Keychains/System.keychain > "$cert_file"
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> "$cert_file"
@8bitDesigner
8bitDesigner / remove.sh
Created May 13, 2013 19:54
MacPorts: Recursively remove remnant ports
while [[ -n $(port list leaves 2> /dev/null) ]]; do
sudo port uninstall leaves
done
@8bitDesigner
8bitDesigner / 1.md
Last active December 16, 2015 12:49

Tiny chat app powered by CouchDB

This was cloned off of some work by the fantastic Max Odgen, and does a great job of showing what CouchDB can do.

Messages in the by_time view:

Client side display

@8bitDesigner
8bitDesigner / playlister.js
Created April 18, 2013 18:30
Export your Turntable.fm playlist as JSON, via very hacky script.
var playlist = $('.songs .song').toArray().map(function(song) {
var song = $(song)
, deets = song.find('.details').text().split(' • ')
, image = $(song).find('.thumb').attr('style')
return {
title: song.find('.title').text(),
artist: deets.shift(),
length: deets.shift(),
cover: image ? /\((.*)\)/.exec(image).pop() : null
@8bitDesigner
8bitDesigner / 1.md
Last active December 15, 2015 23:19

Sending a message with node-xmpp

Basically, you just need to create a client, and then send a formatted chunk of XML representing the message. The spec here has the details on what that XML should look like, and ltx is used to create that element.

Usage

node pruneCss.js styles.css output > strippedFile.css

Use Chrome's audit panel to get a list of unused CSS selectors on the current page, and, presuming your CSS file conforms to the style of "[selector] {all; rules; one: one-line;}" this script will print out the CSS file, omitting the unused selectors.

@8bitDesigner
8bitDesigner / 1.md
Last active December 11, 2015 05:18
Bare bones cluster/domain implementation.

What does this do?

  • Spawns as many workers with your web server as you have CPUS
  • The domain around the worker will catch any errors the worker allows to escape, and escaped errors are punishable by death.
  • If a worker crashes, it's rebooted
  • If a worker exits cleanly (suicides), it's not replaced
  • Sending "SIGINT" to the master process will gracefully shutdown the child instances and then exit the master process