Skip to content

Instantly share code, notes, and snippets.

@stinoga
stinoga / functions.php
Created August 1, 2012 02:32
Responsive images in Wordpress posts
// Remove image width/height, so everything can work responsively in posts
function strip_size($html, $id) {
$html = preg_replace('/\<(.*?)(width="(.*?)")(.*?)(height="(.*?)")(.*?)\>/i', '<$1$4$7>',$html);
return $html;
}
add_filter('get_image_tag', 'strip_size', 10, 2);
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
@stinoga
stinoga / terminal
Created August 1, 2012 01:58
Saving SSH keys on Mac
# Run this in terminal to generate a key on your local machine
ssh-keygen -t rsa
# Next, SSH into your site and and copy the contents of the local file ~/.ssh/mykey.pub to the remote file ~/.ssh/authorized_keys
# I use vi for this, and you can have multiple keys in one file
@stinoga
stinoga / post-commit
Created July 18, 2012 13:47
git post commit hook to push to remote repo
#!/bin/sh
# This hook is used to push a mirrored version of all committed files to your remote repo after they are commited
# Replace this variable with your remote repo name
REPO=dropbox
echo
echo "==== Sending changes to $REPO repo ===="
echo
@stinoga
stinoga / .htaccess
Created May 18, 2012 03:16
Wordpress SEO friendly search rewrite rule
# search redirect
# this will take anything in the query string, minus any extraneous values, and turn them into a clean working url
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
RewriteRule ^$ /search/%1/? [NC,R,L]
@stinoga
stinoga / SQL Query to create table
Created April 22, 2012 03:35
Jquery Ajax Email Signup Form in Wordpress
CREATE TABLE `mailinglist` ( `id` INT NOT NULL AUTO_INCREMENT , `email` TEXT NOT NULL, `user` TEXT NOT NULL , PRIMARY KEY ( `id` ) )