Skip to content

Instantly share code, notes, and snippets.

@pygy
pygy / what-forces-layout.md
Created February 9, 2016 23:35 — forked from paulirish/what-forces-layout.md
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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
function innerCurry(f, args, context) {
return f.bind.apply(f, [context].concat([].slice.call(args)))
}
function add(a, b, c) {
if (arguments.length < 3) return innerCurry(add, arguments)
return a + b + c
}
add(1).lenght === 2
@pygy
pygy / color-conversion-algorithms.js
Last active September 10, 2015 07:14 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation

Broad summary:

  • Elections are on Sunday 5th, July.

  • This is the first time an e-voting system is used in Buenos Aires city.

  • Researchers and IT professionals had been warning about potential issues with the way the system works (short summary at the end).

  • Government officials have said on-record that the machines are only "printers with no memory". There is video evidence that the machines are in fact standard PCs running Ubuntu. USB and VGA ports are located behind a lid on the side. See videos here: https://storify.com/mis2centavos/el-sistema-de-voto-electronico-usado-en-caba

/*\
For now, back to the stable if less featureful v4
TODO: implement http://stackoverflow.com/questions/4845762/onload-handler-for-script-tag-in-internet-explorer
for old ie compatiblity (where script.onload doesn't fire).
`{loading, element} = mithrilLoader(libs::Arrary [, m::mithril])`
where `libs` is an array of strings and array:
@pygy
pygy / widget.js
Last active August 29, 2015 14:21 — forked from gilbert/widget.js
Mithril + j2c
Widget = {
styles: j2c.scoped({
title: {
font_size: '3rem',
"&:before":{
color: "#888",
content: "#"
}
},
content: {
@pygy
pygy / mithril.login_redirect.md
Last active March 23, 2019 16:51
Mithril Login redirect by Barney Carol

Taken from https://gitter.im/lhorie/mithril.js?at=553bdd1763c55be30636a16b in case it disappeared.

@barneycarol said:

[...] FWIW you can overcome a lot of apparent limitations in m.route by reinitialising m.route when things change

@tobscure said:

interesting, examples?

@barneycarol said:

Well I use it when authentication status changes

// This is evolved into j2c: a JavaScript to CSS compiler
// see https://github.com/pygy/j2c

Experimental Generation of Interpersonal Closeness

Instructions to Subjects Included With Task Slips Packet

This is a study of interpersonal closeness, and your task, which we think will be quite enjoyable, is simply to get close to your partner. We believe that the best way for you to get close to your partner is for you to share with them and for them to share with you. Of course, when we advise you about getting close to your partner, we are giving advice regarding your behavior in this demonstration only, we are not advising you about your behavior outside of this demonstration.

In order to help you get close we've arranged for the two of you to engage in a kind of sharing game. You're sharing time will be for about one hour, after which time we ask you to fill out a questionnaire concerning your experience of getting close to your partner.

You have been given three sets of slips. Each slip has a question or a task written on it. As soon as you both finish reading these instructions, you should