Skip to content

Instantly share code, notes, and snippets.

View dj-marko's full-sized avatar

Marko Djordjevic dj-marko

  • Homestory
  • Belgrade,Serbia
View GitHub Profile
@zecar
zecar / Javascript Array betterFilter.md
Last active April 20, 2017 21:27
javascript array.filter faster alternative
Array.prototype.betterFilter = function(expression) {
	var res = [];
	for(var idx=0; idx<this.length; idx++){
		var currentItem = this[idx];
		if(expression(currentItem)){
			res.push(currentItem);
		}
	}
	return res;
@staltz
staltz / introrx.md
Last active May 24, 2024 07:56
The introduction to Reactive Programming you've been missing
@albrow
albrow / IpToDecimal.js
Last active March 3, 2021 14:46
A short javascript function to convert an IP address in dotted decimal notation to a regular decimal. This is useful for IP address geolocation lookups. Supports both IPv4 and IPv6 addresses. http://en.wikipedia.org/wiki/Ip_address
// convert the ip address to a decimal
// assumes dotted decimal format for input
function convertIpToDecimal(ip) {
// a not-perfect regex for checking a valid ip address
// It checks for (1) 4 numbers between 0 and 3 digits each separated by dots (IPv4)
// or (2) 6 numbers between 0 and 3 digits each separated by dots (IPv6)
var ipAddressRegEx = /^(\d{0,3}\.){3}.(\d{0,3})$|^(\d{0,3}\.){5}.(\d{0,3})$/;
var valid = ipAddressRegEx.test(ip);
if (!valid) {
return false;