This file contains 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 Array | |
def to_csv(filename="hash.csv") | |
require 'csv' | |
# Get all unique keys into an array: | |
keys = self.flat_map(&:keys).uniq | |
CSV.open(filename, "wb") do |csv| | |
csv << keys | |
self.each do |hash| | |
# fetch values at keys location, inserting null if not found. | |
csv << hash.values_at(*keys) |
This file contains 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
#delete all images uploaded to your cloudinary cloud | |
require 'cloudinary' | |
$api_key = "YOUR_API_KEY" | |
$api_secret = "YOUR_API_SECRET_KEY" | |
$cloud_name = "YOUR_CLOUD_NAME" | |
Cloudinary.config do |config| | |
config.cloud_name = "#{$cloud_name}" |
This file contains 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
#converts string to MD5 hash in hyphenated and uppercase format | |
$someString = "test" | |
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider | |
$utf8 = new-object -TypeName System.Text.UTF8Encoding | |
$hash = [System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($someString))) | |
#to remove hyphens and downcase letters add: | |
$hash = $hash.ToLower() -replace '-', '' |