Skip to content

Instantly share code, notes, and snippets.

@dominicbartl
dominicbartl / custom-eventemitter1.js
Last active March 3, 2018 21:23
2 ways to inherit from EventEmitter in Node.JS
var EventEmitter = require('events').EventEmitter;
module.exports = new EventEmitter();
exports.emitSomethingLater = function()
setTimeout(function() {
module.exports.emit('something');
}, 1000);
}
@swlaschin
swlaschin / ConstrainedTypesExamples.fsx
Last active May 26, 2024 20:19
Examples of creating constrained types in F#
// General hints on defining types with constraints or invariants
//
// Just as in C#, use a private constructor
// and expose "factory" methods that enforce the constraints
//
// In F#, only classes can have private constructors with public members.
//
// If you want to use the record and DU types, the whole type becomes
// private, which means that you also need to provide:
// * a constructor function ("create").
@suntong
suntong / Unicode official emojis.md
Last active July 28, 2021 10:13
unicode emoji symbols icons in UTF8 (emoticons, etc)

©️ Copyright Sign

®️ Registered Sign

‼️ Double Exclamation Mark

⁉️ Exclamation Question Mark

™️ Trade Mark Sign

ℹ️ Information Source

↔️ Left Right Arrow

↕️ Up Down Arrow

↖️ North West Arrow

↗️ North East Arrow

@peaeater
peaeater / self-signed-cert.ps1
Created April 11, 2017 23:40
Creates new wildcard self-signed SSL certificate for development purposes. Needs PowerShell admin.
# Creates new self-signed certificate for testing purposes
new-selfsignedcertificate -dnsname "*.domain.local" -friendlyname "*.domain.local Development Certificate" -certstorelocation "cert:\LocalMachine\My" -notafter (get-date).AddYears(100)
@pimbrouwers
pimbrouwers / mssql-continent-country.sql
Created May 9, 2017 13:53
MSSQL Continents / Countries (Name, ISO2, ISO3, ISO Num)
CREATE SCHEMA [Geo]
GO
CREATE TABLE [Geo].[Continent](
[Code] [char](2) NOT NULL PRIMARY KEY,
[Name] [nvarchar](25) NULL
)
GO
------------------------------
@pimbrouwers
pimbrouwers / mssql-calendar-table.sql
Last active October 12, 2023 13:20
SQL Server Calendar Table
USE master
GO
IF OBJECT_ID('dbo.calendar') IS NOT NULL
DROP TABLE dbo.calendar;
IF OBJECT_ID('dbo.fn_generate_calendar') IS NOT NULL
DROP FUNCTION dbo.fn_generate_calendar;
GO
@pimbrouwers
pimbrouwers / c-sharp-parse-linkheader.cs
Last active April 5, 2024 20:53
C# Parse Link Header
public class LinkHeader
{
public string FirstLink { get; set; }
public string PrevLink { get; set; }
public string NextLink { get; set; }
public string LastLink { get; set; }
public static LinkHeader LinksFromHeader(string linkHeaderStr)
{
LinkHeader linkHeader = null;
@pimbrouwers
pimbrouwers / ajax.js
Last active January 26, 2018 14:44
AJAX helpers with jQuery
module.exports = new Ajax();
function Ajax() { };
Ajax.prototype.get = function (url, callback, error) {
var req = this.makeRequest('GET', url, callback, error);
req.send();
};
Ajax.prototype.post = function (url, data, callback, error) {
@pimbrouwers
pimbrouwers / reset.css
Created March 27, 2018 13:45
Minimal CSS Reset
html, body, div, span,
h1,h2,h3,h4,h5,h6,hgroup,
ul,ol,dd,
p,figure,
pre,table,fieldset,hr,
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
@peaeater
peaeater / optimize-pdf.ps1
Created May 25, 2018 17:47
Downsamples PDFs with ghostscript.
<#
Downsample PDF and convert to gray if necessary.
Requires Ghostscript (gswin64c).
#>
param (
[string]$indir,
[string]$outdir = $indir,
[string]$gs = "gswin64c",
[string]$dpi = "150"