Skip to content

Instantly share code, notes, and snippets.

@mwin007
mwin007 / RAILS_CHEATSHEET.md
Created April 19, 2018 21:36 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@mwin007
mwin007 / Default.sublime-theme
Created August 3, 2017 15:51 — forked from anonymous/Default.sublime-theme
Sublime Text 2 Default theme file
[
{
"class": "label_control",
"color": [255, 255, 255],
"shadow_color": [24, 24, 24],
"shadow_offset": [0, -1]
},
{
"class": "button_control",
"content_margin": [6, 5, 6, 6],
@mwin007
mwin007 / railscasts.rb
Created September 18, 2016 01:30 — forked from samqiu/railscasts.rb
Download free Railscast video
#!/usr/bin/ruby
require 'rss'
# Usage
# $ ./railscasts.rb http://railscasts.com/subscriptions/YOURRAILSCASTRSS/\/
# episodes.rss
# OR
# $ ./railscasts.rb
p 'Downloading rss index'
@mwin007
mwin007 / ssh-to-ec2
Created July 29, 2016 18:49
AWS useful commands
ssh -i /home/user/Desktop/Kyboe_Development/kyboe-key.pem ec2-54-211-254-26.compute-1.amazonaws.com
@mwin007
mwin007 / introrx.md
Created July 5, 2016 22:16 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@mwin007
mwin007 / Observer.php
Created July 1, 2016 20:48 — forked from IvanChepurnyi/Observer.php
Optimized catalog price rules
<?php
class EcomDev_Optimization_Model_Rule_Observer extends Mage_CatalogRule_Model_Observer
{
protected $_preloadedPrices = array();
public function beforeCollectTotals(Varien_Event_Observer $observer)
{
$quote = $observer->getQuote();
$date = Mage::app()->getLocale()->storeTimeStamp($quote->getStoreId());
class Belvg_SmartyApplyCatalogRule_Model_Rule extends Mage_CatalogRule_Model_Rule {
public function applyRule($rule_id)
{
$rule = Mage::getModel('catalogrule/rule')->load($rule_id);
$this->_getResource()->updateRuleProductData($rule); //solution of the problem
$this->_getResource()->applyAllRulesForDateRange();
$this->_invalidateCache();
$indexProcess = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
if ($indexProcess) {
mysqldump -P3306 -h<ip of host> -u<user> -p database > /tmp/database.sql
@mwin007
mwin007 / .htaccess
Created December 18, 2015 15:02
CI: Simple .htaccess using mod_rewrite for CodeIgniter
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
@mwin007
mwin007 / magento-nginx.conf
Created December 9, 2015 02:20 — forked from gwillem/magento-nginx.conf
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
}