Skip to content

Instantly share code, notes, and snippets.

View navitronic's full-sized avatar
👋

Adrian Palmer navitronic

👋
View GitHub Profile
@navitronic
navitronic / plugins.json
Created September 7, 2012 00:32
Plugin installer script
{
"debug-bar" : "0.8",
"debug-bar-cron" : "0.1.2",
"developer" : "1.0.0",
"jetpack" : "1.7",
"limit-login-attempts" : "1.7.1",
"log-deprecated-notices" : "0.2",
"monkeyman-rewrite-analyzer" : "1.0",
"monster-widget" : "0.1",
"more-fields" : "2.1",
@navitronic
navitronic / gist:3719206
Created September 14, 2012 01:17
Spites in LESS
.bg-item {
background: transparent url(img/background-sprite.png) no-repeat 0 0;
position: absolute;
display: block;
}
.circle {
.sprite(50px, 49px, 0, 0);
}
@navitronic
navitronic / wp_posts-snippet.sql
Created December 20, 2012 22:49
SQL snippet to get an overview of the types of content in your `wp_posts` table.
SELECT post_type, COUNT(*) AS total
FROM wp_posts GROUP BY post_type;
<table><?php
$css_file = 'foo/bar.css';
$css = file_get_contents($css_file);
preg_match_all('/([a-zA-Z-]+)\:(.+)\;/', $css, $matches);
$totals = array();
foreach ($matches[0] as $match)
{
/\[accordion\]([^\[]+)\[\/accordion\]/

Code Snippets


Show the changed files between two folders

Create a text file showing the differences between two sets of files.

diff -qr foldera folderb | grep -v -e 'DS_Store' -e 'Thumbs' | sort > diffs.txt
@navitronic
navitronic / gist:6588564
Created September 17, 2013 00:28
Channel selector
SF.channel_selector = {
init: function($channel_selector) {
var self = this;
if ($channel_selector.length > 0) {
self.channel_selector = $channel_selector.addClass('selector');
self.channel_tabs = self.channel_selector.find('.channel-tabs a');
self.channel_strip = self.channel_selector.find('.channel-strip');
self.channel_strip.css('width', (self.channel_tabs.length * 100) + '%' );
@navitronic
navitronic / gist:9679452
Created March 21, 2014 04:21
Display all hexadecimal colours within a less or css file.
<?php
$less = file_get_contents(__DIR__ . '/app.less');
preg_match_all('/#([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/', $less, $matches);
$colors = array_values($matches[0]);
$colors = array_map(function($color){ return strtolower($color); }, $colors);
$colors = array_unique($colors);
sort($colors);
@navitronic
navitronic / db-backup.sh
Last active September 15, 2017 23:45
A short bash script that exports all databases into separate gzipped files in a chosen location.
#!/bin/bash
# Example usage
# --
#
# ./db-backup.sh -u username -p password -t /target/
while getopts u:p:t: option
do
case "${option}"
@navitronic
navitronic / pre-push
Created April 1, 2015 23:32
pre-push hook
#!/bin/sh
CMD="make php-cs"
# Check if we actually have commits to push
commits=`git log @{u}..`
if [ -z "$commits" ]; then
exit 0
fi