- Easier to combine / split apart components and re-deploy (ie. change your design)
- Easier to manage dependencies (ie. gem versions + bundler)
- No need to coordinate deploys since bundler pulls it all together for you
- No need to serialize / deserialize data (ie. JSON, protobuf, etc)
- No need to do service discovery / load balancing between pieces
- Less need for integration tests (ie a staging environment)
- Sometimes you can get caught wanting to upgrade a gem or ruby version, but something else in your big Rails app needs to the lower version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var routes = []; | |
function on(route, fn) { | |
var keys = ['match']; | |
route = route.replace(/[\/\=\?\$\^]/g, '\\$&').replace(/\{(\w+)\}/g, function(match, key) { | |
keys.push(key); | |
return '(\\w+)'; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.UserController do | |
use Phoenix.Controller | |
def show(conn, %{"id" => id}) do | |
render conn, "show", user: Repo.get!(user, id) | |
end | |
def index(conn, _) do | |
render conn, "index", users: Repo.all(User) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Rocket.DateTime do | |
def type, do: :datetime | |
# Provide our own casting rules. | |
def cast(string) when is_binary(string) do | |
# Try to parse different formats here | |
end | |
# Datetime itself should also be valid | |
def cast(%Ecto.DateTime{} = datetime) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context": | |
[ | |
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)'\"\\]]", "match_all": true }, | |
{ "key": "auto_complete_visible", "operator": "equal", "operand": false } | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if get_req_header(conn, "https") == "on" or | |
get_req_header(conn, "x-forwarded-ssl") == "on" or | |
get_req_header(conn, "x-forwarded-scheme") == "https" or | |
(get_req_header(conn, "x-forwarded-proto") |> to_string |> String.split(",") |> Enum.at(0)) == "https" or | |
conn.scheme == :https do | |
"Secure Request" | |
else | |
"Request" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.CommentView do | |
use MyApp.Web, :view | |
@attributes ~W(id name inserted_at) | |
def render("index.json", %{data: comments}) do | |
for comment <- comments, do: render("show.json", %{data: comment}) | |
end | |
def render("show.json", %{data: comment}) do | |
comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Themost.RateWorker do | |
use GenServer | |
def start_link do | |
:gen_server.start_link({ :local, :NAME }, __MODULE__, ARG, []) | |
end | |
def init do | |
IO.puts "Init" | |
:timer.send_interval(:crowl, 15000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express.createServer(); | |
app.configure(function () { | |
app.use(app.router); | |
}); | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'html'); | |
app.register('.html', require('eco')); |
OlderNewer