Skip to content

Instantly share code, notes, and snippets.

Avatar

Yoander Valdés Rodríguez yoander

View GitHub Profile
@yoander
yoander / nullable-functions.php
Last active Jul 14, 2018
PHP 7.1 New Features
View nullable-functions.php
<?php
function returnStringOrNull($valueToReturn): ?string {
return $valueToReturn;
}
echo 'LibreByte:', gettype(returnStringOrNull('LibreByte')), nl2br("\n");
echo 'null:', gettype(returnStringOrNull(null)), nl2br("\n");
echo '25:', gettype(returnStringOrNull(25)), nl2br("\n");
echo 'SdtClass object:', gettype(returnStringOrNull(new StdClass())), nl2br("\n");
@yoander
yoander / playradio.sh
Last active Mar 2, 2018
Radio Cuba Broadcasting (Play Radio Cuba)
View playradio.sh
#!/usr/bin/env bash
declare -A radios
# Radio Pogreso
radios[RP]=XjfW7qWN
# Radio Rebelde
radios[RRe]=zrXXWK9F
# Radio Reloj
radios[RR]=b3jbfThq
# CMBF Radio Nacional Nacional
radios[CMBF]=Nbtz7HT3
View ObjectComparator.php
<?php
namespace Comparator;
use ReflectionObject;
use InvalidArgumentException;
class ObjectComparator
{
/**
@yoander
yoander / is_root.sh
Last active Dec 22, 2017
Script to detect if one user has root privileges
View is_root.sh
#!/usr/bin/env bash
userdo=
echo Testing if you have root access!
if [[ 'root' == whoami ]]; then
is_root=true
else
is_root=false
fi
View round.go
package main
import (
"log"
"math"
)
func Round(val float64, roundOn float64, places int ) (newVal float64) {
var round float64
pow := math.Pow(10, float64(places))
@yoander
yoander / vboxssh.sh
Last active Dec 10, 2017
Bash function to connect via ssh to Virtual Box VM using VM Name
View vboxssh.sh
#
# Connect to VM by VM Name via shh if user is not specified
# then try to connect using root user
# Examples: vboxssh root@CentOS7, vboxssh CentOS7
#
function vboxssh {
USER=
if [[ "$1" == *@* ]]; then
# Get the user for ssh connection
USER=$(echo $1|cut -d@ -f1) || $(echo root)
View wp-redirect.php
<?php
// Check if a redirect is needed
$redirect = !isset($_SERVER['HTTPS']) || ('on' != $_SERVER['HTTPS']);
$redirect = $redirect || !isset($_SERVER['HTTP_X_FORWARDED_PROTO']) || ('https' != $_SERVER['HTTP_X_FORWARDED_PROTO']);
// Permanent redirect to https version
if ($redirect) {
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], true, 301);
exit();
}
View fastcgi.conf
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
View emails.txt
imperdiet.nec.leo@etmalesuadafames.net
molestie.in.tempus@nuncQuisque.edu
a.sollicitudin.orci@ut.edu
lorem.Donec.elementum@arcuNunc.ca
et.rutrum.eu@nisidictumaugue.ca
augue@Cumsociis.co.uk
adipiscing@convallisestvitae.com
Nunc.sed.orci@rhoncusDonecest.org
pede@tempuslorem.net
imperdiet@InloremDonec.ca
View dirs.txt
gnu linux/debian
gnu linux/ubuntu
cms
commands
editors/vim
editors/geany
games
nosql
unix