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 Aug 29, 2015
Fix Yosemite's asymmetrical Time Machine menu icon
View README.md

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/TimeMachine.menu/Contents/Resources
  4. Replace the four TM*.pdf files with the ones found in this ZIP
@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))
@bfred-it
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)) {
$els = $('ELEMENTS-WITH-VH-UNITS');
updateHeight();//set instantly
$(window).on('orientationchange.vh-height-set', updateHeight);
@bfred-it
bfred-it / README.md
Last active Aug 29, 2015
Simple HTML5 forms cross-browser validation (UMD)
View README.md

bfr Form Validation

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

Usage

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
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 / slideshow.scss
Last active Aug 29, 2015
Automatic SCSS slideshow used on masseriagialli.it'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
bfred-it / CSS clip.md
Last active Aug 29, 2015
Sublime Text 2/3 snippet for the CSS "clip" property, for easier input
View CSS clip.md

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
bfred-it / README.md
Last active Aug 29, 2015
Frame tracker function (tell if two functions have been called in the same frame)
View README.md

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.

Example

Consider this code:

    setTimeout(function hello() { console.log('Logging "Hello"'); }, 10);
    setTimeout(function world() { console.log('Logging "World"'); }, 20);
@bfred-it
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
# https://gist.github.com/bfred-it/9690041
(* 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: http://i.imgur.com/6HRvuWx.png */
/*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.