Skip to content

Instantly share code, notes, and snippets.

View icodesido's full-sized avatar

Ivan icodesido

View GitHub Profile
@icodesido
icodesido / css-long-words
Created October 29, 2015 12:35
Breaking up long words
.hyphenate {
overflow-wrap: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@icodesido
icodesido / git-setup
Created October 21, 2015 10:54
Git init local to server
1- Create a bare git repo in the server
git init --bare
2- Turn your local project into a git project
git init
3- Set the remote destination in your local git config file
[remote "origin"]
url = ssh://skygo@10.64.136.58/var/www/html/skystore
fetch = +refs/heads/*:refs/remotes/origin/*
@icodesido
icodesido / lazy-loading
Created October 20, 2015 13:44
Lazy loading images
var loadImageOnScrollIntoView = function(img) {
var imgPos = img.getBoundingClientRect(),
src = img.getAttribute('data-src');
window.addEventListener('scroll', function loadImgWhenVisible() {
return window.scrollY >= (imgPos.top - window.innerHeight) ? (img.src = src, window.removeEventListener('scroll', loadImgWhenVisible)) : false;
});
};
Array.apply(null, document.querySelectorAll('img')).forEach(function(e) {
loadImageOnScrollIntoView(e);
@icodesido
icodesido / modern clearfix
Created January 30, 2015 12:27
Best clearfix?
.clearfix {
&:before,
&:after {
content: "";
display: table;
}
&:after { clear: both; }
}
@icodesido
icodesido / SASS @ content
Created January 27, 2015 11:51
SASS @content example
@mixin cont {
background-color: black;
color: white;
@content;
}
div {
@include cont {
font-size: 12px;
font-style: italic;
@icodesido
icodesido / Sass Overloaded Args
Last active August 29, 2015 14:14
Sass overloading arguments
@mixin pad ($pads...) {
padding: $pads;
}
.one {
@include pad(20px);
}
.two {
@include pad(10px 20px);
}
@icodesido
icodesido / Mixin example
Last active August 29, 2015 14:14
Sass mixin with arguments and default value from variable
$base-color: orange;
@mixin headline($size, $color: $base-color) {
color: $color;
font-size: $size;
}
h1 {
@include headline(12px);
}
@icodesido
icodesido / SASS mixins
Created November 17, 2014 12:38
Essential SASS mixins
1 - BOX SIZING
@mixin box-sizing($type)
{
-webkit-box-sizing:$type;
-moz-box-sizing:$type;
box-sizing:$type;
}
div {
@include box-sizing(border-box);
@icodesido
icodesido / Reduce to stop Abuse
Created October 27, 2014 12:58
Instead of the double array conundrum, use a memo and reduce.
// abuse
var orig = [...];
var stuff = [];
_.each(orig, function (item) {
var t = // do something to item
// Mutate somebody else's thing
stuff.push(t);
};
// reduce
@icodesido
icodesido / JSON toJSON
Created October 27, 2014 12:41
toJSON as a method in an object changes the behaviour of JSON
var obj = {
foo: 'foo',
toJSON: function () {
return 'bar';
}
};
JSON.stringify(obj); // '"bar"'
JSON.stringify({x: obj}); // '{"x":"bar"}'