Skip to content

Instantly share code, notes, and snippets.

@mattbanks
mattbanks / js-detectie
Created May 4, 2012 14:24 — forked from padolsey/gist:527683
JavaScript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@mattbanks
mattbanks / gist:2956247
Created June 19, 2012 20:07
Animate Scroll to Top
// Animate scroll to top
$('.top').on('click', function() {
$('body,html').animate({
scrollTop: 0
}, 600);
return false;
});
@mattbanks
mattbanks / gist:2979288
Created June 23, 2012 18:20
WordPress as git submodule
cd wpstarter
git init
touch README.md
git submodule add git://github.com/WordPress/WordPress.git wp
cd wp
git fetch --tags
git checkout 3.4
cd ..
git add .
git commit -m 'core files, checkout 3.4'
@mattbanks
mattbanks / gist:3004901
Created June 27, 2012 15:39 — forked from jchristopher/gist:2998780
AppleScript: iTerm tail PHP error log
tell application "iTerm"
activate
set t to (make new terminal)
tell t
tell (make new session at the end of sessions)
exec command "tail -f /Applications/MAMP/logs/php_error.log"
end tell
end tell
end tell
@mattbanks
mattbanks / gist:3153899
Created July 20, 2012 23:46
Create new WP_Query with TextExpander (version 4 required)
<?php
// New query
$%filltext:name=Query Name:default=myquery%_args = array(
'post_type' => '%filltext:name=Post Type:default=post%',
'order' => '%fillpopup:name=popup 7:default=ASC:DESC%',
'orderby' => '%fillpopup:name=popup 9:default=date:ID:rand:title:author:menu_order%',
'post_status' => 'publish',
'posts_per_page' => %filltext:name=Posts Per Page:default=-1%
);
$%filltext:name=Query Name:default=myquery% = new WP_Query( $%filltext:name=Query Name:default=myquery%_args );
@mattbanks
mattbanks / gist:3379965
Created August 17, 2012 15:35 — forked from billerickson/gist:3379905
WordPress Security
WordPress is actually one of the most secure pieces of software available. It powers 17%
of the 1,000,000 most visited websites, so it is being constantly tested both internally
and by hackers. When an issue is discovered, an update is released which you can install
with one click in the dashboard.
The vast majority of hacked WordPress websites are running an out-of-date version of
WordPress. Once WordPress is updated, any vulnerabilities that are patched are now publicly
known, so old versions are vulnerable.
The next most likely source of hacking is your host. If your server isn't secure, it doesn't
@mattbanks
mattbanks / Key Bindings - User
Created August 23, 2012 13:18
Sublime Text 2 Settings
[
{ "keys": ["super+alt+7"], "command": "encode_html_entities" },
{ "keys": ["shift+ctrl+u"], "command": "title_case" },
{ "keys": ["super+enter"], "command": "insert", "args": {"characters": "<br>\n"} },
{ "keys": ["super+alt+l"], "command": "insert_snippet", "args": {"contents": "<li>${0:$SELECTION}</li>" } },
{ "keys": ["super+alt+b"], "command": "insert_snippet", "args": {"contents": "<strong>${0:$SELECTION}</strong>" } },
{ "keys": ["super+alt+i"], "command": "insert_snippet", "args": {"contents": "<em>${0:$SELECTION}</em>" } },
{ "keys": ["super+alt+n"], "command": "insert_snippet", "args": {"contents": "<span>${0:$SELECTION}</span>" } },
{ "keys": ["super+alt+down"], "command": "insert_snippet", "args": {"contents": "<sub>${0:$SELECTION}</sub>" } },
@mattbanks
mattbanks / README.md
Created August 23, 2012 13:42 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@mattbanks
mattbanks / gist:3487914
Created August 27, 2012 12:13 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mattbanks
mattbanks / gist:4741474
Created February 8, 2013 19:50
Pods 2.3a7 post_content filters
function mb_show_testimonial() {
global $post;
$portfolio = pods( 'portfolio', $post->ID );
?>
<div class="testimonial">
<?php echo $portfolio->display( 'testimonial' ); ?>
</div>
<p class="author"><?php echo $portfolio->display( 'testimonial_author' ); ?></p>