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
@porras
porras / triple_dots.rb
Created January 10, 2020 17:40
Example of a usecase of Ruby 2.7 triple dot notation for writing method wrappers
def original_method(a, b)
puts "Called with #{a} and #{b}"
if block_given?
puts "Calling the block"
yield
end
end
def wrapper1(*args) # WRONG: doesn't pass the block
puts "Hi I'm wrapper1"
@janlelis
janlelis / irb.rb
Last active April 8, 2024 09:21
Minimal Ruby REPL
ruby -e'_,__="",binding;loop do$><<">> "if$/>_
puts"=> %p"%[__.eval(_+=gets||exit!),_=""]
rescue Exception
puts"\e[31m%p\e[0m"%[$!,_=""]if/d e|ee/!~"#$!"end'
@thechrisoshow
thechrisoshow / imphash.patch
Created February 20, 2018 22:53
This is a patch to Ruby 2.5.0 to enable es6 like hash literals - instructions in the comments
From a034498e36c02715b9201646d4ce1ddcddf118c3 Mon Sep 17 00:00:00 2001
From: Shugo Maeda <shugo@ruby-lang.org>
Date: Wed, 29 Apr 2015 09:14:15 +0900
Subject: [PATCH] support ES6-like hash literals.
---
parse.y | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 72 insertions(+), 17 deletions(-)
diff --git a/parse.y b/parse.y
@headius
headius / meltdown_in_a_nutshell.md
Last active July 27, 2018 13:43
How Meltdown Works

Algorithm

  1. A secret byte you want to read is stored at inaccessible memory location priv_mem.
  2. The sender triggers an access exception by attempting to read priv_mem.
  3. Due to CPU optimization (out-of-order execution), the load of secret from priv_mem and the use of its value in (4) and (5) below may execute before the exception is triggered.
  4. Calculate an offset into a known array probe by multiplying secret by the width of a cache line (or whatever block size the CPU typically fetches, like a 4096-byte page). This guarantees each of those 256 possible offsets will cache separately.
  5. Load probe[offset], which causes the CPU to cache exactly one chunk of of our array, populating one cache line.
  6. The exception finally triggers, clearing the modified registers...but cached data is not excised.
  7. Iterate over all 256 offsets into probe to find out which one loads fast. You've determined the value of secret.
@collinbarrett
collinbarrett / userChrome.css
Last active April 11, 2024 10:22
A userChrome.css to use with Tree Style Tab (https://github.com/piroor/treestyletab) for Firefox
/*
Windows
Location: C:\Users\<YourUsername>\AppData\Roaming\Mozilla\Firefox\Profiles\<YourFirefoxProfile>\chrome
Notes:
If minimize, maximize, and close buttons are no longer visible, enable the Title Bar or Menu Bar in Firefox Customize.
macOS
Location: /Users/<YourUsername>/Library/Application Support/Firefox/Profiles/<YourFirefoxProfile>/chrome
Notes:
If minimize, maximize, and close buttons overlap other controls, add the Flexible Space in Firefox Customize.
@jorilallo
jorilallo / Flex.js
Created August 17, 2017 20:06
Flexbox component for React
// @flow
import React from 'react';
import styled from 'styled-components';
type GlobalCssValues = 'initial' | 'inherit' | 'unset';
type WrapValue = 'nowrap' | 'wrap' | 'wrap-reverse' | GlobalCssValues;
type JustifyValue =
| 'center'
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@janlelis
janlelis / emoji-variations.md
Last active March 5, 2019 11:01
Emoji Variations and Names

See character.construction/emoji-vs-text for more up-to-date listings.

Emoji Variations and Names (Emoji 11.0 / Unicode 11.0.0)

Text (U+FE0E) Default Emoji (U+FE0F) Name
😀︎ 😀 😀️ GRINNING FACE
😁︎ 😁 😁️ GRINNING FACE WITH SMILING EYES
😂︎ 😂 😂️ FACE WITH TEARS OF JOY
🤣︎ 🤣 🤣️ ROLLING ON THE FLOOR LAUGHING
@janlelis
janlelis / emoji.md
Last active May 25, 2023 17:41
List of 11.0 Emoji (compiled from emoji-test.txt)

Please note: See character.construction/emoji-categories for more up-to-date listings.

Emoji 11.0

Smileys & People

face-positive

😀 😁 😂 🤣 😃 😄 😅 😆 😉 😊 😋 😎 😍 😘 🥰 😗 😙 😚 ☺️ 🙂 🤗 🤩