Skip to content

Instantly share code, notes, and snippets.

@pygy
pygy / combinators.js
Created February 20, 2018 12:18 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
@pygy
pygy / mithril-hyperscript.md
Created July 27, 2017 14:22 — forked from CarlMungazi/mithril-hyperscript.md
Understanding mithril's hyperscript function

Earlier this year at work we re-wrote an internal framework we used to create SPA e-learning courses. After briefly trying out React, Angular 2, Ember and Vue, we settled on mithril (https://mithril.js.org). If I were to compare it to the frameworks we tried out, I would say it's more like React but with a simpler, smaller codebase. By the way, if you like geeking out on code articles, the articles from mithril's old site have some real nuggets of gold (http://lhorie.github.io/mithril-blog/).

A few months after the re-write was done, I dug into mithril's codebase to gain a deeper understanding and this is what I found...

The main entry point into mithril's source code is the m() function, which is a hyperscript function that, according to the docs (https://mithril.js.org/hyperscript.html), represents an element in a mithril view. It's demonstrated below as:

m("div", {id: "box"}, "hello")
// equivalent HTML:
// <div id="box">hello</div>
@pygy
pygy / _grid-ie-calc.scss
Created June 4, 2017 21:34 — forked from robinloeffel/_grid-ie-calc.scss
Dynamic CSS Grid Items in Internet Explorer and Edge
/*
This mixin allows us use CSS grid without having to think about
what -ms-grid-row/-ms-grid-column we have to assign to a grid element
for it to properly work on Internet Explorer and Edge.
It takes three arguments, the last one of which is optional. Specify the
maximum amount of items you want to have in your grid, when they should
break to the next line and, if you like, a grid-gap of some sort.
@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()
@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

@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: {

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