Skip to content

Instantly share code, notes, and snippets.

Avatar
🥑
Hangry

Craig Spence phenomnomnominal

🥑
Hangry
View GitHub Profile
@phenomnomnominal
phenomnomnominal / ParseDate.ts
Created Oct 3, 2020
TypeScript Template Types Date Validator
View ParseDate.ts
// Check it out here:
https://www.typescriptlang.org/play?ts=4.1.0-dev.20201001#code/C4TwDgpgBAcgrgWwEYQE4GcoF4oHIAMuUAPngIxGm4BMleAzHbgCxMCsTAbEwOxMAcTAJy4A3AChQkWAHsAdgC00M7FACiADwDGAGzgATCAB54yNOgA0eQgD4Jk8NACaEAIapVAAwAkAb1MoGAC+fgHmIf6IgegRYcGeElLQALLywAAWmDie+KHySqgyQZ4k5ISluGQUFWS0iY5QACKuIFlQPr4ETNVUtLH5ysUV9OVU9BT2SVAAEjJwGF65kWbxpZ5koVHhJb2jeNQ9+7QV1IwnrPXSCvIQs-NtMAOFa0uPioM7Zd2HlbQO0skAJZyODACBtDpdGpMY5jJisCocWJbeKXaAAZQgWnk+jaQJBYPQaKgQJ0OkB6CxOIhmxWMVp0WRdOKkwa1zkEAACqgIAAzQEaVS4ADUTAAtGJxP9oM0wZz3JS1KhCqgjMlwehXABzaAQDRguS4qDoYCoYFamyqXxQNAqgBcJI12ugQVZ0llEAAKoCEMZxFAA1BPTb9RBDZgTWa5FrxJacP7A8G9QajR1gby0E1XGDvb6ggo-OnM+yIEMAPxQBOBwPyjAQD25iAlowNn0QKwly12qtBkMpzBpuQZjwe8s96u1ymt32PZseruV6seycQJUqoyeacQB0ASTkADdXOT9Fmc22HX5PcU7FKpiut82e1v0aa+2GjZHzRYeyWXx5k++Eaml+PYrvoW6qPe2Zem2s43C20GNn+NjfhOCoQPoJaQehza-qaNixthdbgYhbZvuGp4wb6f5QGW441uhmE3ORRp4R4dHVpxgYdGBW75n4YElkM3ZcQGgnMSJDHEVubrQFBZ4zjIj5LqRilsSxQFRjGcaLoGW5wRyNEARRg7DpRQSeoWQ6Zo25a6Vx8lUcYHpWI2XZPqpEAGRARmhiZVlmaOJQcaJjkIWCC4eXK6FrjIqqeI5jb
View ts-css-lexer.ts
// Check it out here:
// https://www.typescriptlang.org/play?ts=4.1.0-dev.20201001#code/C4TwDgpgBAMg9gdwgJwMYEMDOECCAbMAC3SgF4oBydCqAH0oCMb6LVnKATdiibgM24BzboW4BLbgCtuAa255uAW24A7bnG5huAR27JumbsG4BXbgDduCbgA9uIbgC8KAbgBQoSFACqYSGixcAmIyKABhdDAxYHQ8MUcIAB54JADsfCJ0AD53T2gM4gYIYFCUlAx04JJ6X38KoMzc8GgAORNFIuRMUIoABm4ARm4AJm4AZm4AFm4AVm4ANm4Adm4ADm4ATlcPZqgAZRAOuDxu8goAWm4AfQodrwBJDggVYDE+MRRTqAL0IpL6NodFB0faHBjHTBNLwAdUI0QgmDA6FQ0DOlBBFAAOmoMZjjLiBLi1FDoABFExwYAI0IAIgoNIxdJJUAAKsh0OZPrEegAabhZbiJbgAP24AGptnkoI8egBiSW7MJ4LBfCgAOgVXm8KjEnK63LOACpblKAKIAeQAYj1NdBLWIdZhCBAODbmThgMBkGIGCYqebICoegBtW3fT3e31UpVwbA9AC6YY9Xp9fogEWwqtFGIAetwACTcY0YgCE3FoYdN2hMBsopCTEdTVK+ycjaYDzxBrab6bwseg9G7UfTgW69CrNbwzLCxC6oUez1e70+INh8MRyIHUHJlOp9DZHK5eBBMvoSpVIO1uqPIIt1sHjeHkLcd2gMAgNlNyGQcGQiQAsgimDoII0AflSKgcN0mApioghZKEADeUCKEBIEQAAXFAgGYMBoFQAAvu4r6sugMhBHgiRuFANFQAAalA4HPFBUAwd6cE8tRtEzugXRuAh5BcTRDFMZB3QAAb5ohDp8MCYQEVJMnAgASgR4lQAA-FAQm0TRYSMTYEEsTxc5aTpum6SyZEUYkyk8uEs6YAhWHmbRDEYTpdHEVKVnkdqryUZ5BlGdBsGCJxukmd0oksWxDqCPxoRBT
View slack.crime.js
async function setLotsOfReminders(name, reminder, times) {
await Promise.all(Array.from({ length: times }, (_, i) => i + 1).reduce(async (p, days) => {
await p;
document.querySelector('[role="textbox"]').innerHTML = `remind @${name} to ${reminder} in ${days} days at 4am`;
return new Promise(resolve => {
setTimeout(() => {
document.querySelector('button[aria-label="Send message"]').click();
setTimeout(resolve, 1000);
}, 1000);
});
@phenomnomnominal
phenomnomnominal / stylelint-betterer.ts
Created May 16, 2020
Betterer test for StyleLint errors
View stylelint-betterer.ts
import { BettererFileTest, BettererFileIssuesMapRaw } from '@betterer/betterer';
import * as stack from 'callsite';
import { promises as fs } from 'fs';
import * as glob from 'glob';
import LinesAndColumns from 'lines-and-columns';
import * as minimatch from 'minimatch';
import * as path from 'path';
import { lint } from 'stylelint';
import { promisify } from 'util';
View elsa.magic.ts
type Freezable = {
unfreezable?: never; // Need to make the unfreezable property optional
};
type Frozen<T extends Freezable = Freezable> = T & {
frozen: true;
};
type Thawed<T> = T extends Frozen<infer R>
? R
View video.component.html
<youtube-player
videoId="dQw4w9WgXcQ"
suggestedQuality="highres"
[height]="600"
[width]="1080"
[startSeconds]="43"
[endSeconds]="60">
</youtube-player>
View video.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
template: '<youtube-player videoId="dQw4w9WgXcQ"></youtube-player>',
selector: 'app-video'
})
export class VideoComponent implements OnInit {
ngOnInit() {
const tag = document.createElement('script');
tag.src = 'https://www.youtube.com/iframe_api';
View video.module.ts
import { NgModule } from '@angular/core';
import { YouTubePlayerModule } from '@angular/youtube-player';
import { VideoComponent } from './video.component';
@NgModule({
imports: [YouTubePlayerModule],
declarations: [VideoComponent],
exports: [VideoComponent]
})
View is-this-possible-in-ivy.ts
import { Component, Directive, Pipe } from '@angular/core';
import { DatePipe as date, NgIf as ngIf } from '@angular/common';
import { SomethingComponent as something } from './something.component';
const template = function (templates: TemplateStringsArray, ...declarations: Array<Component | Directive | Pipe>) {
return function () {
// ivyMagicHere?!
};
}
View biometrics-appointment-finder.js
const request = require('request').defaults({ jar: true});
const nodemailer = require('nodemailer');
const LOCATIONS = {
STOCKHOLM: 'Z209',
GÖTEBORG: 'Z102',
MALMÖ: 'KCMA',
TILLSTÅNDSPRÖVNING: 'BBBO',
BORLÄNGE: 'NHL',
JÖNKÖPING: 'Z085',
You can’t perform that action at this time.