Skip to content

Instantly share code, notes, and snippets.

@mattmanning
mattmanning / drugwars.txt
Created June 1, 2011 16:09
Drugwars for the TI-82/83/83+ Calculators
Lbl G
ClrHome
Disp " J.M.'S DRUGWAR"," SIMULATION",""," VERSION 2.00",""," JUST SAY NO."
2000→Z
5000→Y
0→V
100→K
1→B
2→N
0→I
@addyosmani
addyosmani / jQueryPluginPatterns.js
Created August 31, 2011 18:02
jQuery Plugin Patterns
/*
A (very) WIP collection of optimized/recommended jQuery plugin patterns
from @addyosmani, @cowboy, @ajpiano and others.
Disclaimer:
-----------------------
Whilst the end-goal of this gist is to provide a list of recommended patterns, this
is still very much a work-in-progress. I am not advocating the use of anything here
until we've had sufficient time to tweak and weed out what the most useful patterns
anonymous
anonymous / check-time-wordpress
Created October 4, 2011 18:40
checks current time against time of post and expires the post if it's older than today.
// setting posts with current date or older to draft
if (!wp_next_scheduled('sfn_expire_hook')){
wp_schedule_event( time(), 'hourly', 'sfn_expire_hook');
}
add_action( 'sfn_expire_hook', 'sfn_show_expire');
add_action( 'sfn_expire_hook', 'sfn_show_expire');
function sfn_show_expire(){
global $wpdb;
$server_time = date('U');
// below echoes date so we know what's up with the server date
@n1k0
n1k0 / gist:1501173
Created December 20, 2011 10:44 — forked from fbuchinger/gist:1501115
PhantomJS: Capturing single dom elements as png files
var page = new WebPage(),
address, output, size;
//capture and captureSelector functions adapted from CasperJS - https://github.com/n1k0/casperjs
capture = function(targetFile, clipRect) {
var previousClipRect;
var clipRect = {top: 0, left:0, width: 40, height: 40};
if (clipRect) {
if (!isType(clipRect, "object")) {
throw new Error("clipRect must be an Object instance.");
@helen
helen / wp-chosen-tax-metabox.php
Last active April 24, 2022 02:25
Use Chosen for a replacement WordPress taxonomy metabox
<?php
/**
* WordPress Chosen Taxonomy Metabox
* Author: Helen Hou-Sandi
*
* Use Chosen for a replacement taxonomy metabox in WordPress
* Useful for taxonomies that aren't changed much on the fly and are
* non-hierarchical in nature, as Chosen is for flat selection only.
* You can always use the taxonomy admin screen to add/edit taxonomy terms.
* Categories need slightly different treatment from the rest in order to
@oodavid
oodavid / README.md
Last active April 6, 2024 18:45 — forked from aronwoost/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/
@pgaertig
pgaertig / transpose_table.js
Created April 13, 2012 13:48
Transpose HTML table using jQuery
$(function() {
var t = $('#thetable tbody').eq(0);
var r = t.find('tr');
var cols= r.length;
var rows= r.eq(0).find('td').length;
var cell, next, tem, i = 0;
var tb= $('<tbody></tbody>');
while(i<rows){
cell= 0;
@etienned
etienned / changeElementType.js
Created June 15, 2012 03:30
jQuery plugin that change element type, preserving attributes.
(function($) {
$.fn.changeElementType = function(newType) {
this.each(function() {
var attrs = {};
$.each(this.attributes, function(idx, attr) {
attrs[attr.nodeName] = attr.nodeValue;
});
$(this).replaceWith(function() {
@jcobb
jcobb / gist:2993853
Created June 26, 2012 06:42
Combine multiple WordPress queries
<?php
// An example of creating two separate WP queries, combining the results,
// sorting by date and formatting the results for us in a loop like a regular query.
// order the posts by date in descending order (should go in functions.php to keep things tidy)
function order_by_date( $a, $b )
{
return strcmp( $b->post_date, $a->post_date );
}
@ericpedia
ericpedia / gist:3583170
Created September 1, 2012 18:52
PHP crop blank space around image
<?php
/** Loop through all the files in a folder **/
function loop_through_folder_by_extension($path, $extension) {
$processedFiles = array();
$errors = array();
foreach ( "{$path}/*.{$extension}" as $filename ) {