Skip to content

Instantly share code, notes, and snippets.

View stravid's full-sized avatar

David Strauß stravid

View GitHub Profile
@runlevel5
runlevel5 / puma.sh
Last active July 18, 2022 17:37
pumactl is very broken, @nemshilov and @joneslee85 wrote this bash script replacement and it works so reliably on production server. So here it is, share with the world!
#!/usr/bin/env bash
# Simple move this file into your Rails `script` folder. Also make sure you `chmod +x puma.sh`.
# Please modify the CONSTANT variables to fit your configurations.
# The script will start with config set by $PUMA_CONFIG_FILE by default
PUMA_CONFIG_FILE=config/puma.rb
PUMA_PID_FILE=tmp/pids/puma.pid
PUMA_SOCKET=tmp/sockets/puma.sock
@r00k
r00k / gist:5885955
Created June 28, 2013 16:19
Notes for my talk at Engineers4Engineers at Constant Contact on 6/28/13.
My name is Ben Orenstein and I work at thoughtbot in Boston.
Notes will be published.
I'd like to tell you a story. (5:42)
I've never talked about this publicly.
Umass.
Second job.
Version control.
Successful since then.
@hoffmanc
hoffmanc / en.yml
Last active December 20, 2015 15:09
Hand rolled ICS support
# locales/en.yml
en:
time:
formats:
ical: "%Y%m%dT%H%M%SZ"
@maxhoffmann
maxhoffmann / gist:7373563
Last active December 27, 2015 18:59
run local php server and open browser
# local PHP Server
server() {
url="localhost:${2:-8000}"
if [ -z "$1" ]; then
php -S $url & # run server in background
else
php -S $url -t $1 &
fi
sleep 0.3s # wait for server to start
div.description a.autolink
{
display: inline-block;
max-width: 250px;
text-overflow: ellipsis;
overflow: hidden;
}
@searls
searls / app.css
Created May 18, 2014 14:38
Handy trick for debugging to see which parts of your app are being re-rendering in the DOM (without keeping your eyes glued to web inspector)
body * {
-webkit-animation: fade-in 2s ease-out;
animation: fade-in 2s ease-out;
}
@clemens
clemens / invoice.rb
Created July 24, 2014 19:49
invoice number generation per year
class Invoice < ActiveRecord::Base
before_validation :generate_number, on: :create
private
def generate_number
prefix = "R#{Date.today.strftime('%y')}-"
last_order_number_this_year = self.class.where("number LIKE ?", "#{prefix}%").order("number DESC").limit(1).pluck(:number).first
number = last_order_number_this_year ? last_order_number_this_year.match(/\A#{prefix}(\d+)\z/)[1].to_i : 0
@gshaw
gshaw / carrier_wave.rb
Created August 14, 2014 19:06
CarrierWave initialization file for testing with fixtures and support S3 in staging and production.
# NullStorage provider for CarrierWave for use in tests. Doesn't actually
# upload or store files but allows test to pass as if files were stored and
# the use of fixtures.
class NullStorage
attr_reader :uploader
def initialize(uploader)
@uploader = uploader
end
@thbar
thbar / private_buckets_test.rb
Last active August 29, 2015 14:17
Production sanity test to verify that S3 buckets remain private over time
def buckets
[
'myapp-production-backups',
'myapp-staging-backups',
'myapp-s3-logs'
]
end
def test_buckets_subdomain_private
buckets.each do |bucket_name|
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;