Skip to content

Instantly share code, notes, and snippets.

View wbotelhos's full-sized avatar
💭
I'm not my code.

Washington Botelho wbotelhos

💭
I'm not my code.
View GitHub Profile
@chrisjpatty
chrisjpatty / maskDate.js
Last active April 6, 2024 15:27
Javascript date Input mask MM/DD/YYYY
const maskDate = value => {
let v = value.replace(/\D/g,'').slice(0, 10);
if (v.length >= 5) {
return `${v.slice(0,2)}/${v.slice(2,4)}/${v.slice(4)}`;
}
else if (v.length >= 3) {
return `${v.slice(0,2)}/${v.slice(2)}`;
}
return v
}
@pdabrowski6
pdabrowski6 / simple_benchmark.rb
Created February 10, 2018 03:53
Avoid let and before blocks in your test when you don't really have to use them
# user.rb file
class User
attr_reader :admin
def initialize(admin: false)
@admin = admin
end
end
@theoretick
theoretick / Dockerfile.alpine
Created November 12, 2017 01:42
ruby2.3.2, chrome headless, alpine Dockerfile
FROM ruby:2.4.2-alpine3.4
MAINTAINER Lucas Charles (theoretick) <[email protected]>
EXPOSE 8080
ENV APP_PATH /srv/app
RUN echo "http://dl-4.alpinelinux.org/alpine/v3.4/main" >> /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/v3.4/community" >> /etc/apk/repositories
@rbalman
rbalman / dump_memcache.rb
Last active August 2, 2019 19:48
Dumping and restoring the memcache key values using telnet & dalli gem
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
require 'csv'
headings = %w(id expires bytes key)
rows = []
@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
@nisshiee
nisshiee / cluster.tf
Created April 14, 2017 13:44
TerraformでAuroraを立てる
resource "aws_rds_cluster" "default" {
cluster_identifier = "${var.service}-${var.name}-${var.env}"
master_username = "${var.username}"
master_password = "${var.password}"
backup_retention_period = 5
preferred_backup_window = "19:30-20:00"
preferred_maintenance_window = "wed:20:15-wed:20:45"
port = 3306
vpc_security_group_ids = ["${var.security_group_ids}"]
db_subnet_group_name = "${var.subnet_group_name}"
@wbotelhos
wbotelhos / clear-sidekiq-jobs.sh
Last active April 9, 2025 12:42
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@palkan
palkan / any_fixture.rb
Created March 28, 2017 21:49
AnyFixture: make DB fixtures from blocks
module AnyFixture
INSERT_RXP = /^INSERT INTO ([\S]+)/
class Cache
attr_reader :store
delegate :clear, to: :store
def initialize
@store = {}
@bancek
bancek / webdriver.json
Last active June 28, 2018 15:29
Selenim WebDriver Chromedriver disable saving passwords (password_manager_enabled)
{
"chromeOptions": {
"prefs": {
"credentials_enable_service": false,
"profile.password_manager_enabled": false
}
}
}
@tkuchiki
tkuchiki / autoscaling.tf
Last active July 17, 2017 00:04
terraform 設定例 (v0.7.9)
resource "aws_launch_configuration" "test" {
name = "test"
image_id = "${var.ami}"
instance_type = "t2.micro"
associate_public_ip_address = true
security_groups = ["${aws_security_group.internal.id}"]
}
resource "aws_autoscaling_group" "test" {
name = "test"