Skip to content

Instantly share code, notes, and snippets.

View napoli1890's full-sized avatar

napoli1890

View GitHub Profile
@napoli1890
napoli1890 / angularjs-seconds-to-time.js
Created April 15, 2016 08:46
AngularJS Filter that convert Seconds to Time String
app.filter('secondsToDateTime', [function() {
/**
* This code returns a date string formatted manually.
* Code "new Date(1970, 0, 1).setSeconds(seconds)" returns malformed output on days.
* Eg. 4 days, magically becomes 5, 15 becomes 16 and so on...;
* */
return function(seconds) {
var days = Math.floor(seconds/86400);
var hours = Math.floor((seconds % 86400) / 3600);
var mins = Math.floor(((seconds % 86400) % 3600) / 60);
@napoli1890
napoli1890 / angularjs-bytes-filter.js
Last active April 14, 2016 09:26 — forked from thomseddon/gist:3511330
AngularJS Bytes Formatter Filter
app.filter('bytes', function() {
return function(bytes, precision) {
if (bytes == 0 || isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
@napoli1890
napoli1890 / install-wkhtml2pdf.sh
Last active February 5, 2016 17:06 — forked from Zauberfisch/install-wkhtml2pdf.sh
Install wkhtml2pdf on Ubuntu Trusty 64bit (14.04 LTS) with patched QT
# I managed to get the compiled version with patched QT working on ubuntu precise 64bit (12.04 LTS) and thought I'd share my bash history in the hopes it might spare others some trouble shooting.
# Also note that this install process takes rather long, you might want to consider running it in a screen or something
# you will be needing git if you haven't got it yet
sudo apt-get install git-core
# as per installation instructions, install dependencies for wkhtmltopdf
sudo apt-get install openssl build-essential xorg libssl-dev libxrender-dev
# clone the repo
git clone git://github.com/antialize/wkhtmltopdf.git wkhtmltopdf