I think you mean team...
I think you mean squad..
I think you mean gang...
I think you mean pals...
defmodule RequiredFields do | |
defmacro __using__(_opts) do | |
quote do | |
def new(attributes) do | |
Map.merge(%__MODULE__{}, attributes) | |
|> validate | |
end | |
def validate(struct) do | |
missing = missing_attributes(struct) |
defmodule JsonApi do | |
def filter_struct(obj) do | |
is_struct?(obj) or (is_list(obj) && is_struct?(Enum.at(obj,0))) | |
end | |
def is_struct?(obj) do | |
is_map(obj) && Map.get(obj, :__struct__) != nil | |
# ( obj.__struct__ == Ecto.Association.NotLoaded || | |
end | |
def json_api(obj) do |
I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.
Framework | Throughput (req/s) | Latency (ms) | Consistency (σ ms) |
---|
Binary matching is a powerful feature in Elixir that is useful for extracting information from binaries as well as pattern matching. This article serves as a short overview of the available options when pattern matching and demonstrates a few common usecases.
Binary matching can be used by itself to extract information from binaries:
defmodule Metasploit.Pro.Plugs.Authenticate do | |
import Ecto.Query, only: [from: 2] | |
import Plug.Conn | |
def init(configuration) do | |
configuration | |
|> Keyword.put_new(:single_access_token_parm, "single_access_token") | |
|> valid_configuration! | |
end |
# An example of a very simple, rack-compliant web server. | |
# This software is made available under the MIT License. | |
# | |
# Copyright (C) 2025 Brandon Rice | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is |
defmodule MyBlog.Repo.Migrations.CreatePost do | |
use Ecto.Migration | |
def change do | |
create table(:posts, primary_key: false) do | |
add :id, :uuid, primary_key: true | |
add :body, :string | |
add :word_count, :integer | |
timestamps |
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
# This is how I upload my new Sol Trader builds (http://soltrader.net) | |
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
S3KEY="my aws key" | |
S3SECRET="my aws secret" # pass these in | |
function putS3 | |
{ | |
path=$1 |
This project has moved to https://github.com/jonhoo/drwmutex so it can be imported into Go applications.