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
IMG_EXTENSION_REGEX = /(-(\d+)x(\d+))?\.(\w*)$/ | |
PREFERED_IMAGE_SIZE_WITH_CAPTURED_EXTENSION = '-300x160.\+' | |
def extract_image(html) | |
img_src = Nokogiri::HTML(e.content).css("img").first.attributes['src'].value | |
img_src.sub(IMG_EXTENSION_REGEX, PREFERED_IMAGE_SIZE_WITH_CAPTURED_EXTENSION) | |
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
require 'zip' | |
# requires gem rubyzip | |
# usage has_attached_file :attachment, path: path, processors: %i(archive), styles: {original: {format: 'zip', archived_file_name:}} | |
module Paperclip | |
class Archive < Processor | |
def make | |
tempfile = create_zip_tempfile | |
Zip::File.open(tempfile.path, Zip::File::CREATE) do |zip| | |
zip.add(archived_file_name, @file.path) | |
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
function log_write() { echo "$(date +%H:%M:%S) $*" >> ~/work_logs/$(date +%d-%m-%y) } | |
function log_see() { atom ~/work_logs/$(date +%d-%m-%y) } | |
function log_peek() { tail ~/work_logs/$(date +%d-%m-%y)} | |
alias log_arrived=' log_write arrived' | |
alias log_left=' log_write left' |
NewerOlder