Skip to content

Instantly share code, notes, and snippets.

View 5iDS's full-sized avatar
💭
@ease with the Source

Max 5iDS

💭
@ease with the Source
View GitHub Profile
@5iDS
5iDS / getDates
Created November 22, 2015 01:10
Get weeks of year for given period
Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf());
dat.setDate(dat.getDate() + days);
return dat;
};
// Source: http://stackoverflow.com/questions/497790
function convertDate ( d ) {
// Converts the date in d to a date-object. The input can be:
// a date object: returned without modification
@5iDS
5iDS / AutoUpdater
Created June 26, 2015 02:59
PHP Auto Updating Class
<?php
// Prevent loading this file directly and/or if the class is already defined
if ( ! defined( 'ABSPATH' ) || class_exists( 'WPGitHubUpdater' ) || class_exists( 'WP_GitHub_Updater' ) )
return;
/**
*
*
* @version 1.6
@5iDS
5iDS / center_crop_image
Created January 22, 2015 08:05
Center and crop images with a single line of CSS
img {
object-fit: cover;
}
@5iDS
5iDS / CSS3 Tooltips
Created December 29, 2014 09:52
CSS3 Tooltips
/**
* CSS3 Tooltips
* Created by Martin Ivanov
* http://wemakesites.net
*/
/* the tooltip will be applied to any element, containing data-title attribute */
[data-title]
{
position: relative;
@5iDS
5iDS / Crossbrowser RGBA
Created December 29, 2014 09:49
Crossbrowser RGBA and Prevention of Opacity Propagation
/**
* Crossbrowser RGBA and Prevention of Opacity Propagation
* Created by Martin Ivanov
* http://wemakesites.net
*/
.outer
{
position: absolute;
top: 24px;
function array_chunk(input, size, preserve_keys) {
// discuss at: http://phpjs.org/functions/array_chunk/
// original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
// improved by: Brett Zamir (http://brett-zamir.me)
// note: Important note: Per the ECMAScript specification, objects may not always iterate in a predictable order
// example 1: array_chunk(['Kevin', 'van', 'Zonneveld'], 2);
// returns 1: [['Kevin', 'van'], ['Zonneveld']]
// example 2: array_chunk(['Kevin', 'van', 'Zonneveld'], 2, true);
// returns 2: [{0:'Kevin', 1:'van'}, {2: 'Zonneveld'}]
// example 3: array_chunk({1:'Kevin', 2:'van', 3:'Zonneveld'}, 2);
@5iDS
5iDS / .htaccess
Created July 14, 2014 04:37
HTACCESSS Template
# Apache Configuration File
# (!) Using `.htaccess` files slows down Apache, therefore, if you have access
# to the main server config file (usually called `httpd.conf`), you should add
# this logic there: http://httpd.apache.org/docs/current/howto/htaccess.html.
# ##############################################################################
# # CROSS-ORIGIN RESOURCE SHARING (CORS) #
# ##############################################################################
@5iDS
5iDS / Wordpress SSL
Created July 12, 2014 04:36
redirect to SSL
<?php
function redirectTohttps() {
if($_SERVER['HTTPS']!=”on”) {
$redirect= “https://”.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header(“Location:$redirect”);
}
}
?>
@5iDS
5iDS / ww_2_non_www
Created March 19, 2014 02:20
Redirecting www to non-www with .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
@5iDS
5iDS / non_www_2_www
Created March 19, 2014 02:19
Redirecting non-www to www with .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]