Skip to content

Instantly share code, notes, and snippets.

View icodesido's full-sized avatar

Ivan icodesido

View GitHub Profile
$(function(){
$(window).on('scroll', function(){
console.log($(this).scrollTop());
});
});
@icodesido
icodesido / console-tricks
Created March 15, 2017 12:21
Nifty Console Tricks
// Turn content editable
document.body.contentEditable=true
// Time function execution
console.time('myTime'); //Starts the timer with label - myTime
for(var i=0; i < 100000; i++){
2+4+5;
}
@icodesido
icodesido / fav-icons-html
Created March 3, 2017 13:07
All fav icons
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
@icodesido
icodesido / smooth-scrolling
Created March 3, 2017 11:40
Smooth scrolling Techniques
//CSS
body {
scroll-behavior: smooth;
}
//JS
<nav>
<a href="#profile">Profile</a>
<a href="#writing">Writing</a>
<a href="#presentations">Presentations</a>
@icodesido
icodesido / clearfix.css
Created March 2, 2017 17:04
Micro Clearfix hack
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
@icodesido
icodesido / tooltip.css
Created March 2, 2017 17:02
Tool tips in CSS
.tooltip-toggle {
cursor: pointer;
position: relative;
//Tooltip text container - above element
//You can adjust the position to make the container appear below or beside the element
&::before {
background-color: #000;
border-radius: 5px;
color: #fff;
@icodesido
icodesido / split-letters.js
Created February 17, 2017 10:30
Split a sentence into letters and wrap them in a span
// Go through a sentence, wrap its characters with spans
function setUpCharacters() {
var $sentences = $('.sentence');
// Run for each sentence
$sentences.each(function() {
var $sentence = $(this);
var newContent = '';
// Go through all characters of the sentence
@icodesido
icodesido / filter-homogeneous-array.js
Created November 2, 2016 19:47
Filter homogeneous array
let filterHomogenous = a => a.filter(b => b.length > 0 && b.every(e => typeof e == typeof b[0]));
var filterHomogenous = function (a) {
return a.filter(function (b) {
if(b.length > 0) {
return b.every(function (e) {
return typeof e === typeof b[0];
});
}
});
@icodesido
icodesido / nodeList Iteration
Created November 1, 2016 14:13
Node List iteration
var divs = document.querySelectorAll('div');
Array.prototype.forEach.call(divs, function (i) {
var elem = i;
console.log(elem.innerHTML);
});
@icodesido
icodesido / pure-css-loaders.scss
Created October 19, 2016 12:17
Pure css loaders
$base-line-height: 24px;
$white: rgb(255,255,255);
$off-white: rgba($white, 0.2);
$spin-duration: 1s;
$pulse-duration: 750ms;
@keyframes spin {
0% {
transform: rotate(0deg);
}