Skip to content

Instantly share code, notes, and snippets.

View skwp's full-sized avatar

Yan Pritzker skwp

View GitHub Profile
aws dynamodb query \
--table-name app-config \
--key-condition-expression \
"app_name = :app_name" \
--expression-attribute-values \
"{\":app_name\": {\"S\": \"my_app\"}}" \
--limit 1 --no-scan-index-forward \
| jq -r ".Items[0].my_key.S"
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
aws dynamodb put-item \
--table-name app-config \
--item "{\"app_name\": {\"S\": \"myapp\"}, \"my_key\": {\"S\": \"my_val\"}, \"updated_at\": {\"S\": \"$timestamp\"}}"
@skwp
skwp / dynamo_create.sh
Last active October 15, 2016 01:53
Create dynamo table for timestamp based config storage
aws dynamodb create-table \
--table-name app-config \
--attribute-definitions \
AttributeName=app_name,AttributeType=S \
AttributeName=updated_at,AttributeType=S \
--key-schema \
AttributeName=app_name,KeyType=HASH \
AttributeName=updated_at,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
This file has been truncated, but you can view the full file.
2016-08-10T17:29:09Z web:20160726130742/060a78c35106 fatal error: concurrent map read and map write
2016-08-10T17:29:09Z web:20160726130742/060a78c35106
2016-08-10T17:29:09Z web:20160726130742/060a78c35106 goroutine 35665 [running]:
2016-08-10T17:29:09Z web:20160726130742/060a78c35106 runtime.throw(0x1131ea0, 0x21)
2016-08-10T17:29:09Z web:20160726130742/060a78c35106 /usr/local/go/src/runtime/panic.go:547 +0x90 fp=0xc82204bc68 sp=0xc82204bc50
2016-08-10T17:29:09Z web:20160726130742/060a78c35106 runtime.mapaccess1_faststr(0xc0ac40, 0xc821031800, 0xc822042700, 0x20, 0xc8201564b0)
2016-08-10T17:29:09Z web:20160726130742/060a78c35106
2016-08-10T17:29:09Z web:20160726130742/060a78c35106 github.com/convox/rack/api/cache.Get(0x10e71e0, 0x11, 0xc0ebc0, 0xc820435860, 0x0, 0x0)
2016-08-10T17:29:09Z web:20160726130742/060a78c35106 /go/src/github.com/convox/rack/api/cache/cache.go:43 +0x5bf fp=0xc82204be10 sp=0xc82204bcc8
2016-08-10T17:29:09Z web:20160726130742/060a78c35106 github.com/convox/rack/api/provider/aws.(*AWS
#!/bin/sh
set -e
if ! grep fluentd /etc/ecs/ecs.config &> /dev/null
then
echo 'ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","syslog","fluentd"]' >> /etc/ecs/ecs.config
fi
@skwp
skwp / loaded_features
Last active June 22, 2016 19:17
ruby 2.3.1p112 segfaults
* Loaded features:
0 enumerator.so
1 thread.rb
2 rational.so
3 complex.so
4 /usr/local/lib/ruby/2.3.0/x86_64-linux/enc/encdb.so
5 /usr/local/lib/ruby/2.3.0/x86_64-linux/enc/trans/transdb.so
6 /usr/local/lib/ruby/2.3.0/unicode_normalize.rb
/* font size (cards etc) */
html, body, input, select, textarea {font-size: 13px !important;} /* instead of 14px */
/**************** HEADER *****************/
/* header bar */
#header {background: #2B2B2B !important;}
/* header buttons */
.header-btn.header-notifications, .header-btn.header-boards,
en:
activerecord:
attributes:
mything:
sku: SKU
errors:
models:
mything:
attributes:
sku:
class MyThing < ActiveRecord::Base
private
def create_or_update
super
rescue ActiveRecord::RecordNotUnique => e
case e.message
when /index_mytable_on_sku_unique/
errors.add(:sku, :taken)
else
# This should not happen; we want to know if we forgot to handle some unique constraint
class AddUniqueConstraintToSkus < ActiveRecord::Migration
disable_ddl_transaction!
def up
# code to de-dupe the table, if needed in real time. If these are rare and it takes a long time to fix, you can run it as a separate job prior to this migration
connection.execute("CREATE UNIQUE INDEX CONCURRENTLY index_mytable_on_sku_unique ON mytable(lower(sku),user_id) where deleted_at is null;")
end
def down
connection.execute("DROP INDEX CONCURRENTLY IF EXISTS index_mytable_on_sku_unique;")