Skip to content

Instantly share code, notes, and snippets.

View geilt's full-sized avatar

Alexander Conroy geilt

View GitHub Profile
@geilt
geilt / gist:817ff32b20414ddd5a16
Created August 27, 2014 20:10
jQuery $.load into Variable.
var url = 'http://www.google.com';
var load = $('<div>');
var content = '';
load.load(url, function(result){
content = load.html();
});
@geilt
geilt / api-controllers-DropboxController.js
Last active August 29, 2015 14:05
Sails Dropbox oAuth
var passport = require('passport'),
qs = require('querystring'),
request = require('request-promise');
module.exports = {
authenticate: passport.authenticate('dropbox'),
callback: passport.authenticate('dropbox', {
failureRedirect: '/options?' + qs.stringify({success: 'Dropbox failed authentication.'}),
successRedirect: '/options?' + qs.stringify({success: 'Dropbox connected.'})
}),
@geilt
geilt / grab-and-save.php
Created November 19, 2013 06:58
Grab and Save into folder based on category if we have a post_id and a category. Makes a category directory if it doesn't exist in uploads.
<?php
/*
Plugin Name: Grab & Save
Plugin URI: http://digitalmemo.neobie.net/grab-save
Author: Lim Kai Yang
Author URI: http://digitalmemo.neobie.net
Modified: @geilt
Modified On: 11/19/2013
Version: 1.0.4
Description: This plugin allows you to fetch the remote image and save to your local wordpress.
@geilt
geilt / database.class.php
Last active November 22, 2016 18:41
SimpulSections (Wordpress Post Type Database)
<?php
/**
* Database
* @package SimpulFramework
* @version 1.0
*/
//Start the Database Singleton. Yes I know they are evil.
try {
$dbh = new SimpulPDO_mySQL("mysql:host=" . DB_HOST . ";dbname=". DB_NAME, DB_USER, DB_PASSWORD);
$dbh->setAttribute( SimpulPDO_mySQL::ATTR_ERRMODE, SimpulPDO_mySQL::ERRMODE_EXCEPTION );
@geilt
geilt / registry.class.php
Created July 11, 2013 17:22
Registry Class
<?php
/**
* Registry
* Used as an Object Store of all Data used through a page load. It is a static class with a protected static variable.
* All Data is meant to be built off the registry that needs to be passed around instead of using Global Variables
* @package SimpulFramework
* @version 1.0
*/
class Registry{
protected static $object = array();
@geilt
geilt / theme_options.php
Created June 4, 2013 20:34
Theme Options Drop in
<?php
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
/**
* Init plugin options to white list our options
*/
function theme_options_init(){
register_setting( 'ABTmedical_options', 'ABTmedical_theme_options', 'theme_options_validate' );
@geilt
geilt / get_term_meta.php
Created May 9, 2013 08:09
get_term_meta
<?php
if(!function_exists('get_term_meta')):
function get_term_meta($term, $taxonomy, $key, $single = false ){
if(!$taxonomy && !$term):
return false;
endif;
if(!is_numeric($term)):
$term = get_term_by('slug', $term, $taxonomy);
$term = $term->term_id;
endif;
@geilt
geilt / news_meta.php
Created May 7, 2013 17:42
Wordpress News Meta
<?php
/*
* Title: News Meta Function
* Author: Alexander Conroy
* Version: 1.0.1
* Website: http://www.esotech.org
* Purpose: Tags Tags for Current Post and puts it in the header meta comma separated maximum 10 tags.
* License: GPLv3+
*/
@geilt
geilt / add_do_action.php
Created April 24, 2013 23:12
Add Action and Do Action for any system using Globals. Inspired by Wordpress but custom Coded.
<?php
// Queue: Queues a function or object method to be run during do_action
function add_action($action, $function, $priority = 10, $args = array()){
$GLOBALS['actions'][$action][$priority][] = array('function' => $function, 'args' => $args);
}
// Hook: Runs a function or a object method based on add_action
function do_action($action){
$done = '';
if(!empty($GLOBALS['actions'][$action])):
foreach($GLOBALS['actions'][$action] as $priorities):
@geilt
geilt / isBot.php
Last active December 16, 2015 15:29
Checks for proxies as well as the most common bots for pinterest google and twitter when using the share features.
<?php
function isBot(){
if(!empty($_SERVER['VIA'])):
return true;
endif;
if(!empty($_SERVER['REMOTE_PORT']) && in_array($_SERVER['REMOTE_PORT'], array(8080,80,6588,8000,3128,553,554))):
return true;
endif;
//if(!empty($_SERVER['REMOTE_ADDR']) && fsockopen($_SERVER['REMOTE_ADDR'], 80, $errno, $errstr, 30)): // this Causes Lag...
// return false;