Example inputs:
| Variable | Value |
|---|---|
| key | the shared secret key here |
| message | the message to hash here |
Reference outputs for example inputs above:
| Type | Hash |
| defmodule Util do | |
| defmacro __using__(_) do | |
| quote do | |
| require Util | |
| # Should it be imported? | |
| # import Util | |
| end | |
| end | |
| defmacro blank?(x) when is_binary(x) do |
Example inputs:
| Variable | Value |
|---|---|
| key | the shared secret key here |
| message | the message to hash here |
Reference outputs for example inputs above:
| Type | Hash |
| #!/usr/bin/env ruby | |
| # Evaluates a sample of keys/values from each redis database, computing statistics for each key pattern: | |
| # keys: number of keys matching the given pattern | |
| # size: approximation of the associated memory occupied (based on size/length of value) | |
| # percent: the proportion of this 'size' relative to the sample's total | |
| # | |
| # Copyright Weplay, Inc. 2010. Available for use under the MIT license. | |
| # Redis Cheatsheet | |
| # All the commands you need to know | |
| redis-server /path/redis.conf # start redis with the related configuration file | |
| redis-cli # opens a redis prompt | |
| # Strings. |
http://stackoverflow.com/a/808776/1180523
# model
validates :email, :uniqueness => { message: "is wrong" }
validates :name, :uniqueness => { message: "Your name is wrong" }
HUMANIZED_ATTRIBUTES = {
:email => "E-mail address",
:name => "" # don't include column name in error| Rails.redis.get(key) | |
| Rails.redis.set(key, value) | |
| Rails.redis.expire(key, 1.hour) | |
| Rails.redis.del(key) | |
| Rails.redis.sadd(set_name, value) | |
| Rails.redis.srem(set_name, key) | |
| Rails.redis.sismember(set_name, value) # boolean test to see if val exists |
| 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 |
##Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:alexpchin/.git
| # Using the `--exlude-table-data` argument for the `heroku pg:pull` command doesn't seem to be working. | |
| # Instead we're going to copy the Heroku PG database by using the Postgres `pg_dump` and `pg_restore` commands. | |
| # Get the "Connection info string" for myapp | |
| heroku pg:credentials:url DATABASE_URL -a myapp | |
| # Download the database, excluding the `visits` and `ahoy_events` table data. | |
| pg_dump "<PASTE_CONNECTION_INFO_STRING_HERE>" --exclude-table-data visits --exclude-table-data ahoy_events -O -x -Fc -f without_vists_and_ahoy_events.out -v | |
| # In myapp, setup an empty database |