Skip to content

Instantly share code, notes, and snippets.

View nikasulo's full-sized avatar
🚀
Working Remotely

Nikasulo nikasulo

🚀
Working Remotely
View GitHub Profile
Aws.config.update({
region: "us-west-1",
credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']),
})
S3_BUCKET = Aws::S3::Resource.new.bucket(ENV['S3_BUCKET'])
heroku config:set AWS_ACCESS_ID=YOUR_ACCESS_ID
heroku config:set AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
heroku config:set S3_BUCKET=YOUR_BUCKET_NAME
heroku config:set AWS_ACCESS_ID=YOUR_ACCESS_ID
heroku config:set AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
heroku config:set S3_BUCKET=YOUR_BUCKET_NAME
config.before_configuration do
env_file = File.join(Rails.root, 'config', 'local_env.yml')
YAML.load(File.open(env_file)).each do |key, value|
ENV[key.to_s] = value
end if File.exists?(env_file)
end
@nikasulo
nikasulo / CORS Config for AWS S3 guide
Created February 27, 2020 00:41
CORS Config for Setting Up AWS S3
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>http://localhost:3000</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<ul id="root">
@nikasulo
nikasulo / transposition
Last active September 5, 2019 00:15
benchmark
Benchmark.bm(10000000) do |x|
x.report {puts transposer('gngngnnggnngggnnngngngngngngngngngngngngngngngngngngngngngngngngngngngngngngnnnnnnnnnnnnnnggggggggggggggggggggggggggggggggggggggggggngngngngnnnnnnnnnngng')}
end
@nikasulo
nikasulo / transposition
Created September 4, 2019 23:33
Final block
if string[ i ] != 'g' && string[i] != 'n' && string[i]
result += string[ i ]
next
end
@nikasulo
nikasulo / transposition
Created September 4, 2019 22:53
Check for g, n and others
if string[i] == 'g'
deque.pushBack(string[ i ])
next
elsif string[i] == 'n'
deque.pushFront(string[ i ])
next
else
deque.empty_into(result) unless deque.empty?
end
@nikasulo
nikasulo / transposition
Created September 4, 2019 22:49
Split the function into 3 parts
def transposer(string)
#initialize the deque
deque = Deque.new
#initialize the result variable
result = ''
#Correctly define our loop
for i in 0..string.length do
#The rest of our code goes in here
end