Skip to content

Instantly share code, notes, and snippets.

View kceb's full-sized avatar
👨‍💻

Kevin C kceb

👨‍💻
View GitHub Profile
@sethwebster
sethwebster / README.md
Last active April 12, 2023 19:06
Make Docker Cache Gem Installs to speed up Bundle Install

Gem Install Dockerfile Hack

If you're hacking on your Gemfile and using Docker, you know the pain of having the bundle install command run after you've added or removed a gem. Using docker-compose you could mount a volume and stage your gems there, but this adds additional complexity and doesn't always really solve the problem.

Enter this imperfect solution:

What if we installed every gem into it's own Docker layer which would be happily cached for us?

gem-inject-docker does just that. It takes the list of gems used by your app via bundle list and transforms it into a list of RUN gem install <your gem> -v <gem version> statements and injects them into the Dockerfile at a point of your choosing.

@bookmebus
bookmebus / pumaconf.conf
Created November 25, 2018 03:15
ElasticBeanStalk custom puma config for multiprocess x workers.
container_commands:
# directory '/var/app/current'
# threads 8, 32
# workers %x(grep -c processor /proc/cpuinfo)
# bind 'unix:///var/run/puma/my_app.sock'
# pidfile '/var/run/puma/puma.pid'
# stdout_redirect '/var/log/puma/puma.log', '/var/log/puma/puma.log', true
# daemonize false
01backup_config:
@humpok
humpok / reset_sidekiq.rb
Created September 13, 2018 13:38
Delete All Sidekiq Batches and Jobs
Sidekiq::BatchSet.new.each { |batch| Sidekiq::Batch::Status.new(batch.bid).delete }
Sidekiq::Queue.all.each(&:clear)
@fupslot
fupslot / beanstalk node command
Created February 6, 2018 13:25
elastic beanstalk node command not found
# Amazon Elastic Beanstalk
## Grand the access to node command
1. sudo su
2. vipw
3. nodejs:x:496:494::/tmp:/bin/bash (":wq" to save changes)
4. sudo su nodejs
5: PATH=$PATH:`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin
6: node -v (enjoy :)
@gangsta
gangsta / SSL.md
Last active March 9, 2025 17:07
How to Setting Up a Comodo SSL Cert

How to Setting Up a Comodo SSL Cert

  • I advice you to buy SSL Certs from officially Comodo only , or some SSL reseller whose you trust.

These are the steps I went through to set up an SSL cert. Purchase the cert

Prior to purchasing a cert, you need to generate a private key, and a CSR file (Certificate Signing Request). You’ll be asked for the content of the CSR file when ordering the certificate:

openssl req -new -newkey rsa:2048 -nodes -keyout example_com.key -out example_com.csr
@javan
javan / direct-uploads.md
Last active January 9, 2025 01:00
Active Storage direct uploads

direct-uploads

rails/activestorage#81

// direct_uploads.js

addEventListener("direct-upload:initialize", event => {
  const { target, detail } = event
  const { id, file } = detail
@ryu1kn
ryu1kn / Makefile
Last active March 19, 2023 13:02
Encrypt/decrypt with AWS KMS using AWS cli
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli
KEY_ID=alias/my-key
SECRET_BLOB_PATH=fileb://my-secret-blob
SECRET_TEXT="my secret text"
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target
encrypt-text:
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_sidekiq.sh":
mode: "000755"
content: |
#!/bin/bash
. /opt/elasticbeanstalk/support/envvars
PIDFILE=/var/app/containerfiles/pids/sidekiq.pid
if [ -f ${PIDFILE} ]
then
kill -USR1 `cat ${PIDFILE}`
@gaearon
gaearon / connect.js
Last active April 15, 2025 03:44
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
#!/usr/bin/env bash
. /opt/elasticbeanstalk/support/envvars
DIR=/var/app/current
if [ "$WORKER_MODE" = "1" ]
then
if [ -f /var/run/shoryuken.pid ]
then
su -l -c "kill -USR1 `cat /var/run/shoryuken.pid`" root || echo "no process"
su -l -c "rm -f /var/run/shoryuken.pid" root || echo "no file"
fi