Skip to content

Instantly share code, notes, and snippets.

@D-system
D-system / aws_cloudwatch_log_to_appsignal.yml
Created August 16, 2024 02:48
Configure AWS to transfer Cloudwatch group log to AppSignal with CloudFormation
---
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Configures CloudWatch logs stream and Kinesis Data Firehose to
send logs to AppSignal from an existing CloudWatch log group.
It must be deployed in the same region and same account as the CloudWatch log group.
Implements all the steps from AppSignal documentation all at once:
https://docs.appsignal.com/logging/platforms/cloudwatch.html
@D-system
D-system / start_mysql.sh
Created November 24, 2019 12:56
Docker helper
# docker stop mysql_5.7
# docker run -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_DATABASE=circle_test -e MYSQL_HOST=127.0.0.1 -e MYSQL_USER=root --shm-size 2G --name mysql_5.7 circleci/mysql:5.7-ram
docker restart mysql_5.7
@D-system
D-system / .gitconfig
Last active November 24, 2019 12:53
Git configuration file
[user]
name = Thomas Brennetot
email = ...@gmail.com
[core]
editor = code --wait
[commit]
verbose = true
[diff]
tool = vscode
[difftool "vscode"]
@D-system
D-system / .bundle--config
Last active November 24, 2019 12:49
Bundler configuration for Mac
---
BUNDLE_BUILD__LIBXML-RUBY: "--use-system-libraries=true --with-xml2-include=/usr/local/opt/libxml2/include/libxml2/"
BUNDLE_BUILD__MYSQL2: "--use-system-libraries=true --with-mysql-include=/usr/local/opt/mysql/include/mysql/"
@D-system
D-system / isin_code_validator.rb
Created October 29, 2019 13:16
ISIN code validator in Ruby
class IsinCodeValidator
ISIN_FORMAT = '^[A-Z]{2}[A-Z0-9]{9}[0-9]$'.freeze
ISIN_REGEX = Regexp.new(ISIN_FORMAT).freeze
LETTER_TO_CODE_VALUE = 55 # Ascii code for 'A' == 65 && 'A' == 10 in isin calculation cod
def self.valid?(str)
return false if str.nil? || !str.match?(ISIN_REGEX)
proc_isin = str.split(//)
key = proc_isin.pop.to_i
@D-system
D-system / rails_template.rb
Last active November 24, 2019 13:31
Rails (5.x) application template (to customize new or existing app)
## To create a new project: `rails new MY_APP -m __FILE__`
## To run on existing projects: `bin/rails app:template LOCATION=__FILE__`
##
# Generate Gemfile.lock
##
bundle install
git add: '.'
git commit: %Q{ -m 'Initial commit: Rails vanilla' }
@D-system
D-system / list_exceptions.rb
Created January 31, 2019 02:10
[Ruby exceptions list] List all exceptions available (including the main namespace)
exceptions = []
ObjectSpace.each_object(Class) do |k|
exceptions << k if k.ancestors.include?(Exception)
end
puts exceptions.sort { |a,b| a.to_s <=> b.to_s }.join("\n")
@D-system
D-system / service-checklist.md
Last active September 27, 2016 07:49 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@D-system
D-system / application_controller.rb
Created March 19, 2015 08:16
Expires any page in any situation (including the back button action)
def expires_now
# override default method due to some browsers cases (http://stackoverflow.com/a/18516720/856151)
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' # HTTP 1.1.
response.headers['Pragma'] = 'no-cache' # HTTP 1.0.
response.headers['Expires'] = '0' # Proxies.
end