Skip to content

Instantly share code, notes, and snippets.

@jericbas
jericbas / freecurrencyapi.ts
Created February 18, 2026 11:00
Modern FreecurrencyAPI TypeScript rewrite with async/await, AbortController, and full type safety
/**
* @module FreecurrencyAPI
* @description A modern, TypeScript-native client for the Freecurrency API v1.
*
* Features:
* - ✅ Full TypeScript support with complete type definitions
* - ✅ Modern async/await syntax (no promise chains)
* - ✅ AbortController for request cancellation and timeouts
* - ✅ Proper error handling with custom error classes
* - ✅ Zero runtime dependencies
@jericbas
jericbas / Cargo.toml
Created February 18, 2026 00:27
Rust CLI: Currency converter to PHP with 12h rate caching using FreeCurrencyAPI
[package]
name = "currency-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
@jericbas
jericbas / Cargo.toml
Last active February 18, 2026 00:35
Rust CLI: Currency converter to PHP with 12h rate caching using FreeCurrencyAPI
[package]
name = "currency-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
@jericbas
jericbas / vite.config.js
Last active August 7, 2025 03:00
Vite config to keep chunks under 14kB, inspired by https://endtimes.dev/why-your-website-should-be-under-14kb-in-size/. Uses Brotli compression, aggressive minification, and manual chunking to optimize for TCP slow start, reducing load times. Ideal for fast, lightweight websites.
// vite.config.js - Optimized for <14kB chunks per https://endtimes.dev/why-your-website-should-be-under-14kb-in-size/
// Aligns with TCP slow start to minimize latency; use Brotli for ~50kB uncompressed in 14kB delivered.
// Install: npm install vite-plugin-compression --save-dev
import { defineConfig } from 'vite';
import compression from 'vite-plugin-compression';
export default defineConfig({
plugins: [
compression({
@jericbas
jericbas / rules.json
Last active October 12, 2024 13:15
CleanURLs for Online stores or Ecommerce like Shopee.ph
{
"rules": [
{
"urlPattern": "https://shopee.ph/*",
"removeParams": ["sp_atk", "xptdk"]
}
]
}
@jericbas
jericbas / Loop.js
Last active December 7, 2023 04:29
Loop
Certainly! Let's create more realistic test cases for each of the first seven functional methods, using scenarios related to vehicle, house, or land insurance. Each example will use an array with real-life-like data.
1. **forEach (Logging Vehicle Insurance IDs)**:
```javascript
const vehicleInsurances = [
@jericbas
jericbas / Json Preview.tsx
Last active November 9, 2023 09:12
json preview component
import React, { useState } from 'react';
interface JsonDisplayProps {
data: any; // You can use a more specific type based on what JSON you expect
}
const JsonDisplay: React.FC<JsonDisplayProps> = ({ data }) => {
const [isCollapsed, setIsCollapsed] = useState(true);
const jsonString = JSON.stringify(data, null, 2);
const truncateLimit = 100; // You can adjust the truncate limit as needed
@jericbas
jericbas / Last-of-array.ts
Last active November 3, 2023 09:16
Types
const dataArray = ['A', 'B', 'C', 'D', 'E'] as const;
type data = [...(typeof dataArray)];
type Last<T extends any[]> = T extends [...infer _, infer R] ? R : never;
const last: Last<data> = 'E'
@jericbas
jericbas / objectToJSX.tsx
Last active August 18, 2023 04:13
ObjectToJSX
import React, { ReactNode } from 'react';
interface ObjectProps {
[key: string]: any;
children?: ReactNode;
}
function objectToJSX(component: string, object: ObjectProps): JSX.Element {
if (typeof component !== 'string' || typeof object !== 'object') {
throw new Error('Invalid arguments provided.');