Skip to content

Instantly share code, notes, and snippets.

@outring
outring / never.ts
Last active October 26, 2017 09:57
TypeScript exhaustive compile-time checks with `never`
//Play with it here: https://goo.gl/dH6DLj
class UnexpectedValueError {
public readonly stack: string | undefined;
public readonly message: string;
constructor(value: never) {
const error = new Error(`Unexpected value ${value}`);
this.stack = error.stack;
this.message = error.message;
@outring
outring / vk.video.bookmarklet.js
Last active June 30, 2022 09:34
VK video links extractor
(function() {
function setStyle(node, style) {
Object.keys(style).forEach(function(key) {
node.style[key] = style[key];
});
}
if (location.host !== "m.vk.com") {
alert("Для начала надо зайти на m.vk.com, например.");
(function () {
if (location.host !== "kino.pub") {
alert("Для начала надо зайти на kino.pub, например.");
return;
}
var errorHeading = "Что-то пошло не так. \n";
var windowId = "linksBookmarklet";
@outring
outring / reset.css
Last active May 31, 2019 12:49
Selective reset
dd, dl, dt, form, li, p {
margin: 0;
padding: 0;
}
img, table {
margin: 0;
padding: 0;
border: 0;
}
@outring
outring / watchis.bookmarklet.js
Last active August 29, 2015 14:02
Watch.is links bookmarklet
(function() {
if (location.host !== "watch.is") {
alert("Для начала надо зайти на Watch.is, например.");
return;
}
var errorHeading = "Что-то пошло не так.";
var apiTypes = [
{ id: "video", name: "Просто видео" },
@outring
outring / gist:2952747
Created June 19, 2012 07:15
Simple email validation regexp
/^(?:[a-z\d]+(?:[\-_][a-z\d]+)*\.)*[a-z\d]+(?:[\-_][a-z\d]+)*@(?:(?:xn--[a-z\d]+|[a-z\d]+(?:\-[a-z\d]+)*)\.)*(?:xn--[a-z\d]+|[a-z\d]+(?:\-[a-z\d]+)*)\.(?:xn--[a-z\d]+|[a-z]{2,4})$/i