Skip to content

Instantly share code, notes, and snippets.

View trak3r's full-sized avatar

Thomas "Teflon Ted" Davis trak3r

View GitHub Profile
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active April 22, 2024 16:30
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active April 19, 2024 12:30
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@JackDanger
JackDanger / simple_ruby_profile.rb
Last active August 2, 2016 18:05
Fast way to profile a Ruby program
# In your code, right at the top of any source code file.
trap 'PROF' do
File.open("/tmp/profile-#{Time.current.to_f}", 'w') {|f| f.write caller(2).join("\n") }
pid = $$
Thread.new { sleep 0.5; `kill -PROF #{pid}` }
end
# in a terminal
while true; do
sleep 0.1
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@mattetti
mattetti / rails_encryptor_reduction.rb
Last active December 29, 2015 16:28
Quick high level rundown showing how Rails 4 sets the message encryptor used for sessions, signed messages and more.
require "active_support"
require "active_support/key_generator"
require "json"
# Based on https://gist.github.com/mattetti/7624413
module JsonSessionSerializer
def self.load(value)
begin
JSON.parse(value)
rescue JSON::ParserError
@reinh
reinh / README.md
Last active February 20, 2016 00:39

Syntax highlight SQL inside Ruby <<-SQL heredocs

Embeds SQL syntax highlighting inside Ruby heredocs labeled SQL. This will also work to embed other syntaxen, e.g., HTML.

Optional PGSQL enhanced syntax:

(requires https://github.com/exu/pgsql.vim)

 syntax include @SQL syntax/pgsql.vim