Skip to content

Instantly share code, notes, and snippets.

function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};
@bMinaise
bMinaise / Media Queries Bootstrap
Created September 5, 2013 18:15
Bootstrap 3 - Media Queries LESS
/* Extra small devices (phones, up to 480px) */
/* No media query since this is the default in Bootstrap */
/* Small devices (tablets, 768px and up) */
@media (min-width: @screen-sm) { ... }
/* Medium devices (desktops, 992px and up) */
@media (min-width: @screen-md) { ... }
/* Large devices (large desktops, 1200px and up) */
@bMinaise
bMinaise / Boilerplate CSS Media Queries
Created September 5, 2013 18:17
CSS Media Queries Boilerplate
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-width : 320px)
and (max-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@bMinaise
bMinaise / PHP Console Output
Created September 5, 2013 18:25
Output PHP data in console
<?php
/**
* Send debug code to the Javascript console
*/
function debug_to_console($data) {
if(is_array($data) || is_object($data))
{
echo("<script>console.log('PHP: ".json_encode($data)."');</script>");
} else {
echo("<script>console.log('PHP: ".$data."');</script>");
@bMinaise
bMinaise / getgallerywordpress
Created September 6, 2013 01:36
Wordpress Get Galleries
$gallery = get_post_gallery( $post, false );
$ids = explode( ",", $gallery['ids'] );
foreach( $ids as $id ) {
$link = wp_get_attachment_url( $id );
$image = wp_get_attachment_image( $id, "thumbnail");
echo( "<div class='item'><a href='$link'>" . $image . "</a></div>" );
}
@bMinaise
bMinaise / gallery-query.php
Created September 11, 2013 17:14
Wordpress Category Query
public static function get_form_summary(){
global $wpdb;
$form_table_name = self::get_form_table_name();
$lead_table_name = self::get_lead_table_name();
$sql = "SELECT l.form_id, count(l.id) as unread_count
FROM $lead_table_name l
WHERE is_read=0 AND status='active'
GROUP BY form_id";
@bMinaise
bMinaise / show-gallery-urls.php
Created September 26, 2013 00:45
Get Gallery Image URLs Sample plugin illustrating how to retrieve all image URLs of gallery images in a post Author: Pippin Williamson
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
}