Skip to content

Instantly share code, notes, and snippets.

View useless-stuff's full-sized avatar
🤓
Learning

1317 useless-stuff

🤓
Learning
View GitHub Profile
@useless-stuff
useless-stuff / php_regex_iterator.php
Created February 19, 2016 15:44
PHP - RegexIterator
<?php
$data = array('EC2-CHOPIN01','EC2-CHOPIN02','EC2-CHOPIN03','GCE-MOZART01','GCE-MOZART02');
$iterator = new RegexIterator(new ArrayIterator($data),"/(EC2)/");
foreach($iterator as $serviceInstance){
echo $serviceInstance . PHP_EOL;
}
/*
EC2-CHOPIN01
EC2-CHOPIN02
EC2-CHOPIN03
@useless-stuff
useless-stuff / php_append_iterator.php
Created February 19, 2016 11:24
PHP - AppendIterator
<?php
$appendIterator = new AppendIterator();
$data = array('a_elementOne','a_elementTwo','a_elementThree');
$appendIterator->append(new ArrayIterator($data));
$data = array('b_elementOne','b_elementTwo','b_elementThree');
$appendIterator->append(new ArrayIterator($data));
foreach($appendIterator as $item){
@useless-stuff
useless-stuff / letsencrypt.sh
Last active September 23, 2018 13:17
TLS/SSL - Let's Encrypt free SSL certificate install script
#!/bin/bash
a2enmod ssl -y
apt-get update -y
apt-get install git -y
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
cd /opt/letsencrypt
./letsencrypt-auto --apache -d domain.com -d domain.com -d domain.com
@useless-stuff
useless-stuff / letsencrypt.sh
Created February 18, 2016 20:26
TLS/SSL - Let's Encrypt free SSL certificate install script
#!/bin/bash
a2enmod ssl -y
apt-get update -y
apt-get install git -y
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
cd /opt/letsencrypt
./letsencrypt-auto --apache -d anniballo.com -d diego.anniballo.com -d www.anniballo.com
@useless-stuff
useless-stuff / anniballo.com.conf
Last active February 9, 2023 16:38
TLS/SSL - Let's Encrypt free SSL certificate virtual host example
<VirtualHost *:80>
ServerName anniballo.com
ServerAlias diego.anniballo.com www.anniballo.com
Redirect permanent / https://diego.anniballo.com/
</VirtualHost>
<VirtualHost *:443>
ServerName anniballo.com
ServerAlias diego.anniballo.com www.anniballo.com
ServerAdmin diego.anniballo@gmail.com
# [...]
@useless-stuff
useless-stuff / php_infinite_iterator.php
Created February 18, 2016 14:47
PHP - InfiniteIterator
<?php
// Use InfititeIterator for traversing a circular data structure
// https://en.wikipedia.org/wiki/Circular_buffer
/**
* Interface AvailabilityService
*/
interface AvailabilityService
{
/**
@useless-stuff
useless-stuff / error_template.php
Last active March 10, 2016 07:40
WP - Gister plugin
<div class="error">
Gister plugin: you must specified a snippet id attribute for render gist code, try with [gister snippet-id="put here the code"]
</div>
@useless-stuff
useless-stuff / php_empty_iterator.php
Last active February 16, 2016 23:54
PHP - EmptyIterator
<?php
/**
* Class Adapter
*/
abstract class Adapter extends RecursiveArrayIterator{
}
/**
* Class GoogleDriveAdapter
@useless-stuff
useless-stuff / php_norewind_iterator.php
Last active February 16, 2016 14:45
PHP - NoRewindIterator
<?php
/**
* Class Message
*/
abstract class Message
{
protected $text;
/**
@useless-stuff
useless-stuff / php_recursive_caching_iterator.php
Created February 16, 2016 14:28
PHP - RecursiveCachingIterator
<?php
/**
* Class User
*/
class User
{
public $name;
/**