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
| # app/services/store_tracking.rb | |
| # service that tracks user visits to a store, and keeps counters in the models | |
| class StoreTracking | |
| def initialize(store, user, request) | |
| @store = store | |
| @user = user | |
| @request = request | |
| 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
| class Flatten | |
| def initialize(array) | |
| @array = array | |
| end | |
| def flatten(array = @array) | |
| if array.is_a? Integer | |
| [array] | |
| else | |
| array.inject([]) { |memo, elem| memo + flatten(elem) } |
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
| #!/bin/bash | |
| # Compare every file passed over stdin with it's converted one | |
| # i.e. file.extension vs file_imagemagick_converted.extension and echo the bigger one of each pair | |
| # | |
| # Usage: | |
| # ./compare-imgs.sh < converted_images > bigger_imgs | |
| # | |
| # Arguments: | |
| # stdin - list of filenames |
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
| #!/bin/bash | |
| # Convert images received as list of filenames over stdin | |
| # | |
| # Uses imagemagick's convert script https://www.imagemagick.org/script/convert.php | |
| # Follows suggestions on https://developers.google.com/speed/docs/insights/OptimizeImages | |
| # | |
| # Usage: | |
| # find . -path './*original*' -type f | sed 's/\.\///' | ./convert-imgs.sh 615 > converted_images | |
| # |
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
| #!/bin/bash | |
| # Rename files file_imagemagick_converted.extension to file.extension | |
| # | |
| # Usage: | |
| # grep -v imagemagick_converted bigger_imgs | ./rename-imgs.sh | |
| # | |
| # Arguments: | |
| # stdin - list of filenames |
OlderNewer