Skip to content

Instantly share code, notes, and snippets.

View bfintal's full-sized avatar
🎯
Focusing

Benjamin Intal bfintal

🎯
Focusing
View GitHub Profile
@bfintal
bfintal / CreateHGroups.js
Created September 30, 2011 04:47
Automatically wraps groups of headings (h1, h2, h3, h4, h5 and h6) into hgroups. Good for HTML5 styling.
jQuery(document).ready(function($){
var skip = 0;
$('h1, h2, h3, h4, h5, h6').each(function(i) {
if (skip > 0) {
skip--;
return;
}
var group = $(this).add($(this).nextUntil(':not(h1, h2, h3, h4, h5, h6)'));
skip = group.length - 1;
#!/usr/bin/python
from random import randint
from sys import exit
# list of coins containing their weight (2 grams)
coins = [2]*7
# insert a different sized coin (1 or 3 grams randomized)
newcoin = randint(0,1)*2+1
coins.insert(randint(0,7), newcoin)
@bfintal
bfintal / BFIGoogleUrl.php
Created January 20, 2013 08:43
So I've found a ton of Goo.gl API shortener classes out there but nothing worked for me (maybe because of wrong cURL options or outdated urls, etc). This one is simple and works nicely. The function doesn't need any API keys and returns the original url if curl isn't present.
class BFIGoogleUrl {
public static function shorten($url) {
if (!function_exists('curl_init'))
return $url;
$api = 'https://www.googleapis.com/urlshortener/v1/url?';
$data_string = '{"longUrl":"'.$url.'"}';
# Initialize cURL
$ch = curl_init();
@bfintal
bfintal / jquery-ui-1.10.3.mp6.css
Last active December 26, 2015 19:19
Modified jQuery UI theme to match MP6 that I'll use for my page builders in my WordPress themes http://themeforest.net/user/bfintal/portfolio
/*! jQuery UI - v1.10.3 - 2013-10-25
* http://jqueryui.com
* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css, jquery.ui.theme.css
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=%22Open%20Sans%22%2C%20sans-serif&fwDefault=normal&fsDefault=13px&cornerRadius=0&bgColorHeader=%23333&bgTextureHeader=flat&bgImgOpacityHeader=0&borderColorHeader=%23333&fcHeader=%23eee&iconColorHeader=%23eee&bgColorContent=%23fff&bgTextureContent=flat&bgImgOpacityContent=0&borderColorContent=%23eee&fcContent=%23333333&iconColorContent=%23cccccc&bgColorDefault=%23333&bgTextureDefault=flat&bgImgOpacityDefault=0&borderColorDefault=%23333&fcDefault=%23eee&iconColorDefault=%23eee&bgColorHover=%23222&bgTextureHover=flat&bg
@bfintal
bfintal / gist:7582665
Created November 21, 2013 14:39
A factory class for getting the latest version of a class
<?php
if ( !function_exists( 'bfi_thumb' ) ) {
function bfi_thumb() {
return BFI_Class_Factory::getNewestVersion( 'BFI_Thumb' )->run();
}
}
if ( !class_exists( 'BFI_Class_Factory' ) ) {
class BFI_Class_Factory {
public static $versions = array();

Features

Multiple Demos, Single Installation

With WordPress multisite you can create multiple "sites" within the same WordPress instance. Each can have a different look, feel, theme, and plugins activated. Each works as it's own "site" in a network.

WordPress Demo uses the power of multisite to allow your visitors to create unique sandboxes for each "site" within your network. This also allows you to demonstrate different themes and plugins, all with the same WordPress install.

What is a sandbox?

A sandbox is a carbon copy of your demonstration site where your users can try out every aspect of your product without affecting your main demo site. Sandboxes get deleted 24 hours after the user has stopped being active or has logged out.

global $wpdb;
$results = $wpdb->get_results( "select post_author, count(*) post_num from wp_posts where post_type in ('page', 'post', 'cpt') group by post_author" );
@bfintal
bfintal / gist:99488bb2019bca89ac48
Created January 13, 2015 01:23
Twenty Fifteen Social Genericons
.social-navigation a[href$="/feed/"]:before {
content: "\f413";
}
.social-navigation a[href*="codepen.io"]:before {
content: "\f216";
}
.social-navigation a[href*="digg.com"]:before {
content: "\f221";
@bfintal
bfintal / gist:5b565eb32e8472e755a9
Last active July 13, 2016 05:28
Make `is_active_sidebar` work correctly with Custom Sidebars
/**
* This snippet will make `is_active_sidebar` work correctly with Custom Sidebars
* @author Benjamin Intal
*/
/**
* Gathers all the sidebar IDs and the replacement IDs. Most of this code froms from CustomSidebarsReplacer->replace_sidebars()
*/
add_action( 'cs_predetermineReplacements', 'verdant_custom_sidebars_determine_replacements' );
function verdant_custom_sidebars_determine_replacements( $defaults ) {
array (size=81)
'address' =>
array (size=5)
'class' => boolean true
'id' => boolean true
'style' => boolean true
'title' => boolean true
'role' => boolean true
'a' =>
array (size=10)