Skip to content

Instantly share code, notes, and snippets.

View jweslley's full-sized avatar

Jonhnny Weslley jweslley

View GitHub Profile
@mitchellh
mitchellh / merge_vs_rebase_vs_squash.md
Last active June 5, 2025 22:05
Merge vs. Rebase vs. Squash

I get asked pretty regularly what my opinion is on merge commits vs rebasing vs squashing. I've typed up this response so many times that I've decided to just put it in a gist so I can reference it whenever it comes up again.

I use merge, squash, rebase all situationally. I believe they all have their merits but their usage depends on the context. I think anyone who says any particular strategy is the right answer 100% of the time is wrong, but I think there is considerable acceptable leeway in when you use each. What follows is my personal and professional opinion:

# Rails production setup via SQLite3 made durable by https://litestream.io/
# Copy this to Dockerfile on a fresh rails app. Deploy to fly.io or any other container engine.
#
# try locally: docker build . -t rails && docker run -p3000:3000 -it rails
#
# in production you might want to map /data to somewhere on the host,
# but you don't have to!
#
FROM ruby:3.0.2
def roman_numeral(n) = case n
in 1000..3000 then 'M' + roman_numeral(n - 1000)
in 900..999 then 'CM' + roman_numeral(n - 900)
in 500..899 then 'D' + roman_numeral(n - 500)
in 400..499 then 'CD' + roman_numeral(n - 400)
in 100..399 then 'C' + roman_numeral(n - 100)
in 90..99 then 'XC' + roman_numeral(n - 90)
in 50..89 then 'L' + roman_numeral(n - 50)
in 40..49 then 'XL' + roman_numeral(n - 40)
in 10..39 then 'X' + roman_numeral(n - 10)
@le0pard
le0pard / forge-library.js
Last active December 28, 2020 20:07
AES-256-GCM on Ruby and JS (Web Crypto API and forge.js)
// you need to use https://github.com/digitalbazaar/forge
const encryptData = (key, data) => {
const mdKey = forge.md.sha256.create()
mdKey.update(key)
const iv = forge.random.getBytesSync(12)
const cipher = forge.cipher.createCipher('AES-GCM', mdKey.digest())
cipher.start({
@idelem
idelem / titleUrlMarkdownClip.js
Last active May 31, 2025 01:01 — forked from bradleybossard/titleUrlMarkdownClip.js
Bookmarklet to copy current page title and url in Markdown format to clipboard, like [title](url) - Usual for posting links to resources in README.md files
javascript:(function() {
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
/*IE specific code path to prevent textarea being shown while dialog is visible.*/
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
@palkan
palkan / Gemfile
Last active April 25, 2024 14:23
RSpec profiling with RubyProf and StackProf
gem 'stackprof', require: false
gem 'ruby-prof', require: false
@varyonic
varyonic / docker-compose.yml
Last active May 18, 2021 13:18
Capybara standalone Selenium Chrome config
web:
build: .
volumes:
- .:/opt/myapp
ports:
- '3000:3000'
links:
- db
- redis
- selenium
@vasanthk
vasanthk / System Design.md
Last active June 16, 2025 20:31
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@17twenty
17twenty / GoWithC.go
Last active July 11, 2016 04:29
Cross Compiling and Language Interop oh my!
package main
import (
"./binding"
"fmt"
)
func main() {
binding.PrintHello()
binding.Seed(1)
fmt.Println(binding.Random())