Skip to content

Instantly share code, notes, and snippets.

// Consider a "relative" pointer to some offset within
// a buffer with some base address.
struct RelativePtr {
void* base;
int offset;
}
// Now consider some operation to compute the relative address:
@paulirish
paulirish / what-forces-layout.md
Last active July 29, 2024 01:56
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
@kevinrobinson
kevinrobinson / circleci-frontend-walkthrough.md
Last active January 9, 2021 16:09
CircleCI frontend walkthrough

Hello!

This is a commentary and discussion from walking through what happens on startup in [https://github.com/circleci/frontend], looking at this SHA in December 2014: [https://github.com/circleci/frontend/commit/273558250040ce197e44e683d5528381f36c4eea].

The first part is a literal walkthrough, where I'm tracing my reading of how the code works. This is a way to check my understanding, since of course I don't have all of your context. And it's also a way to echo back to you how someone else might experience this code without that context. The second part is about asking questions, making suggestions, and exploring some paths for making it even more awesome. I also mixed in a few asides in the walkthrough part where I jump ahead a bit.

Doing this with colleagues has worked well for me as a way to do in-depth code reviews about more abstract design and architectural questions. The goal of the the first part is to clarify we're all looking at the same thing, which creates the space and shared understa

@palladin
palladin / gist:c5fca07b74da782832cb
Last active September 25, 2021 17:52
Parallel Streams Test
#time
#r "bin/Release/Streams.Core.dll"
open Nessos.Streams.Core
let data = [|1..10000000|] |> Array.map int64
#r "../../packages/FSharp.Collections.ParallelSeq.1.0/lib/net40/FSharp.Collections.ParallelSeq.dll"
@netshade
netshade / gist:3a237588e51124c6fc52
Created July 21, 2014 14:20
Thoughts About Data At Rest

So this thing has been happening a lot lately as I observe game developers talk about data. They have multiple phases to how data is dealt with, namely:

  • Data when it must be written to (designed)
  • Data when it is being read (played)

And they treat the data in very different ways. During the design phase, data is expressly flexible and transformable. Store it in XML? Dynamically allocate all the things? Objects whose properties can be discovered at runtime? All acceptable ideas, because efficiency isn't the /point/ during this phase.

But in the transition from design phase to play phase will traditionally have a baking step, wherein the data as designed is turned into a very efficient (and mechanically simple) representation. What was once a 2MB XML file is now a 200kb packed binary representation that can be mmap'd and read directly from structs.

The efficiency in this case isn't the thing I'm interested in, however. It's the guarantee of representation and the understanding that data as it enters

@JagCesar
JagCesar / .travis.yml
Last active April 29, 2016 15:26 — forked from johanneswuerbach/.travis.yml
Deploy to Testflight using Travis-CI
language: objective-c
before_script:
- chmod +x scripts/travis/add-key.sh
- chmod +x scripts/travis/remove-key.sh
- chmod +x scripts/travis/testflight.sh
- ./scripts/travis/add-key.sh
script: xctool -workspace [Workspace name].xcworkspace -scheme '[Scheme to use]' -configuration [Build configuration name] -sdk iphoneos7.1 CONFIGURATION_BUILD_DIR='~/build/' build
after_success:
- ./scripts/travis/testflight.sh
after_script:
@taumuon
taumuon / MonteCarloExoticOptions
Created April 25, 2014 20:52
Monte Carlo pricing of Exotic Options in F#
open MathNet.Numerics.Distributions
open MathNet.Numerics.Statistics
let callPayoff strike price = max (price - strike) 0.0
let europeanPayoff payoff assetPath = assetPath |> Seq.last |> payoff
let europeanCallPayoff strike assetPath = assetPath |> europeanPayoff (callPayoff strike)
let asianArithmeticMeanCallPayoff strike (assetPath:seq<float>) = assetPath.Mean() |> callPayoff strike
@kai-qu
kai-qu / monet.md
Created February 18, 2014 20:45
The most poetic description of a hardware random number generator I've ever read. From "What Painting Is" by James Elkins, pages 12-13. http://www.jameselkins.com/images/stories/jamese/pdfs/what-painting-is-2.pdf

But as I learned by trying to copy Monet’s paintings, that idea is completely mistaken (Colorplate 2). It is not possible to reproduce the effect of a Monet painting by jousting mechanically with the canvas, jabbing a dot of paint here and planting another one there, until the surface is uniformly puckered in Monet’s signature texture. A painter who does that will end up with a picture that looks soft and uninteresting, with a dull pattern of swirling circles like the ones left by some electric rug cleaners. A brush that’s loaded with paint and then pushed onto the canvas makes a circle, more or less, but Monet’s pictures do not have any circles in them. There is only one slightly rounded mark in this detail from one of his garden paintings—the blue patch at the lower right—and it’s rectangular, not circular at all. [The painting below is a different one.]

open System
open System.Globalization
open System.Json
open System.Collections.Generic
open ReadOnlyCollectionsExtensions
let (|JArray|JObject|JNumber|JBool|JString|JNull|) (o: JsonValue) =
match o with
| :? JsonArray as x ->
let values = (x :> JsonValue IList).AsReadOnlyList()
@mausch
mausch / gist:8227399
Created January 2, 2014 21:37
Erik Meijer quotes in Reactive Programming Coursera. I did not gather them, I merely copied this from https://class.coursera.org/reactive-001/forum/thread?thread_id=1356 to make them public.
"Hopefully the third answer is right; but who knows, maybe I made a mistake; I’m just a human, I can throw exceptions as well."
"I am waving my hands on purpose here, this is very spaghetti like code. And spaghetti is great as food, but not good as code."
"flatMap will allow us to focus on the happy path. flatMap will take care of all the noise. flatMap is the dolby for programmers."
"Great programmers write baby code"
"it's obviously correct"