Skip to content

Instantly share code, notes, and snippets.

<script>
// Fix for themeforest preview frame
if( self != top ) {
headTag = document.getElementsByTagName("head")[0].innerHTML;
var frameCSS = headTag + '<style type="text/css">@media screen and (max-width:600px){.carousel-item-transparent{max-height:420px;}}</style>';
document.getElementsByTagName('head')[0].innerHTML = frameCSS;
}
</script>
@StephenPunwasi
StephenPunwasi / gist:95cd8d77b0a1a956b07cda99ef098af6
Created April 25, 2016 14:12
Exclude OS X .DS_Store and Git files when zipping.
zip -r [filename.zip] [foldername] -x "*.DS_Store" -x *.git*
jQuery('img').each(function(){imgsrc = this.src); console.log(imgsrc);})
@StephenPunwasi
StephenPunwasi / gist:d547aa41e280f247579a
Created February 26, 2016 22:45
Center Isotope fitRow Elements
// Override and customize Isotope FitRows layout mode: CENTER each rows
var fitRows = Isotope.LayoutMode.modes.fitRows.prototype;
fitRows._resetLayout = function() {
// pre-calculate offsets for centering each row
this.x = 0;
this.y = 0;
this.maxY = 0;
this._getMeasurement( 'gutter', 'outerWidth' );
this.centerX = [];
@StephenPunwasi
StephenPunwasi / gist:6d4e7ad384b1cce99867
Created November 26, 2015 17:21
Wordpress HTTP Debug To Log
// DEBUG HTTP REQUESTS W/ LOG
function wp_log_http_requests( $response, $args, $url ) {
// set your log file location here
$logfile = plugin_dir_path( __FILE__ ) . '/http_requests.log';
// parse request and response body to a hash for human readable log output
$log_response = $response;
if ( isset( $args['body'] ) ) {
parse_str( $args['body'], $args['body_parsed'] );
}
@StephenPunwasi
StephenPunwasi / wp-attatchment-taxonomy.php
Created November 18, 2015 15:53
Add Categories and Tags To Wordpress Attachments
// Add Categories To WordPress Attachments
add_action( 'init' , 'add_categories_for_attachments' );
function add_categories_for_attachments(){
register_taxonomy_for_object_type( 'category', 'attachment' );
}
// Add Tags To WordPress Attachments
add_action( 'init' , 'add_tags_for_attachments' );
function add_tags_for_attachments() {
register_taxonomy_for_object_type( 'post_tag', 'attachment' );
#!/usr/bin/env bash
function optimize
{
echo $1
filesize=`stat -f %z "$1"`
if [[ $filesize -lt 10000 ]]; then
jpegtran -copy none -optimize "$1" > "$1.bak"
echo "pet
else