Skip to content

Instantly share code, notes, and snippets.

View nucliweb's full-sized avatar

Joan León nucliweb

View GitHub Profile
/**
* fullscreenify()
* Stretch canvas to size of window.
*
* Zachary Johnson
* http://www.zachstronaut.com/
*
* See also: https://gist.github.com/1178522
*/
@nucliweb
nucliweb / gist:b2d3c202ab81202336b6
Created December 1, 2014 10:01
ViewportDetect(element)
function g(el) {
var rect = el.getBoundingClientRect();
return rect.bottom > 0 && rect.top < (window.innerHeight || document.documentElement.clientHeight);
}
// JavaScript hasClass, addClass, removeClass
//source: http://www.avoid.org/?p=78
function hasClass(el, name) {
return new RegExp('(\\s|^)'+name+'(\\s|$)').test(el.className);
}
function addClass(el, name)
{
if (!hasClass(el, name)) { el.className += (el.className ? ' ' : '') +name; }
@nucliweb
nucliweb / CSSAnimationEvents
Created December 8, 2014 13:15
CSS Animation Events
//---------------------------------------------------------------------------
// var anim = d.querySelector('.buy .fade-out'),
// PrefixedEvent(anim, 'AnimationEnd', function(){
// ...
// });
var pfx = ["webkit", "moz", "MS", "o", ""];
function PrefixedEvent(element, type, callback) {
for (var p = 0; p < pfx.length; p++) {
if (!pfx[p]) type = type.toLowerCase();
element.addEventListener(pfx[p]+type, callback, false);
# For SCSS-Lint v0.31.0
linters:
BangFormat:
enabled: true
space_before_bang: true
space_after_bang: false
BorderZero:
@nucliweb
nucliweb / mobilecheck.js
Created January 26, 2015 12:45
mobilecheck()
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( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|j
@nucliweb
nucliweb / isMobile.js
Created January 26, 2015 13:26
isMobile
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
@nucliweb
nucliweb / gist:5910ffd220008095fa87
Created January 26, 2015 21:47
Javascript: Convert arguments to Array
function myFn(/* any number of arguments */) {
var args = Array.prototype.slice.call(arguments);
// or [].slice.call(arguments)
args.forEach(function(arg) {
// do something with args here
});
}
@nucliweb
nucliweb / Git.md
Last active July 29, 2016 16:31
Git Tips

Git notes

git init                          <-- Create repo

git add .                         <-- Add change to
git commit -m "Message"          <-- Commit to repo
git commit -m "Message" <files>  <-- Commit to repo
git commit -am "Message"         <-- Add files & Commit to repo
git commit -a --amend             <-- Add change to Commit, option to change de description of Commit