Skip to content

Instantly share code, notes, and snippets.

@ivandoric
ivandoric / date-time.rb
Created November 12, 2015 11:52
Ruby: Date and time formating
Date (Year, Month, Day):
%Y - Year with century (can be negative, 4 digits at least)
-0001, 0000, 1995, 2009, 14292, etc.
%C - year / 100 (round down. 20 in 2009)
%y - year % 100 (00..99)
%m - Month of the year, zero-padded (01..12)
%_m blank-padded ( 1..12)
%-m no-padded (1..12)
%B - The full month name (``January'')
@ivandoric
ivandoric / gist:0e70b26d5647d4cab8b8
Last active February 21, 2016 21:50 — forked from billerickson/gist:3698476
wordpress: WP Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@ivandoric
ivandoric / gist:25d62025a6824a7dff85
Created April 27, 2015 08:05
wordpress: Add container around video embeds (functions.php)
<?php
/* Add container around videos */
add_filter( 'embed_oembed_html', 'custom_oembed_filter', 10, 4 ) ;
function custom_oembed_filter($html, $url, $attr, $post_ID) {
$return = '<div class="video-container">'.$html.'</div>';
return $return;
}
@ivandoric
ivandoric / gist:6303f631c6258fe1d644
Created March 13, 2015 10:28
RoR: Locomotive install unicorn fix
#Remove or comment out this line in config/initializers/devise.rb
config.secret_key = "d9eb5171c59a4c817f68b0de27b8c1e340c2341b52cdbc60d3083d4e8958532" \
"18dcc5f589cafde048faec956b61f864b9b5513ff9ce29bf9e5d58b0f234f8e3b"
@ivandoric
ivandoric / gist:2deba6093cf23d8b9522
Created March 13, 2015 10:05
RoR: Bundle install exec LocomotiveCMS
rails _3.2.13_ new app_name --skip-active-record --skip-test-unit --skip-javascript --skip-bundle
(change version rails version number)
@ivandoric
ivandoric / gist:322d04863f41a7377148
Created February 26, 2015 12:38
android: Using Android Emulator with virtual hosts
1. Copy /etc/hosts somewhere etc. /Users/username/AndroidHosts
2. Change copied hosts file so that you have 10.0.2.2 instead of 127.0.0.1 for every one of your virtual hosts
3. Start your emulator from Google SDK
4. When Emulator starts execute these commands
$ adb remount
$ adb push /Users/username/AndroidHosts/hosts /system/etc/
Virtual hosts should work now.
@ivandoric
ivandoric / list.phtml
Last active March 17, 2021 22:09
magento: Check if product is new in product listing
<?php
$newFromDate = Mage::getModel('catalog/product')->load($_product->getID())->getNewsFromDate();
$newToDate = Mage::getModel('catalog/product')->load($_product->getID())->getNewsToDate();
$now = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
if(($newFromDate < $now && $newFromDate != NULL) && ($newToDate > $now || $newToDate == "")){
echo "New Product";
}
?>
@ivandoric
ivandoric / gist:3a77c31e6f868fe4db6f
Created July 19, 2014 15:47
drupal: template suggestions depending on content type name
<?php
function themeName_preprocess_page(&$vars, $hook) {
if (isset($vars['node'])) {
// If the node type is "blog_madness" the template suggestion will be "page--blog-madness.tpl.php".
$vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;
}
}
?>
@ivandoric
ivandoric / gist:9dba122b81dc892a6619
Created July 6, 2014 08:39
wordpress: default styles
/* == WordPress WYSIWYG Editor Styles == */
.entry-content img {
margin: 0 0 1.5em 0;
}
.alignleft, img.alignleft {
margin-right: 1.5em;
display: inline;
float: left;
}
@ivandoric
ivandoric / gist:0c8c0b7b0d6dc4a6f7a6
Created June 9, 2014 13:50
drupal: remove system css files
<?php
/* Add this to themes template.php */
function THEME_NAME_css_alter(&$css)
{
unset($css[drupal_get_path('module', 'system').'/system.theme.css']);
unset($css[drupal_get_path('module','system').'/system.base.css']);
unset($css[drupal_get_path('module', 'system').'/system.messages.css']);
unset($css[drupal_get_path('module', 'comment').'/comment.css']);