Skip to content

Instantly share code, notes, and snippets.

View fregante's full-sized avatar

Federico Brigante fregante

View GitHub Profile
@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
@fregante
fregante / gist:2946234
Created June 18, 2012 00:53
<button> css reset, now you can stop using <a>
button{
display: inline-block;
cursor: pointer;
color: inherit;
padding: inherit;
border: none;
background: inherit;
box-sizing: content-box;
font: inherit;
-webkit-appearance: none;
@fregante
fregante / style.css
Created July 15, 2012 03:08
Facebook: Finally Readable (CSS)
/* to be compressed via http://compressor.ebiene.de/*/
/*admin panel in page*/
#AdminTip,
.notification,
.preview,
.author,
.timestamp,
.uiHeader *,
@fregante
fregante / action.js
Created July 20, 2012 01:36
Add class when leaving page
//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);
@fregante
fregante / gist:3379426
Created August 17, 2012 14:51
Switch CSS background instead of resizing it. With media queries
html{
background: url(res/bg/1280.jpg) fixed center black;
}
@media only screen and (min-width:1281px),
only screen and (min-height:801px) {
html{ background-image: url(res/bg/1366.jpg); }
}
@media only screen and (min-width:1367px),
only screen and (min-height:855px) {
html{ background-image: url(res/bg/1440.jpg); }
@fregante
fregante / gist:3762133
Created September 21, 2012 15:21
Replace <html>'s "no-js" class with "js"
document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/, 'js');
@fregante
fregante / gist:3865283
Created October 10, 2012 12:25
Check for scrollbar visibility and load jScrollPane if scrollbars are visible
//This example requires YepNope or Modernizr.load (which are the same) and jQuery
var customScroll = (function () {
var customScroll = {};
customScroll.selector = ".entry-gallery, .entry-main";
customScroll.init = function () {
try {
(yepnope || Modernizr.load)({
@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 {
@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!)