Skip to content

Instantly share code, notes, and snippets.

View rachelbaker's full-sized avatar

Rachel Baker rachelbaker

View GitHub Profile
@c3mdigital
c3mdigital / front-end-uploads.php
Created November 16, 2012 17:14
Two file upload handler functions
/**
* File upload ajax handler function to save the file and send image or file html back to the browser
* These functions are part of a class
*/
function ajax_upload_file() {
check_ajax_referer( 'ugc_user_upload', 'nonce' );
$file_data = array(
'name' => $_FILES['ugc_attachment_file']['name'],
'type' => $_FILES['ugc_attachment_file']['type'],
'tmp_name' => $_FILES['ugc_attachment_file']['tmp_name'],
@markjaquith
markjaquith / plugin-deploy.sh
Created November 16, 2012 05:04 — forked from scribu/plugin-deploy.sh
Plugin deploy script
#!/bin/bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)
DEST_DIR=~/svn/wp-plugins/$DIR_NAME/$BRANCH
@DrewAPicture
DrewAPicture / plupload_scaling.php
Last active October 12, 2015 18:38
Enable and set plupload scaling dimensions
function plupload_scaling( $defaults ) {
$defaults['resize'] = array(
'width' => 1024,
'height' => 1024,
'quality' => 100
);
return $defaults;
}
add_filter( 'plupload_default_settings', 'plupload_scaling' );
@nb
nb / class-query-iterator.php
Created November 12, 2012 15:34
WordPress Chunk Query Iterators
<?php
/**
* Iterates over results of a query, split into many queries via LIMIT and OFFSET
*/
class QueryIterator implements Iterator {
var $limit = 500;
var $query = '';
var $global_index = 0;
@pdewouters
pdewouters / gist:3945494
Created October 24, 2012 11:07
WP_Query on a diet
// From Alex King prez
$example = new WP_Query(array(
'posts_per_page' => 2,
'orderby' => 'date',
'order' => 'DESC',
'no_found_rows' => true,
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
));
@thefuxia
thefuxia / plugin-class-demo.php
Last active September 5, 2024 01:34
Plugin Class Demo
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Fuxia Scholz
* License: GPL
* Text Domain: plugin_unique_name
* Domain Path: /languages
@siffring
siffring / .bash_login
Created September 12, 2012 19:02
.bash_login
# Some goodies for your /Users/[username]/.bash_login file
# Set your search path
PATH=$PATH:/usr/local/bin
export PATH
# Alias for clearing your dns cache
alias dnscacheflush='dscacheutil -flushcache'
# Alias for subl
@rachelbaker
rachelbaker / launch_sublime_from_terminal.markdown
Created September 11, 2012 19:43 — forked from artero/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@ajmorris
ajmorris / gist:3662973
Created September 7, 2012 04:01
Python
# Close hubspot
if 'hubspotutk' in request.COOKIES:
hs_userToken = request.COOKIES['hubspotutk']
hs_date = datetime.date.today().strftime("%m/%d/%Y")
hs_client_contact = requests.get('http://api.hubapi.com/contacts/v1/contact/utk/{0}/profile?hapikey={1}'.format(hs_userToken, HUBSPOT_API_KEY))
if hs_client_contact.status_code == 200:
hs_response = json.loads(hs_client_contact.text)
hs_client_id = hs_response['vid']
hs_data = {'properties': {'lifecyclestage': 'customer', 'closedate': hs_date}}
hs_client_close = requests.post('http://api.hubapi.com/contacts/v1/contact/vid/{0}/profile?hapikey={1}'.format(hs_client_id, HUBSPOT_API_KEY), data=hs_data)
@BFTrick
BFTrick / get-closest-ancestral-featured-image.php
Last active October 10, 2015 05:07
This script looks for a featured image on the current page, if it can't find a featured image it will continue to look backwards through the family tree until it can find one. Then it will print it.