Skip to content

Instantly share code, notes, and snippets.

View iansu's full-sized avatar

Ian Sutherland iansu

View GitHub Profile
@sid24rane
sid24rane / net.js
Last active February 7, 2024 08:05
Simple TCP Client and Server in Node.js (Covering all useful Properties & Methods)
var net = require('net');
// creates the server
var server = net.createServer();
//emitted when server closes ...not emitted until all connections closes.
server.on('close',function(){
console.log('Server closed !');
});
@stongo
stongo / app.js
Last active January 23, 2024 18:48
Joi validation in a Mongoose model
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
@elnygren
elnygren / index.ts
Last active January 12, 2022 09:44
TypeScript type guard for ensuring / asserting specific optional property
/** Interface with optional properties */
interface IOptionalData {
foo?: { bar?: string };
other?: { bar?: string};
always: { bar?: string };
}
/** Make certain keys of a type required */
type RequiredKeys<T, K extends keyof T> = Exclude<T, K> & Required<Pick<T, K>>
@schierlm
schierlm / SUBSETS.txt
Last active August 31, 2020 19:53
Text document containing all characters of the Multilingual European Subsets of Unicode and some other common Unicode subsets (and a small Java program to verify the file has not been garbled)
Common Unicode Subsets
======================
ASCII
~~~~~
Not exactly known as a Unicode subset; the Unicode character set starts with
ASCII, though; therefore, ASCII is the smallest widely-used subset of
Unicode.
@sindresorhus
sindresorhus / issuehunt-bounties.md
Last active July 5, 2019 08:51
IssueHunt bounties