Skip to content

Instantly share code, notes, and snippets.

View pelusium's full-sized avatar

Mauro Gama pelusium

View GitHub Profile
@pelusium
pelusium / isOver16.js
Created January 11, 2017 14:58
Jquery validator over 16 years
jQuery.validator.addMethod('isOver16', function(value, element) {
var birthDate = value.split('-');
var tempDate = new Date((parseInt(birthDate[2])+16), parseInt(birthDate[1]-1), parseInt(birthDate[0]));
return (tempDate <= new Date());
});
@pelusium
pelusium / parse-xml.php
Created February 1, 2018 21:48 — forked from stojg/parse-xml.php
Parsing a huge XML with closure in PHP
<?php
// Open the XML
$handle = fopen('file.xml', 'r');
// Get the nodestring incrementally from the xml file by defining a callback
// In this case using a anon function.
nodeStringFromXMLFile($handle, '<item>', '</item>', function($nodeText){
// Transform the XMLString into an array and
print_r(getArrayFromXMLString($nodeText));