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
@bfred-it
bfred-it / README.md
Last active Mar 28, 2019
OS X connection monitor
View README.md

Connection monitor

Note: if you need a simple connection icon, check out BitBar and its internet checker plugin.

This program notifies you when Internet goes down and when it comes back up.

It pings Google's DNS every 4 seconds; when a ping fails it quickly tries a few more times and switches to downtime mode. When Internet is available again, the cycle restarts.

Tools used

@bfred-it
bfred-it / TimelineLite.addDelay.js
Last active Dec 24, 2018
Method to add delays at any position in Greensocks TimelineLite and TimelineMax (Javascript GSAP)
View TimelineLite.addDelay.js
/**
* Add a delay at the end of the timeline (or at any label)
* @param {number} delay Seconds to wait
* @param {string} position Label name where to start the delay
*
* Usage: tl.addDelay(4); //easy!
*/
TimelineLite.prototype.addDelay = function (delay, position) {
var delayAttr;
if(typeof delay === 'undefined' || isNaN(delay)){
@bfred-it
bfred-it / action.js
Created Jul 20, 2012
Add class when leaving page
View action.js
//make sure downloads open in another page with target="_blank"
//"beforeunload" is fired any time a link is clicked.
//If the link points to a file to download, the user won't be actually leaving the page, but beforeunload will still have fired.
(function () {
var unload = {};
unload.init = function () {
//cache html element
unload.$html = $(document.documentElement);
@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
@bfred-it
bfred-it / Instructions
Last active Feb 9, 2018
YouTube "I'm Feeling Lucky" search engine for Chrome
View Instructions
Visit chrome://settings/searchEngines
Enter a name, like "YouTube direct"
Pick a keyword, like "y"
Paste this URL: http://www.google.com/search?q=%s+site%3Ayoutube.com&btnI=Im+Feeling+Lucky
Click [Done]
In the address bar, type your keyword followed by the video name, like: "y get lucky" (try it!)
View index.js
Promise.reject(1).catch(err => {
if (err instanceof Error) {
throw err; // Exception
}
// Rejection
}).catch(exitProcess)
@bfred-it
bfred-it / style.css
Created Jul 15, 2012
Facebook: Finally Readable (CSS)
View style.css
/* to be compressed via http://compressor.ebiene.de/*/
/*admin panel in page*/
#AdminTip,
.notification,
.preview,
.author,
.timestamp,
.uiHeader *,
@bfred-it
bfred-it / pop-out.js
Created Dec 17, 2014
Bookmarklet: Pop out the current window in a small, "mobile" window
View pop-out.js
javascript:window.open(document.location.href,''+Math.random(),'width=320,height=480,top='+(screen.height/2-480/2+Math.random()*100-50)+', left='+(screen.width/2-320/2+Math.random()*100-50))
You can’t perform that action at this time.