Skip to content

Instantly share code, notes, and snippets.

View Maximization's full-sized avatar

Maxim Orlov Maximization

View GitHub Profile
@Maximization
Maximization / valid-parentheses-solution.js
Last active September 5, 2023 03:24
Solution to the Valid Parentheses challenge from LeetCode
/**
* Author: Maxim Orlov <hello@maximorlov.com>
* Website: https://maximorlov.com
*
* @param {string} s
* @return {boolean}
*/
const OPEN_PARENS = ['(', '{', '['];
function isValid(s) {
@Maximization
Maximization / portfolio-project-01.md
Last active April 28, 2023 11:11
The first portfolio project from the Full-stack JavaScript Developer study guide

Project #1 - Bookmark Manager landing page

Build the landing page for a fictional Bookmark Manager and follow these guidelines:

  • Use TailwindCSS framework to style the landing page
  • Incorporate modern CSS layouts such as Flexbox and Grid
  • Use semantic HTML elements such as header, nav, footer and ensure that the page is accessible by performing an accessibility audit
  • Utilize JavaScript for the tab bars and subscribe form
  • Match the design as closely as possible
  • Ensure that the page is responsive and looks good on all screen sizes
@Maximization
Maximization / mapLimit-example.js
Last active January 24, 2023 14:17
A working example of using iterators to implement a mapLimit utility function
async function mapLimit(array, iterateeFn, concurrency) {
const results = [];
async function runTasks(tasksIterator) {
for (const [index, element] of tasksIterator) {
console.log("Running iterateeFn for element", element);
try {
results[index] = await iterateeFn(element);
} catch (error) {
@Maximization
Maximization / debug-sizes.html
Last active April 18, 2023 04:50
A script that console.logs the computed sizes values of your image as you resize the window
<img class="testing" srcset="..." sizes="...">
<script>
// On resize and img load events, logs:
// - `currentSrc` width (selected from `srcset`)
// - element width
// - parsed size value (selected from `sizes`)
// - a boolean indicating if the parsed size matches the element width
// There seem to be issues with `HTMLImageElement.natural{Width,Height}`, so we have to rely on this
// instead.
@Maximization
Maximization / index.js
Created October 30, 2020 11:43
Google-like pagination
// Create dummy posts to work with
const posts = [];
for (let i = 0; i < 100; i++) {
posts.push(`Post ${i}`);
}
// Configurable variables
const POSTS_PER_PAGE = 5;
const CURRENT_PAGE = 13;
const PAGINATION_SIZE = 10;
@Maximization
Maximization / server-template-instructions.md
Last active April 2, 2022 21:33
Server Template Instructions

Server Template for Busy Hackers

These are the instructions for the Server Template for Busy Hackers.

Getting started

1. Sign up for a DigitalOcean account (if you don't have one)

We'll be using DigitalOcean to spin up a server (or droplets as they're called). DigitalOcean is a popular choice for developers because of its friendly user interface and good customer support. Their prices are competitive and they offer good value for what you pay.

@Maximization
Maximization / nginx.conf
Created August 3, 2020 14:20
Basic Nginx configuration for serving multiple websites at different domains
# `events` block is required so we add an empty one for validity
events {}
http {
# Configuration block for weatherapp.com
server {
listen 80; # HTTP
server_name weatherapp.com; # match all requests originating from "weatherapp.com" domain
# Route all requests to port 3000 on localhost
@Maximization
Maximization / .htaccess
Created July 27, 2020 15:31
Redirect to non-www and https in one step with Apache
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) https://example.com/$1 [L,R=301]
</IfModule>
@Maximization
Maximization / FCC Solution
Last active August 29, 2015 14:21
Solution to @terakilobyte's problemset, posted at: 12-05-2015 4:05AM GMT+2 in FreeCodeCamp's Slack #general chatroom
/*
* solved by Maximization on 12 May 2015
*
* PROBLEM STATEMENT
* I want you to iterate through the range n = (1, 200). If n modulo any key on the object === 0,
* I want you to subtract (so the negatives will add, yes) the value the key associates to and tell
* me the value after you iterate through the range. Start with a sum of 0.
*/
// object to check against