Skip to content

Instantly share code, notes, and snippets.

View aaronranard's full-sized avatar

Aaron Ranard aaronranard

View GitHub Profile
@aaronranard
aaronranard / file-upload.js
Last active August 29, 2015 14:12
Angular: File Uploader
$scope.onFileSelect = function($files) {
// https://github.com/danialfarid/angular-file-upload
var file = $files[0];
$scope.upload = $upload.upload({
url: apiEndpoint + '/api/file/upload',
// method: 'POST' or 'PUT',
// headers: {'header-key': 'header-value'},
// withCredentials: true,
//data: {myObj: $scope.myModelObj},
file: file, // or list of files: $files for html5 only
@aaronranard
aaronranard / cookies.js
Last active August 29, 2015 14:00
Javascript: Cookie Management
/**
* determine whether this is the first visit to the animation page
* @param {string} c_name cookie name
* @return {string} cookie value
*/
function getCookie(c_name){
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start === -1){
c_start = c_value.indexOf(c_name + "=");
@aaronranard
aaronranard / acf-gallery.php
Created April 8, 2014 17:00
WordPress: ACF - Output Gallery
@aaronranard
aaronranard / custom-taxonomies.php
Last active August 29, 2015 13:58
WordPress - get custom taxonomies for post
$categories = get_the_terms( get_the_id() , 'service' );
$separator = '<br />';
$output = '';
if($categories){
foreach($categories as $category) {
//$output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
$output .= $category->name . $separator;
}
echo trim($output, $separator);
}