Skip to content

Instantly share code, notes, and snippets.

View name-k's full-sized avatar
💢

Mykhailo Pronin name-k

💢
  • Nuix
  • Homeless
View GitHub Profile
.rgba(@colour, @alpha) {
@alphaColour: hsla(hue(@colour), saturation(@colour), lightness(@colour), @alpha);
@ieAlphaColour: argb(@alphaColour);
background-color: @colour; // Fallback for older browsers
// IE hacks
zoom: 1; // hasLayout
background-color: transparent\9;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=@{ieAlphaColour}, endColorstr=@{ieAlphaColour})"; // IE 8+
@font-face {
font-family: 'font_name';
src: url('font_name.eot');
src: local('font_name'), local('font_name'),
url('font_name.eot?#iefix') format('embedded-opentype'),
url('font_name.woff') format('woff');
}
//============================================================
//
// linear-gradient
//
// @param dir : top, left, 90deg
// @param start-color : #000, rgba(255,255,255,0.5)
// @param end-color : #000, rgba(255,255,255,0.5)
//
// NOTE: The direction for the IE gradient is automagically
// worked out for you based either on the direction or the
$(function() {
// To keep track of how many images have loaded
var loaded = 0;
// Let's retrieve how many images there are
var numImages = $("img").length;
// Let's bind a function to the loading of EACH image
$("img").load(function() {
// One more image has loaded
++loaded;
// Only if ALL the images have loaded
// from http://stackoverflow.com/a/11381730/989439
function mobilecheck() {
var check = false;
(function(a){if(/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|
@name-k
name-k / .htaccess - Block Access to Hidden Files and Directories.htaccess
Created December 22, 2013 09:46
Block Access to Hidden Files and Directories We try to push our code to productions servers without hidden files and directors, like our revision system directors, but that doesn't always happen. This snippet prevents those files from being accessible:
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>
@name-k
name-k / .htaccess - Compress Served Files by MIME Type.htaccess
Created December 22, 2013 09:46
Compress Served Files by MIME Type There are a number of file types we know we want compressed on the way out, and with mod_deflate, we can direct the server to do so:
<IfModule mod_deflate.c>
# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
# as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
@name-k
name-k / .htaccess - Allow Cross-Domain Fonts with CORS.htaccess
Last active January 1, 2016 02:39
Allow Cross-Domain Fonts with CORS I had no idea how big of a response I'd have when I first posted about cross-domain fonts. They're a big, confusing problem for people but HTML5BP also has a solution:
<IfModule mod_headers.c>
<FilesMatch "\.(eot|otf|ttc|ttf|woff)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
@name-k
name-k / .htaccess - Allow Cross-Domain Images with CORS.htaccess
Created December 22, 2013 09:47
Allow Cross-Domain Images with CORS Images are usually cool to serve from a different domain but if you want access to their data with canvas, you're in trouble. This snippet allows you to get raw image data via canvas:
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch "\.(cur|gif|ico|jpe?g|png|svgz?|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
@name-k
name-k / .htaccess - Expires.htaccess
Created December 22, 2013 09:48
Expires Expires headers are an awesome way of setting long cache expirations on your files. Setting long expiration times on your static files (CSS, images, JavaScript, etc.) can be a massive performance boost! You may be asking yourself about updating your files and issues with new file versions not being update. Add a querystring to your file …
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"