Skip to content

Instantly share code, notes, and snippets.

View hd1801's full-sized avatar
:octocat:
I may be slow to respond.

Hardik Dhawan hd1801

:octocat:
I may be slow to respond.
View GitHub Profile
@hd1801
hd1801 / ActionSheetRenderer.tsx
Created April 27, 2024 10:51
Clean way to implement a common components that provides you a bunch of options to choose from, like menu , action-sheets, etc
// ActionSheetRenderer.tsx
import _ from 'lodash';
import React, { FC, ReactElement } from 'react';
import { Icon } from 'react-native-paper';
import { useDisclose } from '../../hooks';
import { CustomBottomSheet } from '../../pages';
import { ActionSheetItem } from '../events';
import { VStack } from '../layout';
export interface ActionSheetRendererProps {
@hd1801
hd1801 / flexbox_sidebar_overflowing_grid_items.md
Created January 8, 2024 16:48 — forked from CMCDragonkai/flexbox_sidebar_overflowing_grid_items.md
Flexbox Sidebar with Overflowing Grid Items #css #flexbox #grid

Flexbox Sidebar with Overflowing Grid Items

Most flexbox layouts work by using the intrinsic sizing.

This means the sizes of boxes are determined by the size of the contents.

This is usually a good thing because you want your layout to stretch to the content, but also to the available space.

This makes layouts "flexible".

@hd1801
hd1801 / ideas_in_http_restful_api.md
Created January 8, 2024 16:48 — forked from CMCDragonkai/ideas_in_http_restful_api.md
Ideas in HTTP Restful API #http

Ideas in HTTP Restful API

Pagination

Pagination should always be using 2 parameters: seek and limit.

The seek is the offset into the collection.

The limit is how many to items to acquire.

@hd1801
hd1801 / multi_file_content_type_http_apis.md
Created January 8, 2024 16:48 — forked from CMCDragonkai/multi_file_content_type_http_apis.md
Multi-file Content-Type for HTTP APIs

Multi-file Content-Type for HTTP APIs

Sometimes you need to send a combination of key-value data and also file data in 1 single atomic request or response.

Use multipart/form-data for both requests and responses. Prefer this over using application/x-tar format.

Multipart actually has multiple subtypes. But the only one supported by HTTP clients and servers is multipart/form-data.

Libraries:

Load Balancer Characteristics

  1. Load Balance - distributing load and processing things in parallel - round robin, weighted, random, least loaded
  2. Failover - continuation service when a service fails or crashes - redundancy, capacity, heartbeats/monitoring, exception handling, stonith
  3. Routing - selecting a path for traffic to services - (unicast, boadcaset, multicast, anycast, geocast)
  4. Scheduling - assignment of time or resources to a task/service or vice versa - work stealing, pre-emptive, co-operative, fifo, priority, work-conserving
  5. Migration - Version upgrades, and resource optimisation
@hd1801
hd1801 / storage_tiers.md
Created January 8, 2024 16:48 — forked from CMCDragonkai/storage_tiers.md
Storage Tiers

Storage Tiers

  1. Block Devices
  2. Filesystems
  3. Object Storage
  4. Application Domain

Block Devices

At the bottom we have block devices supplied by HDDs and SSDs. These use a protocol like SCSI or ATA or SAS or SATA.

@hd1801
hd1801 / ssh_vpn.md
Created January 8, 2024 16:47 — forked from CMCDragonkai/ssh_vpn.md
SSH VPN #cli

SSH VPN

Here's an example of setting up a basic point to point VPN using SSH tunnels.

First you need a server in the cloud that isn't behind a NAT.

Ensure that the host and server has port 22 open and is running sshd.

If you're using AWS, make sure to check your security groups.

@hd1801
hd1801 / power_measurement.md
Created January 8, 2024 16:47 — forked from CMCDragonkai/power_measurement.md
Power Measurement #cli

Power Measurement

When picking a laptop, power is really important!

Basically laptop chassis comes with usually a fixed battery capacity. So remember as you change your components, your battery usually won't get more energy available! In fact modifying the configuration can definitely reduce your battery life. Connecting components like keyboards and other USB devices will also increase the drain on your system.

Unfortunately companies don't seem to be willing to create a tool that estimates your power usage as you perform configuration. Instead we can use this tool: http://powersupplycalculator.net/

@hd1801
hd1801 / orchestrators.md
Created January 8, 2024 16:47 — forked from CMCDragonkai/orchestrators.md
Orchestrators

Orchestrators

Orchestration is the practice of programming in the large.

In rigorous terms, orchestration represents higher-order programs that wire up first-order programs. Consider the analogy of wires and components. This is a first order program. A higher program would be where the components (along with their connecting wires) can be sent as data through the wires of a "higher" program. This is the same idea as higher order functions (where they are functions on functions), and higher order logic and also exponential objects in