Skip to content

Instantly share code, notes, and snippets.

@moeamaya
Created October 17, 2015 22:27
Show Gist options
  • Save moeamaya/56da29b829f88c029c37 to your computer and use it in GitHub Desktop.
Save moeamaya/56da29b829f88c029c37 to your computer and use it in GitHub Desktop.
# shows the svgs in the last 100
broken = Image.limit(100).reverse_order.where(mobile_720: nil)
image = Image.last(300)
# actual array of images we'll move
process = []
# add all images that aren't svgs to process array
image.each {|img| filetype = img.original.split(".").last; unless filetype.to_s == "svg"; process << img; end; }
# swap out cdn domain names
process.each {|i| i.thumb_160 = i.thumb_160.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.thumb_320 = i.thumb_320.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.mobile_480 = i.mobile_480.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.mobile_720 = i.mobile_720.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.mobile_960 = i.mobile_960.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.mobile_1280 = i.mobile_1280.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.desktop_2048 = i.desktop_2048.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.desktop_2880 = i.desktop_2880.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.save() }
# for UserAvatars
avatar.each {|i| avatar.mobile_250 = avatar.mobile_250.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); avatar.desktop_500 = avatar.desktop_500.gsub('cdn.amonograph.com', 'archive-cdn.monograph.io'); i.save(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment