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
{"AWSTemplateFormatVersion":"2010-09-09","Description":"EKS cluster (dedicated VPC: true, dedicated IAM: true) [created and managed by eksctl]","Resources":{"ControlPlane":{"Type":"AWS::EKS::Cluster","Properties":{"Name":"dev3","ResourcesVpcConfig":{"SecurityGroupIds":[{"Ref":"ControlPlaneSecurityGroup"}],"SubnetIds":[{"Ref":"SubnetPublicUSWEST2C"},{"Ref":"SubnetPublicUSWEST2A"},{"Ref":"SubnetPublicUSWEST2B"},{"Ref":"SubnetPrivateUSWEST2C"},{"Ref":"SubnetPrivateUSWEST2A"},{"Ref":"SubnetPrivateUSWEST2B"}]},"RoleArn":{"Fn::GetAtt":"ServiceRole.Arn"},"Version":"1.11"}},"ControlPlaneSecurityGroup":{"Type":"AWS::EC2::SecurityGroup","Properties":{"GroupDescription":"Communication between the control plane and worker node groups","Tags":[{"Key":"Name","Value":{"Fn::Sub":"${AWS::StackName}/ControlPlaneSecurityGroup"}}],"VpcId":{"Ref":"VPC"}}},"InternetGateway":{"Type":"AWS::EC2::InternetGateway","Properties":{"Tags":[{"Key":"Name","Value":{"Fn::Sub":"${AWS::StackName}/InternetGateway"}}]}},"NATGateway":{"Type":"AWS:: |
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
$ eksctl create cluster -v 4 --name=dev3 --nodes-min=2 --nodes-max=10 | |
2018-12-21T16:54:51Z [ℹ] using region us-west-2 | |
2018-12-21T16:54:52Z [▶] role ARN for the current session is "arn:aws:iam::797098425712:user/vojtech" | |
2018-12-21T16:54:52Z [▶] determining availability zones | |
2018-12-21T16:54:52Z [ℹ] setting availability zones to [us-west-2c us-west-2a us-west-2b] | |
2018-12-21T16:54:52Z [▶] VPC CIDR (192.168.0.0/16) was divided into 8 subnets [192.168.0.0/19 192.168.32.0/19 192.168.64.0/19 192.168.96.0/19 192.168.128.0/19 192.168.160.0/19 192.168.192.0/19 192.168.224.0/19] | |
2018-12-21T16:54:52Z [ℹ] subnets for us-west-2c - public:192.168.0.0/19 private:192.168.96.0/19 | |
2018-12-21T16:54:52Z [ℹ] subnets for us-west-2a - public:192.168.32.0/19 private:192.168.128.0/19 | |
2018-12-21T16:54:52Z [ℹ] subnets for us-west-2b - public:192.168.64.0/19 private:192.168.160.0/19 | |
2018-12-21T16:54:52Z [▶] resolving AMI using StaticGPUResolver for region us-west-2, instanceType m5.large and imageFamily AmazonLinux2 |
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
git config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*' | |
git fetch | |
git checkout -t origin/pr/12 | |
# Based on https://gist.github.com/piscisaureus/3342247 |
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
package main | |
import "fmt" | |
func main() { | |
slice := make([]int, 159) | |
// Split the slice into batches of 20 items. | |
batch := 20 |
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
package zlib | |
import ( | |
"bytes" | |
"io" | |
"testing" | |
) | |
type zlibTest struct { | |
desc string |
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
export new_user="your_user" | |
export dbname="your_db_name" | |
cat <<EOF | docker run -i --rm --link postgres:postgres postgres sh -c "psql -h \$POSTGRES_PORT_5432_TCP_ADDR -p \$POSTGRES_PORT_5432_TCP_PORT -U postgres -d $dbname" | grep ALTER | docker run -i --rm --link postgres:postgres postgres sh -c "psql -h \$POSTGRES_PORT_5432_TCP_ADDR -p \$POSTGRES_PORT_5432_TCP_PORT -U postgres -d $dbname" | |
SELECT 'ALTER TABLE '||schemaname||'.'||tablename||' OWNER TO $new_user;' | |
FROM pg_tables WHERE schemaname = 'public'; | |
SELECT 'ALTER SEQUENCE '||relname||' OWNER TO $new_user;' FROM pg_class WHERE relkind = 'S'; | |
EOF |
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
package main | |
import ( | |
"log" | |
"net/http" | |
"github.com/pressly/chi" | |
) | |
func main() { |
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
sourceURL := "http://example.com" | |
// Resolve URL up to 12 redirects. | |
client := &http.Client{ | |
CheckRedirect: func() func(req *http.Request, via []*http.Request) error { | |
redirects := 0 | |
return func(req *http.Request, via []*http.Request) error { | |
if redirects > 12 { | |
return errors.New("stopped after 12 redirects") | |
} |
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
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type Map map[string]string | |
type Object struct { |
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
# Run job in background, redirect its output to a non-blocking pipe, | |
# and leave the rc and stdout/stderr to be handled by attach_wait_jobs() | |
jobs_tmp_dirs="" | |
function run_job() { | |
local dir=$(mktemp -d -t gearXXXXXX) | |
jobs_tmp_dirs="$jobs_tmp_dirs $dir" | |
mkfifo $dir/pipe | |
mkfifo $dir/pipe_nonblock | |
"$@" &>$dir/pipe_nonblock & | |
echo $! >$dir/pid |