Directly from CLI
alias x='exit'
funcsave x
or create a file in
~/.config/fish/functions
with name
defmodule MyApp.User do | |
def changeset(model, params \\ :empty) do | |
model | |
|> cast(params, @required_fields, @optional_fields) | |
|> validate_format(:email, ~r/@/) | |
|> validate_length(:password, min: 8) | |
|> validate_format(:password, ~r/[0-9]+/, message: "Password must contain a number") # has a number | |
|> validate_format(:password, ~r/[A-Z]+/, message: "Password must contain an upper-case letter") # has an upper case letter | |
|> validate_format(:password, ~r/[a-z]+/, message: "Password must contain a lower-case letter") # has a lower case letter | |
|> validate_format(:password, ~r/[#\!\?&@\$%^&*\(\)]+/, message: "Password must contain a symbol") # Has a symbol |
# This demonstrates that, when using async/await, a crash in the task will crash the caller | |
defmodule Tasker do | |
def good(message) do | |
IO.puts message | |
end | |
def bad(message) do | |
IO.puts message | |
raise "I'm BAD!" | |
end |
# Config for Nginx to act as a front-end for Riak | |
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc) | |
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_) | |
# Config is in /etc/nginx/sites-available/default or somewhere like that | |
# Set up load-balancing to send requests to all nodes in the Riak cluster | |
# Replace these IPs/ports with the locations of your Riak nodes | |
upstream riak_hosts { | |
server 127.0.0.1:8098; |
Directly from CLI
alias x='exit'
funcsave x
or create a file in
~/.config/fish/functions
with name
[default] | |
DB_NAME=mydb | |
DB_PASSWORD=mypass | |
DB_USERNAME=myuser |
defimpl Kipatest.Can, for: Kipatest.User do | |
use Kipatest.Web, :model | |
def can?(%User{} = subject, :owner, %User{} = user) do | |
user.id == subject.id | |
end | |
end |
# prompt color and format variables | |
# A color init string consists of one or more of the following numeric codes: | |
# * Attribute codes: | |
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed | |
# * Text color codes: | |
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white | |
# * Background color codes: | |
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white | |
# * Extended color codes for terminals that support more than 16 colors: |
defmodule Map.Helpers do | |
@moduledoc """ | |
Functions to transform maps | |
""" | |
@doc """ | |
Convert map string camelCase keys to underscore_keys | |
""" | |
def underscore_keys(nil), do: nil |
#!/bin/bash | |
# Maintainer Joel Jacobson | |
VERSION="5.0.0" | |
# to start the services you must be root | |
if [ "$EUID" -ne 0 ]; then | |
echo "Please run as root" | |
exit 1 | |
fi |
import { Link } from 'react-router-dom' | |
import { Badge, Col, Menu } from 'antd' | |
const StyledBadge = styled(Badge)` | |
.ant-badge-count { | |
background-color: #7ECBBF; | |
color: white; | |
box-shadow: 0 0 0 1px #d9d9d9 inset; | |
} | |
` |