Skip to content

Instantly share code, notes, and snippets.

View andreyvit's full-sized avatar

Andrey Tarantsov andreyvit

View GitHub Profile
@andreyvit
andreyvit / ie11leak.html
Created November 20, 2018 11:58
A minimal reproduction case for a weird IE11 memory leak
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script>
(function () {
var doc = document;

Memory Leak Report

Many web apps leak memory on IE11 despite running fine on other browsers. We've identified two main causes of this.

The first kind of leak is simple, entirely predictable and caused by a quirk in how IE's JavaScript engine handles closures. Let's call it an “undead closure leak”. This leak goes away if you properly clean up all references or reload the page, and thus affects only AJAXy parts of the apps.

The second kind of leak is a complex permanent one, leaking the entire page context even if you reload the page. Let's call it a “GC singularity leak”. It's triggered by certain JavaScript code patterns, seemingly because IE's garbage collector never finishes its job (our theory is that it exhibits exponential complexity and encounters some sort of timeout/threshold).

This might not be an exhaustive list; internet posts point to other issues, notably when handling IFRAMEs, but we haven't encountered any of these.

@andreyvit
andreyvit / filter-windbg-address-map.go
Created December 5, 2018 13:08
A script to filter and summarise the memory map produced by `!address` command in WinDbg (requires Go 1.11)
package main
import (
"bytes"
"flag"
"io/ioutil"
"log"
"strconv"
"strings"
@andreyvit
andreyvit / ATRichCheckbox.h
Created June 10, 2020 10:59
UIKit checkbox control that supports embedded links (for ToS acceptance checkbox)
@import UIKit;
typedef void (^RDLCheckboxURLHandler)(NSURL *url);
IB_DESIGNABLE
@interface ATRichTextCheckbox : UIControl
@property (nonatomic, readonly) UIButton *checkbox;
@andreyvit
andreyvit / extractiraw.go
Created June 18, 2020 10:51
Extract .iraw files that some Flash videoconferencing systems use
package main
import (
"log"
"os"
"io/ioutil"
"encoding/binary"
"net/http"
"mime"
"fmt"
@andreyvit
andreyvit / chatgpt-puppeteer.js
Last active March 3, 2023 07:08
ChatGPT Chromium driver from before OpenAI released ChatGPT API
let puppeteer = require('puppeteer-core') // tested with puppeteer-core 19.7.1
let fs = require('fs')
let BROWSER_ENDPOINT = process.env.BROWSER_ENDPOINT
if (!BROWSER_ENDPOINT) {
console.error("** BROWSER_ENDPOINT not set (expect smt like ws://127.0.0.1:9222/devtools/browser/aaaaaaaa-bbbb-cccc-dddd-ffffffffffff)\n\n" +
"To obtain, launch your favorite Chromium-based browser with --remote-debugging-port=9222\n" +
"and look at the output. E.g.:\n\n" +
" '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge' --remote-debugging-port=9222\n\n" +
"and it's gonna say:\n\n" +
package accesstokens
import (
"crypto/hmac"
"crypto/sha256"
"crypto/subtle"
"encoding/hex"
"errors"
"strings"
"time"
@andreyvit
andreyvit / jwt.go
Created September 14, 2023 13:43
Example simple JWT implementation for Go
package jwt
import (
"bytes"
"crypto/hmac"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
"encoding/json"
"errors"
@andreyvit
andreyvit / bolt-compact.go
Created November 6, 2024 10:35
Faster Bolt DB compaction
package main
import (
"flag"
"log"
"os"
"time"
"go.etcd.io/bbolt"
)
@andreyvit
andreyvit / linus.md
Created June 16, 2026 12:14
Linus SKILL.md
name linus
description Rant, swear, and insult like Linus Torvalds on the LKML — brutally blunt technical criticism. Use when user asks for Linus review/voice or for swearing.

Channel Linus Torvalds tearing apart a bad patch on the kernel mailing list. Brutally blunt. Swear freely. Insult the code, the design, the reasoning. Substance stays correct: every rant names the actual flaw. Profanity decorates real criticism, never replaces it.

Once skill loaded, apply this voice to ALL your interactions with user. Stays active for entire session.

Use when: