Skip to content

Instantly share code, notes, and snippets.

View juanpujol's full-sized avatar
🇧🇷
Always Working Remotely

Juan Pujol juanpujol

🇧🇷
Always Working Remotely
View GitHub Profile
@juanpujol
juanpujol / gist:2230290
Created March 28, 2012 20:34
HTML: HTML5 Shiv
<!--[if lt IE9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
$(document).ready(function() {
$('table.tracks tbody').makeSortable({ url: "<%= sort_my_mix_tracks_path(mix) -%>" });
});
@juanpujol
juanpujol / Procfile
Created June 9, 2012 18:25
Heroku Procfile
web: bundle exec rails server thin -p $PORT
@juanpujol
juanpujol / app.js
Created July 21, 2012 01:23
Simple Node.js Express app that renders every file in the /public directory.
// Install express with: npm install express.
var express = require('express'),
app = express();
// Before any request console.log all requests.
app.use(function(req, res, next){
console.log('Intercepted request from: ' + req.url);
next();
});
@juanpujol
juanpujol / _font-rem.scss
Last active November 15, 2022 13:15
Convert px units of font-size and line-height to rems with fallback to px for old browsers. Sass @mixin
/* ==========================
@mixin font-rem
=============================
Convert px units to rems with fallback to older browsers.
Sample:
h1 { @include font-rem(16px, 24px) };
Compiles to no CSS:
h1 {
@juanpujol
juanpujol / deploy.sh
Last active December 10, 2015 09:49
Quick deploy. Little shell script to connect and copy files to a server via SSH.
#!/bin/sh
# Execution:
# Without arguments the script will copy everythin on the $path
# ~ sh deploy.sh
#
# Or you can especify files or folders to copy via arguments.
# ~ sh deploy.sh index.html styles myfile.txt
# Folder:
@juanpujol
juanpujol / contains-in-array.js
Created January 4, 2013 17:16
Add method contains to Array Prototype.
// Add method contains to Array Prototype.
Array.prototype.contains = function(obj) {
var i = this.length;
while (i--) {
if(this[i] === obj) { return true; }
}
return false;
}
@juanpujol
juanpujol / animate-scroll.js
Last active April 4, 2023 18:23
Animate scroll for anchors with href="#"
var NavBarHeight = 70 // Change this variable to controll the top of the scroll.
$('a[href*=#]').each(function() {
var target;
target = $(this).attr('href');
return $(this).on('click', function(e) {
e.preventDefault();
setToActive($(this));
// Google Analitycs event tracking.
@juanpujol
juanpujol / humanize-constant-filter.js
Created June 22, 2013 01:01
AngularJS Filter to transform a constant like strings to human text. i.e. "SUPPORT_SYSTEM" => "Support system"
angular.module('app').filter('humanizeConstant', function(){
return function(text) {
if(text) {
var string = text.split("_").join(" ").toLowerCase();
var string = string.charAt(0).toUpperCase() + string.slice(1);
return string
};
};
});
web: node server