Skip to content

Instantly share code, notes, and snippets.

var d = Object.create(Date.prototype);
Date.call(d);
d instanceof Date // true
d.getTime() // throws an Error!
@arshednabeel
arshednabeel / vicsek.py
Last active April 26, 2024 20:02
A minimal implementation of the Vicsek model in ~50 lines of code
import numpy as np
from tqdm import trange
def get_neighbour_matrix(x, L, R):
dx = np.subtract.outer(x[:, 0], x[:, 0])
dy = np.subtract.outer(x[:, 1], x[:, 1])
dx[dx > (L / 2) ** 2] -= (L / 2) ** 2
dy[dy > (L / 2) ** 2] -= (L / 2) ** 2
pair_dist = dx ** 2 + dy ** 2
let foo = 1;
let bar = 2;
let obj = { foo, bar };
obj.foo // 1
obj.bar // 2
@n1snt
n1snt / Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md
Last active April 26, 2024 20:02
Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

var smc = new SourceMapConsumer(theSourceMapJSON);
var smg = SourceMapGenerator.fromSourceMap(smc);
smc.sources.forEach(function (s) {
smg.setSourceContent(s, somehowGetTheSourceContentsOf(s));
});
// This is your modified map.
smg.toJSON();
@fitzgen
fitzgen / gist:95f8b2ea672d773f3537
Created August 2, 2014 22:12
Generators + prototypes
function* G() { yield this.x; }
G.prototype = { x: 5 };
console.log([...G()]);
@floxay
floxay / get_client_version.py
Last active April 26, 2024 20:01
Get VALORANT client/build version from game executable
import pefile
def get_product_version(data: bytes) -> str:
pe = pefile.PE(data=data, fast_load=True)
pe.parse_data_directories(
directories=[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_RESOURCE"]]
)
for file_info in pe.FileInfo:
for entry in file_info:
Cu.import("resource://gre/modules/Task.jsm")
let runTaskWhileValid = (isValid, generator) => {
Task.spawn(function* () {
const g = generator();
let value, resolved;
let done = false;
while (!done) {
try {
({ value, done }) = g.next(resolved);
@arch1t3cht
arch1t3cht / resources.md
Last active April 26, 2024 20:01
Encoding Resources

So this is supposed to be a list of encoding-related resources together with some very basic instructions. Kind of an encoding analogue to fansub.html. This is not a full guide on encoding.

Since this page is starting to get linked elsewhere, I should also make clear that it mostly comes from (a person adjacent to) the JET community. In particular, it's written primarily from the perspective of anime encoding. Still, most parts will hold up equally well for live action and other areas.

This guide may seem fairly technical. Partly this is because I have a background in pure mathematics and this is how I learned the material, but partly it's just because encoding is cursed and complicated, and you will need to learn the things listed here in order to not make stupid mistakes.

Some sections contain some longer rants about stuff, most others don't. This is almost entirely based on the mood I was in when writing them.

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const ALLOCATIONS_TREE_INDENTATION = 16; // px
const AUTO_EXPAND_DEPTH = 3; // depth