Skip to content

Instantly share code, notes, and snippets.

Fran Herrero franher

Block or report user

Report or block franher

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@franher
franher / license-adder.sh
Created Nov 23, 2017
Add a license header for all the js files under ./src folder (recursively)
View license-adder.sh
#!/bin/bash
for i in $(find ./src -name '*.js' );
do
if ! grep -q Copyright "$i"
then
echo "$i"
cat license-header.txt "$i" > "$i".new && mv "$i".new "$i"
fi
done
@franher
franher / fs-stat-custom-promisify.js
Created Jun 18, 2017
Custom fs.stat promisify as identity function
View fs-stat-custom-promisify.js
const util = require('util');
const fs = require('fs');
/**
* identity function f(v) -> v
* Using ES6 Promise
*
* async/await approach:
* async function identityAsync(v) {
* return v;
@franher
franher / fs-read-promisify-test.js
Created Jun 18, 2017
fs.read promisified version
View fs-read-promisify-test.js
const { promisify } = require('util');
const { read, open } = require('fs');
const readPromisified = promisify(read);
const openPromisified = promisify(open);
const expected = Buffer.from('xyz\n');
const buffer = Buffer.allocUnsafe(expected.length);
openPromisified('x.txt', 'r').then(fd => {
You can’t perform that action at this time.