Skip to content

Instantly share code, notes, and snippets.

Avatar

Aryan Beezadhur AryanBeezadhur

View GitHub Profile
@AryanBeezadhur
AryanBeezadhur / fibonacci_sequence.py
Created Jan 30, 2022
Generate the Fibonacci Sequence for the length given
View fibonacci_sequence.py
def gen_fibonacci_sequence(length):
fibonacci_sequence = ["1", "1"]
for num in range(2, length):
prev_num = int(fibonacci_sequence[num - 1])
prev_prev_num = int(fibonacci_sequence[num - 2])
curr_num = prev_num + prev_prev_num
fibonacci_sequence.append(str(curr_num))
@AryanBeezadhur
AryanBeezadhur / pascals_triangle.py
Created Jan 30, 2022
Generate Pascal's Triangle for the number of rows given
View pascals_triangle.py
def gen_pascals_triangle(rows):
pascals_triangle = [[1, 1]]
for row in range(1, rows):
curr_row = [1, 1]
prev_row = pascals_triangle[row - 1]
for num in range(0, len(prev_row) - 1):
num_above = prev_row[num]
@AryanBeezadhur
AryanBeezadhur / db-relationships.md
Last active Jan 30, 2022
Relationships and foreign keys in SQL databases
View db-relationships.md

I'll be using an Ecommerce application in these examples.

PK stands for Primary Key, and FK stands for Foreign Key.


One-to-one

Use a foreign key on both sides of the relationship.

@AryanBeezadhur
AryanBeezadhur / full-page-bg-img.css
Created Nov 25, 2021
CSS Full-page background image
View full-page-bg-img.css
html {
background: url(image.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@AryanBeezadhur
AryanBeezadhur / flex-rows.css
Last active Dec 16, 2021
CSS Flexbox with specified number of boxes in rows
View flex-rows.css
.flex-container {
display: flex;
flex-wrap: wrap;
--flex-gap: 1.25rem;
gap: var(--flex-gap);
}
.flex-child {
--flex-items-per-row: 3;
@AryanBeezadhur
AryanBeezadhur / npm-downloads-api.md
Last active Jan 22, 2022
npm REST API endpoint for package downloads
View npm-downloads-api.md

npm downloads API endpoint:

https://api.npmjs.org/downloads/range/{start_date}:{end_date}/{package_name}

Where {start_date} and {end_date} are in the form yyyy-mm-dd, and {end_date} is optional.

View comma-thousands-separator.js
function numWithCommas(num) {
return num.toLocaleString()
}
View fetch-api.js
async function postData(url = '', data = {}) {
const response = await fetch(url, {
method: 'POST', // GET (default), POST, PUT, DELETE, etc.
mode: 'cors', // no-cors, cors (default), same-origin
cache: 'no-cache', // default (default), no-cache, reload, force-cache, only-if-cached
credentials: 'same-origin', // include, same-origin (default), omit
headers: {
'Content-Type': 'application/json'
// 'Content-Type': 'application/x-www-form-urlencoded',
},
@AryanBeezadhur
AryanBeezadhur / center-items-flexbox.css
Created Nov 10, 2021
Center items using CSS flexbox
View center-items-flexbox.css
.flex {
display: flex;
justify-content: center;
align-items: center;
}
@AryanBeezadhur
AryanBeezadhur / link-new-tab.html
Created Nov 10, 2021
HTML Hyperlink that opens in new tab
View link-new-tab.html