Skip to content

Instantly share code, notes, and snippets.

Ivan Dorić ivandoric

Block or report user

Report or block ivandoric

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ivandoric
ivandoric / gist:a714e4ae85f9a117387e
Created Jan 4, 2016
Laravel: Do this after deploy
View gist:a714e4ae85f9a117387e
$ php composer install
$ php composer dumpautoload -o
$ php artisan config:cache
$ php artisan route:cache
View gist:a152fa03e17e794c59e2
// Starting model factory
$ php artisan tinker
>>> factory('App\ModelName', 10)->create();
@ivandoric
ivandoric / date-time.rb
Created Nov 12, 2015
Ruby: Date and time formating
View date-time.rb
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 Feb 21, 2016 — forked from billerickson/gist:3698476
wordpress: WP Query $args
View gist:0e70b26d5647d4cab8b8
<?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 Apr 27, 2015
wordpress: Add container around video embeds (functions.php)
View gist:25d62025a6824a7dff85
<?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 Mar 13, 2015
RoR: Locomotive install unicorn fix
View gist:6303f631c6258fe1d644
#Remove or comment out this line in config/initializers/devise.rb
config.secret_key = "d9eb5171c59a4c817f68b0de27b8c1e340c2341b52cdbc60d3083d4e8958532" \
"18dcc5f589cafde048faec956b61f864b9b5513ff9ce29bf9e5d58b0f234f8e3b"
@ivandoric
ivandoric / gist:2deba6093cf23d8b9522
Created Mar 13, 2015
RoR: Bundle install exec LocomotiveCMS
View gist:2deba6093cf23d8b9522
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 Feb 26, 2015
android: Using Android Emulator with virtual hosts
View gist:322d04863f41a7377148
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 Jun 13, 2019
magento: Check if product is new in product listing
View list.phtml
<?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 Jul 19, 2014
drupal: template suggestions depending on content type name
View gist:3a77c31e6f868fe4db6f
<?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;
}
}
?>
You can’t perform that action at this time.