Skip to content

Instantly share code, notes, and snippets.

Avatar

Yoander Valdés Rodríguez yoander

View GitHub Profile
View ObjectComparator.php
<?php
namespace Comparator;
use ReflectionObject;
use InvalidArgumentException;
class ObjectComparator
{
/**
@yoander
yoander / preseed.cfg
Last active May 26, 2020
Debian automatic installer script
View preseed.cfg
#### Contents of the preconfiguration file (for buster)
### Localization
# Preseeding only locale sets language, country and locale.
#d-i debian-installer/locale string en_US
# The values can also be preseeded individually for greater flexibility.
d-i debian-installer/language string en
d-i debian-installer/country string EC
d-i debian-installer/locale string en_US.UTF-8
# Optionally specify additional locales to be generated.
@yoander
yoander / xmlpp.py
Last active Jan 9, 2020
Python script to pretty print XML files
View xmlpp.py
#!/usr/bin/python
import os
import re
import HTMLParser as parser
import xml.dom.minidom as minidom
import sys
try:
# Read de file name from standard input
filename = sys.argv[1]
@yoander
yoander / wsrv-stop.sh
Last active Feb 22, 2019
Script to stop Apache server on Android (Termux)
View wsrv-stop.sh
#
# This script is part of the video,
# Cómo instalar Apache Web Server en Android: https://youtu.be/cwp63pJMy_A and
# it's intended to be used on Termux Android 32 bits in order to fix the issue,
# https://github.com/termux/termux-packages/issues/1727
# Before executing this script you must install termux-chroot see de video,
# Cómo hacer chroot en Termux: https://youtu.be/gdy12S94BBk
#
#!/usr/bin/env bash
aps=$(pidof httpd)
View abstract-override1.php
<?php
abstract class A
{
abstract function test(string $s);
}
abstract class B extends A
{
abstract function test($s) : int;
View data.xml
<?xml version="1.0" encoding="UTF-8"?>
<records>
<record>
<Name>Nicole</Name>
<Company>Ac Mattis LLC</Company>
<Address>Ap #823-8881 Adipiscing Avenue</Address>
<City>Fontanellato</City>
<Country>Puerto Rico</Country>
<Phone>(444) 834-6922</Phone>
<Geo>5.84145, -13.30146</Geo>
@yoander
yoander / polylang-hack.php
Last active Sep 11, 2018
Polylang hack for category, tag translation
View polylang-hack.php
function before_get_post ($stm) {
if ($stm->is_category || $stm->is_tag) {
$term_lang = !empty($stm->query['lang']) ? $stm->query['lang'] : '';
if (empty($term_lang) ||
!function_exists('pll_default_language') ||
($term_lang === pll_default_language())) {
return;
}
@yoander
yoander / db.php
Last active Aug 2, 2018
Generators
View db.php
<?php
function connect() {
$link = @mysqli_connect('localhost:2483', 'root', 'root', 'world');
if ($error = mysqli_connect_errno()) {
return sprintf("Error de conexión: #%s - %s\n", $error, mysqli_connect_error());
}
mysqli_set_charset($link, 'utf8');
return $link;
}
View symmetric-array-destructuring-keys-values.php
<?php
$countries = [
['country' => 'Spain', 'lang' => 'ES', 'currency' => 'EUR'],
['country' => 'USA', 'lang' => 'EN', 'currency' => 'USD']
];
foreach ($countries as ['country' => $countryName, 'lang' => $language, 'currency' => $currency]) {
echo "<strong>Country: </strong> $countryName, <strong>Language: </strong> $language, <strong>Currency: </strong> $currency";
echo nl2br("\n");
View negative-string-offset.php
<?php
var_dump("abcdef"[-2]); // Print: string (1) "e"
var_dump(strpos("aabbcc", "b", -3)); // Print: int(3)
$string = 'bar';
echo "El último carácter de '$string' es '$string[-1]'.\n";
// Print: El último carácter de 'bar' is 'r'