Skip to content

Instantly share code, notes, and snippets.

@bobuk
bobuk / switcher.ahk
Created November 1, 2024 14:25
So bored to use default keyboard layouts switcher so write mine with ahk
#Requires AutoHotkey v2.0
; Initialize global variables and load keyboard layouts
global ru := DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 1, "UInt")
global en := DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1, "UInt")
; Create a custom combination handler
#HotIf
~LAlt & LWin:: ; Left Alt being held and Left Win pressed
~LWin & LAlt:: ; Left Win being held and Left Alt pressed
@shufengh
shufengh / LocalStorageExport.md
Created July 11, 2019 05:23
How to export content in Chrome's local storage for a website

Original idea is from this post

  1. Open a tab and navigate to the website where you have content to export.

  2. Open devtools and switch to the console tab.

  3. Copy and paste the following snippet in the console and Chrome should ask you to save the output file

var obj = JSON.stringify(localStorage, null, 4)
@soullivaneuh
soullivaneuh / index.js
Created September 28, 2018 12:47
Prevent PageUp and PageDown press in textarea moving website out of the window
// @see http://www.competa.com/blog/chrome-bug-pageup-pagedown-textarea-moves-website-window/
// @see https://bugs.chromium.org/p/chromium/issues/detail?id=890248
document.querySelector('textarea').addEventListener('keydown', event => {
if (event.key === 'PageUp' || event.key === 'PageDown') {
const cursorPosition = event.key === 'PageUp' ? 0 : event.target.textLength;
event.preventDefault();
event.target.setSelectionRange(cursorPosition, cursorPosition);
}
});
@tomasevich
tomasevich / nginx_nodejs.md
Last active May 28, 2025 08:20
Сервер в связке Nginx + NodeJs

Сервер в связке Nginx + NodeJs

Данная пошаговая инструкция поможет освоить основы на простом примере

Для справки

Сервер поднимался на Debian 8 c характеристиками:

CPU - 1 ядро x 500 МГц

@pongo
pongo / free.md
Last active August 18, 2022 08:13
Сервисы email-рассылок

На этих сервисах есть бесплатные тарифы

Можно в их редакторах придумать внешний вид письма и затем скопировать html. А так же и вовсе делать через них большие рассылки.

@zmts
zmts / tokens.md
Last active October 2, 2025 11:04
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@daliborgogic
daliborgogic / delay.js
Created December 16, 2016 15:26
Node.js Async/Await delay
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {
@jh0ker
jh0ker / mwt.py
Last active February 3, 2023 20:38
Memoize-with-timeout decorator
#!/usr/bin/env python
# Source: http://code.activestate.com/recipes/325905-memoize-decorator-with-timeout/#c1
import time
from functools import wraps
class MWT:
"""Memoize With Timeout"""
_caches = {}
_timeouts = {}
@pongo
pongo / Javascript EventEmitters benchmark.md
Last active January 27, 2023 16:28
EventEmitter javascript libraries benchmark -- sorted by ops/sec
Library Input Output Gzip Stars 1 emit (ops/sec) many ons and emits ↓
chrisdavies/eev 2.02 KB 1.00 KB 457 b 166 9 722 398 362 175
alexanderGugel/micro-events 3.55 KB 1.53 KB 611 b 20 8 313 328 268 100
primus/eventemitter3 8.50 KB 3.24 KB 993 b 1010 36 762 683 266 752
riot/riot 8 045 274 147 673
Nicolab/evemit 4.18 KB 1.16 KB 494 b 15 3 634 852 139 524
Gozala/events 8.33 KB 3.94 KB 1.17 KB 378 48 177 783 130 989
developit/mitt 1.47 KB 304 (465) B
@swapnilshrikhande
swapnilshrikhande / function.php
Created April 26, 2016 10:08 — forked from YugalXD/function.php
Send mail with mailgun api by PHP CURL.
<?php
define('MAILGUN_URL', 'https://api.mailgun.net/v3/DOMAIN_NAME');
define('MAILGUN_KEY', 'KEY');
function sendmailbymailgun($to,$toname,$mailfromnane,$mailfrom,$subject,$html,$text,$tag,$replyto){
$array_data = array(
'from'=> $mailfromname .'<'.$mailfrom.'>',
'to'=>$toname.'<'.$to.'>',
'subject'=>$subject,
'html'=>$html,