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
@mconnell
mconnell / audio_switch.applescript
Last active August 24, 2018 09:22
AppleScript for quickly flipping between 2 audio sources
-- Open automator
-- * New Service
-- * Service Recieves: no input
-- * Paste the following
-- * Alter audio sources to match your machine
-- * Save
-- Open Keyboard
-- * Shortcuts
-- * Services
-- * Bind to shortcut

Forward GnuPG agent from macOS to Linux

On the remote machine

Run gpg once as your to create the directory structure

gpg --list-keys

For headless systemd based hosts

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?

@wjessop
wjessop / lock.rb
Created September 26, 2016 14:26
with_exclusive_lock("my_operation") do
# Something that can only happen one at a time
end
def with_exclusive_lock(lock_name, &block)
lock_file_name = "/tmp/#{lock_name}.lock"
FileUtils.touch(lock_file_name)
lock_file = File.new(lock_file_name)
lock_file.flock(File::LOCK_EX)
yield
@jeka-kiselyov
jeka-kiselyov / index.js
Last active October 4, 2018 09:28
CloudWatch to AWS Lambda to Slack Channel Alerts and Charts. Posts CloudWatch Alerts via SNS topic via Lambda function to Slack channel. And draws charts for CPUUtilization metrics(both for EC2 abd RDS).
////// Save as index.js and upload it to Lambda as zip archive with node_modules directory. After:
////// npm install aws-cloudwatch-chart
////// npm install request
////// no need to upload aws-sdk module
////// Don't forget to change API keys here.
////// License: MIT
////// Docs:
@strax
strax / .gitattributes
Created March 24, 2015 16:08
Auto-resolving schema.rb version conflicts on Rails 4.0+
db/schema.rb merge=railsschema
# RSpec matcher to spec delegations.
# Forked from https://gist.github.com/ssimeonov/5942729 with fixes
# for arity + custom prefix.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:name).to(:author).with_prefix(:any) } # post.any_name
# it { should delegate(:month).to(:created_at) }
@slindberg
slindberg / README.md
Last active July 27, 2022 09:22
Ember debug helpers intended to be used in the JavaScript console

Ember.Console

This is a set of helpers for finding the application's currently active models/routes/controllers/etc. This isn't a straightforward process because of how Ember (rightly) encapsulates application objects, but it's useful in debugging environments to be able to quickly access them. And with the beta release of Ember Data, the store is not easily accessible without helpers either.

Usage

All helpers can be called directly if you provide them an application instance:

@snikch
snikch / test.rb
Last active January 6, 2022 13:18
Convert a UUID to UTF-8 encoding to visually shorten.
>> code = Urlcode.uuid_to_code("4c3559f0-cd95-482f-a27d-b2bbc68523ef")
=> "䰵姰축䠯ꉽ늻욅⏯"
>> Urlcode.code_to_uuid(code)
=> "4c3559f0-cd95-482f-a27d-b2bbc68523ef"