Skip to content

Instantly share code, notes, and snippets.

I'm admittedly very biased when it comes to this question, because I really love development in Linux and do think it is better, but in the case of Ruby, I also think it makes everything easier. That said, I feel like I owe you more of an explanation than simply "I also think it makes everything easier", so you'll find that explanation below... with my opinions inevitably mixed in. :)

First off, yes, Ruby does run on Windows! I've only ever run Ruby on Windows once (testing a script I wrote for a friend, using my mom's desktop), but I think I used RubyInstaller to get it installed.

I do have a few concerns about Ruby in Windows though:

  1. Ruby is designed and built for the most part by people on *nix (Unix and Linux) systems, and then adapted for use in Windows; the vast majority of people in the community are on *nix systems; and Ruby applications running in production are almost always running on Linux. Because of this, I've always felt that support for Ruby in Linux has
defmodule T2t.API.V1.Auth.TokenController do
use T2t.Web, :controller
alias T2t.User
def create(conn, %{"user" => %{"email" => email, "password" => password}}) do
user = User.from_email(email)
if user && Comeonin.Bcrypt.checkpw(password, user.encrypted_password) do
token = SecureRandom.base64(32)
encrypted_token = Comeonin.Bcrypt.hashpwsalt(token)
@bchase
bchase / new_phoenix_dot_iex.exs
Last active October 26, 2016 19:08
Officially tired of aliasing `Repo` and importing `Ecto.Query` by hand every IEx session
#!/usr/bin/env elixir
ecto_import = "import Ecto.Query, only: [from: 2]"
mixexs =
Path.join(["mix.exs"])
|> File.read!
namespace =
Regex.run(~r{defmodule\s+(\w+)\.}, mixexs)

Easy Minecraft Server on AWS EC2

Note: "easy", assuming you're familiar with Linux, have an AWS account, and already have a .pem registered there.

I hunted this information down from a handful of places, so nothing particularly new here, but hopefully this tl;dr saves someone else some time.

AWS

require 'active_support/all'
class Message < String
def initialize
super sprintf template, *types
end
def template
[0x48, 0x61, 0x70, 0x70, 0x79, 0x20, 0x25, 0x73, 0x2c, 0x20, 0x25, 0x73, 0x2c, 0x20, 0x25, 0x73, 0x20, 0x42, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x79, 0x21]
.map(&:chr)
| |
exit undo | | kill (cut/delete)
C-d C-/ | backwards search | > char > word > line
| C-r | C-d M-d C-k
ENTER run | ↑ | < char < word | yank/paste
C-m C-j | C-p | C-h C-w | C-y
| prev line | | M-y(cycle)
-------------------- ↑ ----------------------------
C-c
BOL ← word ← char ← clear → char → word → EOL
+----------+
| Movement |
+----------+ up | j
down | k
-------------------|--------
page up | u
page down | d
-------------------|--------
top of manpage | gg
bottom of manpage | G
require 'json'
text = File.read 'freq-words.json'
json = JSON.parse text
item = json[2]
fail item.to_s unless \
item['rank'] == 3 &&
item['word'] == '一' &&
CODE / NOTES
https://gist.github.com/bchase/f52f5ff2eb52b81295d5
REFERENCES
details on print formatting:
http://apidock.com/ruby/Kernel/sprintf
(recommend scrolling to the examples)