Skip to content

Instantly share code, notes, and snippets.

View pazguille's full-sized avatar

Guille Paz pazguille

View GitHub Profile
@pazguille
pazguille / namespace.js
Last active May 9, 2016 23:07
Namespace template
(function (window) {
'use strict';
var namespace = (function () {
// Private members
var core = {
// Public members
};
@pazguille
pazguille / node-install
Created April 17, 2012 13:49
Install NodeJS - Amazon Fedora
Install base tools:
yum groupinstall "Development Tools"
Now install openssl-devel:
yum install openssl-devel
Esta instalado en sudo su -
Install+update NODE:
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.basic
@pazguille
pazguille / countdown.days.js
Created April 28, 2012 14:21
Countdown days
var countDown = function (finalDate) {
var final = new Date(finalDate),
today = new Date(),
diff = final.getTime() - today.getTime(),
days = Math.floor(diff / (1000 * 60 * 60 * 24)),
segs = Math.floor(diff / 1000);
return days;
};
@pazguille
pazguille / bottom.js
Created May 10, 2012 15:43
Determining when scroll to bottom of a page
$(window).on("scroll", function () {
if(window.scrollY + window.innerHeight == document.body.scrollHeight) {
console.log("bottom!");
}
});
@pazguille
pazguille / Preferences.sublime-settings
Last active January 16, 2016 11:42
My Sublime Text 2 Preferences
{
"color_scheme": "Packages/Babel/Monokai Phoenix.tmTheme",
"font_face": "Monaco",
"font_size": 14,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
"open_files_in_new_window": false,
@pazguille
pazguille / proxy.js
Last active October 8, 2015 14:28
Using http-proxy module for node.js
var http = require('http'),
httpProxy = require('http-proxy');
httpProxy.createServer({
hostnameOnly: true,
router: {
'test.me': '127.0.0.1:8080',
'test.com': '127.0.0.1:8081'
}
}).listen(80);
@pazguille
pazguille / Inheritance.js
Created August 27, 2012 18:52
Inheritance Patterns
/**
* Helpers
*/
function clone(obj) {
var copy = {},
prop;
for (prop in obj) {
if (hasOwn(obj, prop)) {
copy[prop] = obj[prop];
@pazguille
pazguille / CDNfallback.js
Created October 18, 2012 14:47
JavaScript CDN Fallback
<script src="http://code.jquery.com/jquery-1.7.2.js"></script>
<script>
if (jQuery === undefined) {
var script = document.createElement('script');
script.src = '/local/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
}
</script>
@pazguille
pazguille / exports.js
Last active October 11, 2015 21:38
Exports your library - support AMD / CommonJS
// @see http://addyosmani.com/writing-modular-js/
// library was previously defined
// AMD suppport
if (typeof window.define === 'function' && window.define.amd !== undefined) {
window.define('library', [], function () {
return library;
});
// CommonJS suppport
} else if (typeof module !== 'undefined' && module.exports !== undefined) {
@pazguille
pazguille / delegate.js
Created October 23, 2012 10:03
Event Delegation
document.addEventListener('click', function (event) {
event = event || window.event;
var target = event.target || event.srcElement;
console.log(target);
});