Skip to content

Instantly share code, notes, and snippets.

@jacks0n
jacks0n / utility-classes.css
Created January 14, 2015 03:12
CSS Utility Classes
/* Text colours */
.text-white { color: white; }
.text-black { color: black; }
/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }
.text-nowrap { white-space: nowrap; }
@jacks0n
jacks0n / font-anti-aliasing.css
Created January 14, 2015 03:10
Enables font anti-aliasing, nice and crisp text!
body {
/* Crisp text - antialiase */
font-smoothing: antialiased !important;
-moz-osx-font-smoothing: grayscale !important;
-webkit-font-smoothing: antialiased !important;
-moz-font-smoothing: antialiased !important;
/* Kerning */
text-rendering: optimizeLegibility !important;
@jacks0n
jacks0n / remote-jquery-migrate.php
Created January 14, 2015 03:08
Remove/un-enqueue the jQuery migrate file, which is often not required.
<?php
/**
* Removes the jquery-migrate file, often not-required.
*/
add_filter('wp_default_scripts', 'remove_jquery_migrate');
function remove_jquery_migrate(&$scripts)
{
if (!is_admin()) {
$scripts->remove('jquery');
$scripts->add('jquery', false, array('jquery-core'), '');
@jacks0n
jacks0n / .htaccess
Last active August 29, 2015 14:11
Force the www or non-www canonical domain (example.com => www.example.com or www.example.com => example.com). Includes re-directing files/assets.
# Force the canonical www-subdomain
# example.com => www.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# Force the canonical root domain
# www.example.com => example.com
RewriteEngine On
@jacks0n
jacks0n / wp-auto-login.php
Last active November 19, 2023 16:35
Automatically login to WordPress, with a given user and optionally whitelist IPs. Add this to the bottom of wp-config.php, or your theme functions.php. To automatically login, visit the admin login page (/wp-login.php or /wp-admin/).
/**
* Automatically logs in a visitor when accessing the admin login area (/wp-login.php)
*
* @copyright Copyright (c) 2014, Jackson Cooper
* @license MIT
*
* Whitelist IPs: add IPs to whitelist in $ip_whitelist. If it is empty, it will allow all IPs.
* Username: Specify the username to login as with the "user" GET parameter (eg. ?user=admin).
* If the "user" get parameter is not set, $default_user_login will be used. If set
* to "*", it will login as the first administrator found. Otherwise it will use the
@jacks0n
jacks0n / SQL Queries to Cleanup WordPress.sql
Last active September 17, 2019 19:55
Useful SQL Queries to Cleanup a WordPress Database
-- Delete all old post revisions
DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision';
-- Cleanup weird characters
UPDATE wp_posts SET post_content = REPLACE(post_content, '“', '“');
UPDATE wp_posts SET post_content = REPLACE(post_content, '”', '”');
UPDATE wp_posts SET post_content = REPLACE(post_content, '’', '’');
UPDATE wp_posts SET post_content = REPLACE(post_content, '‘', '‘');
@jacks0n
jacks0n / .htaccess
Created June 6, 2014 03:37
Lock down a specific site to a given IP address
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !=59.167.223.97
RewriteRule ^(.*)$ 404.php [R=404,L]
</IfModule>
@jacks0n
jacks0n / .gitignore
Created May 28, 2014 11:37
Minimal .gitignore
# OS's
.DS_Store
Desktop.ini
Thumbs.db
# Server
.ftpquota
error_log
cgi-bin/
.htpasswd
@jacks0n
jacks0n / fix-permissions.sh
Last active August 29, 2015 14:01
Fixes / restores permissions for most CMSs
# General
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
# Magento
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod 550 mage # For magento 1.5+
# Joomla
@jacks0n
jacks0n / install-google-fonts.sh
Created May 19, 2014 02:22
Install all Google Fonts for OS X
# To update replace line below with: hg pull && hg update
hg clone https://googlefontdirectory.googlecode.com/hg/ googlefonts
find . -name "*.ttf" -exec cp {} /Library/Fonts \;
fc-cache -f