Skip to content

Instantly share code, notes, and snippets.

View osvik's full-sized avatar
💭
Working

Osvaldo osvik

💭
Working
View GitHub Profile
@osvik
osvik / gist:3961003
Created October 26, 2012 19:43
Greek phone validation
var isGreek = {
mobile: function(value) {
return /^(\+30|0030)?69\d{8}$/.test( value.replace(/[\s\-()\.]/g, "") );
},
landline: function(value) {
return /^(\+30|0030)?(210)?\d{7}$/.test( value.replace(/[\s\-()\.]/g, "") );
},
phone: function(value) {
return isGreek.mobile(value) || isGreek.landline(value);
}
@osvik
osvik / testing-page.html
Created July 15, 2014 15:55
Google Analytics AB testing code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>AB Google Analytics testing code</title>
<!-- Load the Content Experiment JavaScript API client for the experiment -->
<script src="//www.google-analytics.com/cx/api.js?experiment=[YOUR EXPERIMENT ID]"></script>
<!DOCTYPE html>
<html>
<head>
<title>Greenpeace España</title>
<!-- Page header free html -->
<meta name="msvalidate.01" content="0EFA63D991131147715CF37F8DB5CE8C" />
<meta name='yandex-verification' content='6af16d6b271bec04' />
@osvik
osvik / manual-gzip-howto-and-test.html
Created August 10, 2014 17:08
How to manually gzip CSS and JS files and serve them with Apache
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Manually gzip CSS and JS files</title>
<link rel="stylesheet" href="bootstrap-custom.min.css" type="text/css">
<script src="header-scripts.min.js"></script>
</head>
@osvik
osvik / valida_nif_cif_nie.js
Created November 28, 2014 13:40
valida_nif_cif_nie
// -- VALIDATE ID NUMBER,
//Retorna: 1 = NIF ok, 2 = CIF ok, 3 = NIE ok, -1 = NIF error, -2 = CIF error, -3 = NIE error, 0 = ??? error
function valida_nif_cif_nie(a)
{
var temp=a.toUpperCase();
var cadenadni="TRWAGMYFPDXBNJZSQVHLCKE";
if (temp!==''){
//si no tiene un formato valido devuelve error
@osvik
osvik / connect_and_insert.php
Created May 25, 2016 08:23
Connect to Universe
<?php
class Universe {
/**
* Logins in Salesforce for the API
*
* @return array Returns an associative array with 'access_token' and other
*/
public static function login() {
<?php
$salesforce_credentials = Universe::login();
if ( isset( $salesforce_credentials['instance_url'] ) && isset( $salesforce_credentials['access_token'] ) ) {
$universe_login_error = '';
$universe_login_error_description = '';
$instance_url = $salesforce_credentials['instance_url'];
@osvik
osvik / emailTrack.php
Last active January 29, 2017 22:29
Class to create a GA email tracking pixel
<?php
/**
* @file Class to create a Google Analytics email tracking pixel.
* It will be used to integrate our html email generator "Fabricador"
*/
class EmailTrack {
public $GAtrackingID = 'UA-7467053-1'; // Replace by your Google Analytics Tracking ID
/**
* @namespace Custom validation related
*/
var customValidation = {
/**
* Known str_replace funcion. Required in valida_nif_cif_nie
*/
str_replace: function(e, t, n) {
var j;
@osvik
osvik / AddBrowserLanguagesAsClasses.js
Last active April 23, 2017 08:30
Add browser languages as CSS classes
/*jshint browser: true*/
/**
* Adds the content of navigator.languages or navigator.language as classes to body
* This script must be added after the opening <body> tag.
* @author Osvaldo Gago
*/
(function () {