Skip to content

Instantly share code, notes, and snippets.

View zedtux's full-sized avatar

Guillaume Hain zedtux

View GitHub Profile
@barrettkingram
barrettkingram / capybara_config.rb
Created December 30, 2020 14:48
Configuration to use unicorn with capybara
Capybara.register_server :unicorn do |app, port, host, **options|
rackup_opts = Unicorn::Configurator::RACKUP
rackup_opts[:host] = host
rackup_opts[:port] = port
rackup_opts[:set_listener] = true
server = Unicorn::HttpServer.new(app, rackup_opts[:options])
server.logger.level = :warn
at_exit do
trap(:CHLD, nil)
server.stop(false)
@bazzel
bazzel / README.md
Last active July 27, 2024 16:48
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
@hossainemruz
hossainemruz / mysql-initialization-with-init-container.yaml
Created November 2, 2018 05:56
This sample show how to use init container to download init.sql file and initialize mysql database using this file
# this pvc will be used to store downloaded init.sql file
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: init-script
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
@nruth
nruth / selenium.rb
Last active March 22, 2023 13:10
translating old capybara selenium/chrome preferences and switches to new
# load into test setup after `require 'capybara/rails'`
# some sources for below flags and profile settings
# https://stackoverflow.com/questions/43143014/chrome-is-being-controlled-by-automated-test-software/43145088
# https://sqa.stackexchange.com/questions/26051/chrome-driver-2-28-chrome-is-being-controlled-by-automated-test-software-notif
# http://stackoverflow.com/questions/12211781/how-to-maximize-window-in-chrome-using-webdriver-python
# update sources for new Options object
# https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings
# https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selenium/driver.rb
begin
@Dman46
Dman46 / jail.local
Last active July 15, 2020 20:20
Fail2ban - send Slack notifications
...
action_with_slack_notification = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
slack[name=%(__name__)s]
action = %(action_with_slack_notification)s
...
@delaneyparker
delaneyparker / performance_logs_network.rb
Created May 1, 2017 21:14
Example parser for Network logs from Selenium / Chrome
# Since Ruby preserves hash key insertion order, you can iterate over values.
request_hash = Hash.new { |h, k| h[k] = {} }
# Used to convert event timestamps to epoch time.
wall_time_offset = nil
# Note: Calling logs.get() will clear the log buffer.
performance_logs = page.driver.browser.manage.logs.get('performance')
# Extract request / response data from log messages.
@ColCh
ColCh / app.js
Created February 24, 2017 13:25
catch errors and send 'em to Crashlytics in React Native
// WARNING: SIDE-EFFECTS. ONLY FOR PROD VERSION
if (!__DEV__) {
require('./utils/log.js');
}
// SIDE-EFFECTS END
@soultech67
soultech67 / application.rb
Last active December 13, 2022 19:48
How to make Unicorn and Rails log with consistent output tagging
# this is an example of: config/application.rb
require 'rails/all'
require 'rspec-rails'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module UnicornHostedRailsApp
@aburnett
aburnett / docker-machine-prompt.sh
Created October 16, 2015 13:40
Cheesy method to show currently active docker machine in PS1
#Usage: PS1='[$(__active_machine "{%s} ")\u@\h $]
EMOJI=🐳
__active_machine() {
FORMAT=$1
if ACTIVE=$(docker-machine active 2>/dev/null); then
STATE=$(docker-machine status $ACTIVE)
if [ "$STATE" = "Running" ]; then
unset STATE
IP=$(docker-machine ip $ACTIVE)
fi
@tomgidden
tomgidden / wsrep_notify_slack
Created February 25, 2015 21:32
Send wsrep / galera notifications for mysql clusters to a slack.com webhook
#!/usr/bin/env python
# configure this in my.cnf on a Galera-based MySQL-alike server:
# wsrep_notify_cmd=/usr/local/sbin/wsrep_notify_slack
# by Tom Gidden <[email protected]>
url = 'https://hooks.slack.com/services/XXXXXXX/XXXXXXXX/XXXXXXXX'
import argparse