Skip to content

Instantly share code, notes, and snippets.

@MrChocolatine
MrChocolatine / TS - More precise return type method Date#toISOString.d.ts
Last active July 12, 2024 00:28
TypeScript – How to accurately type dates in ISO 8601 format
// In TS, interfaces are "open" and can be extended
interface Date {
/**
* Give a more precise return type to the method `toISOString()`:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
*/
toISOString(): TDateISO;
}
type TYear = `${number}${number}${number}${number}`;
@EvanMu96
EvanMu96 / ac.cpp
Last active January 26, 2022 08:11
Aho-Corasick String match algorithm
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
const int K = 26;
struct Vertex {
@ayan-b
ayan-b / c-cpp-oops.md
Last active January 24, 2024 19:27
C, C++ & OOPS for Interviews
// smart_ptr_deleters.cpp
// shows how to use custom deleters with unique_ptr and shared_ptr
// Bartlomiej Filipek, April 2016, bfilipek.com
#include <iostream>
#include <memory>
#include <functional>
#include <cassert>
// This class cannot be changed, might come from 3rd party library