Skip to content

Instantly share code, notes, and snippets.

View SHoar's full-sized avatar

Sean Hoar SHoar

View GitHub Profile
@SHoar
SHoar / roanoke-va-lumber-suppliers.html
Created February 2, 2025 19:23
Roanoke, VA Lumber suppliers
<!DOCTYPE html>
<html>
<head>
<title>Roanoke Lumber Suppliers Map</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Leaflet CSS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<style>
/* Set the height for the map container */
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Lesson 1</title>
<link rel="stylesheet" href="style.css" />
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
@SHoar
SHoar / move_to_rds.rb
Created February 26, 2018 06:33 — forked from guenter/move_to_rds.rb
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
@SHoar
SHoar / aws-ec2-describe-images
Created November 13, 2017 14:02
AWS EC2 Describe Available Images
aws ec2 describe-images
[--executable-users <value>]
[--filters <value>]
[--image-ids <value>]
[--owners <value>]
[--dry-run | --no-dry-run]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
@SHoar
SHoar / aws-terminate-ec2-instance.sh
Created November 13, 2017 14:00
AWS Terminate EC2 Instance using AWS CLI SDK
aws ec2 terminate-instances --instance-ids {i-1234567890abcdef0}
@SHoar
SHoar / aws-run-ec2-instance.sh
Created November 13, 2017 13:58
AWS RUN (Create) EC2 Instance using AWS SDK CLI
aws ec2 run-instances --image-id {ami-abc12345} --count 1 --instance-type {t2.micro} --key-name {MyKeyPair} --security-group-ids {sg-903004f8} --subnet-id {subnet-6e7f829e}
@SHoar
SHoar / WhenToTest.md
Last active June 1, 2017 12:13
When to test (TDD)

When to test

When deciding when and how to test, it’s helpful to understand why to test. In my view, writing automated tests has three main benefits:
  1. Tests protect against regressions, where a functioning feature stops working for some reason.
  2. Tests allow code to be refactored (i.e., changing its form without changing its function) with greater confidence.
  3. Tests act as a client for the application code, thereby helping determine its design and its interface with other parts of the system.

Although none of the above benefits require that tests be written first, there are many circumstances where test-driven development (TDD) is a valuable tool to have in your kit. Deciding when and how to test depends in part on how comfortable you are writing tests; many developers find that, as they get better at writing tests, they are more inclined to write them first. It also depends on how difficult the test is relative to the application code, how pre

@SHoar
SHoar / findMaxOfSubArrays.js
Created May 7, 2017 18:42
Given an Array that has sub-arrays, find the largest number in each sub-array.
function maxOfSubs(arr) {
// You can do this!
var newArr =[];
for(var i = 0; i< arr.length; i++){
newArr[i] = Math.max.apply(null, arr[i]);
}
return newArr;
}
// test case:
@SHoar
SHoar / capitalizeEachArrayElem.js
Created May 7, 2017 17:52
Return a string with each word capitalized.
function titleCase(str) {
let arr = str.toLowerCase().split(' ');
str = arr.map(function(elem){
let upper = elem[0].toUpperCase();
return elem.replace(elem[0],upper);
}).join(' ');
return str;
}
// test
// titleCase("I'm a little tea pot");
@SHoar
SHoar / factorialize.js
Last active August 20, 2017 16:06
a js function to return the factorial result of a number
function factorialize(num) {
let factorial= 1;
for (let i = 1; i <= num; i++){
factorial *= i;
}
return factorial;
}