Skip to content

Instantly share code, notes, and snippets.

@ilyakatz
ilyakatz / ssl_puma.sh
Created October 27, 2016 18:06 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@ilyakatz
ilyakatz / siera.sh
Last active November 1, 2016 14:39
Max OS X sierra upgrade
xcode-select --install
bundle config build.nokogiri --use-system-libraries   
bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
gem install eventmachine -v '1.0.7' -- --with-cppflags=-I/usr/local/opt/openssl/include          
@ilyakatz
ilyakatz / opsworks.rb
Last active August 29, 2015 14:22
Viewing logs in OpsWorks
require 'aws-sdk-core'
deployments = opsworks.describe_commands(deployment_id: deployment_id)
region = "us-east-1"
opsworks = Aws::OpsWorks::Client.new(region: region)
deployments = opsworks.describe_commands(deployment_id: deployment_id)
deployments[0].collect(&:log_url).compact
@ilyakatz
ilyakatz / largest.sql
Last active July 1, 2021 11:10
Largest tables (mysql)
/*
http://www.percona.com/blog/2008/02/04/finding-out-largest-tables-on-mysql-server/
*/
SELECT CONCAT(table_schema, '.', table_name) ,
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 ), 2), 'M') total_size,
ROUND(index_length / data_length, 2) idxfrac
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFRY6TUBCADgzqFSpV15H77BC574fnzYNl7rFEerbyeK1JIwnkCRvssS/S8ZzGNwgYUn
eMZFT3t9euYAzTx0WgHwhdDUZpRPXsYIfzjz44bXPd4yhJtes12twpj4ZD9RBmbDLnnVpPY1
ZVvk6EICKsy3FuwaQ1t/SxwWJ/w/aVHzTmlvxHuLYsp418Ik+5S+EAg/zB0ME/V89BUNiC/w
tEisE2EZj6JZSXeQrs7YQhZxe5E5HNewBdEvpigvlFUS/Q3aObeFe1lj5M1sGn6Cmrzs8GXy
Q/qWzVuRqjiVy7229Tm2+yARLm87KbbyRWVjdj43ykM1NcDwl/GEau57o6QNuwKUl1KrABEB
AAG0HklseWEgS2F0eiA8aWx5YWthdHpAZ21haWwuY29tPokBMgQQAQgAJgUCVFjpNwYLCQgH
AwIJEFLp7GBMMJSGBBUIAgoDFgIBAhsDAh4BAACvwAf/dv8j/OfJ1IjxQrFvRXv/BxTBZ8UD
99igTFHM8KuYhK/AluOKQZMR34yUNVyGPvO6Iz3+jDeES8d3PoVOOD8y7VKtqwkooXLjFb4m
Verifying that +katzmopolitan is my Bitcoin username. You can send me #bitcoin here: https://onename.io/katzmopolitan
@ilyakatz
ilyakatz / active_admin.rb
Created August 12, 2014 17:35
Custom default order order in active_admin
# initializers/active_admin.rb
module ActiveAdmin
class OrderClause
alias_method :initialize_old, :initialize
alias_method :valid_old?, :valid?
alias_method :to_sql_old, :to_sql
def initialize(clause)
if clause.class == String
initialize_old(clause)
@ilyakatz
ilyakatz / abd_broadcase_receivers.sh
Created March 9, 2014 14:33
List all registered BroadcastReceivers
#statuc
adb shell dumpsys activity b
# dynamic
adb shell dumpsys package
@ilyakatz
ilyakatz / primary_key_autoincrement. rb
Created February 5, 2014 19:30
Update the value of the primary key auto increment for a model in rails
klazz = SoftwareMember
klazz .connection.execute("ALTER TABLE #{klazz .table_name} AUTO_INCREMENT = 1000")

In order to use asset pipeline available for static error pages (like 404.html), a few steps are required

  • Move static pages from /public into /app/assets

    (eg: public/422.html → app/assets/html/422.html.erb)

  • Add html directory to the asset pipeline

  • Update exceptions middleware to understand assets with digests