Skip to content

Instantly share code, notes, and snippets.

@nblackburn
nblackburn / camelToKebab.js
Last active December 15, 2023 03:19
Convert a string from camel case to kebab case.
module.exports = (string) => {
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
};
{
"62870901": {
"HashKey": "WEAPON_SNOWLAUNCHER",
"NameGXT": "WT_SNOWLNCHR",
"DescriptionGXT": "WTD_SNOWLNCHR",
"Name": "Snowball Launcher",
"Description": "There's no greater gift than pummeling someone with rounds of festive cheer. With automatic reload, there's no time for anyone to disagree. Part of The Chop Shop.",
"Group": "GROUP_HEAVY",
"ModelHashKey": "W_LR_CompactSL_M32",
"DefaultClipSize": 20,
@indilo53
indilo53 / dlcweapondata.js
Last active November 22, 2023 02:08
alt:V MemoryBuffer usage example
function getDlcWeaponData(dlcWeaponIndex) {
const buffer = new alt.MemoryBuffer(312);
game.getDlcWeaponData(dlcWeaponIndex, buffer);
const data = [
buffer.int(0), // int emptyCheck; //use DLC1::_IS_DLC_DATA_EMPTY on this
buffer.int(8), // int weaponHash;
buffer.int(16), // int unk;
@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
{