from http://www.davidhampgonsalves.com/Damerau-Levenshtein
337659
function damerauLevenshteinDistance(source, target) {
  if (!source || source.length === 0)
    if (!target || target.length === 0)
      return 0;
    else
      return target.length;
  else if (!target)
    return source.length;

  var sourceLength = source.length;
  var targetLength = target.length;
  var score = [];

  var INF = sourceLength + targetLength;
  score[0] = [INF];
  for (var i=0 ; i <= sourceLength ; i++) { score[i + 1] = []; score[i + 1][1] = i; score[i + 1][0] = INF; }
  for (var i=0 ; i <= targetLength ; i++) { score[1][i + 1] = i; score[0][i + 1] = INF; }

  var sd = {};
  var combinedStrings = source + target;
  var combinedStringsLength = combinedStrings.length;
  for(var i=0 ; i < combinedStringsLength ; i++) {
    var letter = combinedStrings[i];
    if (!sd.hasOwnProperty(letter))
      sd[letter] = 0;
  }

  for (var i=1 ; i <= sourceLength ; i++) {
    var DB = 0;
    for (var j=1 ; j <= targetLength ; j++) {
      var i1 = sd[target[j - 1]];
      var j1 = DB;

      if (source[i - 1] == target[j - 1]) {
        score[i + 1][j + 1] = score[i][j];
        DB = j;
      }
      else
        score[i + 1][j + 1] = Math.min(score[i][j], Math.min(score[i + 1][j], score[i][j + 1])) + 1;

      score[i + 1][j + 1] = Math.min(score[i + 1][j + 1], score[i1][j1] + (i - i1 - 1) + 1 + (j - j1 - 1));
    }
    sd[source[i - 1]] = i;
  }
  return score[sourceLength + 1][targetLength + 1];
}
993896
function getViajesExtranjeros (senador, periodo, incluyeSenador) {
  let url = URL_VIAJES_INTERNACIONALES.replace(/:year:/, periodo)

  return scraperjs.StaticScraper.create()
    .get(url)
    .catch(ex => {
      console.log('Some srioues problem happened!\n\n\n')
      return new Promise()
    })
    .scrape($ => {
      const nombre = senador.nombre.split(',')[1].split(' ')[1]
      const apellido = senador.nombre.split(',')[0].split(' ')[0]

      const preResults = $('#main tbody tr:not(:first-child)').filter((i, el) => {
        const _apellido = removeAccent($(el).find('td:nth-child(2)').text().trim())
        const _nombre = removeAccent($(el).find('td:nth-child(4)').text().trim())
        return _nombre.indexOf(removeAccent(nombre).toUpperCase()) > -1 && _apellido.indexOf(removeAccent(apellido).toUpperCase()) > -1
      })

      const results = preResults.map(function () {
        const rubro = $(this).find('td:nth-child(1)').text().trim()
        const dateStr = $(this).find('td:nth-child(5)').text().split('-')
        const month = parseInt(dateStr[1])
        const day = parseInt(dateStr[0])
        const year = parseInt(dateStr[2])
        const fecha = new Date(year, month - 1, day)
        const pais = $(this).find('td:nth-child(6)').text().trim()
        const viatico = parseInt($(this).find('td:nth-child(7)').text().trim())
        const motivo = $(this).find('td:nth-child(8)').text().trim()
        return {
          rubro,
          fecha,
          pais,
          viatico,
          motivo
        }
      }).get()
      return incluyeSenador ? Object.assign(senador, { internacionales: results }) : results
    })
}
1211360
function(oneaccidental) {
    var key = this.key(), limit = oneaccidental ? 2 : 3;

    return ['m3', 'm2', 'm-2', 'm-3']
      .map(this.interval.bind(this))
      .filter(function(note) {
      var acc = note.accidentalValue();
      var diff = key - (note.key() - acc);

      if (diff < limit && diff > -limit) {
        var product = vector.mul(knowledge.sharp, diff - acc);
        note.coord = vector.add(note.coord, product);
        return true;
      }
    });
  }
866529
def dBinaryRochedy (r, D, q, F):
    
    return -r[1]*(r[0]*r[0]+r[1]*r[1]+r[2]*r[2])**-1.5 -q*r[1]*((r[0]-D)*(r[0]-D)+r[1]*r[1]+r[2]*r[2])**-1.5 + F*F*(1+q)*r[1]
1248538
public function toUriString() : string
    {
        $uri = '';

        if (($scheme = $this->getScheme()) != '') {
            $uri .= $scheme . ':';
        }

        if (($authority = $this->getAuthority()) != '' || $scheme === 'file') {
            $uri .= '//' . $authority;
        }

        $uri .= $this->getPath();

        if (($query = $this->getQuery()) != '') {
            $uri .= '?' . $query;
        }

        if (($fragment = $this->getFragment()) != '') {
            $uri .= '#' . $fragment;
        }

        return $uri;
    }
327919
@SuppressWarnings("unchecked")
	public static <T extends Levenshtein> T damerau(String baseTarget, String compareTarget) {
		return (T) new Damerau(baseTarget).update(compareTarget);
	}
956048
function LevDist (s, t) {
    var d = []
      , n = s.length
      , m = t.length
      , i
      , j
      , s_i
      , t_j
      , cost
      , mi
      , b
      , c
      ;

    if (n == 0) return m;
    if (m == 0) return n;

    // Step 1
    for (i = n; i >= 0; --i) { d[i] = []; }

    // Step 2
    for (i = n; i >= 0; --i) { d[i][0] = i; }
    for (j = m; j >= 0; --j) { d[0][j] = j; }

    // Step 3
    for (i = 1; i <= n; ++i) {
        s_i = s.charAt(i - 1);

        // Step 4
        for (j = 1; j <= m; ++j) {

            // Check the jagged ld total so far
            if (i == j && d[i][j] > 4) { return n; }

            t_j = t.charAt(j - 1);

            // Step 5
            cost = (s_i == t_j) ? 0 : 1;

            //Calculate the minimum
            mi = d[i - 1][j] + 1;
            b = d[i][j - 1] + 1;
            c = d[i - 1][j - 1] + cost;

            if (b < mi) { mi = b; }
            if (c < mi) { mi = c; }

            // Step 6
            d[i][j] = mi;

            //Damerau transposition
            if (i > 1 && j > 1 && s_i == t.charAt(j - 2) && s.charAt(i - 2) == t_j) {
                d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
            }
        }
    }

    // Step 7
    return d[n][m];
}
949747
public function afficherDetailAdresse($idAdresse, $idEvenementGroupeAdresse)
    {
        /*
		 * Etape :
		 * Afficher la google map
		 * Afficher le sommaire des evenements
		 * Récupérer la liste des evenements et les afficher un par un
		 *
		 */

        //Template loading
        $this->messages->display();
        $t = new Template('modules/archi/templates/evenement');
        $t->set_filenames(array('index'=>'index.tpl'));
        $title = $this->displayTitle();

        //Init auth var to check furtherly user state (connected or not)
        $authentification = new archiAuthentification();



        //Setting idAdresse
        if (isset($idAdresse) && $idAdresse!='') {//Setting idEvenementGroupeAdresse
            if ((isset($idEvenementGroupeAdresse)!=1) || ($idEvenementGroupeAdresse=='')) {
                $requete = "SELECT idEvenement FROM _adresseEvenement WHERE idAdresse = ".$idAdresse;
                $result = $this->connexionBdd->requete($requete);
                $fetch = mysql_fetch_assoc($result);
                $oldIdEvt = $idEvenementGroupeAdresse;
                $idEvenementGroupeAdresse = $fetch['idEvenement'];
            }
        }

        //Getting coordo for the current address
        $requete = "SELECT latitude , longitude FROM historiqueAdresse WHERE idAdresse = ".$idAdresse;
        $result = $this->connexionBdd->requete($requete);
        $fetch = mysql_fetch_assoc($result);
        $coordonnees['longitude'] = $fetch['longitude'];
        $coordonnees['latitude'] = $fetch['latitude'];


        //Displaying google map
        $e = new archiEvenement();//Should be moved to archiUtils
        $calqueGoogleMap = new calqueObject(array('idPopup'=>10));
        $contenuIFramePopup = $e->getContenuIFramePopupGoogleMap(array(
                'idAdresseCourante'=>$idAdresse,
                'calqueObject'=>$calqueGoogleMap,
                'idEvenementGroupeAdresseCourant'=>$idEvenementGroupeAdresse
        ));
        $t->assign_block_vars('CarteGoogle', array(
                'src'=>$this->creerUrl('', 'afficheGoogleMapIframe', array('noHeaderNoFooter'=>1,'longitude'=>$coordonnees['longitude'],'latitude'=>$coordonnees['latitude'],'archiIdAdresse'=>$idAdresse,'archiIdEvenementGroupeAdresse'=>$idEvenementGroupeAdresse)),
                'lienVoirCarteGrand'=>"<a href='#' onclick=\"".$calqueGoogleMap->getJsOpenPopupNoDraggableWithBackgroundOpacity()."document.getElementById('iFrameDivPopupGM').src='".$this->creerUrl('', 'afficheGoogleMapIframe', array('longitude'=>$coordonnees['longitude'],'latitude'=>$coordonnees['latitude'],'noHeaderNoFooter'=>true,'archiIdAdresse'=>$idAdresse,'archiIdEvenementGroupeAdresse'=>$idEvenementGroupeAdresse,'modeAffichage'=>'popupDetailAdresse'))."';\" class='bigger' style='font-size:11px;'>"._("Voir la carte en + grand")."</a>",
                'popupGoogleMap'=>$calqueGoogleMap->getDivNoDraggableWithBackgroundOpacity(array('top'=>20,'lienSrcIFrame'=>'','contenu'=>$contenuIFramePopup))
        ));

        //Getting neighborhood addresses
        $arrayEncartAdresses = $this->getArrayEncartAdressesImmeublesAvantApres(array('idEvenementGroupeAdresse'=>$idEvenementGroupeAdresse));
        $urlAutreBiens = $this->getArrayRetourLiensVoirBatiments($idAdresse);


        $t->assign_block_vars('listeAdressesVoisines', array(
                'content' => $arrayEncartAdresses['html'],
                'urlAutresBiensRue'=>$urlAutreBiens['urlAutresBiensRue'],
                'urlAutresBiensQuartier' => $urlAutreBiens['urlAutresBiensQuartier']
                ));
        $t->assign_block_vars('sommaireEvenements', array());


        //Preparing the loop on all related event to the current address
        $requeteIdEvenements = "
				SELECT DISTINCT ee.idEvenementAssocie as idEvenement
				FROM _evenementEvenement ee
				LEFT JOIN positionsEvenements pe on pe.idEvenement = ee.idEvenementAssocie
				WHERE ee.idEvenement = $idEvenementGroupeAdresse
				ORDER BY IF(pe.position IS NULL,0, pe.position) ASC
				";
        $resultIdEvenements = $this->connexionBdd->requete($requeteIdEvenements);


        //Add actions buttons
        //Ajouter sous evenement
        $t->assign_block_vars(
            'actionsSommaire',
            array(
                        'urlAction'=>$this->creerUrl('', 'ajouterSousEvenement', array('idAdresse'=>$idAdresse,'archiIdEvenement' =>$idEvenementGroupeAdresse)),
                        'labelAction' => 'Ajouter un événement'
                )
        );

        // Selection des images
        // Copy/paste code from old function
                $afficheSelectionImages = 1;
        if ($authentification->estConnecte() && isset($this->variablesGet ['afficheSelectionImage']) && $this->variablesGet ['afficheSelectionImage'] == '1') {
            $afficheSelectionImages = 0;
        }
        if ($authentification->estConnecte()) {
            if ($authentification->estAdmin()) {
                $t->assign_block_vars('actionsSommaire', array (
                'urlAction' => $this->creerUrl('', 'evenement', array (
                        'idEvenement' => $idEvenementGroupeAdresse,
                        'archiIdAdresse' => $idAdresse,
                        'afficheSelectionImage' => $afficheSelectionImages
                )),
                'labelAction' => 'Sélectionner des images'
                ));
            }
        }
        // Selection de l'image principale
                $afficheSelectionImagePrincipale = 1;

        /*
		if ($authentification->estConnecte () && isset ( $this->variablesGet ['afficheSelectionImagePrincipale'] ) && $this->variablesGet ['afficheSelectionImagePrincipale'] == '1') {
			$afficheSelectionImagePrincipale = 0;
		}
		*/
        if ($authentification->estConnecte()) {
            if ($authentification->estAdmin()) {
                $t->assign_block_vars('actionsSommaire', array (
                'urlAction' => $this->creerUrl('', 'evenement', array (
                        'idEvenement' => $idEvenementGroupeAdresse,
                        'archiIdAdresse' => $idAdresse,
                        'afficheSelectionImagePrincipale' => $afficheSelectionImagePrincipale
                )),
                'labelAction' => 'Sélectionner l\'image principale'
                ));
            }
        }

        // Selection du titre
                $afficheSelectionTitre = 1;
        /*
		if ($authentification->estConnecte () && isset ( $this->variablesGet ['afficheSelectionTitre'] ) && $this->variablesGet ['afficheSelectionTitre'] == '1') {
			$afficheSelectionTitre = 0;
		}
		*/
        if ($authentification->estConnecte()) {
            if ($authentification->estAdmin()) {
                $t->assign_block_vars('actionsSommaire', array (
                'urlAction' => $this->creerUrl('', 'evenement', array (
                        'idEvenement' => $idEvenementGroupeAdresse,
                        'archiIdAdresse' => $idAdresse,
                        'afficheSelectionTitre' => $afficheSelectionTitre
                )),
                'labelAction' => 'Sélectionner un titre'
                ));
            }
        }

        // Repositionner les evenements
                $affichePositionnementEvenements = 1;
        if ($authentification->estConnecte() && isset($this->variablesGet ['affichePositionnementEvenements']) && $this->variablesGet ['affichePositionnementEvenements'] == '1') {
            $affichePositionnementEvenements = 0;
            $a = new archiEvenement();
            $imageObject = new imageObject(); // objet image du framework
            $a->addToJsHeader($imageObject->getJSFunctionsDragAndDrop(array (
            'withBalisesScript' => true
            ))); // rajoute les fonctions de deplacement d'elements dans le header du formulaire
        }
        if ($authentification->estConnecte()) {
            if ($authentification->estAdmin()) {
                $t->assign_block_vars('actionsSommaire', array (
                'urlAction' => $this->creerUrl('', 'evenement', array (
                        'archiIdAdresse' => $idAdresse,
                        'idEvenement' => $idEvenementGroupeAdresse,
                        'archiIdAdresse' => $idAdresse,
                        'affichePositionnementEvenements' => $affichePositionnementEvenements
                )),
                'labelAction' => 'Repositionner les événements'
                ));
            }
        }

        //Loop on all evenet related to this idAdresse specified in argument of this function
        while ($fetch = mysql_fetch_assoc($resultIdEvenements)) {
            //Getting all the infos with this method
            $evenement = $e->getEventInfos($fetch['idEvenement']);
            $result = $e->displaySingleEvent($evenement);
            $t->assign_block_vars('event', array('content'=>$result));
            //Filling the template with the infos
            $t->assign_block_vars('evenement', $evenement['evenementData']);


            $titre =stripslashes($evenement['evenementData']['titre']);
            if (isset($evenement['evenementData']['titre']) &&$evenement['evenementData']['titre']!="") {
                $titre.=" - ";
            }
            $ancre = "#evenement".$evenement['evenementData']['idEvenement'];
            $t->assign_block_vars('sommaireEvenements.sommaireItem', array(
            'ancre' => $ancre,
            'titre' => $titre,
            'date' =>$evenement['evenementData']['dates']
            ));
        }


        //Getting all the miscellaneous images (vueSur / prisDepuis)
                $image = new archiImage();
                $idVueSur = $image->getIdImageVueSur($idEvenementGroupeAdresse);
                $idPrisDepuis = $image->getidImagePrisDepuis($idEvenementGroupeAdresse);


        if (!empty($idVueSur)) {
            $evenementVueSur = $image->getEventInfosMiscImage($idVueSur, $idAdresse, "Autres vues sur");
            $t->assign_block_vars('evenement', $evenementVueSur);
        }

        if (!empty($idPrisDepuis)) {
            $evenementPrisDepuis = $image->getEventInfosMiscImage($idPrisDepuis, $idAdresse, "Vues prises depuis");
            $t->assign_block_vars('evenement', $evenementPrisDepuis);
        }


                $listeCommentaires=$this->getListeCommentaires($idEvenementGroupeAdresse);
                $formulaireCommentaire = $e->getFormComment($idEvenementGroupeAdresse, $this->getCommentairesFields(), '');

                $s = new archiSource();
                $t->assign_vars(array(
                'title' => $title,
                'listeCommentairesAdresse' => $listeCommentaires,
                'formulaireCommentaireAdresse' => $formulaireCommentaire,
                'popupDescriptionSource' =>     $s->getPopupDescriptionSource()

                ));

                ob_start();
                $t->pparse('index');
                $html .= ob_get_contents();
                ob_end_clean();
                return $html;
    }
765558
function getBrowserData(){
	//Mobile
	function mobilecheck() {
		var check = false;
		(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera);
		return check;
	}
	//Mobile or Tablet
	function mobileAndTabletcheck() {
		var check = false;
		(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera);
		return check;
	}
	//Device Type
	var device = 'desktop';
	if(mobilecheck()){
		device = 'mobile';
	}
	else if(mobileAndTabletcheck()){
		device = 'tablet';
	}
	//Browser
	var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
	if(/trident/i.test(M[1])){
		tem=/\brv[ :]+(\d+)/g.exec(ua) || []; 
		return {name:'IE',version:(tem[1]||'')};
		}
	if(M[1]==='Chrome'){
		tem=ua.match(/\bOPR\/(\d+)/)
		if(tem!=null)   {return {name:'Opera', version:tem[1]};}
		}
	M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
	if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);}
	//Screen Size
	var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
	var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	return {
		device: device,
		name: M[0],
		version: M[1],
		width: width,
		height: height
	}
}
33697
public function indexAction()
    {
        if (!$this->name) {
            return '';
        }
        //lista dozwolonych znaków
        $characters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'W', 'Z'];
        $word = '';
        $charsCount = count($characters) - 1;

        //generuje 5 literowy string
        for ($i = 0; $i < 5; $i++) {
            $word .= $characters[rand(0, $charsCount)];
        }

        //tworzenie obrazu
        $img = imagecreatetruecolor(130, 50);

        //konfiguracja kolorów
        $green = imagecolorallocate($img, 0x00, 0x77, 0x00);
        $gray = imagecolorallocate($img, 0xF5, 0xF5, 0xF5);
        $darkGray = imagecolorallocate($img, 0x99, 0x99, 0x99);

        //czcionka
        $font = BASE_PATH . '/web/resource/cmsAdmin/ttf/dejavu.ttf';

        //ramka
        imagefilledrectangle($img, 0, 0, 129, 49, $darkGray);
        imagefilledrectangle($img, 1, 1, 128, 48, $gray);

        $prevSpace = -5;
        $prevAngle = 0;

        //przesunięcia i obroty
        for ($i = 0; $i < strlen($word); $i++) {
            if ($i % 2 != 0) {
                $size = rand(32, 36);
                $height = rand(42, 46);
                $angle = rand(5, 15);
                $space = 25 + $prevSpace;
            } else {
                $size = rand(28, 32);
                $height = rand(39, 43);
                $angle = rand(-15, 5);
                $space = 13 + $prevSpace;
            }
            $prevSpace = $space;
            $prevAngle = $angle;
            imagefttext($img, $size, $angle, $space, $height, $green, $font, $word[$i]);
        }

        //zapis do sesji
        $formSession = new \Mmi\Session\SessionSpace('captcha');
        //filtracja nazwy pola z nazwy formularza + pola
        $name = strpos($this->name, '[') === false ? $this->name : substr($this->name, strpos($this->name, '[') + 1, -1);
        $formSession->$name = $word;

        //ustalenie nagłówka na niebuforowany
        $this->getResponse()
            ->setHeader('Expires', 'Mon, 15 Dec ' . (date('Y') - 1) . ' 01:00:00 GMT+0100')
            ->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT')
            ->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate')
            ->setHeader('Cache-Control', 'post-check=0, pre-check=0', false)
            ->setHeader('Pragma', 'no-cache')
            ->setTypeJpeg();

        //zwrot obrazu
        imagejpeg($img, NULL, 25);
        return '';
    }
671468
public function &c() {
    $args = func_get_args();
    if (count($args) > $this->argsCount) {
      $rel = array_pop($args); // rel ist übergeben worden
    } else {
      $rel = 0;
    }
    for ($i=0; $i < $this->argsCount; $i++) {
      $this->values[$i][] = $args[$i];
    }

    $key = $this->getKey($args);
    if (!array_key_exists($key,$this->counts)) {
      $this->counts[$key] = $this->initCount;
    }
    $ref =& $this->counts[$key];
    $ref += $rel;
    return $ref;
  }
38189
private function hpkp(): array
    {
        // TODO : lever une exception si les champs hashes et max-age sont vide, car ils doivent tous les deux avoir une valeur chacun (cad un hash au minimum + un maxage)
        $values = [];
        foreach ($this->security['hpkp']['hashes'] as $hash) {
            $values[] = sprintf('pin-sha256="%s"', $hash);
        }
        $values[] = sprintf('max-age=%d', $this->security['hpkp']['max-age']);
        if ($this->security['hpkp']['include-sub-domains']) {
            $values[] = 'includeSubDomains';
        }
        if (! empty($this->security['hpkp']['report-uri'])) {
            $values[] = sprintf('report-uri="%s"', $this->security['hpkp']['report-uri']);
        }
        $header = $this->security['hpkp']['report-only']
            ? 'Public-Key-Pins-Report-Only'
            : 'Public-Key-Pins';

        return [$header => implode('; ', $values)];
    }
34652
public function index() {        
        $tree = Globals::getTree();
        $controller = new PageController();
        $controller
        ->setPageTitle(I18N::translate('Certificate'))
        ->restrictAccess(
            $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($tree)
        );
        
        $cid = Filter::get('cid');
        
        $certificate = null;
        if(!empty($cid) && strlen($cid) > 22){
            $certificate = Certificate::getInstance($cid, $tree, null, $this->provider);
        }
        
        $data = new ViewBag();
        $data->set('title', $controller->getPageTitle());
        
        $data->set('has_certif', false);
        if($certificate) {
            $controller->restrictAccess($certificate->canShow());
            $data->set('title', $certificate->getTitle());
            $data->set('has_certif', true);
            $data->set('certificate', $certificate);
            
            $data->set(
                'url_certif_city', 
                'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . 
                    '&mod_action=Certificate@listAll' .
                    '&ged=' . $tree->getNameUrl() .
                    '&city=' . Functions::encryptToSafeBase64($certificate->getCity())
            );
            
            $controller->addInlineJavascript('
                jQuery("#certificate-tabs").tabs();
			    jQuery("#certificate-tabs").css("visibility", "visible");    
            ');
            
            $data->set('has_linked_indis', false);
            $data->set('has_linked_fams', false);
            
            $linked_indis = $certificate->linkedIndividuals();
            $linked_fams = $certificate->linkedFamilies();
                        
            if($linked_indis && count($linked_indis) > 0) {
                $data->set('has_linked_indis', true);
                $data->set('linked_indis', $linked_indis);
            }
            
            if(!empty($linked_fams)) {
                $data->set('has_linked_fams', true);
                $data->set('linked_fams', $linked_fams);
            }
        }
        
        ViewFactory::make('Certificate', $this, $controller, $data)->render();
    }
329044
def Descargar(self, url=URL, filename="padron.txt", proxy=None):
        ""
        proxies = {}
        if proxy:
            proxies['http'] = proxy
            proxies['https'] = proxy
            proxy_handler = urllib2.ProxyHandler(proxies)
        print "Abriendo URL %s ..." % url
        req = urllib2.Request(url)
        if os.path.exists(filename):
            http_date = formatdate(timeval=os.path.getmtime(filename), 
                                   localtime=False, usegmt=True)  
            req.add_header('If-Modified-Since', http_date)
        try:
            web = urllib2.urlopen(req)
        except urllib2.HTTPError, e:
            if e.code == 304:
                print "No modificado desde", http_date
                return 304
            else:
                raise
        # leer info del request:
        meta = web.info()
        lenght = float(meta['Content-Length'])
        date = meta['Last-Modified']
        tmp = open(filename + ".zip", "wb")
        print "Guardando"
        size = 0
        p0 = None
        while True:
            p = int(size / lenght * 100)
            if p0 is None or p>p0:
                print "Leyendo ... %0d %%" % p
                p0 = p
            data = web.read(1024*100)
            size = size + len(data)
            if not data:
                print "Descarga Terminada!"
                break
            tmp.write(data)
        print "Abriendo ZIP..."
        tmp.close()
        web.close()
        uf = open(filename + ".zip", "rb")
        zf = zipfile.ZipFile(uf)
        for fn in zf.namelist():
            print "descomprimiendo", fn
            tf = open(filename, "wb")
            tf.write(zf.read(fn))
            tf.close()
        return 200
200043
function levenshtein( source, target ) {
  
  var s = source.length
  var t = target.length
  
  if( s === 0 ) return t
  if( t === 0 ) return s
  
  var i, k, matrix = []
  
  for( i = 0; i <= t; i++ ) {
    matrix[i] = [ i ]
  }
  
  for( k = 0; k <= s; k++ )
    matrix[0][k] = k
  
  for( i = 1; i <= t; i++ ) {
    for( k = 1; k <= s; k++ ) {
      ( target.charAt( i - 1 ) === source.charAt( k - 1 ) )
        ? matrix[i][k] = matrix[ i - 1 ][ k - 1 ]
        : matrix[i][k] = Math.min(
            matrix[ i - 1 ][ k - 1 ] + 1,
            Math.min(
              matrix[i][ k - 1 ] + 1,
              matrix[ i - 1 ][k] + 1
            )
          )
    }
  }
  
  return matrix[t][s]
  
}
638569
function getMetadata ($) {
  const image = ($('figure[representativeofpage=true] img').attr('src') ||
                 $('meta[property="og:image"]').attr('content') ||
                 '')

  const dateStr = ($('meta[property="article:modified_time"]').attr('content') ||
                   $('meta[property="article:published_time"]').attr('content') ||
                   $('meta[name="DC.date.issued"]').attr('content') ||
                   $('meta[property=date]').attr('content') ||
                   $('.news-body-date time').attr('datetime') ||
                   '').replace(' ', '')

  const publishedDate = new Date(dateStr)

  const author = ($('meta[name=author]').attr('content') ||
                  $('[itemprop=articleBody] .data [itemprop=author] [itemprop=name]').text().trim() ||
                  $('article .news-author [itemprop=author] [itemprop=name]').text().trim() ||
                  $('article [itemprop=name]').text().trim() ||
                  $('.main [itemprop=author]').text().trim() ||
                  $('.cuerpo-articulo [href^="/autor"]').text().trim() ||
                  $('.news-info-box-author [itemprop=author]').text().trim() ||
                  // For ara - Currently not working
                  // $('#content p.pg-bkn-dateline small').text().trim() ||
                  // For eldiario.es
                  $('#content address.dateline small').text().trim() ||
                  // The following 2 lines are for huffingtonpost
                  $('article .info .thirdparty-logo').text().trim() ||
                  $('article .info .name.fn').text().trim() ||
                  $('.detalleFullTexto .author a').text().trim() ||
                  '')

  const title = ($('meta[property="og:title"]').attr('content') ||
                 '')

  return {
    image,
    publishedDate,
    source: {
      author
    },
    title
  }
}
495756
@Override
    public String toDot() {
        StringBuilder dotBuilder = new StringBuilder();

        dotBuilder.append("digraph G {\n");

        for (int state = 0; state < d_stateOffsets.size(); ++state) {
            for (int trans = d_stateOffsets.get(state); trans < transitionsUpperBound(state); ++trans)
                dotBuilder.append(String.format("%d -> %d [label=\"%c\"]\n",
                        state, d_transitionTo.get(trans), d_transitionChars[trans]));

            if (d_finalStates.get(state))
                dotBuilder.append(String.format("%d [peripheries=2,label=\"%d (%d)\"];\n", state, state, d_stateNSuffixes.get(state)));
            else
                dotBuilder.append(String.format("%d [label=\"%d (%d)\"];\n", state, state, d_stateNSuffixes.get(state)));
        }

        dotBuilder.append("}");

        return dotBuilder.toString();
    }