Skip to content

Instantly share code, notes, and snippets.

View mattc41190's full-sized avatar
🐌
there is no effort without error

Matt Cale mattc41190

🐌
there is no effort without error
View GitHub Profile
@mattc41190
mattc41190 / get-thanksgiving.js
Last active April 14, 2021 14:58
When is Thanksgiving and Why?
// Problem Statement:
// Find out how to calculate Thanksgiving in a given year
// Credits: https://coffeescript-cookbook.github.io/chapters/dates_and_times/date-of-thanksgiving
// SOLUTION:
const isDateInPast = (_date) => {
const now = new Date()
const nowInt = Date.parse(now)
const dateInt = Date.parse(_date)
return nowInt - dateInt > 0
@mattc41190
mattc41190 / date-calc.js
Created April 8, 2021 14:47
How do those dern date calculators work?
const calculateTimeLeft = (month, day) => {
const now = new Date()
const nowInt = Date.parse(now)
const year = new Date().getFullYear()
const toDate = new Date(`${month}/${day}/${year}`)
const toDateInt = Date.parse(toDate)
const diff = toDateInt - nowInt
console.log(diff);
package main
import (
"database/sql"
"fmt"
"log"
"os"
goqu "github.com/doug-martin/goqu/v9"
_ "github.com/go-sql-driver/mysql"
@mattc41190
mattc41190 / basic-osi-model-markdown.md
Created January 22, 2019 21:59
OSI Model Table in Markdown (osi, md, markdown, table)
Layer Name Format Function Example Protocol Address Type
1 Physical Bit Raw bits on physical medium TIA-323-F, DOCSIS N/A
2 Data Link Frame Node-To-Node Communication MPLS MAC Address
3 Network Packet Routing and addressing IP, IGMP IP Address
4 Transport Protocol Data Unit (PDU) -- Segment End-To-End Integrity TCP, UDP Port
5 Session Data Connection Dialog SOCKS, RPC Socket
6 Presentation Data Data Representation XDR, SMB Hostname
7 Application Data Interactions with user FTP Hostname
1) getText should return the text of multiple elements:
Error: java.net.SocketException: Connection reset
at new RuntimeError (lib/utils/ErrorHandler.js:104:12)
at Request._callback (lib/utils/RequestHandler.js:253:35)
at Request.self.callback (node_modules/request/request.js:186:22)
at Request.<anonymous> (node_modules/request/request.js:1163:10)
at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
# Demo Perf Stuff
### Have slide show open
1. Welcome folks.
2. Explain the current situation (our present Jmeter set up and the difficulties)
3. Explain what blazemeter and taurus are
4. Show them your report in blaze in it’s failing slow state and ask you to check a change in
5. Show them a barebones test
6. Show them a barebones Jenkinsfile
@mattc41190
mattc41190 / install-and-start.sh
Last active July 14, 2017 03:38
Start simple server on linux with or without initial docker installation
# Update EC2 Linux package manager
sudo yum update -y
# Use package manager to install docker
sudo yum install -y docker
# Use Linux service to start docker service
sudo service docker start
# Ensure ec2-user has rights to perform docker commands
sudo usermod -a -G docker ec2-user
# Pull image
sudo docker pull mattc41190/tomdog
@mattc41190
mattc41190 / build-and-run.sh
Created July 14, 2017 01:53
Shell script to run simple server docker image
# Tell docker to build an image called/tagged as mattc41190/tomdog and to use the durrent dir and context for the Dockerfile
docker build -t mattc41190/tomdog .
# Tell docker to run a container (in detatched made `d`) based on the tomdog
# image and to expose port 80 on the container to the host machine
docker run -e "PORT=80" -p 80:80 -d mattc41190/tomdog
@mattc41190
mattc41190 / Dockerfile
Created July 14, 2017 01:49
Simple Server Dockerfile
# Choose a base image
FROM node:8.1.3
# Make a landing zone for our app
RUN mkdir app
# Copy the contents of the pwd/cwd into the image's /app directory
COPY . /app
# Go into the /app dir and run npm install
RUN cd /app; npm install
# Choose some ports to expose to the host machine
EXPOSE 3344 80
'use strict';
const Hapi = require('hapi'); // Server tech
const Inert = require('inert'); // Hapi plugin for serving static content
const PORT = process.env.PORT || 3344; // Port to run my app on
const server = new Hapi.Server(); // Create instance of Server
server.connection({ port: PORT}); // Add connection to server
server.register(Inert, (err) => {