Skip to content

Instantly share code, notes, and snippets.

@mattslack
mattslack / gist:1214139
Created September 13, 2011 15:38
Color Selector
<style>
.spectrum {
display: block;
width: 150px;
height: 15px;
margin-left: 2px;
background: -webkit-linear-gradient(left, hsl(0,100%,50%),hsl(60,100%, 50%), hsl(120,100%, 50%), hsl(180, 100%, 50%), hsl(240,100%,50%), hsl(300,100%,50%) 100%),
-moz-linear-gradient(left, hsl(0,100%,50%),hsl(60,100%, 50%), hsl(120,100%, 50%), hsl(180, 100%, 50%), hsl(240,100%,50%), hsl(300,100%,50%) 100%)
-o-linear-gradient(left, hsl(0,100%,50%),hsl(60,100%, 50%), hsl(120,100%, 50%), hsl(180, 100%, 50%), hsl(240,100%,50%), hsl(300,100%,50%) 100%);
}
@mattslack
mattslack / drupal_to_6.sql
Created October 11, 2011 21:48
Some handy SQL queries to make the move from Drupal 5 to Drupal 6 go better
DROP TABLE IF EXISTS cache_form;
DROP TABLE IF EXISTS menu_router;
DROP TABLE IF EXISTS menu_links;
DROP TABLE IF EXISTS menu_custom;
CREATE TABLE IF NOT EXISTS `cache_location` (
`cid` varchar(255) NOT NULL default '',
`data` longblob,
`expire` int(11) NOT NULL default '0',
`created` int(11) NOT NULL default '0',
@mattslack
mattslack / sentinel_cleaner.user.js
Last active December 11, 2015 02:29
A handy Chrome user script that clears out a bunch of visual crap (including some ads) from the Holland Sentinel website.
// ==UserScript==
// @name Sentinel Cleaner
// @version 1.4.14
// @author Matt Slack
// @description Depaginates articles, and clears out a bunch of visual crap (including most ads) from the Holland Sentinel website.
// @match http://www.hollandsentinel.com/*
// ==/UserScript==
(function () {
"use strict";
@mattslack
mattslack / pocket_readability.user.js
Last active August 10, 2017 17:11
Improve the readability on Pocket (formerly Read it Later).
// ==UserScript==
// @name Pocket Readability
// @version 1.3
// @author Matt Slack
// @description Improve the readability on Pocket (formerly Read it Later).
// @match https://getpocket.com/a/*
// ==/UserScript==
// Stolen from https://developer.mozilla.org/en-US/docs/DOM/CSSStyleSheet/insertRule
function addStylesheetRules(decls) {
@mattslack
mattslack / gitclean.sh
Created October 17, 2013 13:53
Clean up a directory full of git repos. Maybe get back some hard disk space.
#!/bin/zsh
PROJECTS_DIR="${HOME}/Projects"
cd $PROJECTS_DIR
for client in `find ${PROJECTS_DIR} -type d -name ".git"`; do
cd ${client}
cd ..
echo "Checking: `pwd`"
git gc
git remote prune origin
if [ -d log ]; then
@mattslack
mattslack / selector_count.js
Last active September 14, 2017 15:08
Count the number of CSS selectors used on a given page.Refactored from: http://stackoverflow.com/questions/5228459/selector-count-in-css
/*properties
cssRules, href, length, log, selectorText, split, styleSheets
*/
(function () {
"use strict";
var j = 0,
totalRules = 0,
totalSelectors = 0,
count_rules = function (styleSheet) {

Keybase proof

I hereby claim:

  • I am mattslack on github.
  • I am mattslack (https://keybase.io/mattslack) on keybase.
  • I have a public key whose fingerprint is 705E 29C1 8381 0626 0938 288C 99D3 7AA5 F656 C3FD

To claim this, I am signing this object:

@mattslack
mattslack / dupefinder.js
Last active March 1, 2017 21:36
Find duplicate IDs in a document.
(function () {
"use strict";
var find_dupes = function () {
var identified = document.querySelectorAll('[id]'),
unique = [],
dupes = [],
id,
idx = 0;
while (idx < identified.length) {
id = (identified[idx]).getAttribute('id');
@mattslack
mattslack / remaster.sh
Last active May 8, 2020 14:17
Checkout a branch, update gems, run migrations, and prune merged branches
#!/bin/sh
BRANCH="master"
ROOT=`git rev-parse --show-toplevel`
[[ 0 < $# ]] && BRANCH=$1
[[ `git status -b -s --porcelain | egrep '^\#\# ($BRANCH)'` ]] || git checkout ${BRANCH} && {
(git pull origin ${BRANCH} || git pull --rebase origin ${branch} ) &&
git fetch -a &&
@mattslack
mattslack / pre-commit
Last active March 10, 2020 19:38
git hooks
#!/bin/bash
# Built off of Standard JS's pre-commit example: https://standardjs.com/#is-there-a-git-pre-commit-hook
# Ensure all files staged for commit pass standard code style
function xargs-r() {
# Portable version of "xargs -r". The -r flag is a GNU extension that
# prevents xargs from running if there are no input files
if IFS= read -r -d $'\n' path; then
{ echo "$path"; cat; } | xargs $@