Skip to content

Instantly share code, notes, and snippets.

View couto's full-sized avatar
👽
Did you raid area 51?

Luís Couto couto

👽
Did you raid area 51?
View GitHub Profile
@couto
couto / curry-es6.js
Last active April 12, 2018 04:13
ES5 version of curry
// curry :: (* -> a) -> (* -> a)
const curry = (fn) => function cf(...args){
return (args.length >= fn.length) ?
fn(...args) :
(...newArgs) => cf(...[...args, ...newArgs])
};
const nameBuilder = function (firstName = "John", lastName = "Doe") {
console.log(firstName + " " + lastName);
};
nameBuilder();
@couto
couto / a.js
Last active February 8, 2016 20:33
What's the value being logged?
var hello = require('./hello.json');
hello.hello = 100;

Kirby + Patterns = <3

When I heard about Brad Frost's Patternlab for the first time at beyond tellerrand I was intrigued. The idea of splitting your design work for a website into simple modules or patterns isn't new and starts to become more and more of a standard. But organizing this into a very visual styleguide/patternlab seemed to make so much sense. Brad also introduced a very interesting approach with his separation of modules into categories, such as atoms, molecules and organisms.

I started porting Brad's patternlab app to Kirby, but it never really made it to something polished and it turned out for me after using it for Kirby's panel UI, that it's actually a pain in the ass to maintain such a pattern collection.

The problem of patternlab

The problem with such a styleguide or patternlab is that it exists next to the real thing. When you change something in your code base you also have to update the particular code for the pattern in patternlab. To be honest I went very quickly from being

@couto
couto / dropkick.sh
Created December 22, 2015 09:18
Detect and disconnect WiFi cameras and google glass https://julianoliver.com/output/log_2015-12-18_14-39
#!/bin/bash
#
# DROPKICK.SH
#
# Detect and Disconnect the DropCam and Withings devices some people are using to
# spy on guests in their home, especially in AirBnB rentals. Based on Glasshole.sh:
#
# http://julianoliver.com/output/log_2014-05-30_20-52
#
# This script was named by Adam Harvey (http://ahprojects.com), who also
{
"name": "tmp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --config webpack.conf.js"
},
"keywords": [],
"author": "",
@couto
couto / gulpfile.js
Last active November 25, 2015 15:53
gulp-eslint simple example
const gulp = require('gulp');
const eslint = require('gulp-eslint');
gulp.task('lint', function () {
return gulp.src(['**/*.js','!node_modules/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
@couto
couto / raspberry-pi_kodi_livestreampro_tv-portuguesa.md
Last active May 1, 2019 20:25
Raspberry Pi with Kodi, LiveStreamsPro and TV Portuguesa

Raspberry Pi with Kodi, LiveStreamsPro and TV Portuguesa

I'm currently testing OpenElec as a way of having Kodi running on a Raspberry Pi, I'm not a particular fan, but it seems to work fine.

  1. Download the OpenElec image file for the Raspberry Pi.
  2. Uncompress the downloaded file tar -xzf OpenELEC-Generic.x86_64-5.0.8.tar
  3. Follow the "Install the system to the SD card" instructions on the ArchLinux on a Raspberry Pi gist
  4. Download the ZIP from the Shani-08/ShaniXBMCWork
  5. Save the URL: http://pastebin.com/raw.php?i=s5ZyhaHB
@couto
couto / what-forces-layout.md
Last active September 19, 2015 10:55 — forked from paulirish/what-forces-layout.md
What forces layout/reflow in Chrome. 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()
// Kinda pseudo code
// This script will download and resize each image to half
// Because the images can be RRREAAALLY big
// the download and resize is done sequentially (in my case, inside a child_process)
// to ensure that memory is released after each image.
// We dont know how many images there are
let images = [
'https://flickr.com/photo/1',
'https://flickr.com/photo/2'