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
| def self.extract_dominant_colors(image_path, quantity=5, threshold=0.01) | |
| image = MiniMagick::Image.open(image_path) | |
| # Get image histogram | |
| result = image.run_command('convert', image_path, '-format', '%c', '-colors', quantity, '-depth', 8, 'histogram:info:') | |
| # Extract colors and frequencies from result | |
| frequencies = result.scan(/([0-9]+)\:/).flatten.map { |m| m.to_f } | |
| hex_values = result.scan(/(\#[0-9ABCDEF]{6,8})/).flatten | |
| total_frequencies = frequencies.reduce(:+).to_f |
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 | |
| echo "WARN: This will remove everything from docker: volumes, containers and images. Will you dare? [y/N] " | |
| read choice | |
| if [ \( "$choice" == "y" \) -o \( "$choice" == "Y" \) ] | |
| then | |
| sudo echo "> sudo rights [OK]" | |
| sizea=`sudo du -sh /var/lib/docker/aufs` |