Skip to content

Instantly share code, notes, and snippets.

View fregante's full-sized avatar

Federico Brigante fregante

View GitHub Profile
@fregante
fregante / Emmet.sublime-settingsJSON
Created March 13, 2014 04:19
Use this setting to disable Emmet's CSS autocompletion
{
"disable_tab_abbreviations_for_regexp": "source\\.s?css"
}
<?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}'
@fregante
fregante / duck-itunes-volume.scpt
Last active August 29, 2015 13:57
Duck iTunes' volume (lower volume and then raise it again) with a keyboard shortcut
# 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
@fregante
fregante / README.md
Last active August 29, 2015 14:02
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.

Example

Consider this code:

    setTimeout(function hello() { console.log('Logging "Hello"'); }, 10);

setTimeout(function world() { console.log('Logging "World"'); }, 20);

@fregante
fregante / CSS clip.md
Last active August 29, 2015 14:02
Sublime Text 2/3 snippet for the CSS "clip" property, for easier input

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
@fregante
fregante / slideshow.scss
Last active August 29, 2015 14:04
Automatic SCSS slideshow used on masseriagialli.it's homepage
$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;
@fregante
fregante / README.md
Last active August 29, 2015 14:10
Simple HTML5 forms cross-browser validation (UMD)

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.

@fregante
fregante / README.md
Last active August 29, 2015 14:12
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/TimeMachine.menu/Contents/Resources
  4. Replace the four TM*.pdf files with the ones found in this ZIP
@fregante
fregante / gist:2077913
Created March 18, 2012 17:19
Get popup player from any embedded Flash video
//Click on the closest parent element of a video to have it popped out and the main window closed
(function (css, int, d, s) {
d.body.appendChild(s = document.createElement('style'));
s.innerHTML = ':hover{border-left:3px solid papayawhip;}';
d.body.onclick = function (e) {
var popd,
v = e.srcElement.querySelectorAll('embed,object,iframe')[0] || d.querySelectorAll('embed,object,iframe')[0],
w = int(css(v).width) || 400,
h = int(css(v).height) || 300,
pop = window.open(d.location.href,''+Math.random(),'height='+h+',width='+w),
@fregante
fregante / gist:2768880
Created May 22, 2012 12:57
Minisito WordPress multilingua
<?php
/*
Struttura del sito:
• home <- home del sito italiano
• chi siamo
• contatti
• english home <- home del sito inglese (id: 15)
• • about us <- sottopagina
• • contacts <- sottopagina