Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
@ajsharp
ajsharp / pg_dump
Last active September 19, 2021 17:35
pg_dump to dump an entire postgres database
pg_dump -a --format=c --no-owner --no-privileges --no-publications --no-subscriptions -d DBNAME -U USERNAME -W -h HOSTNAME -f dump.sql
@samlambert
samlambert / management.md
Created January 9, 2021 00:16
Management @ PlanetScale

We want PlanetScale to be the best place to work. But every company says that, and very few deliver. Managers have a role in creating an amazing work experience, but things go awry when the wrong dynamic creeps in.

We have all seen those managers who collect people as “resources” or who control information as a way to gain “power.” In these cultures, people who “can’t” end up leading the charge. This is management mediocrity.

What will make us different? At PlanetScale, we won’t tolerate management mediocrity. We are building a culture where politics get you nowhere and impact gets you far. Managers are here to support people who get things done. They are as accountable to their team as their team is accountable to them.

We evaluate managers on the wellbeing and output of their team, how skillfully they collaborate with and influence others, and how inclusively and transparently they work.

You can expect your manager to:

  • Perceive a better version of you and support you in getting there
@ajsharp
ajsharp / gist:3cdc7bda232c6f886c6b66e88f0f3a68
Created November 28, 2018 03:16
A set of commands to clone environment vars from one heroku app to another
heroku config -s -a SOURCE_APP | ruby -e '`heroku config:set #{$stdin.read.split("\n").join(" ")} -a DEST_APP`'
@jlis
jlis / .gitlab-ci.yml
Created May 15, 2018 13:16
AWS ECS and ECR deployment via Docker and Gitlab CI
image: docker:latest
variables:
REPOSITORY_URL: <AWS ACCOUNT ID>.dkr.ecr.eu-central-1.amazonaws.com/<ECS REPOSITORY NAME>
REGION: eu-central-1
TASK_DEFINTION_NAME: <TASK DEFINITION NAME>
CLUSTER_NAME: <CLUSTER NAME>
SERVICE_NAME: <SERVICE NAME>
services:
@januszm
januszm / change_eb_ruby_version.sh
Last active October 17, 2022 20:16
Change Ruby minor version in AWS Elastic Beanstalk
# Currently (2017/2018) it's not possible to change the Ruby 'minor' version (eg. 2.3 => 2.4) using the web console
# However, it's possible using the 'awscli' tool.
brew install awscli # pip install awscli
aws elasticbeanstalk update-environment \
--solution-stack-name "64bit Amazon Linux 2017.09 v2.6.1 running Ruby 2.4 (Puma)" \
--environment-name "myappenv1" --region "us-east-2" \
--version-label "app-1234-210000_120123"
# For Amazon Linux 2
@waffleau
waffleau / extract_dominant_colors.rb
Last active March 27, 2024 10:22
Extract dominant colours from an image in Ruby using MiniMagick
def self.extract_dominant_colors(image_path, quantity=5, threshold=0.01)
image = MiniMagick::Image.open(image_path)
# Get image histogram
result = image.run_command('convert', image_path, '-format', '%c', '-colors', quantity, '-depth', 8, 'histogram:info:')
# Extract colors and frequencies from result
frequencies = result.scan(/([0-9]+)\:/).flatten.map { |m| m.to_f }
hex_values = result.scan(/(\#[0-9ABCDEF]{6,8})/).flatten
total_frequencies = frequencies.reduce(:+).to_f
@maxdbn
maxdbn / sidekiq.config
Last active May 23, 2021 12:05
Gracefully restarting Sidekiq on Elasticbeanstalk, only after it's done with the running jobs. Tested on: 64bit Amazon Linux 2016.09 v2.3.0 running Ruby 2.3 (Puma). Thanks to ssaunier for the original gist! https://gist.github.com/ssaunier/44bbebb9c0fa01953860
# Sidekiq interaction and startup script
commands:
create_post_dir:
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh":
mode: "000755"
owner: root
group: root
@kitwalker12
kitwalker12 / 0000_bundle.config
Last active November 27, 2017 21:24
Sneakers and Sidekiq Configuration on AWS Beanstalk
packages:
yum:
git: []
option_settings:
aws:elasticbeanstalk:application:environment:
BUNDLE_WITHOUT: test:development
ClickHouse administration tips.
CPU
SSE 4.2 instruction set support is required. Most recent (since 2008) CPUs have this instruction set.
When choosing between CPU with more cores and slightly less frequency and CPU with less cores and more frequency, choose first.
For example, 16 cores with 2600 MHz is better than 8 cores with 3600 MHz.
@ajsharp
ajsharp / Makefile
Last active January 9, 2021 05:36
This Makefile exposes commands to do a manual deploy to AWS Elastic Beanstalk using the AWS CLI. Normally, you would do a deploy with the `eb` command, but using the AWS CLI is more convenient for orchestrating continuous deployment from a CI server.
VERSION=$(shell git rev-parse --short HEAD)
DESC=$(shell git log -1 --pretty=%B)
BUCKET_NAME="my-bucket"
PROJECT_NAME="my-project"
REGION="us-east-1"
ENV_NAME="elasticbeanstalk-environment-name"
archive:
git archive --format=zip -o $(VERSION).zip HEAD