Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@JoshCheek
JoshCheek / pipeline.rb
Created December 10, 2016 22:36
A shell pipeline in Ruby
# Read initial standard input from the data segment at the end of the file
# You can also see what is ultimately output down there
pos = DATA.pos # => 1617
$stdin.reopen __FILE__ # => #<IO:/var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20161210-36802-czciw7/program.rb>
$stdin.seek pos, :SET # => 0
# The commands that will be piped together
commands = [
%w[cat],
%w[tr a A],

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

#!/bin/sh
export DEBIAN_FRONTEND=noninteractive
sudo rm -rf /etc/apt/sources.list.d/mysql.list
sudo add-apt-repository -y ppa:ondrej/mysql-5.5
sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/remove-data-dir boolean true"
sudo apt-get remove --purge -y mysql-client mysql-common mysql-community-client mysql-community-server mysql-server php5-mysql libmysqlclient-dev libmysqlclient18
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo -E bash -c 'apt-get -y --force-yes install mysql-server libmysqlclient-dev'
mysqladmin -u root password semaphoredb
@vielhuber
vielhuber / README.MD
Last active April 18, 2025 14:39
ffmpeg: Video convert m2ts to mp4, mp4 to webm, mp4 to ogv, mp3 wav hz, extract frames #tools

video convert m2ts to mp4, mp4 to webm, mp4 to ogv

mp4 to mp4 (medium)

ffmpeg -i input.mp4 -b 1000000 output.mp4

m2ts to mp4

ffmpeg -i input.m2ts -vcodec libx264 -crf 20 -acodec ac3 -vf "yadif" output.mp4
@smedstadc
smedstadc / read_only_hash.rb
Created April 12, 2015 23:42
Read Only Ruby Hash Snippet
# By extending a regular ruby hash with this module the hash will behave as if
# it were an immutable object. The brackets and fetch methods will return copies
# of values and the assignment method will raise an exception.
#
# Other methods that should be redefined for a truly immutable hash object.
# :delete, :delete_if, :reject!, :select!, :keep_if, :merge!, :update
module ReadOnlyHash
def [](key)
value = super(key)
value ? value.dup : default
@adamloving
adamloving / show-express-routes-gulp-task.js
Created June 9, 2014 18:23
Gulp task to show the routes in an express app (similar to rails rake routes).
var app = require('../server/app.js').create()
var gulp = require('gulp');
var task = require('./index');
/*
Output all the routes that the app supports
*/
gulp.task('routes', function() {
@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@mgreenly
mgreenly / gist:1109325
Created July 27, 2011 13:11
database cleaner multiple connections single orm outside of rails
RSpec.configure do |config|
config.before(:suite) do
ActiveRecord::Base.establish_connection database['one']
DatabaseCleaner.strategy = :deletion
ActiveRecord::Base.establish_connection config.database['two']
DatabaseCleaner.strategy = :deletion
end
config.before(:each) do