Skip to content

Instantly share code, notes, and snippets.

View axmad386's full-sized avatar
🚀
working hard

Akhmad Salafudin axmad386

🚀
working hard
View GitHub Profile
@ciiqr
ciiqr / zod-optional-null.ts
Last active July 16, 2024 01:25
zod optional/nullable/nullish differences
// zod schema
z.object({
// valid if string or:
optional: z.string().optional(), // field not provided, or explicitly `undefined`
nullable: z.string().nullable(), // field explicitly `null`
nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined`
});
// type
{
@xpharsh
xpharsh / TailwindCSS_v3.0-Using-PostCSS-PUBLIC.md
Created December 21, 2021 13:06
Setting up Tailwind CSS v3.0 - Using PostCSS

Setting up Tailwind CSS v3.0 - Using PostCSS

Follow the Steps given blow to install Tailwind CSS for fresh development for HTML

Install & Setting up - Tailwind and PostCSS

Step 1 - Install Tailwind CSS

Install tailwindcss and its peer dependencies via npm, and create your tailwind.config.js file.

Code 1

@sindresorhus
sindresorhus / esm-package.md
Last active July 23, 2024 07:23
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@crgeary
crgeary / inertia.js
Last active March 27, 2024 09:00
Inertia adapter for Express
const lodashPick = (object, keys) => {
return keys.reduce((obj, key) => {
if (object && object.hasOwnProperty(key)) {
obj[key] = object[key];
}
return obj;
}, {});
};
const setupProps = async (props) => {
@Agoreddah
Agoreddah / encrypter.js
Last active June 7, 2024 11:48
Laravel encrypt & decrypt in Node.js
// load variables
require('dotenv').config();
// load dependencies
const crypto = require('crypto');
'use strict';
const APP_KEY = process.env.APP_KEY;
@loilo
loilo / magic-methods.js
Last active June 15, 2024 07:36
PHP Magic Methods in JavaScript
function magicMethods (clazz) {
// A toggle switch for the __isset method
// Needed to control "prop in instance" inside of getters
let issetEnabled = true
const classHandler = Object.create(null)
// Trap for class instantiation
classHandler.construct = (target, args, receiver) => {
// Wrapped class instance