Skip to content

Instantly share code, notes, and snippets.

View noma4i's full-sized avatar
💭
🦑 Daily Kraken

Alexander Tsirel noma4i

💭
🦑 Daily Kraken
View GitHub Profile
@noma4i
noma4i / storage.yml
Last active October 31, 2024 05:12
Contabo Object Storage/Vultr - Ruby on Rails. ActiveStorage setup
vultr_production:
service: S3
access_key_id: YOUR_ACCESS_KEY
secret_access_key: YOUR_SECRET_KEY
endpoint: https://sgp1.vultrobjects.com # endpoint from the Vultr. Pay attention to the region
region: unused # Yes. Unused is the value
bucket: YOUR_BUCKET_NAME
contabo_production:
service: S3
@noma4i
noma4i / install.sh
Created December 29, 2023 08:21 — forked from kodavn/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# https://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# https://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# https://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# https://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE`
@noma4i
noma4i / customdomain.rb
Created October 9, 2022 08:00 — forked from johnthethird/customdomain.rb
rack middleware to resolve a custom domain to an original subdomain in a multi-tenant application
require 'net/dns/resolver'
# Custom Domain
#
# Require net-dns gem
#
# A Rack middleware to to resolve the custom domain to original subdomain
# for your multi telent application.
#
# It's all transperant to your application, it performs cname lookup and
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####
{
"title": "Language toggler",
"rules": [
{
"description": "Language toggler on SHIFTS",
"manipulators": [
{
"conditions": [
{
"type": "input_source_if",
@noma4i
noma4i / README.md
Created September 19, 2018 03:35 — forked from mahemoff/README.md
MySQL thread-safe multi-database switching in Rails 5

The code here is a tech demo showing how to switch between databases in Rails 5, in a thread-safe manner.

BACKGROUND: HOW NOT TO CHANGE DATABASES

The simple way to switch databases is:

ActiveRecord::Base.establish_connection :user_shard1
puts User.find(1) # this is executed on the database keyed on "user_shard1" in database.yml
ActiveRecord::Base.establish_connection :development
@noma4i
noma4i / rw_ro_access.sql
Created September 7, 2018 00:17 — forked from checco/rw_ro_access.sql
How to create a read only user in AWS RDS PostgreSQL and a user with superuser privileges on AWS RDS PostgreSQL
--
-- Read only
--
-- Create a group
CREATE ROLE postgres_ro_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO postgres_ro_group;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_ro_group;
@noma4i
noma4i / postgres_queries_and_commands.sql
Created August 21, 2018 04:57 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@noma4i
noma4i / rails_ar_bug.rb
Created February 7, 2018 00:07
Rails 5.1.5 AR uses 3 queries to destroy 2 records
# frozen_string_literal: true
begin
require 'bundler/inline'
rescue LoadError => e
warn 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
@noma4i
noma4i / Dockerfile
Created December 12, 2017 00:16 — forked from renatosousafilho/Dockerfile
Deploy com Mina, Docker e Docker Compose
FROM rails:4.2.3
MAINTAINER Renato Filho <[email protected]>
ENV HOME /home/app
ENV RAILS_ENV development
RUN useradd -m -s /bin/bash app
RUN gem install -N bundler