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
// 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
#!/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
#!/bin/sh | |
vn="/usr/bin/vnstat -i eth0 -s" | |
echo | |
$vn | head -n 2 | tail -n 1 # header | |
$vn | tail -n 2 | head -n 1 # today | |
$vn | head -n 5 | tail -n 1 # month |
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
var bol = require ('bolcom') ('apikey'); | |
// Find something | |
bol.catalog.search ({ q: 'node.js' }, function (err, data) { | |
if (err) { | |
console.log ('Search failed'); | |
console.log (err); | |
} else { | |
for (var i = 0; i < data.products.length; i++) { | |
var product = data.products [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
# swap when less than N % mem is available | |
vm.swappiness = 10 | |
# cache inodes (50 = don't shrink inode cache) | |
vm.vfs_cache_pressure = 50 | |
# % memory available for all processes -- some suggest 50 | |
vm.overcommit_ratio = 100 | |
# 0 = fuzzy available memory guessing : bad |
OlderNewer