Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / what-forces-layout.md
Last active April 28, 2024 14:20
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
@PJUllrich
PJUllrich / big-o.md
Last active April 28, 2024 14:19
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements
@sbose78
sbose78 / views.py
Created September 9, 2012 20:02
Uploading files in Django using pymongo
import os
import gridfs
from django.http import HttpResponse
from pymongo.connection import Connection
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.template import Context, RequestContext,loader
from bson.object import ObjectId
#uploading form including image/file
@DraTeots
DraTeots / ComPort over Network.md
Last active April 28, 2024 14:16
ComPort over Network
@KalleMacD
KalleMacD / TwineiOS
Last active April 28, 2024 14:14
How to make a Twine game into an iOS web-app
//This quick guide will show you how add an optional web-app (iOS) view to your Twine game!
//First you'll need to open up your Twine (.tws) file.
1. Add a new passage to your story and name it "script"
2. Enter the tags section and add the word "script"
3. Now, in the main body, add the code:
document.addEventListener('touchmove', function(e) {
e.preventDefault();
}, false);
@MM1212
MM1212 / InheritClasses.ts
Created December 20, 2023 19:47
Inherit any number of classes with some type-safety
type GrabConstructorParameters<T> = {
[K in keyof T]: T[K] extends new (...args: infer P) => any ? P : never;
}
// https://stackoverflow.com/a/50375286
type UnionToIntersection<U> =
(U extends any ? (x: U)=>void : never) extends ((x: infer I)=>void) ? I : never
type JoinConstructors<T extends (new (...args:any[]) => any)[]> =
new (...args: GrabConstructorParameters<T>) => UnionToIntersection<InstanceType<T[number]>>
@thomasheller
thomasheller / INSTALL.md
Last active April 28, 2024 14:08
Install Arch Linux in VirtualBox VM
@pbnj
pbnj / .tmux.conf
Last active April 28, 2024 14:08
Toggle-able Terminal in Tmux
bind-key -n 'C-\' run-shell -b ${HOME}/.local/bin/tmux-toggle-term
@josephg
josephg / 0dedict.py
Last active April 28, 2024 14:07
Apple dictionaries
# Thanks to commenters for providing the base of this much nicer implementation!
# Save and run with $ python 0dedict.py
# You may need to hunt down the dictionary files yourself and change the awful path string below.
# This works for me on MacOS 10.14 Mohave
from struct import unpack
from zlib import decompress
import re
filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data'
f = open(filename, 'rb')
import UIKit
final class TransitionDelegate: NSObject,
UIViewControllerTransitioningDelegate {
private let interactiveController = UIPercentDrivenInteractiveTransition()
private let duration = CATransaction.animationDuration()
func presentationController(forPresented presented: UIViewController,