Skip to content

Instantly share code, notes, and snippets.

View soulsam480's full-sized avatar
⚰️
ded

sambit soulsam480

⚰️
ded
View GitHub Profile
@soulsam480
soulsam480 / object_diff.ts
Last active April 9, 2022 21:19
Deep diff between two objects. has a few deps
export const toString = (val: any) => Object.prototype.toString.call(val)
export type NullToUndefined<T> = T extends null ? undefined : T
/**
* Get deep diff of objects
* @param toMatch base data
* @param newData new data
* @param asNullKeys convert `undefined` to `null`
* @returns diff
*/
@soulsam480
soulsam480 / june_sanitizer.ts
Created September 22, 2021 07:37
A sanitizer for mongo response
const toString = Object.prototype.toString;
type MaybeObjArrStrNum =
| { [x: string]: MaybeObjArrStrNum }
| (MaybeObjArrStrNum | string | number)[]
| string
| number;
export function sanitizeResponse(data: {
@soulsam480
soulsam480 / 📊 Weekly development breakdown
Last active January 9, 2024 21:01 — forked from antfu/📊 Weekly development breakdown
📊 weekly dev (excl. office work)
JavaScript 2 hrs 5 mins ██████████████████▌░░ 88.4%
JSON 7 mins █░░░░░░░░░░░░░░░░░░░░ 5.2%
Vue.js 6 mins █░░░░░░░░░░░░░░░░░░░░ 4.8%
TypeScript 2 mins ▎░░░░░░░░░░░░░░░░░░░░ 1.4%
Markdown 0 secs ░░░░░░░░░░░░░░░░░░░░░ 0.1%
@soulsam480
soulsam480 / vue 3 custom properties.md
Created November 8, 2020 13:45
Declaring custom instance properties in Vue 3 and typescript
//declare the property so that it can be used by ts
declare module '@vue/runtime-core' {
    interface ComponentCustomProperties {
        $socket: SocketIOClient.Socket;
    }
}

const app = createApp(App)
//mount app with the vue 3 global properties api
@soulsam480
soulsam480 / vue.json
Last active October 26, 2020 15:28
Vue 2 javascript & Vue 3 with typescript and scss snippet
{
"vue 3 typescript scss ": {
"prefix": "vbts",
"description": "Vue 3 Typescript SCSS snippet",
"body": [
"<script lang='ts'>",
"import { defineComponent, reactive } from 'vue';",
"",
"export default defineComponent({",
" name: '${TM_FILENAME_BASE}',",