Skip to content

Instantly share code, notes, and snippets.

View stemwinder's full-sized avatar

Joshua Smith stemwinder

View GitHub Profile
@stemwinder
stemwinder / MY_Input.php
Created February 12, 2014 14:55
Extends CodeIgniter Input method to provide for POST checking
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Input extends CI_Input {
function post($index = '', $xss_clean = FALSE)
{
// this will be true if post() is called without arguments
if($index === '')
{
return ($_SERVER['REQUEST_METHOD'] === 'POST');
@stemwinder
stemwinder / gist:9179611
Created February 24, 2014 00:35
OS X files that may contain $PATH definitions
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
@stemwinder
stemwinder / maxHeightIn.js
Created February 24, 2014 17:16
Iterates through elements and returns the value of the maximum height. From http://stackoverflow.com/questions/6060992/element-with-the-max-height-from-a-set-of-elements
maxHeight = Math.max.apply(null, $("div.panel").map(function(){
return $(this).height();
}).get());
.container{
position: relative;
z-index:1;
overflow:hidden; /*if you want to crop the image*/
}
.container:before{
z-index:-1;
position:absolute;
left:0;
top:0;
@stemwinder
stemwinder / jqueryMobileBSCarousel.js
Created February 25, 2014 19:16
Enables swipe for Bootstrap 3 carousels w/ jQuery Mobile
$(".carousel").swiperight(function() {
$(this).carousel('prev').carousel('pause');
}).swipeleft(function() {
$(this).carousel('next').carousel('pause');
});
@stemwinder
stemwinder / flatten_array_recursive.php
Created March 10, 2014 18:48
Flattens recursive array
function flatten(array $array) {
$return = array();
array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; });
return $return;
}
@stemwinder
stemwinder / Base64_decode.sh
Created March 16, 2014 02:48
Base64 decoding/encoding in ruby
ruby -e "require 'base64'; print Base64.decode64( STDIN.read )"
#main {
position: relative;
}
#main:after {
content : "";
display: block;
position: absolute;
top: 0;
left: 0;
background-image: url(/wp-content/uploads/2010/11/tandem.jpg);
@stemwinder
stemwinder / chmod_directories.sh
Created May 21, 2014 19:13
set permission recursively on directories only
find /path/to/base/dir -type d -exec chmod 755 {} +
@stemwinder
stemwinder / cors_subdomain.conf
Created June 28, 2014 17:05
Apache config or htaccess directives shim for subdomain CORS implementation
# Credit: http://stackoverflow.com/a/18958914
<IfModule mod_rewrite.c>
<IfModule mod_headers.c>
# Define the root domain that is allowed
SetEnvIf Origin .+ ACCESS_CONTROL_ROOT=yourdomain.com
# Check that the Origin: matches the defined root domain and capture it in
# an environment var if it does
RewriteEngine On
RewriteCond %{ENV:ACCESS_CONTROL_ROOT} !=""