This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Spree::Product.class_eval do | |
| def self.simple_scopes | |
| [ | |
| :ascend_by_random, | |
| :ascend_by_updated_at, | |
| :descend_by_updated_at, | |
| :ascend_by_name, | |
| :descend_by_name, | |
| # Need to have master price scopes here | |
| # This makes them appear in admin/product_groups/edit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 6ff235b69503dc6c7b1df425c003413c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $amount = 17.50; | |
| print (int) $amount * 100; # => 1700 # My implementation. I was wrong. | |
| print (int) ($amount * 100); # => 1750 # After bugfix. PHP first casts, then multiplies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| php> $are_you_insane_php = (int) 'hello world' | |
| php> var_dump($are_you_insane_php) #=> int(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function foo($bar = NULL) { | |
| if (isset($bar)) { | |
| print "bar is set\n"; | |
| var_dump($bar); | |
| } | |
| else { | |
| print "bar is not set\n"; | |
| var_dump($bar);//If not set should throw at least a NOTICE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class String | |
| # http://confreaks.com/videos/1228-aloharuby2012-keynote-rails-4-and-the-future-of-web | |
| def t13d | |
| if length > 2 | |
| return "#{self[0,1]}#{(length - 2)}#{self[-1,1]}" | |
| else | |
| return self | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function foo($bar) { | |
| var_dump($bar); | |
| } | |
| foo(array()); # => array(0) {} | |
| ## Works as expected. But now... | |
| function foo(&$bar) { | |
| var_dump($bar); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'RMagick' | |
| require 'smartcropper' | |
| class DemoChopper | |
| def initialize width, height, filename | |
| @width, @height, @filename = width, height, filename | |
| @files = [{ | |
| image: ::Magick::ImageList.new(filename).resize_to_fit!(600, 1000), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class View{ | |
| var $attributes = array(); | |
| var $object; | |
| public function __construct($object) { | |
| $this->object = $object; | |
| $reflection = new ReflectionClass($object); | |
| $props = $reflection->getProperties(ReflectionProperty::IS_PUBLIC); | |
| foreach ($props as $prop) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/Performing-Backups.md b/Performing-Backups.md | |
| index d5e1511..472e9a2 100644 | |
| --- a/Performing-Backups.md | |
| +++ b/Performing-Backups.md | |
| @@ -191,6 +191,24 @@ The `backup perform` command will exit with the following status codes: | |
| **2**: All triggers were _processed_, but some failed. | |
| **3**: A fatal error caused Backup to exit. Some triggers may not have been processed. | |
| +Passing Arbitrary Variables | |
| +--------------------------- |