Skip to content

Instantly share code, notes, and snippets.

View fregante's full-sized avatar

Federico Brigante fregante

View GitHub Profile
@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 / 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 / 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
<?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 / 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"
}
@fregante
fregante / readme.md
Created December 6, 2013 04:02
TweenLite.disperseTo(): a plugin to randomize values

Sometimes we overcomplicate things unnecessarily. I realized it after I wrote this plugin.
Twenty-nine lines to be able to write this:

TweenLite.disperseTo(elements, 1, {x:100}, {x:5}); //this means: animate elements.x to 100±5

instead of this:

for(var i = 0, l = elements.length; i < l; i++){
  TweenLite.to(elements[i], 1, {x: 100 - 5 + 10*Math.random() });
}
@fregante
fregante / element-rotation-with-mouse.js
Last active December 27, 2015 14:09
Quick way to rotate any element on a page just by moving the mouse around. Good for testing
var elementStyle = document.querySelector('SELECTOR HERE').style;
document.addEventListener('mousemove', function (e) {
var transform = 'rotateX('+e.pageY+'deg) rotateY('+e.pageX+'deg)';
elementStyle.webkitTransform = transform;
elementStyle.transform = transform;
}, false);
@fregante
fregante / TimelineLite.addDelay.js
Last active December 24, 2018 11:53
Method to add delays at any position in Greensocks TimelineLite and TimelineMax (Javascript GSAP)
/**
* 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)){
@fregante
fregante / Instructions
Last active June 26, 2022 14:45
YouTube "I'm Feeling Lucky" search engine for Chrome
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!)
@fregante
fregante / dabblet.css
Created October 22, 2012 12:56
CSS transition after animation
/**
* CSS transition after animation
*/
div {
transition: transform 1s;
}
div:hover {
transform: rotate(45deg);
}
div:active {