Skip to content

Instantly share code, notes, and snippets.

View kepek's full-sized avatar
💭
I may be slow to respond.

Michal Kechner kepek

💭
I may be slow to respond.
View GitHub Profile
@kepek
kepek / kepek.modal.js
Last active August 29, 2015 13:55
How to extend Bootstrap JavaScript Plugin? See below :)
+function ($) {
'use strict';
// BOOTSTRAP
var Bootstrap = $.fn.modal.Constructor;
// MODAL CLASS DEFINITION
// ======================
@kepek
kepek / synchronous-fn.js
Created February 10, 2014 18:02
JavaScript Synchronous (Deferred) Functions.
function sayIt(ms, def) {
setTimeout(function() {
console.log('middle');
def.resolve();
return 10;
}, ms);
}
function slowPromise() {
@kepek
kepek / include_with_variable_in_twig.twig
Created March 26, 2014 16:10
Include with Variable in Twig
{% include var|default('index') ~ '_foo.html' %}
(function () {
var language = {
delimiters: {
thousands: ',',
decimal: '.'
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
{{ "text.rating_counter"|transchoice(votes)|desc("{0} 0 ratings|{1} 1 rate|]1,Inf] %votes% ratings") }} {# :) #}
{{ "text.month_counter"|transchoice(months)|desc("{0} 0 months|{1} 1 month|]1,Inf] %months% months") }} {# :( #}
@kepek
kepek / head.phtml
Created July 27, 2011 13:04
Quick Social Media for Magento
<!-- SOCIAL NETWORK CODE -->
<script type="text/javascript" src="http://connect.facebook.net/<?php echo Mage::app()->getLocale()->getLocaleCode() ?>/all.js#xfbml=1"></script>
<script type="text/javascript" src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"></script>
<?php $_product = Mage::registry('current_product'); if($_product): ?>
<?php $_header = new Mage_Page_Block_Html_Header(); ?>
<meta property="og:title" content="<?php echo $this->stripTags($_product->getName(), null, true) ?>"/>
<meta property="og:url" content="<?php echo $this->helper('core/url')->getCurrentUrl();?>"/>
<meta property="og:type" content="product"/>
<meta property="og:image" content="<?php echo $this->helper('catalog/image')->init($_product, 'image') ;?>"/>
<meta property="og:site_name" content="<?php echo $_header->getLogoAlt() ?>" />
@kepek
kepek / gist:1307371
Created October 23, 2011 13:42
IE6 CSS
<!--[if lte IE 6]>
<link rel="stylesheet" href="http://universal-ie6-css.googlecode.com/files/ie6.0.3.css" media="screen, projection" />
<![endif]-->
function aboriginal_theme_option($atts) {
// EXAMPLE USAGE:
// [theme_option show="company_address"]
$options = aboriginal_get_theme_options();
extract(shortcode_atts(array(
'show' => ''
), $atts));
return $options[$show] ? $options[$show] : false;
}
add_shortcode('theme_option', 'aboriginal_theme_option');
@kepek
kepek / gist:1398017
Created November 27, 2011 19:22
Custom Author Permalink for Wordpress
<?php
function kepek_author_rewrite() {
global $wp_rewrite;
$wp_rewrite->author_base = 'autor';
$wp_rewrite->flush_rules();
}
add_action('init', 'kepek_author_rewrite');
@kepek
kepek / gist:1404560
Created November 29, 2011 11:56
Magento Multilanguage Category Description (Fast Workaround)
<?php
/* Vritual Helper Function */
public function translate($text = false, $lang = false) {
$lang = $lang ? $lang : Mage::app()->getLocale()->getLocaleCode();
if($text) {
preg_match('#\[translate lang="'.$lang.'"\](.*?)\[/translate\]#si', $text, $match);
if($match) {
$output = trim($match[1]);