Skip to content

Instantly share code, notes, and snippets.

@SoftwareDevPro
SoftwareDevPro / install_aws_sdk.sh
Created September 3, 2020 01:31
Node install of AWS SDK
npm install aws-sdk
@SoftwareDevPro
SoftwareDevPro / is_leap.py
Last active August 25, 2020 01:26
Python leap year method
def leap_year(y):
if y % 400 == 0:
return True
if y % 100 == 0:
return False
if y % 4 == 0:
return True
else:
return False
@SoftwareDevPro
SoftwareDevPro / simple_ajax_call.js
Created August 24, 2020 02:11
Simple AJAX call, no frills, no library
function success() {
const data = JSON.parse(this.responseText);
console.log(data);
}
function error(err) {
console.log('Request Error', err);
}
@SoftwareDevPro
SoftwareDevPro / form.html
Created June 19, 2020 01:46
A web server with Go
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<div>
<form method="POST" action="/form">
<label>Name</label><input name="name" type="text" value="" />
<label>Address</label><input name="address" type="text" value="" />
@SoftwareDevPro
SoftwareDevPro / telephone-number-validation.json
Created May 24, 2019 00:34
Implementation of Telephone Number Validation for Free Code Camp
{"index.js":"function telephoneCheck(s) {\n var reg = /^(1\\s?)?(\\(\\d{3}\\)|\\d{3})[\\s\\-]?\\d{3}[\\s\\-]?\\d{4}$/;\n return reg.test(s);\n}\n\ntelephoneCheck(\"555-555-5555\");"}
@SoftwareDevPro
SoftwareDevPro / roman-numeral-converter.json
Created May 24, 2019 00:33
Roman Numeral Converter Implementation for Free Code Camp
{"index.js":"function convertToRoman(num) {\n\n var decVal = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];\n var romanVal = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ];\n\n var romanized = '';\n\n for (var index = 0; index < decVal.length; index++) {\n while (decVal[index] <= num) {\n romanized += romanVal[index];\n num -= decVal[index];\n }\n }\n\n return romanized;\n }\n\nconvertToRoman(36);"}
@SoftwareDevPro
SoftwareDevPro / palindrome-checker.json
Created May 24, 2019 00:33
Palindrome Checker Implementation for Free Code Camp
{"index.js":"function palindrome(str) {\n return str.replace(/[\\W_]/g, '').toLowerCase() ===\n str.replace(/[\\W_]/g, '')\n .toLowerCase()\n .split('')\n .reverse()\n .join('');\n}\n\npalindrome(\"eye\");"}
@SoftwareDevPro
SoftwareDevPro / cash-register.json
Created May 24, 2019 00:32
Implementation of Cash Register for Free Code Camp
{"index.js":"\nvar denominations = [\n { name: 'ONE HUNDRED', val: 100.00},\n { name: 'TWENTY', val: 20.00},\n { name: 'TEN', val: 10.00},\n { name: 'FIVE', val: 5.00},\n { name: 'ONE', val: 1.00},\n { name: 'QUARTER', val: 0.25},\n { name: 'DIME', val: 0.10},\n { name: 'NICKEL', val: 0.05},\n { name: 'PENNY', val: 0.01}\n];\n\nfunction checkCashRegister(price, cash, cid) {\n var result = { status: null, change: [] };\n var change = cash - price;\n\n var register = cid.reduce(function(acc, curr) {\n acc.total += curr[1];\n acc[curr[0]] = curr[1];\n return acc;\n }, { total: 0 });\n\n if (register.total === change) {\n result.status = 'CLOSED';\n result.change = cid;\n return result;\n }\n\n // Handle obvious insufficient funds\n if (register.total < change) {\n result.status = 'INSUFFICIENT_FUNDS';\n return result;\n }\n\n var change_arr = denominations.reduce(function(acc, curr) {\n var value = 0;\n \n while (register[curr.name] > 0 && change >= curr.val) {
@SoftwareDevPro
SoftwareDevPro / caesars-cipher.json
Created May 24, 2019 00:31
Implementation of Caesars Cipher for Free Code Camp
{"index.js":"function rot13(str) { // LBH QVQ VG!\n return str.split('')\n .map.call(str, function(char) {\n \n let x = char.charCodeAt(0);\n \n if (x < 65 || x > 90) { \n return String.fromCharCode(x);\n } else if (x < 78) { \n return String.fromCharCode(x + 13); \n }\n \n return String.fromCharCode(x - 13);\n }).join(''); \n}\n\n// Change the inputs below to test\nrot13(\"SERR PBQR PNZC\");"}
@SoftwareDevPro
SoftwareDevPro / square_root.py
Created January 27, 2019 00:32
Square Root of a Number in Python
def square_root(num):
return num ** 0.5