Skip to content

Instantly share code, notes, and snippets.

@yoander
yoander / nullable-functions.php
Last active July 14, 2018 22:19
PHP 7.1 New Features
<?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 March 2, 2018 15:12
Radio Cuba Broadcasting (Play Radio Cuba)
#!/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
<?php
namespace Comparator;
use ReflectionObject;
use InvalidArgumentException;
class ObjectComparator
{
/**
@yoander
yoander / is_root.sh
Last active December 22, 2017 02:39
Script to detect if one user has root privileges
#!/usr/bin/env bash
userdo=
echo Testing if you have root access!
if [[ 'root' == whoami ]]; then
is_root=true
else
is_root=false
fi
@yoander
yoander / round.go
Created December 15, 2017 14:33 — forked from pelegm/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 December 10, 2017 16:35
Bash function to connect via ssh to Virtual Box VM using VM Name
#
# 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)
<?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();
}
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;
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
@yoander
yoander / dirs.txt
Last active November 7, 2016 19:08
gnu linux/debian
gnu linux/ubuntu
cms
commands
editors/vim
editors/geany
games
nosql
unix