Skip to content

Instantly share code, notes, and snippets.

Avatar

Jacob Elder jelder

View GitHub Profile
View lambda-context-cloudwatch-logs-deep-link.js
@jelder
jelder / get_lambda_request
Created Oct 31, 2018
Find logs for a single Lambda invocation and report timing data
View get_lambda_request
#!/usr/bin/env node
const { truncate, chain } = require("lodash")
const AWS = require("aws-sdk")
AWS.config.update({ correctClockSkew: true })
const logs = new AWS.CloudWatchLogs()
const totalTimes = {}
const getAll = async ({ requestId, logGroupName, logStreamNames, nextToken, lastTimestamp }) => {
const response = await logs.filterLogEvents({ logGroupName, logStreamNames, nextToken }).promise()
@jelder
jelder / .my.cnf
Last active Nov 9, 2018
My ~/.psqlrc
View .my.cnf
[mysql]
prompt=\\d mysql>\_
auto-vertical-output=true
@jelder
jelder / .gitconfig
Created Apr 6, 2017
Jacob Elder's .gitconfig
View .gitconfig
[user]
name = Jacob Elder
email = jacob@blissfully.com
[status]
submodulesummary = false
# https://gist.github.com/jelder/ce4344696139c36786ea08e860b1cf6f
[alias]
out = "log @{u}.."
fetchall = !git pull && git submodule update --init --remote --recursive && git submodule foreach -q --recursive 'echo Updating $name && git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch || echo master) && git -C $toplevel/$name pull && echo ---'
@jelder
jelder / summer_2015.md
Last active Sep 22, 2015
Summer 2015 Reading Recommendations.
View summer_2015.md

The Culture (Series)

https://en.wikipedia.org/wiki/Culture_series

A series of novels exploring the political, economic, social, and military history of a galactic-scale, post-material-scarcity, post-singuarlty, and post-captialism society. Features godlike AIs embodied in hundred-cubic-kilometer starships!

Seven Eves

Seveneves

@jelder
jelder / passenger_throttle.sh
Created Apr 8, 2015
Dynamically configure Passenger based on current Dyno type
View passenger_throttle.sh
#!/bin/bash
# http://stackoverflow.com/questions/24634958/programmatically-detect-heroku-dyno-size-at-run-time/24634959#24634959
function dyno_size() {
case $(ulimit -u) in
256)
echo "1X"
;;
512)
echo "2X"
@jelder
jelder / json.sql
Created Mar 25, 2015
Converting between types of arrays in PostgreSQL
View json.sql
BEGIN;
CREATE TABLE json_test (
id SERIAL PRIMARY KEY,
label text,
examples text[] DEFAULT '{}'::text[]
);
INSERT INTO json_test (label,examples) VALUES ('before','{}');
INSERT INTO json_test (label,examples) VALUES ('before','{"[{\"a\":1}]"}');
@jelder
jelder / email.sql
Created Mar 12, 2015
Filtering emails by domain in PostgreSQL
View email.sql
BEGIN;
CREATE FUNCTION email_domain(email text) RETURNS text
LANGUAGE sql IMMUTABLE
AS $$
SELECT reverse(split_part(lower(email), '@', 2))
$$;
CREATE INDEX idx_users_email_domain ON users (email_domain(email));
EXPLAIN ANALYZE SELECT "users".* FROM "users" WHERE email_domain(email) = 'moc.sseldnuob' ORDER BY "users"."proposed_changes_count" DESC;
ROLLBACK;
@jelder
jelder / deep_store.rb
Last active Aug 29, 2015
Extend Hash to allow insertion by path
View deep_store.rb
require 'ap'
class Hash
def store_by_path(path, value)
case path
when String
if path =~ %r{/}
store_by_path(path.split('/'), value)
else
self[path] = value
end
@jelder
jelder / store_by_path.rb
Last active Aug 29, 2015
Hash insertion by path
View store_by_path.rb
require 'ap'
class Hash
def store_by_path(path, value)
case path
when String
if path =~ %r{/}
store_by_path(path.split('/'), value)
else
self[path] = value