Class names are CamelCase
.
Methods and variables are snake_case
.
Methods with a ?
suffix will return a boolean.
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 sh | |
# checks to see if running | |
launchctl list | grep elasticsearch | |
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist | |
launchctl remove homebrew.mxcl.elasticsearch | |
pkill -f elasticsearch |
# This solution attempts to handle flattening of nested arrays gracefully | |
class CustomArray | |
def flatten(array) | |
raise 'input is not an array' unless array?(array) | |
return [] if array.empty? | |
recursive_flatten(array) | |
end | |
private |
Over the weekend I spun up a new Elixir :ecto, "2.2.7" project that I was able to get working with CockroachDB and this adapter fork - with some caveats I wanted to share to help others.
Only the root
user can create databases
This requires you configure the Ecto.Adapters.Postgres
username
as root
or else the mix ecto.create
command will always fail. You can go back and change your configured username
to something else after the database has been created, or create your database and user permissions using cockroach sql
and skip the mix ecto.create
command.
Configuring Ecto primary_key ID to be created by CockroachDB
By default when configuring your Ecto.Schema
using autogenerate: false
it appears either CockroachDB, Ecto or the Postrex adapter (I did not investigate this) uses the BIGINT
unique_rowid()
function as the default value for IDs
@primary_key {:id, :id, autogenerate:
Note: "Forked" from Latency Numbers Every Programmer Should Know
Event | Nanoseconds | Microseconds | Milliseconds | Comparison |
---|---|---|---|---|
L1 cache reference | 0.5 | - | - | - |
Branch mispredict | 5.0 | - | - | - |
L2 cache reference | 7.0 | - | - | 14x L1 cache |
Mutex lock/unlock | 25.0 | - | - | - |
// bower dependency: "ng-file-upload" | |
// npm dependency: "loopback-component-storage" | |
'use strict'; | |
angular | |
.module('app', [ | |
'ngFileUpload' | |
]) | |
.controller('UploadController', function(Upload) { |
[1,2,3].map{|x| x.to_s} | |
[1,2,3].map(&:to_s) | |
Proc.new{|x| x.to_s} | |
def sym_to_proc(sym) | |
Proc.new{ |x| x.send(sym) } | |
end | |
sym_to_proc(:to_s).call(3) | |
:to_s.to_proc.call(3) | |
[1,2,3].map &->(n) { n.to_s } |
// This function takes a contents object with a files array. | |
// The goal is to cache each file details in redis then replace | |
// the file's path with a secure, obscured url. | |
// Finally the contents object is returned with the updated array | |
// in place of the old one. | |
// async = require('async') | |
// uuid = require('node-uuid') | |
// redis.client = require('node-redis').createClient() |