Skip to content

Instantly share code, notes, and snippets.

Avatar

Alberto Hernández devluis

View GitHub Profile
View gist:c64bb716cf407a1a28c9
<?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);
}
?>
View gist:60d0ef940a9b42323e23
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 Mar 21, 2015
Auto-load MySQL on startup on OSX Yosemite
View com.mysql.mysql.plist
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>
View multiple-markers-google-maps.html
<!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 May 29, 2020
Responsive Multilevel Horizontal Menu only with CSS
View horizontal-responsive-multilevel-menu.html
<!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 Dec 15, 2014
Style Placeholder Text
View styles-placeholder.css
::-webkit-input-placeholder {
color: red;
}
:-moz-placeholder { /* Firefox 18- */
color: red;
}
::-moz-placeholder { /* Firefox 19+ */
color: red;
@devluis
devluis / replace-special-chars.php
Created Dec 12, 2014
Replace special chars in php
View replace-special-chars.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.'
View gist:77208839596faeee71fd
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 Nov 1, 2014
Snippet Favicons for all devices
View all-favicons.html
<!-- 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 Oct 18, 2014
Increase / Decrease value on input with Jquery
View changevalueinput.html
<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');
You can’t perform that action at this time.