Skip to content

Instantly share code, notes, and snippets.

View basti's full-sized avatar

Slobodan Kovačević basti

View GitHub Profile
@basti
basti / s3-policy.json
Created August 14, 2020 11:43
AWS policy that gives access to S3 bucket with permissions required by Rails ActiveStorage
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObjectAcl",
"s3:GetObject",
@basti
basti / README.md
Last active April 7, 2023 16:25
AWS S3 CORS configuration for Rails ActiveStorage

AWS S3 now uses JSON for CORS configuration and cors.json is minimal configuration for Rails 7 direct uploads.

@basti
basti / 0_README.md
Last active November 9, 2016 15:37
Heroku-like Vagrant setup
@basti
basti / README.md
Last active October 23, 2017 17:14 — forked from jterrace/xvfb
xvfb init script for Ubuntu
# download and copy xvfb file from this gist to /etc/init.d/

# make it executable
sudo chmod a+x /etc/init.d/xvfb

# start xvfb on display number 10
export DISPLAY=:10
sudo /etc/init.d/xvfb start
@basti
basti / gist:2bb63487196474f8a146
Last active August 29, 2015 14:01 — forked from dschneider/gist:2941985
RSpec - Stub Remote IP Request
allow_any_instance_of(ActionDispatch::Request).to receive(:remote_ip).and_return("192.168.0.1")
@basti
basti / application.rb
Last active March 1, 2021 10:42 — forked from keighl/application.rb
Local Rails 4 assets precompilation using Capistrano 3 and rsync
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
@basti
basti / parse_paypal_date.rb
Last active October 22, 2017 16:42
Snippet to convert PayPal date format to DateTime (taken from: http://rhnh.net/2008/03/17/paypal-ipn-fails-date-standards)
# taken from: http://rhnh.net/2008/03/17/paypal-ipn-fails-date-standards
# parses PayPal non-standard format
DateTime.strptime("18:30:30 Jan 1, 2000 PST", "%H:%M:%S %b %e, %Y %Z").new_offset(0)
# in Rails you can use to_time_in_current_zone to convert it to TimeWithZone
DateTime.strptime("18:30:30 Jan 1, 2000 PST", "%H:%M:%S %b %e, %Y %Z").to_time_in_current_zone
module AuthHelper
def http_login
user = 'username'
pw = 'password'
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end
end
module AuthRequestHelper
#
@basti
basti / Simple YAML configuration
Created June 12, 2013 10:42
Simple custom configuration within Rails App using initializer and YAML file.
Based on http://railscasts.com/episodes/85-yaml-configuration-revised
@basti
basti / Amazon SES & Rails app
Created May 28, 2013 09:53
Quick Amazon SES setup for Rails app
Quick way to setup Amazon SES as a mailer for a Rails app