Skip to content

Instantly share code, notes, and snippets.

View jeffkreeftmeijer's full-sized avatar
🦞

Jeff Kreeftmeijer jeffkreeftmeijer

🦞
View GitHub Profile
class Foo
def foo
puts "ok!"
end
end
Foo.prepend(Module.new do
def foo
puts "prepend!"
super

Terminal colors with ANSI escape sequences

Terminal emulators use ANSI escape sequences to --amongst other things like controlling the cursor’s position-- read the desired text and background color when printing output.

$ echo -e "\033[31mred\033[m" # Prints "red" in red.

While most terminal emulators, including Apple’s Terminal.app, support true color now, most utilities use one of the main sixteen colors (black, red, green, yellow, blue, magenta, cyan, white, and a high intensity or bright version of each). For example, git shows diffs with additions in green and deletions in red, and most testing frameworks print green dots and red "F"s for failures.

Rails with mssql on macOS

Start mssql in docker

docker pull microsoft/mssql-server-linux:2017-latest
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=B4n44n123' -p 1401:1433 --name sql1 -d microsoft/mssql-server-linux:2017-latest
docker ps -a
<ul>
<li>
<article>
<time datetime="2017-10-17">2017-10-17</time>
<span><a href="/vim-reformat-dates/">Find, convert and replace dates with Vim substitutions</a></span>
</article>
</li>
<li>
<article>
<time datetime="2017-09-19">2017-09-19</time>
@jeffkreeftmeijer
jeffkreeftmeijer / math.ex
Created August 26, 2017 20:58
POC for type spec tests with StreamData.
defmodule Math do
@spec square(integer) :: integer
def square(a) do
a * a
end
end
@jeffkreeftmeijer
jeffkreeftmeijer / roast_potatoes.md
Last active August 21, 2017 17:02
Recipes I kept having to look up.

Roast potatoes

Roast potatoes

Potatoes

  • Salt
  • 1/2 teaspoon baking soda (~4g)
  • Potatoes

Boil for ~10 minutes

Property-based testing in Elixir using PropEr

# Use Ctrl-a instead of Ctrl-b as the tmux prefix
set-option -g prefix C-a
# Set the base index to 1 instead of 0 for both windows and panes.
set-option -g base-index 1
set-option -g pane-base-index 1
# Use vim keybindings in copy mode
setw -g mode-keys vi
@jeffkreeftmeijer
jeffkreeftmeijer / README.md
Last active January 30, 2019 09:45
enough.css is a tiny CSS style sheet with most of the styling you'll need for that blog of yours. It moved to https://github.com/jeffkreeftmeijer/enough.css
require 'socket'
require 'rack'
require 'rack/lobster'
app = Rack::Lobster.new
server = TCPServer.new 5678
while session = server.accept
request = session.gets
puts request