Related Posts
Javascript Quicksort implementation with dynamic comparator.
[javascript] Array.prototype.swap=function(a, b) { var tmp=this[a]; this[a]=this[b]; this[b]=tmp; } function quickSort(array,comparator) { qsort(array,0,array.length,comparator); } /** * NOTE: the comparator is a dynamic function you will define like so comparator(a,b) { if (a > b) return 1; else if (a < b) return -1; else { return 0; } } * it is up to you […]
How to ban/unban ips in linux
In case you’re not an iptables guru, you might want to create a couple scripts and put em somewhere on your $PATH. I’ve created two scripts called ban_ip and unban_ip. Create a file called ban_ip touch ban_ip chmod +x ban_ip Edit it and copy the following code inside: #!/bin/bash sudo iptables -A INPUT -s $1 […]
Javascript: Capitalize Text Like In This Title
On this one, we’ll show of the dynamic nature of javascript and we’re going to make all strings have a new method called “capitalize()”. So you can do stuff like this: [javascript] console.log("this text should look nicer now".capitalize()); >> This Text Should Look Nicer Now [/javascript] Here’s the magic code you’ll need to add somewhere […]