This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert bytes to KiB, MiB, etc. (object) | |
// humanBytes( number, numDecimals ) | |
// ex. humanBytes( 10714 ) = { number: 10, str: "10 KiB", unit: "KiB" } | |
// ex. humanBytes( 10714 ).str = "10 KiB" | |
// ex. humanBytes( 10714, 2 ).str = "10.46 KiB" | |
function humanBytes( bytes, decimals ) { | |
var units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; | |
var unit = 'B'; | |
var num = bytes; | |
var dec = decimals !== undefined ? Math.pow( 10, decimals ) : 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/node | |
/* | |
Post-process script for SABnzbd and AppNotifications | |
~ when a download is completed this script will send a push | |
~ notification to your mobile device using AppNotifications.com | |
Depends: | |
- NodeJS: http://nodejs.org | |
- NPM: http://npmjs.org (comes with Node) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:window.location.href.replace(/app\.net\/([\w-]+)(\/post\/([\d]+))?/,function(s,u,s,p){if(p){window.location='netbot:///status/'+p}else{window.location='netbot:///user_profile/'+u}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:window.location.href.replace(/twitter\.com\/(\!#\/)?([\w-]+)(\/status\/(\d+))?/,function(s,h,u,s,p){if(p){window.location='tweetbot:///status/'+p}else{window.location='tweetbot:///user_profile/'+u}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.makeBookmarkletCommand({ | |
name: "Evernote", | |
description: "Save a note on Evernote.", | |
icon: "http://www.evernote.com/favicon.ico", | |
homepage: "http://www.makadia.com", | |
author: {name: "Svapan Makadia", email: "codewzrd@hotmail.com"}, | |
help: "Select content and invoke this command to save the selection as a note or just save the whole page without selecting anything.", | |
url: "javascript:(function(){EN_CLIP_HOST='http://www.evernote.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})();" | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$results = 11; // add 1 for dir total | |
$cwd = getcwd(); | |
$dir = scandir( $cwd ); | |
foreach( $dir as $item ) { | |
if( $item === '..' ) { continue; } | |
$path = $cwd .'/'. $item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Object.forEach( function( value, key, index ) {} ) | |
Object.prototype.forEach = function( cb ) { | |
var keys = Object.keys(this); | |
for( var i = 0; i < keys.length; i++ ) { | |
var key = keys[i]; | |
cb( this[key], key, i ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert bytes to string '123.6 KiB', MiB, etc. | |
// var bytes = 8765432 | |
// var human = bytes.humanBytes( 2 ) | |
// 8.36 MiB | |
Number.prototype.humanBytes = function( decimals ) { | |
var units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; | |
var unit = 'B'; | |
var bytes = this.valueOf(); | |
var dec = decimals ? Math.pow( 10, decimals ) : 1; | |
var i = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" == "-h" ]; then | |
echo "Colorful Homebrew update script" | |
echo | |
echo "USAGE: update [-y]" | |
echo | |
echo " -y skip questions" | |
echo " -h display this help" | |
echo | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add pre-exit script | |
process.on ('exit', code => { | |
console.log (`Whoa! Exit code ${code}, cleaning up...`); | |
// i.e. close database | |
}); | |
// Add another for fun | |
process.on ('exit', code => { | |
if (code > 0) { | |
console.log ('Hmm something went wrong'); |
OlderNewer