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 /
Last active Aug 29, 2015
Fix Yosemite's asymmetrical Time Machine menu icon

The asymmetrical Time Machine menu icon in Yosemite was bugging me, so I fixed it.

Icon comparison

Here's how to do it:

  1. Open Finder
  2. Press ⌘⇧G
  3. Go to /System/Library/CoreServices/Menu Extras/
  4. Replace the four TM*.pdf files with the ones found in this ZIP
bfred-it / pop-out.js
Created Dec 17, 2014
Bookmarklet: Pop out the current window in a small, "mobile" window
View pop-out.js,''+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))
bfred-it / VH-units-setter.js
Created Nov 22, 2014
Fix Android variable VH units (when the browser's bar disappears vh change)
View VH-units-setter.js
$(function () {
var $els;
var updateHeight = function () {
$els.css('height', ''); // reset previously-set height
$els.height($els.height());// set the current height in px
if (/android/i.test(navigator.userAgent)) {
updateHeight();//set instantly
$(window).on('orientationchange.vh-height-set', updateHeight);
bfred-it /
Last active Aug 29, 2015
Simple HTML5 forms cross-browser validation (UMD)

bfr Form Validation

Make HTML5 form validation cross-browser and with custom callbacks.


Create an HTML form with the correct attributes to enable the HTML Form validation (type, pattern and required) and then call bfrFormValidation.setup on the form(s) that need to be validated.

The three callbacks, if specified, will be called when validation is not met or met again.

bfred-it /
Last active Mar 28, 2019
OS X connection monitor

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 / slideshow.scss
Last active Aug 29, 2015
Automatic SCSS slideshow used on's homepage
View slideshow.scss
$images-count: 4;
$slideshow-duration: 6;
$slideshow-percentage-per-slide: 100/$images-count;
$slideshow-slides-overlap: $slideshow-duration/($images-count+1)+1;
.slideshow {
overflow: hidden;
position: relative;
height: 400px;
z-index: 0;
background-color: $color-golden;
bfred-it / CSS
Last active Aug 29, 2015
Sublime Text 2/3 snippet for the CSS "clip" property, for easier input
View CSS

This snippet will help you define the clip values in order:

  • top
  • left
  • height
  • width

If you're using SASS (or maybe LESS) that's it. Otherwise you will have to do some easy math in place:

  • height+top
  • width+left
bfred-it /
Last active Aug 29, 2015
Frame tracker function (tell if two functions have been called in the same frame)

Frame tracker

This code will mark each frame and it will make it easier to pin down console.logs being called in the same frame—intended as in frames per second, not html frames.


Consider this code:

    setTimeout(function hello() { console.log('Logging "Hello"'); }, 10);
    setTimeout(function world() { console.log('Logging "World"'); }, 20);
bfred-it / duck-itunes-volume.scpt
Last active Aug 29, 2015
Duck iTunes' volume (lower volume and then raise it again) with a keyboard shortcut
View duck-itunes-volume.scpt
(* Duck iTunes' volume (lower volume and then raise it again) *)
(* Instructions:
- Create a service with Automator
- Add the "Run AppleScript" action
- Paste this in
- Save
- Open System Preferences > Keyboard > Shortcuts > Services
- Find what you just created
View notifica-per-pagamento.php
<?php /*screenshot: */
/*visibile anche sul front end, se ha effettuato l'accesso*/
add_action( 'wp_before_admin_bar_render', 'add_invoice_to_admin_bar' );
function add_invoice_to_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'id' => 'pay_invoice',
'title' => '<span style="background: red;color:white;display:block;">Il pagamento della fattura 19 è in attesa da Novembre. Paga <strong style="font-weight:bold">oggi</strong> con PayPal o tramite bonifico.</span>',
'href' => '{Link per pagamento tramite paypal}'
You can’t perform that action at this time.