Skip to content

Instantly share code, notes, and snippets.

View ifthenelse's full-sized avatar
🏎️
LIFE BE LIKE

Andrea Collet ifthenelse

🏎️
LIFE BE LIKE
View GitHub Profile
@ifthenelse
ifthenelse / setCSSClasses
Created July 9, 2012 09:47
A function to set CSS classes to an html element such as "first", "last", "odd", "even" and "active"
<?php
/* Sets classes such as "first", "last", "odd", "even" and "active"
* @param $articles An array of articles to count
* @param $index The index to watch for
* @param $currentArticle The index of the current article
* @return string
**/
function setCSSClasses($index = null, $articles = null, $currentArticle = null) {
@ifthenelse
ifthenelse / gist:3974067
Created October 29, 2012 15:08
CSS Cross-browser opacity
opacity: .75;
filter: alpha(opacity=75);
-ms-filter: "alpha(opacity=75)";
-khtml-opacity: .75;
-moz-opacity: .75;
@ifthenelse
ifthenelse / whichTransitionEvent.js
Last active December 16, 2015 12:18
Use modernizr to check CSS transitions events support: * 'WebkitTransition':'webkitTransitionEnd' (Chrome / Safari) * 'MozTransition':'transitionend' (Mozilla) * 'OTransition':'oTransitionEnd' (Opera) * 'transition':'transitionend' (Internet Explorer)
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'OTransition':'oTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
}
@ifthenelse
ifthenelse / favicon.php
Last active April 22, 2021 22:33
favicon html code for all browsers (got from http://www.sitepoint.com/favicon-a-changing-role/ )
<?php $favicon_path = "/docroot/img/ico/"; ?>
<!-- Default -->
<link rel="shortcut icon" href="<?php echo $favicon_path; ?>favicon.ico"/>
<!-- For IE6+ -->
<link rel="shortcut icon" href="<?php echo $favicon_path; ?><?php echo $favicon_path; ?>favicon.ico" type="image/x-icon">
<!-- For IE6+ -->
<link rel="shortcut icon" href="<?php echo $favicon_path; ?>favicon.ico">
/**
* This casper scipt checks for 404 internal links for a given root url.
*
* Usage:
*
* $ casperjs 404checker.js http://mysite.tld/
* $ casperjs 404checker.js http://mysite.tld/ --max-depth=42
*/
/*global URI*/
@ifthenelse
ifthenelse / fb_autogrowth.html
Last active December 22, 2015 03:29
Facebook autogrowth code for Facebook Tabs.
<div id="fb-root"></div>
<script type="text/javascript">
var goTo = true;
function goToLogIn() {
if (goTo) {
self.location = "{{ path('facebook_security_check') }}";
}
}
window.fbAsyncInit = function() {
FB.init({
@ifthenelse
ifthenelse / imgrollover.js
Created September 25, 2013 09:22
jQuery script to manage rollover effect on img elements with a '.hoverable' class and two images (one with -normal and one with -hover suffix)
// init rollovers on images
imgRollover: function() {
var $app = this;
$.each($app.$hoverable, function(index, val) {
var $this = $(this);
// if the hoverable object is <img>
if (typeof $this === 'object' && $this.is("img")) {
@ifthenelse
ifthenelse / regex-utils-st3
Created September 26, 2013 10:28
Useful regexp snippets for quick find/replace fixes on Sublime Text 2 and 3
// find all anchor tags without 'title' attribute
<a\s+((class|id|href|)="[^"]+"\s*)+/?>
// find all img tags without 'alt' attribute
<img\s+((width|height|border|class|id|src|usemap|hspace|vspace)="[^"]+"\s*)+/?>
@ifthenelse
ifthenelse / fb-batch-dl.html
Last active December 25, 2015 17:09
Script that lists the images of a Facebook user, separated by album, using OpenGraph API. Just provide the target Facebook user id. Original code by Nicola de Lazzari. Thanks to Enrico Vedovo.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Facebook batch photo download</title>
<meta name="description" content="This script will hopefully last longer than other apps. At lest until FB will change their damnd API again">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
var vimeoRegexp = /(?:https?\:)?\/\/(?:www\.|player\.)?vimeo.com\/(?:video\/|channels\/|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/;
var vimeoVideoUrl = "//player.vimeo.com/video/2243632";
var vimeoVideoArray = vimeoRegexp.regexp(vimeoVideoUrl);
var vimeoVideoID = vimeoVideoArray[3];