Skip to content

Instantly share code, notes, and snippets.

View regiswilson's full-sized avatar

Regis Wilson regiswilson

  • TrueCar.com
  • Santa Monica, CA USA
View GitHub Profile
@regiswilson
regiswilson / www.conf
Created May 11, 2020 18:41
PHP FPM configuration file for metrics and log collection for the Datadog agent
pm.status_path = /status
ping.path = /ping
ping.response = pong
access.log = /proc/self/fd/2
access.format = '{"date":"%{%FT%T.%LZ}t", "php-fpm": {"cpu":"%C","duration_ms":"%{mili}d","filname":"%f","method":"%m","memory_b":"%M","pool":"%n","query_string":"%q","uri":"%r","remote_ip":"%R","status":"%s","end_time":"%{%FT%T.%LZ}T"}}'
@regiswilson
regiswilson / gist:19061433a556828fd10b8244e21450b0
Created May 11, 2020 18:36
Apache JSON logging for the Datadog ECS agent
ErrorLog /proc/self/fd/2
ErrorLogFormat "{ \"time\":\"%{cu}tZ\", \"function\" : \"[%-m:%l]\" , \"process\" : \"[pid %P:tid %T]\" , \"message\" : \"%M\"}"
LogFormat "{\"date\":\"%{%Y-%m-%d}tT%{%T}t.%{msec_frac}tZ\", \"http\": {\"duration_ms\":%{ms}T, \"bytes\": %{}B, \"filename\":\"%f\", \"remoteIP\":\"%a\", \"url_details\": {\"host\":\"%V\", \"path\":\"%U\", \"query\":\"%q\"}, \"method\":\"%m\", \"status_code\":%>s, \"userAgent\":\"%{User-agent}i\", \"referer\":\"%{Referer}i\"}}" jsoncombined
CustomLog /proc/self/fd/1 jsoncombined
@regiswilson
regiswilson / auto_conf.yaml
Last active May 11, 2020 18:13
Datadog PHP FPM autoconfiguration file
# Place this file inside /etc/datadog-agent/conf.d/php_fpm.d/auto_conf.yaml
# Then follow documentation on how to start or restart the datadog agent
# You must restart the agent to pick up changes to these files
init_config:
ad_identifiers:
- php_fpm
instances:
- status_url: http://%%host%%:%%port%%/status
@regiswilson
regiswilson / fixmimetypes.js
Last active November 15, 2021 15:20
NodeJS Lambda@Edge Origin Response S3 Header Fixes
var mime = require('mime-types');
const MIN_CACHE_TTL = 24 * 60 * 60;
const DEFAULT_CONTENT_TYPE = 'application/octet-stream';
const blacklistContentTypes = [DEFAULT_CONTENT_TYPE];
if ('server' in headers && headers.server[0].value === 'AmazonS3') {
let fixContentType = false;
// Special s3 origin header fixes
if ('content-type' in headers) {
if (blacklistContentTypes.includes(headers['content-type'][0].value.toLowerCase())) {
USE core;
CREATE TABLE events (
Owner_id int not null
Recipient_id int
Owner_type type
Recipient_type type
Event_key json
Created_at date not null
) PARTITION BY RANGE (created_at);
SELECT "core"."events".*
FROM "core"."events"
WHERE ("core"."events"."owner_id" = 1234 AND
"core"."events"."owner_type" = 'Core::Consumer' OR
"core"."events"."recipient_id" = 1234 AND
"core"."events"."recipient_type" = 'Core::Consumer') AND
("core"."events"."event_key") IN
('consumer.showroom.event1',
'consumer.showroom.event2',
'consumer.marketplace.event3')
USE core;
CREATE TABLE events (
Owner_id int not null
Recipient_id int
Owner_type type
Recipient_type type
Event_key json
Created_at date not null
) PARTITION BY RANGE (created_at);
from apig_wsgi import make_lambda_handler
import bottle
from bottle import request
import os
app = bottle.default_app()
alb_lambda_handler = make_lambda_handler(app)
@app.get('/internal/<check>')
def health_check(check='health'):
from apig_wsgi import make_lambda_handler
import bottle
app = bottle.default_app()
# bottle.debug = True
alb_lambda_handler = make_lambda_handler(app)
@app.get('/browse/hello')
def hello():
@regiswilson
regiswilson / clientinit.rb
Last active May 20, 2019 23:32
LaunchDarkly Relay Proxy
require 'ldclient-rb'
if Settings.LAUNCH_DARKLY_LOG_LEVEL
ld_logger = ::Logger.new($stdout)
ld_logger.level = ::Logger.const_get(Settings.LAUNCH_DARKLY_LOG_LEVEL.upcase)
Ethon.logger = ld_logger
else
ld_logger = Rails.logger
end
feature_store = if ENV['REDIS_URL'].to_s.downcase.start_with?('redis://') && ENV['LAUNCH_DARKLY_USE_LDD'].to_s.downcase == 'true'