Skip to content

Instantly share code, notes, and snippets.

@adamturtle
adamturtle / Wordpress list last 5 posts by last modified date
Created June 26, 2012 20:46
Wordpress list last 5 posts by last modified date
$args=array(
'orderby'=> 'modified',
'order' => 'ASC',
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 5,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
@adamturtle
adamturtle / blogger-password-protect
Last active June 14, 2022 02:05
Password protect for Blogger. Paste this snippet before the closing </body> tag in your blogger template. It's a simple jQuery login box, so not very secure at all (a simple 'view-source' will reveal the password…) but is effective for at least partial privacy. Customize the password on line 64.
<style type='text/css'>
#custom_overlay {
background: #222;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 3000;
}
@adamturtle
adamturtle / functions.php
Created June 7, 2013 14:12
Replaces the standard "Error with submission" message in Gravity Forms with a more useful summary of the errors.
<?php
function gf_custom_validation_message($message, $form){
return '<div class="validation_error">Please correct the following errors:<br/><div id="error_list"></div></div>';
}
add_filter("gform_validation_message", "gf_custom_validation_message", 10, 2);
@adamturtle
adamturtle / 0_reuse_code.js
Created September 27, 2013 15:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/usr/bin/env bash
#
# simple recursive search and replace string in files
# setup: alias replace='~/replace.sh'
# notes: you will need to escape special chars! eg: replace '\/dir1' '\/dir2' .
# usage: replace <oldstring> <newstring> <path> <depth>
# examples:
# replace "([^\s]+.php)" "\/\1" .
# replace "\"\/([^\/]+.php)" "\"\/dir\/\1" .
/*
Theme Name: Example Child Theme Name
Theme URI: http://child-theme-homepage.tld
Description: A description of your child theme.
Author: Child Theme Author Name
Author URI: http://child-theme-author-homepage.tld
Version: 1.0
Tags: translation-ready, ...
@adamturtle
adamturtle / gist:8797154
Last active August 29, 2015 13:56
Child theme comment
/*
Theme Name: Child Theme {Child Theme of Worpress Foundation}
Theme URI: http://320press.com/wpfoundation
Description: A bones/Zurb foundation based wordpress theme.
Version: 1.0
Template: wordpress-foundation
*/
@import url("../wordpress-foundation/style.css");
@adamturtle
adamturtle / module.js
Created August 6, 2014 20:55
Javascript module pattern
var Module = (function(){
// private var
var _privateVar = "private";
// private method
function _privateMethod() {
return "private bar";
}
// return public
/**
* Takes a jQuery collection and wraps each 'groupSize' items with 'wrapHtml'
* Example: $('#Example span').wrapInGroups('<div/>', 4);
* Will wrap every 4 span's inside #Example with a div
* See for yourself: http://jsfiddle.net/M9ZFh/
* Author: iMoses (imoses.g@gmail.com)
*/
(function($) {
$.fn.wrapInGroups = function(wrapHtml, groupSize) {
var selector = this.selector;
@adamturtle
adamturtle / style.css
Created September 19, 2014 17:33
Full width div break container
.break {
margin-left:-100%;
margin-right:-100%;
}