Skip to content

Instantly share code, notes, and snippets.

Adrian Palmer navitronic

Block or report user

Report or block navitronic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@navitronic
navitronic / db-backup.sh
Last active Sep 15, 2017
A short bash script that exports all databases into separate gzipped files in a chosen location.
View db-backup.sh
#!/bin/bash
# Example usage
# --
#
# ./db-backup.sh -u username -p password -t /target/
while getopts u:p:t: option
do
case "${option}"
View export-table.php
<?php
/*** mysql hostname ***/
$hostname = 'localhost';
$dbname = 'dbname';
/*** mysql username ***/
$username = 'username';
@navitronic
navitronic / gist:758177
Created Dec 29, 2010
PHP Code to remove Google Analytics cruft from urls
View gist:758177
<?php
preg_replace('/(\?|\&)?utm_[a-z]+=[^\&]+/', '', 'http://mashable.com/2010/12/14/android-quick-start-guide/?utm_source=twitterfeed&utm_medium=twitter&utm_campaign=Feed%3A+Mashable+%28Mashable%29');
// Returns http://mashable.com/2010/12/14/android-quick-start-guide/
# 100 urls to test against
# ========================
#
# http://activeinboxhq.com/?utm_medium=Argyle+Social&utm_source=TweetDeck&utm_content=http=//activeinboxhq.com/
View gist:6588564
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) + '%' );
View code-snippets.md

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
View gist:4561344
/\[accordion\]([^\[]+)\[\/accordion\]/
View css-analysis.php
<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)
{
@navitronic
navitronic / wp_posts-snippet.sql
Created Dec 20, 2012
SQL snippet to get an overview of the types of content in your `wp_posts` table.
View wp_posts-snippet.sql
SELECT post_type, COUNT(*) AS total
FROM wp_posts GROUP BY post_type;
View gist:3719206
.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 / plugins.json
Created Sep 7, 2012
Plugin installer script
View plugins.json
{
"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",
You can’t perform that action at this time.