Skip to content

Instantly share code, notes, and snippets.

View bfintal's full-sized avatar
🎯
Focusing

Benjamin Intal bfintal

🎯
Focusing
View GitHub Profile
#!/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)
var getCTNode = function( domElement ) {
// Go through all the editable regions of CT
var regions = ContentTools.EditorApp.get().regions();
for ( var i in regions ) {
// Go through all the children / Element Nodes
var children = regions[ i ].children;
for ( var k in children ) {
/**
* A collection of functions that extend the capabilities of HTMLString to
* manipulate CSS styles.
*
* This is used by various formatting tools.
*/
/* globals HTMLString */
/***************************************************************************
* Change Bold tool. Instead of just adding a `<b>` tag,
* use font-weight styles.
***************************************************************************/
ContentTools.Tools.Bold.canApply = function(element, selection) {
return ContentTools.Tools.Heading.canApply( element, selection );
};
ContentTools.Tools.Bold.isApplied = function(element, selection) {
var from = 0, to = 0, _ref;
@bfintal
bfintal / gist:f595728ee55171affbef
Last active November 25, 2015 09:30
This index.html has a br after the image
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ContentTools sandbox</title>
<link rel="stylesheet" type="text/css" href="sandbox.css">
<link rel="stylesheet" type="text/css" href="../build/content-tools.min.css">
</head>
<body>
<article class="article">
@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();
@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 ) {
<script>
// This
document.addEventListener( 'DOMContentLoaded', function() {
window.dispatchEvent( new CustomEvent( 'resize' ) );
} );
</script>
<script>
// Or this
document.addEventListener( 'DOMContentLoaded', function() {