Skip to content

Instantly share code, notes, and snippets.

@sue445
sue445 / isucon.tf
Last active Aug 23, 2021
ISUCONの素振りの環境構築用Terraform (c.f. https://sue445.hatenablog.com/entry/2021/08/22/213634 )
View isucon.tf
resource "aws_vpc" "main" {
cidr_block = "172.31.0.0/16"
tags = {
Name = "isucon VPC"
}
}
resource "aws_subnet" "public_a" {
vpc_id = aws_vpc.main.id
@sue445
sue445 / db_migrate_monkey_patch.rake
Last active May 29, 2020
A monkey patch to switch the connection destination from pgbouncer to PostgreSQL only when `rake db:migrate`
View db_migrate_monkey_patch.rake
# A monkey patch to switch the connection destination from pgbouncer to PostgreSQL only when `rake db:migrate`
#
# Usage: Put this file to `lib/tasks/db_migrate_monkey_patch.rake`
#
# https://gist.github.com/sue445/e82bbc8b626e4681f87182aa5981b68d
require "tmpdir"
require "fileutils"
module DbMigrateMonkeyPatch
@sue445
sue445 / service_account-datadog.tf
Created Feb 17, 2020
Service account for datadog
View service_account-datadog.tf
# Service account for datadog
# c.f. https://docs.datadoghq.com/ja/integrations/google_cloud_platform/?tab=datadogussite#setup
resource "google_service_account" "datadog" {
account_id = "datadog"
display_name = "datadog"
}
# Compute Viewer
resource "google_project_iam_binding" "datadog_compute_viewer" {
View CVE-2019-16892-rubyzip-patch.rb
# zip bomb measures for rubyzip v1.3.0
# c.f. https://github.com/rubysec/ruby-advisory-db/blob/master/gems/rubyzip/CVE-2019-16892.yml
#
# validate_entry_sizes has been default enabled since rubyzip v2.0.0, but must be explicitly enabled in v1.3.x
#
# Put this file as `config/initializers/CVE-2019-16892-rubyzip-patch.rb` if rails
begin
require "zip"
require "zip/version"
View deploy.rb
# envリポジトリのcurrent
set :env_current, "/home/deploy/docker-gitlab-env/current"
set :stack_name, "gitlab"
namespace :stack do
desc "docker stack deploy"
task :deploy do
on roles(:app) do
within release_path do
View docker-compose.yml
version: '3.7'
services:
redis:
restart: always
image: sameersbn/redis:4.0.9-2
command:
- --loglevel warning
deploy:
View z_backup_repository_monkey_patch.rake
# 巨大なリポジトリのバックアップを作ろうとするとBackup::Repositoryでエラーになるのでコネクションを明示的に取得するためのモンキーパッチ
# (lib/tasks/gitlab/backup.rake よりも後にloadされてほしいのでわざとz_を付与)
# https://gitlab.com/gitlab-org/gitlab-ce/blob/v12.2.4/lib/backup/repository.rb
# FIXME: gitlab-ceにMRを投げてマージされたら削除したい
task :backup_repository_monkey_patch do
module BackupRepositoryMonkeyPatch
MAX_RETRY_COUNT = 1
def backup_custom_hooks(project)
@sue445
sue445 / .gitlab-ci.yml
Last active Jun 23, 2019
Example: deployment gitpanda using GitLab CI c.f. https://inside.pixiv.blog/sue445/7256
View .gitlab-ci.yml
stages:
- test
- deploy
.default: &default
image: sue445/awscli-all
variables:
GITPANDA_VERSION: v0.3.4
AWS_DEFAULT_REGION: ap-northeast-1
@sue445
sue445 / flowchart.svg
Last active Mar 17, 2019
六大異変攻略作戦 《輝く湖タークディアバーブ》のフローチャート (for PlantUML)
View flowchart.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View git update
#!/bin/sh -e
if [ -n "$1" ]; then
master=$1
else
master=`git remote show origin | grep 'HEAD branch:' | cut -d : -f 2 | tr -d '[[:space:]]'`
fi
current=`git branch | grep '*' | cut -f 2 -d ' '`