Skip to content

Instantly share code, notes, and snippets.

View juanbrujo's full-sized avatar
:octocat:

Jorge Epuñan juanbrujo

:octocat:
View GitHub Profile
@juanbrujo
juanbrujo / README.md
Last active August 29, 2015 14:23
createElement JavaScript function

#createElement(element,attribute,inner);

use:

createElement("tag","[attr:val][attr:val]",[element1,"some text",element2,element3,"or some text again :)"]);

basic:

@juanbrujo
juanbrujo / README.md
Last active August 29, 2015 14:22
Vanilla JavaScript useful variables (almost jQuery)

#Vanilla JavaScript useful variables (almost jQuery)

Tests: JSBin

Test 1: 1 element (ID)

$('#hola').style.color = 'red';

Test 2: 2 elements (selector)

@juanbrujo
juanbrujo / fireonceonscroll.js
Created June 8, 2015 19:18
fire once while listening to the scroll event
var elem = document.querySelector('#video');
var fired = false;
window.addEventListener('scroll', function(e){
if (document.body.scrollTop >= 300 && fired === false) {
console.log('fire!');
fired = true;
}
}, true);
@juanbrujo
juanbrujo / randBetweenValues.jade
Created June 1, 2015 21:57
Get a random value between 2 ranges
// JS Function expressed in Jade lang.
- var randBetweenValues = function(min,max){
- return Math.floor(Math.random() * (max - min + 1) + min);
- }
// USE:
p #{randBetweenValues(205,215)}
// OUTPUT:
<p>209</p>
@juanbrujo
juanbrujo / DWTFYWTPL
Created May 15, 2015 01:32
DWTFYWTPL Licence
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// The Mixin:
@mixin bp($type) {
@if $type == small {
@media (min-width: 24em) { @content; }
}
@else if $type == medium {
@media (min-width: 46.8em) { @content; }
}
@else if $type == large {
@media (min-width: 50em) { @content; }
@juanbrujo
juanbrujo / demo.less
Created February 3, 2015 17:40
@font-face LESS Mixin
// USE
.font-face(Ubuntu-Regular, 'https://dl.dropbox.com/u/1220078/ubuntu-new/Ubuntu-Regular-webfont', 400, normal);
.font-face(Ubuntu-Italic, 'https://dl.dropbox.com/u/1220078/ubuntu-new/Ubuntu-Regular-Italic-webfont', 400, italic);
.font-face(Ubuntu-Bold, 'https://dl.dropbox.com/u/1220078/ubuntu-new/Ubuntu-Bold-webfont', 700, normal);
.test {
.font(Ubuntu-Regular, 1em, normal, normal);
h1 {
.font(Ubuntu-Bold, 1.7em, bold, normal);
}
@juanbrujo
juanbrujo / windowBlurFocus.css
Created January 30, 2015 15:10
Detect window blur/focus
.focus,
.blur {
transition: 1s;
}
.focus #focus,
.blur #blur {
display: inline-block;
}
.focus #blur,
.blur #focus {
@juanbrujo
juanbrujo / fullCalendarDisablePrevNext.js
Last active August 14, 2024 05:32
jQuery FullCalendar.js: disable prev/next button for past/future dates
$('#calendar').fullCalendar({
viewRender: function(currentView){
var minDate = moment(),
maxDate = moment().add(2,'weeks');
// Past
if (minDate >= currentView.start && minDate <= currentView.end) {
$(".fc-prev-button").prop('disabled', true);
$(".fc-prev-button").addClass('fc-state-disabled');
}
else {
@juanbrujo
juanbrujo / equalHeight.js
Created January 9, 2015 03:23
equalHeight: get the higher and resize the sibling HTML elements using CSS
/**
* Columns Equal Height
* http://css-tricks.com/equal-height-blocks-in-rows/
* USE: equalHeight(elements);
*/
equalHeight = function(container){
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,