This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable react-refresh/only-export-components */ | |
| import { | |
| createMemoryHistory, | |
| createRootRoute, | |
| createRoute, | |
| createRouter, | |
| useRouterState, | |
| type NotFoundRouteProps, | |
| } from "@tanstack/react-router"; | |
| import { createContext, useContext, type ReactNode } from "react"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Request, Response } from 'express'; | |
| import { Body, Controller, Post, Req, Res } from '@nestjs/common'; | |
| import { UserService } from './user.service'; | |
| import * as Redis from 'ioredis'; | |
| import { RateLimiterRedis } from 'rate-limiter-flexible'; | |
| const redisClient = new Redis({enableOfflineQueue: false}); | |
| const maxWrongAttemptsByIPperDay = 100; | |
| const maxConsecutiveFailsByUsernameAndIP = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| All code you write MUST be fully optimized.“Fully optimized” includes: | |
| • Maximizing algorithmic big-O efficiency for memory and runtime (e.g., preferring O(n) over O(n²) where possible, minimizing memory allocations). | |
| • Using parallelization and vectorization where appropriate (e.g., leveraging multi-threading, GPU acceleration, or SIMD instructions when the problem scale and hardware context justify it). | |
| • Following proper style conventions for the code language (e.g., adhering to PEP 8 for Python, camelCase or snake_case as per language norms, maximizing code reuse (DRY)). | |
| • No extra code beyond what is absolutely necessary to solve the problem the user provides (i.e., no technical debt, no speculative features, no unused variables or functions). | |
| • Ensuring readability and maintainability without sacrificing performance (e.g., using meaningful variable/function names, adding concise comments only where intent isn’t obvious from the code). | |
| • Prioritizing language-specific best practices and idiomatic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Usage: | |
| // Replace React.lazy(() => import('x')); | |
| // with retryDynamicImport(() => import('x')); | |
| import { ComponentType, lazy } from 'react'; | |
| const MAX_RETRY_COUNT = 15; | |
| const RETRY_DELAY_MS = 500; | |
| // Regex to extract the module URL from the import statement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const hasGroup = typeof Object.groupBy === typeof undefined || typeof Array.groupToMap === typeof undefined || typeof Array.group === typeof undefined; | |
| if (!hasGroup) { | |
| const groupBy = (arr, callback) => { | |
| return arr.reduce((acc = {}, ...args) => { | |
| const key = callback(...args); | |
| acc[key] ??= [] | |
| acc[key].push(args[0]); | |
| return acc; | |
| }, {}); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker ps -f status=exited | grep "\-cache-" | awk '{print $1}' | xargs docker rm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #### https://docs.oracle.com/cd/E37670_01/E41138/html/section_uxg_lzh_nr.html | |
| Enable IP forwarding: | |
| # echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf | |
| # sysctl -p | |
| net.ipv4.ip_forward = 1 | |
| Add firewall rules to allow VRRP communication using the multicast IP address 224.0.0.18 and the VRRP protocol (112) on each network interface that Keepalived will control, for example: | |
| # iptables -I INPUT -i eth0 -d 224.0.0.0/8 -p vrrp -j ACCEPT | |
| # iptables -I OUTPUT -o eth0 -d 224.0.0.0/8 -p vrrp -j ACCEPT | |
| # service iptables save |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user www-data; | |
| http { | |
| ## | |
| # Basic Settings | |
| ## | |
| sendfile on; | |
| tcp_nopush on; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| # Internal image resizing server. | |
| server_name localhost; | |
| listen 8888; | |
| location /resize { | |
| alias /var/www/app/current/public/imgs; | |
| image_filter resize $arg_width $arg_height; | |
| image_filter_jpeg_quality 75; | |
| allow 127.0.0.0/8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://stackoverflow.com/a/28818420/484780 | |
| git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1` |
NewerOlder