Skip to content

Instantly share code, notes, and snippets.

View matschaffer's full-sized avatar
🧡

Mat Schaffer matschaffer

🧡
View GitHub Profile
require 'gsl'
require 'time'
module Diskalerter
class ThresholdEstimator
attr_reader :timestamps, :signal, :threshold, :now
# timestamps - a list of timestamps in epoch milliseconds
# signal - a list of values for the provided timestamps
# threshold - the "exhaustion" threshold (e.g., 100 for a percentage signal)
[StatsdInput]
address = "localhost:8125"
[StatAccumInput]
type = "StatAccumInput"
ticker_interval = 1
emit_in_fields = true
percent_threshold = 95
[statmetric_atlas_encoder]
~/safecast/safecastapi staging-postgis-setup* 43s
❯ dropdb safecast_test
~/safecast/safecastapi staging-postgis-setup*
❯ rake db:test:prepare
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
rake aborted!
ActiveRecord::StatementInvalid: PG::Error: ERROR: PostGIS is already installed in schema 'postgis', uninstall it first
: CREATE EXTENSION IF NOT EXISTS postgis
/Users/mat/.rvm/gems/ruby-1.9.3-p551/gems/activerecord-3.2.21/lib/active_record/connection_adapters/postgresql_adapter.rb:1163:in `exec'
safecast_development=# create extension if not exists postgis;
ERROR: PostGIS is already installed in schema 'postgis', uninstall it first
safecast_development=# drop extension postgis;
ERROR: extension "postgis" does not exist
on slashCommand(cmd)
tell application "System Events"
delay 0.1
key code 44
delay 0.1
keystroke cmd
delay 0.1
keystroke return
end tell
return 0
@matschaffer
matschaffer / running_instances.sh
Created July 24, 2015 06:48
List running instances with name, cost-center, etc.
#!/bin/sh
aws ec2 describe-instances |\
jq -r '.Reservations[].Instances[] |
select(.State.Code == 16) |
[
( .Tags[] | select(.Key == "Name") | .Value ),
( .Tags[] | select(.Key == "cost-center") | .Value),
.InstanceId,
.InstanceType
~
❯ curl -v https://api.stellar.org
* Rebuilt URL to: https://api.stellar.org/
* Hostname was NOT found in DNS cache
* Trying 108.162.204.108...
* Connected to api.stellar.org (108.162.204.108) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
* Server certificate: *.stellar.org
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
#!/usr/bin/env bash
echo a
echo b
echo ----
echo c
echo d
echo ----
echo
# -*- mode: toml -*-
# vi: set ft=toml :
[hekad]
base_dir = "/tmp"
[on_space]
type = "TokenSplitter"
delimiter = " "
@matschaffer
matschaffer / gist:4912279e49dce41ab9b2
Last active July 6, 2021 13:05
Bash-friendly ec2 prices
#!/usr/bin/env bash
URL="http://a0.awsstatic.com/pricing/1/ec2/ri-v2/linux-unix-shared.min.js"
(echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s "$URL") |\
node |\
jq -r '.config.regions[] |
select(.region == "us-east-1") |
.instanceTypes[] |
[