Skip to content

Instantly share code, notes, and snippets.

@SoftwareDevPro
SoftwareDevPro / fetch_cheatsheet.md
Created November 21, 2020 01:09
Common Fetch API requests,and response handling

Fetch Cheatsheet

The most common API requests

Type Example
1. Simple GET request fetch('{url}').
  then(response => console.log(response));
2. Simple POST request fetch('{url}', { method: 'post' })
  .then(response => console.log(response));
3. GET with an authorization token (Bearer) fetch('{url}', { headers: { 'Authorization': 'Basic {token}' } })  .then(response => console.log(response));
@SoftwareDevPro
SoftwareDevPro / main1go
Created November 6, 2020 03:26
Validation of SSL Certificates with Go
package main
// Checking for an SSL certificate
import (
"crypto/tls"
)
func main() {
@SoftwareDevPro
SoftwareDevPro / dynamodb.md
Created October 2, 2020 21:00
DynamoDB Cheat sheet For JavaScript

DynamoDB Cheat sheet For JavaScript

Install

npm install aws-sdk

Configure

@SoftwareDevPro
SoftwareDevPro / append_list_aws_dyndb.js
Created September 27, 2020 00:52
Append to a list in an AWS DynamoDb Table
async function appendToList(table, key, ue, ean, eav) {
const params = {
TableName: table,
Key: key,
UpdateExpression: ue,
ExpressionAttributeNames: ean,
ExpressionAttributeValues: eav
}
@SoftwareDevPro
SoftwareDevPro / append_nested_obj_aws_dyndb.js
Created September 25, 2020 18:02
Appending to a nested object in a AWS DynamoDb Table
async function appendToAnObject (table, key, ue, ean, eav) {
const params = {
TableName: table,
Key: key,
UpdateExpression: ue,
ExpressionAttributeNames: ean,
ExpressionAttributeValues: eav
}
@SoftwareDevPro
SoftwareDevPro / is_prime.js
Created September 25, 2020 18:00
Is Prime in Python and Javascript, O(sqrt(num))
is_prime = (num) => {
if (num == 1) {
return false
}
let i = 2
while (i * i <= num) {
if (num % i == 0) {
return false
}
@SoftwareDevPro
SoftwareDevPro / update_nested_attr_aws_dyndb.js
Created September 24, 2020 22:51
Update to a nested attribute
async function updateNestedAttribute(table, key, ue, ce, ean, eav) {
const params = {
TableName: table,
Key: key,
UpdateExpression: ue,
ConditionExpression: ce,
ExpressionAttributeNames: ean,
ExpressionAttributeValues: eav
}
@SoftwareDevPro
SoftwareDevPro / configure_aws_dyndb.js
Created September 23, 2020 23:38
AWS DynamoDb setup
const AWS = require('aws-sdk')
const ddb = new AWS.DynamoDB.DocumentClient()
@SoftwareDevPro
SoftwareDevPro / basic_recursive_solution.py
Created September 21, 2020 21:51
Fibonacci Implementation in Python
# O(2^n)
from time import time
def fibonacci(num):
if num == 0:
return 0
elif num == 1:
return 1
else:
@SoftwareDevPro
SoftwareDevPro / benchmark.js
Created September 19, 2020 00:34
Fibonacci in Javascript
// Tests and Benchmarking Time
let startOne = Date.now();
console.log(fibonacciRecursive(1));
console.log(fibonacciRecursive(4));
console.log(fibonacciRecursive(12));
console.log(fibonacciRecursive(40));
let endOne = Date.now();
console.log("Naive Recursive Time (ms): ", endOne - startOne);
let startTwo = Date.now();