Skip to content

Instantly share code, notes, and snippets.

View DmitriyWebDev's full-sized avatar

Dmitriy Gavrilov DmitriyWebDev

View GitHub Profile
@DmitriyWebDev
DmitriyWebDev / WebSockets.md
Created May 4, 2019 11:42 — forked from subudeepak/WebSockets.md
The problems and some security implications of websockets - Cross-site WebSockets Scripting (XSWS)

WebSockets - An Introduction

WebSockets is a modern HTML5 standard which makes communication between client and server a lot more simpler than ever. We are all familiar with the technology of sockets. Sockets have been fundamental to network communication for a long time but usually the communication over the browser has been restricted. The general restrictions

  • The server used to have a permanent listener while the client (aka browser) was not designated any fixed listener for a more long term connection. Hence, every communication was restricted to the client demanding and the server responding.
  • This meant that unless the client requested for a particular resource, the server was unable to push such a resource to the client.
  • This was detrimental since the client is then forced to check with the server at regular intervals. This meant a lot of libraries focused on optimizing asynchronous calls and identifying the response of asynchronous calls. Notably t
@DmitriyWebDev
DmitriyWebDev / stop-all-ajax-requset.js
Created September 28, 2020 17:31 — forked from msankhala/stop-all-ajax-requset.js
Stop all ajax request
// Stop all ajax request by http://tjrus.com/blog/stop-all-active-ajax-requests
$.xhrPool = []; // array of uncompleted requests
$.xhrPool.abortAll = function() { // our abort function
$(this).each(function(idx, jqXHR) {
jqXHR.abort();
});
$.xhrPool.length = 0
};
$.ajaxSetup({
@DmitriyWebDev
DmitriyWebDev / config
Created April 11, 2021 20:24 — forked from rbialek/config
ssh/.config
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile /home/user/.ssh/id_rsa
@DmitriyWebDev
DmitriyWebDev / the-bind-problem.jsx
Created January 27, 2022 18:31 — forked from Restuta/the-bind-problem.jsx
React, removeEventListener and bind(this) gotcha
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));
@DmitriyWebDev
DmitriyWebDev / HOC.ts
Created July 17, 2023 20:20 — forked from vezaynk/HOC.ts
HOC helpers. reduceHOCs and applyHOCs.
interface HOC<T> {
(Component: React.ComponentType<T>): (props: T) => JSX.Element
}
const reduceHOCs = <T>(...hocs: HOC<T>[]): HOC<T> => hocs
.reduce((reduced, next) => (c) => next(reduced(c)));
const applyHOCs = <T>(...hocs: HOC<T>[]) {
const reducedHoc = reduceHOCs(...hocs);
@DmitriyWebDev
DmitriyWebDev / secure-vscode-ru.md
Created February 20, 2025 22:21 — forked from isumix/secure-vscode-ru.md
Безопасное окружение для разработчика

Недавно я задался вопросом безопасности своего дев. окружения - vscode nodejs git yarn npm... Как известно пакеты и их зависимости представляют обширный вектор для атак. Тоже самое можно сказать и про Visual Studio Code с его плагинами и средствами автоматизации, и про другие утилиты. По сути это все есть ящик пандоры с доступом к вашей системе.

Первое что пришло на ум, это создать под проект виртуальную машину и примонтировать каталог проекта в нее. Таким образом бы достигалась полная безопасность остальной системы. Но как показала практика это не очень удобно. Скорость работы оставляет желать лучшего, виртуальная машина потребляет много ресурсов, да и поддержка нескольких операционных систем занимает время.

В голове все это время крутилось: "контейнеры", поэтому решение не заставило себя долго ждать. В общем недавно у нас появилась возможность запускать сервер для vscode и подключаться к нему из своей локальной версии vscode используя remote расширение или вообще через броузер.

Я решил пойти