Skip to content

Instantly share code, notes, and snippets.

Federico Brigante bfred-it

Block or report user

Report or block bfred-it

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
View index.js
Promise.reject(1).catch(err => {
if (err instanceof Error) {
throw err; // Exception
}
// Rejection
}).catch(exitProcess)
View README.md

work-cli

Personal launcher to start working in whatever directory you're into. Customize it as needed

$ work
# tries launching GitHub.app
# tries launching Sublime Text
# tries launching the build tool (npm run watch, gulp, grump in this order)
@bfred-it
bfred-it / bookmarklet.js
Last active Jun 7, 2016
Play videos inline on the iPhone (bookmarklet)
View bookmarklet.js
// to be flattened with http://chriszarate.github.io/bookmarkleter/
var s = document.createElement('script');
s.onload = function () {
[].forEach.call(document.querySelectorAll('video'), makeVideoPlayableInline);
};
s.src='https://rawgit.com/bfred-it/ffd71c642d2fcf4649b230bd71bc9a93/raw/fb39a59c458aeb49d882d81c9d4be2b3ae0b3b93/enabler.js';
document.head.appendChild(s);
@bfred-it
bfred-it / show-reddit-posts.js
Last active Feb 25, 2016
Bookmarklet: show current url posted on Reddit
View show-reddit-posts.js
// Create bookmarklet with: https://ted.mielczarek.org/code/mozilla/bookmarklet.html
var getPermalink = post => 'https://www.reddit.com'+post.data.permalink;
var getPermalinks = r => r.data.children.map(getPermalink);
var buildLink = url => {
var a = document.createElement('a');
a.href = url;
a.textContent = url.match(/\/r\/[^/]+/) && url.match(/\/r\/[^/]+/)[0] || url;
a.style.display = 'block';
return a;
};
@bfred-it
bfred-it / header.js
Last active May 21, 2016 — forked from dominikwilkowski/header.js
Doc strange outline love (jQuery-free)
View header.js
//detecting tab key press
document.body.addEventListener('keydown', function detector (e) {
var keyCode = e.keyCode || e.which;
if(keyCode == 9) {
console.log( 'Tab detected' );
document.documentElement.className += ' is-keyboarduser';
document.body.removeEventListener('keydown', detector);
@bfred-it
bfred-it / moved.md
Last active Dec 26, 2016
If you preventDefault on clicks, wrap the handler with this
@bfred-it
bfred-it / git-get-git-put.md
Created Jun 30, 2015
Use git get and put instead of git pull and push
View git-get-git-put.md

As explained on Don't Be Scared of git rebase, git fetch+rebase is a better alternative to git pull; unfortunately it's not as concise.

git get

From now on, use git get instead of git pull, a custom command that does this:

# get data from remote
git fetch origin
# rebase the remote branch with the same name as local
You can’t perform that action at this time.