Skip to content

Instantly share code, notes, and snippets.

View justinmk's full-sized avatar
💦

Justin M. Keyes justinmk

💦
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 24, 2024 12:47
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@tarruda
tarruda / nvim-terminal-edit.py
Last active September 4, 2020 05:32
Edit file in host Neovim instance from a :terminal buffer
#!/usr/bin/env python
"""Edit a file in the host nvim instance."""
import os
import sys
from neovim import attach
args = sys.argv[1:]
if not args:
print "Usage: {} <filename> ...".format(sys.argv[0])
@tarruda
tarruda / snake.py
Last active June 11, 2021 00:01
snake.py
# Snake for Neovim! Adapted from https://gist.github.com/sanchitgangwar/2158084
# To install, create a ~/.vim/rplugin/python/snake.py file with this
# code, then run `nvim -c 'UpdateRemotePlugins' -c 'q'` from a shell.
#
# Make sure you have read the internal help explaining how to setup python
# host for external plugins(:help nvim-python)
#
# To start a new game, use the `:SnakeStart` command on an empty buffer(uses 80
# columns and 20 rows)
from threading import Thread, Lock
@tarruda
tarruda / .bashrc
Last active August 29, 2015 14:00
Shell functions for working with github pull requests
# Start working on a pull request, this requires a .git/user-repo file
# containing the string "user/repository"
pr() {
if [[ ! -r .git/user-repo ]]; then
echo "Need to setup user/repo" >&2
return 1
fi
local user_repo=$(< .git/user-repo)
local pr_num=$1
if [[ -z $pr_num ]]; then
@anderser
anderser / convert.py
Last active January 3, 2024 08:52
Convert from NodeXL (via GraphML-format) to D3-ready json for force layout while adding modularity groups (communities) as attribute to nodes. Useful for coloring nodes via modularitygroup attribute. Requires networkx and python-louvain. First export as GraphML file from your NodeXL-sheet. Then run: >>> python convert.py -i mygraph.graphml -o ou…
#!/usr/bin/env python
import sys
import argparse
import networkx as nx
import community
from networkx.readwrite import json_graph
def graphmltojson(graphfile, outfile):
@zclancy
zclancy / Common.cs
Created July 17, 2012 15:08
A simple console application for testing Lync Group Chat SDK. Command line parameters build the message, and specify the chat room. NDesk.Options is used for command line argument parsing.
using System;
using System.Configuration;
using System.Net;
using Microsoft.Rtc.Collaboration;
using Microsoft.Rtc.Collaboration.GroupChat;
using Microsoft.Rtc.Signaling;
namespace GroupChat
{
public static class Common