Skip to content

Instantly share code, notes, and snippets.

View krsyoung's full-sized avatar

Christopher Young krsyoung

View GitHub Profile
@jonathanloos
jonathanloos / LocalQueryPerformance.md
Last active February 25, 2022 04:47
Find a common list of queries we at Harled have used in our Ruby on Rails Platforms

Query Performance Monitoring

We've had the case where a seemingly small change in a query (such as adding a .join() clause) actually caused us a large load-related headache when run multiple times by our users in production. To avoid this issue in future iterations we now use (rack-mini-profiler)[https://github.com/MiniProfiler/rack-mini-profiler] to help us measure our queries in development! The profiler will give you a file-by-file, query-by-query analysis of your page load times and flag expensive queries.

@monsha
monsha / Pghero on Rails with Dokku.txt
Last active March 8, 2025 18:25
Pghero on Rails with Dokku
#postgresql setup
ssh -i ~/.ssh/id_rsa root@<domain>
dokku postgres:connect <db>
psql=# SHOW config_file;
-> /var/lib/postgresql/data/postgresql.conf
psql=# \q
docker ps
@kimadactyl
kimadactyl / README.sh
Last active May 10, 2024 14:23
Dokku / Digital Ocean / Rails / Postgres / Let's Encrypt / persistent storage
# Creating a Digital Ocean droplet running Rails + Postgres with persistant storage and https
#--------------------------------------------------------------------------------------------
# For your ctrl-D pleasure...
# SERVER_IP
# APP_NAME
# RAILS_SECRET (generate with `rails secret`)
# ADMIN_EMAIL
@stungeye
stungeye / instructions.md
Last active April 8, 2022 19:27
SSL Using Let's Encrypt for Rails/Passenger/Nginx

After installing certbot:

sudo service nginx stop
sudo ./certbot-auto certonly --standalone -d sub.example.com --standalone-supported-challenges http-01
sudo service nginx start

Modified the ngnix site conf:

server {

listen 80;

@the-bass
the-bass / application.html.erb
Last active April 15, 2020 15:01
Using Google Analytics with Rails 5 and Turbolinks 5. This code is taken from the conversation between @preetpalS and @packagethief on https://github.com/turbolinks/turbolinks/issues/73.
<%# Put this code snippet between the <head></head>-tags in your application layout and %>
<%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %>
<%# ... %>
<head>
<%# ... %>
<% if Rails.env.production? %>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@pugsley
pugsley / mysql-backup.md
Last active March 19, 2025 12:06
MySQL dump > compress > encrypt

Generate openssl keys:

openssl req -x509 -nodes -newkey rsa:2048 -keyout mysqldump-key.priv.pem -out mysqldump-key.pub.pem

Create a mysql default file:

# ~/.mysqldump
[mysqldump]
host = host.here.com
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active March 14, 2025 01:20
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@justinweiss
justinweiss / filterable.rb
Last active January 30, 2025 13:06
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@yhsiang
yhsiang / gulpfile.js
Last active July 21, 2018 03:52 — forked from chriskjaer/gulpfile.js
switch node-sass to stylus
var gulp = require('gulp'),
gutil = require('gulp-util'),
stylus = require('gulp-stylus'),
uglify = require('gulp-uglify'),
jade = require('gulp-jade'),
concat = require('gulp-concat'),
livereload = require('gulp-livereload'),
tinylr = require('tiny-lr'),
express = require('express'),
app = express(),
@suryart
suryart / application.html.erb
Last active October 26, 2023 00:16
Rails 4 flash messages using Twitter Bootstrap(bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass). An improved version of https://gist.github.com/roberto/3344628
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>