- Install
libgmp-dev libgmp3c2
or equivalent using the system package manager. - Add
export PATH="$HOME/.ghc/bin:$HOME/.cabal/bin:$PATH"
to your.<shell>rc
. - Also run the command above now.
- Get the [GHC binary tarball][ghc] and extract it.
./configure --prefix="$HOME/.ghc" && make install
- Get the [cabal-install source tarball][cabal] and extract it.
EXTRA_CONFIGURE_OPTS=-p sh bootstrap.sh
cabal update
; FIXME: The grammar has been transformed so that `w` appears after a | |
; token, but there is no way in ABNF to define it as token-separator | |
; that can optionally contain a mix of comments and white-space. Take | |
; `;;` as an example, for that to match `sql-stmt-list` `w` would | |
; have to match the empty string. But if `w` matches the empty string | |
; then `ISNOT` is the same as `IS NOT`. | |
sql-stmt-list = [ sql-stmt ] *( ";" w [ sql-stmt ] ) | |
sql-stmt = [ "EXPLAIN" w [ "QUERY" w "PLAN" w ] ] ( alter-table-stmt / analyze-stmt / attach-stmt / begin-stmt / commit-stmt / create-index-stmt / create-table-stmt / create-trigger-stmt / create-view-stmt / create-virtual-table-stmt / delete-stmt / delete-stmt-limited / detach-stmt / drop-index-stmt / drop-table-stmt / drop-trigger-stmt / drop-view-stmt / insert-stmt / pragma-stmt / reindex-stmt / release-stmt / rollback-stmt / savepoint-stmt / select-stmt / update-stmt / update-stmt-limited / vacuum-stmt ) | |
alter-table-stmt = "ALTER" w "TABLE" w [ schema-name w "." w ] table-na |
#!/bin/bash | |
ip=`echo $SSH_CONNECTION | cut -d " " -f 1` | |
hostname=`hostname` | |
fqdn=`hostname -f` | |
logger -t ssh-wrapper $USER login from $ip | |
sendmail -t <<EOF | |
To: Alex <adzhurinskij@gmail.com> |
#!/usr/bin/ruby | |
# chkconfig: 35 99 01 | |
# description: EC2 DNS registration | |
# processname: ec2hostname | |
require 'aws-sdk' | |
require 'net/http' | |
`touch /var/lock/subsys/ec2hostname` |
#!/usr/bin/ruby | |
# chkconfig: 35 99 01 | |
# description: EC2 DNS loadbalancing | |
# processname: ec2hostname | |
require 'aws-sdk' | |
require 'net/http' | |
`touch /var/lock/subsys/ec2hostname` |
When you have a set of application servers running in EC2 in an active/passive configuration, the easiest way to failover is to simply update the DNS to point to the second server as soon as it's available to serve requests. If you are using Route 53 to manage your DNS configuration, with the AWS CLI you can make this change in a single command.
- Install the AWS CLI
- Login with an account that has an IAM Policy that gives it access to the Route53 Service
- Get the HostedZoneID for the domain you want to update from the AWS console here: https://console.aws.amazon.com/route53/home#hosted-zones:
The CLI expects the change to be submitted via a JSON-formatted configuration file. I've inclu
CONSOLE=php app/console | |
COMPOSER=php -d "apc.enable_cli=0" ../composer.phar | |
PHPUNIT=php bin/phpunit | |
init: git-clone install | |
install: git-subup composer-install cache-clear assets db cache-clear | |
update: git-update git-subup composer-install db-update cache-clear composer-optimize test-unit |
defmodule YourApp.Validators.Email do | |
use Ecto.Changeset | |
@mail_regex ~r/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/ | |
# ensure that the email looks valid | |
def validate_email(changeset, field) do | |
changeset | |
|> validate_format(field, @mail_regex) | |
end | |
end |
defmodule App.RegistrationController do | |
use App.Web, :controller | |
alias App.{Registration, Repo} | |
def new(conn, _params) do | |
changeset = Registration.changeset(%Registration{}) | |
render conn, :new, changeset: changeset | |
end | |
def create(conn, %{"registration" => registration_params}) do |
I recently wanted to rename a model and its postgres table in a Phoenix app. Renaming the table was simple and documented, but the table also had constraints, sequences, and indexes that needed to be updated in order for the Ecto model to be able to rely on default naming conventions. I couldn't find any examples of what this would look like but was eventually able to figure it out. For anyone else in the same situation, hopefully this example helps.
In the example below, I'm renaming the Permission
model to Membership
. This model belongs to a User
and an Account
, so it has foreign key constraints that need to be renamed.
defmodule MyApp.Repo.Migrations.RenamePermissionsToMemberships do
use Ecto.Migration