Skip to content

Instantly share code, notes, and snippets.

View devluis's full-sized avatar

Alberto Hernández devluis

View GitHub Profile
<?php
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */
function makeMyUrlFriendly($url){
$output = preg_replace("/\s+/" , "_" , trim($url));
$output = preg_replace("/\W+/" , "" , $output);
$output = preg_replace("/_/" , "-" , $output);
return strtolower($output);
}
?>
function getSignature() {
//pretty basic function for testing
if ( startupChecks()) { return; }
var email = SpreadsheetApp.getActiveSpreadsheet().getActiveCell().getValue().toString();
if ( email === "" ) {
Browser.msgBox("No email selected", "Please select a cell containing a user's email" , Browser.Buttons.OK);
return;
}
var result = authorisedUrlFetch(email, {});
Browser.msgBox(result.getContentText());
@devluis
devluis / com.mysql.mysql.plist
Created March 21, 2015 17:30
Auto-load MySQL on startup on OSX Yosemite
First, create a new file: /Library/LaunchDaemons/com.mysql.mysql.plist
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true />
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>ProgramArguments</key>
@devluis
devluis / multiple-markers-google-maps.html
Created February 19, 2015 20:46
Google Maps Multiple Markers
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 500px; height: 400px;"></div>
@devluis
devluis / horizontal-responsive-multilevel-menu.html
Last active June 9, 2021 14:38
Responsive Multilevel Horizontal Menu only with CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Responsive Multilevel Horizontal Menu</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<style>
#menu ul {
margin: 0;
padding: 0;
@devluis
devluis / styles-placeholder.css
Created December 15, 2014 02:20
Style Placeholder Text
::-webkit-input-placeholder {
color: red;
}
:-moz-placeholder { /* Firefox 18- */
color: red;
}
::-moz-placeholder { /* Firefox 19+ */
color: red;
@devluis
devluis / replace-special-chars.php
Created December 12, 2014 20:54
Replace special chars in php
<?php
$stringOriginal = "Este string contiene acentos, ÁFRICA, MÉXICO, ÍNDICE, CANCIÓN y NÚMERO.";
$specialChars = array("á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", "ñ", "Ñ");
$replacementChars = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "n", "N");
$replacedString = str_replace($specialChars, $replacementChars, $originalString);
print $replacedString; // output 'Este string contiene acentos, ÁFRICA, MÉXICO, ÍNDICE, CANCIÓN y NÚMERO.'
var API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
var mc_base_url = 'http://us7.api.mailchimp.com/1.3/?method=listSubscribe';
var mc_list_id = 'xxxxxxxxxx';
var mc_double_optin = false;
/**
* Uses the MailChimp API to add a subscriber to a list.
*/
function sendToMailChimp_(fn, ln, em, yr){
@devluis
devluis / all-favicons.html
Created November 1, 2014 19:16
Snippet Favicons for all devices
<!-- Favicon for old browsers -->
<link rel="shortcut icon" type="image/x-icon" href="img/favicon/16.ico"/>
<!-- Favicons for browser with out support .ico file -->
<link rel="icon" type="image/png" href="img/favicon/16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="img/favicon/32x32.png" sizes="32x32">
<!-- For Google TV -->
<link rel="icon" type="image/png" href="img/favicon/96x96.png" sizes="96x96">
@devluis
devluis / changevalueinput.html
Created October 18, 2014 05:15
Increase / Decrease value on input with Jquery
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/Javascript">
$(document).ready(function () {
$(function () {
$('.add').on('click',function(){
var $qty=$(this).closest('p').find('.qty');