Skip to content

Instantly share code, notes, and snippets.

View stephencweiss's full-sized avatar
🎉

Stephen Weiss stephencweiss

🎉
View GitHub Profile
@stephencweiss
stephencweiss / sudo yum install nginx - successful
Created November 30, 2018 17:18
Installing nginx on AWS if outbound traffic is restricted
[ec2-user@ip-172-31-1-221 ~]$ sudo yum install nginx
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00:00
amzn-updates | 2.5 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.12.1-1.33.amzn1 will be installed
--> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.12.1-1.33.amzn1.x86_64
--> Running transaction check
---> Package gperftools-libs.x86_64 0:2.0-11.5.amzn1 will be installed
@stephencweiss
stephencweiss / sudo yum install nginx - timeout
Last active November 30, 2018 17:17
Installing nginx can timeout on AWS if outbound traffic is restricted
[ec2-user@ip-172-31-1-221 ~]$ sudo yum install nginx
Loaded plugins: priorities, update-motd, upgrade-helper
Could not retrieve mirrorlist http://repo.us-east-2.amazonaws.com/latest/main/mirror.list error was
12: Timeout on http://repo.us-east-2.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 5000 milliseconds')
http://packages.us-east-1.amazonaws.com/2018.03/main/c31535f74c6e/x86_64/repodata/repomd.xml?instance_id=i-0b48b031c3318d644&region=us-east-2: [Errno 12] Timeout on http://packages.us-east-1.amazonaws.com/2018.03/main/c31535f74c6e/x86_64/repodata/repomd.xml?instance_id=i-0b48b031c3318d644&region=us-east-2: (28, 'Connection timed out after 5000 milliseconds')
Trying other mirror.
^C
Current download cancelled, interrupt (ctrl-c) again within two seconds
to exit.
^C
@stephencweiss
stephencweiss / wrk test on remote proxy
Last active November 30, 2018 20:05
Running an http test for product descriptions service routed through a proxy - both services running remotely on EC2
wrk -t12 -c400 -d10s http://13.59.138.186:8080/product/280
@stephencweiss
stephencweiss / wrk test on remote service
Last active November 30, 2018 00:01
Running an http test for product descriptions service running remotely on EC2
wrk -t12 -c400 -d30s http://3.17.69.68:8081/product/821
@stephencweiss
stephencweiss / newrelic.js
Created November 28, 2018 23:46
proxy config
'use strict'
/**
* New Relic agent configuration.
*
* See lib/config/default.js in the agent distribution for a more complete
* description of configuration variables and their potential values.
*/
exports.config = {
/**
* Array of application names.
@stephencweiss
stephencweiss / Axios baseURL
Last active November 28, 2018 00:17
Refactoring an Axios get method from within a React App to use a baseURL
// The original GET request which worked when the service ran on its own
getData(id){
axios.get(`/data/${id}`)
.then( (response) => {
this.setState({ data : response.data }) })
.catch( (error) => { console.log( `The error of the axios GET is: -------> `, error); })
}
// Refactored GET request to take advantage of an example baseURL
getData(id){
@stephencweiss
stephencweiss / NewRelic.js
Created November 27, 2018 17:54
A newRelic configuration for my Trailblazer-SDC project
'use strict'
/**
* New Relic agent configuration.
*
* See lib/config/default.js in the agent distribution for a more complete
* description of configuration variables and their potential values.
*/
exports.config = {
/**
* Array of application names.
@stephencweiss
stephencweiss / psql - common index commands
Created November 21, 2018 20:33
Four common PostgreSQL shell commands related to indexes
CREATE INDEX <index_name> ON <table_name> (<field(s)>) # Add an index
DROP INDEX index_name; # Drop an index
\d <table_name>; # See all indexes on a table
\di; # See all indexes in a database
//psql
sdc=# EXPLAIN ANALYZE SELECT * FROM descriptions WHERE product_id = 98242;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
Gather (cost=1000.00..671780.94 rows=1 width=461) (actual time=28182.350..28187.140 rows=1 loops=1)
Workers Planned: 2
Workers Launched: 2
-> Parallel Seq Scan on descriptions (cost=0.00..670780.84 rows=1 width=461) (actual time=19120.669..28177.305 rows=0 loops=3)
Filter: (product_id = 98242)
Rows Removed by Filter: 33334
@stephencweiss
stephencweiss / mongoDB - common Index commands
Created November 21, 2018 20:19
Three common index related commands in the mongo shell
//mongo sh
db.collection.createIndex()
db.collection.getIndexes()
db.collection.dropIndexes(["<index_name>"])