Skip to content

Instantly share code, notes, and snippets.

@jrson83
jrson83 / server.js
Created October 14, 2023 20:41 — forked from modeware/server.js
Run a .ts extension file on a browser (Was wondering how vite was able to run a ts file on a browser, in memory transpilation, browser only cares for the header that tells file type.)
var http = require("http");
var { readFileSync } = require("fs");
var path = require("path");
//create a server object:
http
.createServer(function (req, res) {
if (req.method === "GET" && req.url == "/") {
const file = readFileSync(path.join(__dirname, "/index.html"));
res.writeHead(200, { "Content-Type": "text/html" });
@jrson83
jrson83 / index.ts
Created October 14, 2023 20:39 — forked from mike-jewell/index.ts
vite-plugin-ssr_https
import express from 'express'
import compression from 'compression'
import { renderPage } from 'vite-plugin-ssr'
import { Options } from 'sirv'
import fs from 'fs'
import path from 'path'
import https from 'https'
const isProduction = process.env.NODE_ENV === 'production'
const root = `${__dirname}/..`
@jrson83
jrson83 / input.scss
Last active October 2, 2023 22:20
Generated by SassMeister.com.
.first {
color: green;
}
%example-default {
color: red;
}
.bdg {
@extend %example-default;
import * as React from "react";
const displayItem = (currentPage: number, maxPerPage: number, index:number): boolean => {
const currentPageStart = ((currentPage - 1) * maxPerPage) + 1;
const currentPageEnd = currentPage * maxPerPage;
if ((index + 1) >= currentPageStart && (index + 1) <= currentPageEnd ) {
return true;
}
@jrson83
jrson83 / detect.ts
Created August 14, 2023 01:01
detect package manager
import fs from 'node:fs/promises'
import path from 'node:path'
import { exec } from 'node:child_process'
import { promisify } from 'node:util'
export const execAsync = promisify(exec)
export interface PackageJson {
name: string
@jrson83
jrson83 / input.scss
Created August 1, 2023 04:39
Generated by SassMeister.com.
@use 'sass:map';
@use 'sass:math';
$font-size-base: 1rem !default;
$font-size-min: 0.875rem !default;
$font-size-max: 1.125rem !default;
$font-ratios: () !default;
$font-ratios: map.merge(
(
@jrson83
jrson83 / input.scss
Created July 31, 2023 13:45
Generated by SassMeister.com.
@use 'sass:map';
$colors: () !default;
$colors: map.merge(
(
'light': (
'color-bg': hsl(0deg 0 100),
'color-surface': hsl(0deg 0 90),
'color-text': hsl(0deg 0 0),
'color-text-2': hsl(0deg 0 10),
@jrson83
jrson83 / input.scss
Created July 31, 2023 13:44
Generated by SassMeister.com.
.collapse {
width: 100%;
margin: 1rem 0;
border: 1px solid var(--x33);
border-radius: 0.25rem;
background: #fff;
background-color: var(--x22);
&__header {
@jrson83
jrson83 / type-scale.sass
Created July 31, 2023 03:17 — forked from nfrostdev/type-scale.sass
SASS Type Scale
// The basis of calculations, and your root html font size.
$base-font-size: 16px
// Change this to your type scale modifier.
// https://type-scale.com/
$type-scale: 1.25
// The desired unit supports "rem", "em", and "%".
$desired-unit: 'rem'
// Generate a type scale value based on the number of steps if this is ascending or descending.
// It is recommended to compile with the "--precision 3" flag to avoid long decimals.
import { useState, useLayoutEffect } from 'react'
type FullScreenState = boolean
type ToggleFullScreen = () => void
function useFullScreen<E extends HTMLElement>(ref: React.RefObject<E>): [FullScreenState, ToggleFullScreen] {
const [isFullScreen, setFullScreen] = useState(
Boolean(document.fullscreenElement),
)