Probably one of the easiest things you'll ever do with gpg
Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH
First get the public key
keybase pgp export | gpg --import
Next get the private key
Probably one of the easiest things you'll ever do with gpg
Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH
First get the public key
keybase pgp export | gpg --import
Next get the private key
Examples of ordered set aggregates in Postgres.
SELECT round(avg(pie)::numeric, 2),
percentile_cont(array[0.25, 0.5, 0.75, 0.95]) WITHIN GROUP (ORDER BY pie) AS percentiles
FROM player_stats_advanced
WHERE permode = 'pergame';
round | percentiles
files: | |
"/etc/rsyslog.d/11-sidekiq.conf": | |
mode: '000644' | |
content: | | |
EB_CONFIG_APP_LOGS=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir) | |
$InputFileName $EB_CONFIG_APP_LOGS/sidekiq.log | |
$InputFileTag sidekiq | |
$InputFileStateFile sidekiq-state | |
$InputFileSeverity info |
# Ensure: | |
# * "cf" security group has all ports open (until ports required are better understood) | |
# * replace 'YOUR-BOSH-UUID' with UUID from "bosh status" | |
# * replace 2.3.4.5 with an elastic IP from target AWS region | |
# * replace 'mycloud.com' with your base domain that maps *.DOMAIN to your IP address | |
# | |
# Also: | |
# * your microbosh has port 53 (UDP or TCP) open for internal DNS | |
# | |
# Optional: |
We've seen lots of Ruby feature requests about converting an Enumerable to a Hash: to_h
, map_hash
, map_to
, each_with_hash
, etc. Let's look at one common, simple case of this.
Building a key/value mapping from a collection of keys is awkward. We commonly see Hash[*collection.map { |element| [element, calculate(element)] }]
or collection.each_with_object({}) { |element, hash| hash[element] = calculate(element) }
. Both are verbose. They require boilerplate code that's not relevant to the programmer's intent: to associate an enumerable of keys with calculated values.
Ruby has the idea of an association already: a key and value paired together. It's used by Array#assoc
to look up a value from a list of pairs and by Hash#assoc
to return a key/value pair. Building up a mapping of key/value pairs is associating keys with values.
So! Consider Enumerable#associate
which builds a mapping by associating keys with values:
# Associate filenames with URLs. Before:
# Migration (created from Devise) | |
class DeviseCreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table(:users) do |t| | |
t.database_authenticatable :null => false | |
t.recoverable | |
t.rememberable | |
t.trackable | |
t.string :name |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
{ | |
"locale": "de", | |
"text": { | |
"#authors": [ | |
{ | |
"name": "Malte Ubl", | |
"screen-name": "cramforce" | |
} | |
], | |
"tweet": { |
#!/usr/bin/env ruby | |
# A quick and dirty implementation of an HTTP proxy server in Ruby | |
# because I did not want to install anything. | |
# | |
# Copyright (C) 2009-2014 Torsten Becker <[email protected]> | |
# | |
# 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, |