Skip to content

Instantly share code, notes, and snippets.

//
// Swizzle.swift
// RouterTester
//
// Created by Ivan Bruel on 17/05/2017.
// Copyright © 2017 Unbabel. All rights reserved.
//
import Foundation
import ObjectiveC
@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
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
@enkore
enkore / gist:14f5b53f6e302fa1baa1
Last active April 1, 2022 16:04
C++ variadic template to make C-style callbacks for arbitrary member functions
#include <utility>
#include <iostream>
/**
* Trampolines to methods for C-style callbacks.
*
* The void* / callback data is the instance you want the method
* called on.
*/
template<typename T, typename ...Types>
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@neonichu
neonichu / implementationWithBlock.swift
Created September 29, 2014 08:17
How to use imp_implementationWithBlock in Swift
import Foundation
import ObjectiveC.runtime
let myString = "foobar" as NSString
println(myString.description)
let myBlock : @objc_block (AnyObject!) -> String = { (sself : AnyObject!) -> (String) in
"✋"
}
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@armstrongnate
armstrongnate / basic-auth.swift
Created July 20, 2014 21:45
HTTP Basic Authentication using NSURLSession in swift
import Foundation
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let userPasswordString = "username@gmail.com:password"
let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding)
let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(nil)
let authString = "Basic \(base64EncodedCredential)"
config.HTTPAdditionalHeaders = ["Authorization" : authString]
let session = NSURLSession(configuration: config)
@staltz
staltz / introrx.md
Last active May 6, 2024 01:44
The introduction to Reactive Programming you've been missing
@gshrikant
gshrikant / uart.c
Last active November 16, 2022 10:19
Routines for asynchronous UART communication on the ATMega328P
/*
* uart.c
*
* Asynchronous UART example tested on ATMega328P (16 MHz)
*
* Toolchain: avr-gcc (4.3.3)
* Editor: Eclipse Kepler (4)
* Usage:
* Perform all settings in uart.h and enable by calling initUART(void)
* Compile:
@noelboss
noelboss / page_tsconfig.txt
Created November 21, 2013 14:18
How to configure gridelements for Typo3 purely with TypoScript and TSconfig and thus living in files. Based on this article: http://www.networkteam.com/blog/post/gridelements-professionell-nutzen.html
# Page TSConfig:
tx_gridelements.setup {
# ID of Element
1 {
title = Two Columns
config {
colCount = 2
rowCount = 1
rows {
1 {