for
should only be used when you actually want the iteratee to be accessible after you leave the block. for
pollutes the parent scope with old iteratees. For this reason, each
should be your default.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
class NodeColor: | |
""" | |
Assign a random but deterministic color to a string, suitable for coloring a graph. | |
""" | |
def __init__(self, tag): | |
self.hue = self.__get_hue(tag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { URL } from "url" | |
/** Construct a deep link to the CloudWatch Logs console given a Lambda execution context and start time */ | |
const cloudwatchUrl = context => { | |
const path = "cloudwatch/home" | |
const url = new URL(path, "https://console.aws.amazon.com/") | |
let region | |
if (typeof context.invokedFunctionArn === "string") { | |
const [, , , arnRegion, accountId, , functionName] = context.invokedFunctionArn.split(":") | |
region = arnRegion | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub vcl_recv { | |
if (req.url == "/crossdomain.xml") { | |
error 843 "OK"; | |
} | |
} | |
sub vcl_error { | |
if (obj.status == 843) { | |
set obj.status = 200; | |
set obj.http.Content-Type = "application/xml; charset=utf-8"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# url.txt should contain the URL load in Chrome in full screen. | |
do shell script "open '/Applications/Google Chrome.app' " & readFile("/url.txt") | |
tell application "Google Chrome" to activate | |
tell application "System Events" | |
keystroke "f" using {command down, shift down} | |
end tell | |
# All this just to read a file; no backticks in AppleScript. | |
on readFile(unixPath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
description prod | |
maxconn 7777 # About 54k per connection; 400MB free on this machine. | |
stats socket /var/run/haproxy.stat mode 600 level admin | |
user haproxy | |
group haproxy | |
defaults | |
mode http | |
maxconn 7700 # Should be slightly smaller than global.maxconn. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mysql] | |
prompt=\\d mysql>\_ | |
auto-vertical-output=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 ---' |
NewerOlder