Skip to content

Instantly share code, notes, and snippets.

View rcanepa's full-sized avatar

Renzo Canepa rcanepa

  • Santiago, Chile
View GitHub Profile
@rcanepa
rcanepa / color-conversion-algorithms.js
Created August 12, 2017 23:15 — 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
@rcanepa
rcanepa / get_enum_values.sql
Last active July 27, 2017 21:51
Get values from a PostgreSQL enum
-- Returns an array of all values
SELECT enum_range(NULL::my_enum_name)
-- Returns a row for each value
SELECT unnest(enum_range(NULL::my_enum_name))
@rcanepa
rcanepa / something.css
Created July 18, 2017 21:02
CSS debugging tricks
/* A trick to see the design's "skeleton" */
.someClass * {
background-color: rgba(100, 100, 100, 0.2);
}
/* Another trick */
*,
::before,
@rcanepa
rcanepa / notes.md
Last active June 21, 2017 23:53
How Webpack actually works
@rcanepa
rcanepa / .block
Last active June 11, 2017 04:00
line shape
license: mit
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
someObservable.retry(3)
consts tasks =
{
....{....5......2.......3...}
............{......5............4....3}
............................................{5...2...4}
.....................................................{...5}
}
@rcanepa
rcanepa / plugin.js
Last active May 21, 2017 02:09
Playing with ASTs (Babelv6)
export default function(babel) {
const { types: t } = babel;
return {
name: "consoleImproved",
visitor: {
CallExpression(path) {
if (path.node.callee.object && path.node.callee.object.name === "console") {
const parentFunction = path.findParent(t.isFunctionDeclaration);
const parentFunctionExpression = path.findParent(t.isFunctionExpression);
const Price = (props) => {
const price = props.children.toLocaleString('en', {
style: props.showSymbol ? 'currency' : undefined,
currency: props.showSymbol ? 'USD' : undefined,
maximumFractionDigits: props.showDecimals ? 2 : 0,
});
return <span className={props.className}>{price}</span>
};