I hereby claim:
- I am dominiceden on github.
- I am domeden (https://keybase.io/domeden) on keybase.
- I have a public key ASA0XfiFjvsxD3PSUnzZICKWY2DvEtyQMeFz2t6_yC3zDgo
To claim this, I am signing this object:
# You can use this with irb. | |
require 'csv' | |
CSV.open("codes.csv", "wb") do |csv| # Open the empty csv file. Make sure you run irb in the directory where the empty codes.csv file is | |
(1..10000).each do |i| # Run 10,000 times | |
randAlphaNumeric = Array.new(8){[*"a".."z", *"0".."9"].sample}.join # Generate a random alphanumeric number that's 8 digits long | |
csv << ["prefix-" + randAlphaNumeric] # Generate a code that begins with prefix- (if required), add the alphanumeric code and write it to the CSV file | |
end | |
end |
require 'fileutils' | |
# Replace Dominic with your actual user name. Use 'pwd' command to find this if you're not sure. | |
source_dir = Dir["/Users/Dominic/Downloads/sourcedirectory/*.*"] # Get all files with any extension in the folder 'sourcedirectory' | |
source_dir.each do |item| | |
FileUtils.cp(item, '/Users/Dominic/Documents/targetdirectory/') # Copy the item in the loop to the folder 'targetdirectory' | |
sleep(5) # Wait 5 seconds before moving on to the next item in the loop. | |
end |
require 'httparty' | |
redirects = [ # FIELD1 is the current URL; FIELD2 is the URL you want the user to be redirected to. | |
{ | |
"FIELD1": "http:\/\/www.myshop.com\/products\/urban-camo-tracksuit", | |
"FIELD2": "http:\/\/www.myshop.com\/collections\/tracksuit\/products\/urban-camo-tracksuit-bottoms" | |
}, | |
{ | |
"FIELD1": "http:\/\/www.myshop.com\/products\/urban-camo-vest", | |
"FIELD2": "http:\/\/www.myshop.com\/collections\/mens-vests\/products\/kutula-urban-camo-vest" |
# Monday is 1 | |
# Tuesday is 2 | |
# Wednesday is 3 | |
# Thursday is 4 | |
# Friday is 5 | |
# Saturday is 6 | |
# Sunday is 7 | |
# Note - the Postgres isodow function as used below gives us Monday - Sunday as 0-7. The dow function does Sunday-Monday, 0-6. |
I hereby claim:
To claim this, I am signing this object:
require 'csv' | |
in_csv = CSV.read('/Users/Dominic/Downloads/in.csv').reverse | |
CSV.open("/Users/Dominic/Downloads/out.csv", "wb") do |csv| | |
in_csv.each do |line| | |
csv << line | |
end | |
end |
# I had issues with moving S3 files in a non-standard region, such as London | |
# (eu-west-2). The AWS docs don't seem to say that you cannot pass a simple | |
# string as the new_object destination - it must be a Hash that contains a | |
# Aws::S3::Client instance. This is so the region is set correctly - it's passed | |
# in the client instance. Otherwise, you get the error "The bucket you are | |
# attempting to access must be addressed using the specified endpoint". | |
# Tested and working using the Ruby AWS SDK v2.9.5 in January 2018. | |
client = Aws::S3::Client.new(region: 'eu-west-2') | |
resource = Aws::S3::Resource.new(client: client) |
#!/bin/sh | |
# | |
# Automatically adds branch name to every commit message. | |
# e.g. [feature/some-feature] Commit message here | |
# Remove .sh extension when copying into your .git/hooks folder. | |
# | |
NAME=$(git branch | grep '*' | sed 's/* //') | |
echo "[$NAME]"' '$(cat "$1") > "$1" |
// I've spent a few hours working out how to simulate the selection of a select option in my React app using the Polaris. Polaris provides a | |
// <Select /> component to use that wraps the <select> DOM element, so simulating a change is a bit tricky and involves reading the Polaris | |
// source to work out what's going on. Here's how I got it working for me. | |
// Polaris wants an event object with currentTarget defined. Not sure why they use currentTarget instead of target... | |
mountedWrapper.find('select[name="location_id"]').prop('onChange')({ | |
currentTarget: { | |
value: newLocationId, | |
}, | |
}); |