Skip to content

Instantly share code, notes, and snippets.

View rodrigoSyscop's full-sized avatar
🇧🇷
¯\_(ツ)_/¯

Rodrigo Vieira rodrigoSyscop

🇧🇷
¯\_(ツ)_/¯
  • Curitiba - PR
View GitHub Profile
<?php
namespace App\Http\Controllers;
use App\Http\Requests\UrlRequest;
use App\Model\Url;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
<table border="1">
<tr>
<td rowspan="4">11</td>
<td rowspan="2">11</td>
<td>11</td>
<td>11</td>
<td>11</td>
</tr>
<tr>
@rodrigoSyscop
rodrigoSyscop / renew_aws_ec2_eip.py
Created March 9, 2019 19:06
Renew current EIP of an AWS EC2 Instance
import boto3
import urllib.request
from botocore.exceptions import ClientError
METADATA_URL = 'http://169.254.169.254/latest/meta-data'
instance_id = urllib.request.urlopen(METADATA_URL + '/instance-id').read().decode()
current_eip = urllib.request.urlopen(METADATA_URL + '/public-ipv4').read().decode()
@rodrigoSyscop
rodrigoSyscop / app.php
Created March 10, 2018 17:34
framework/src/app.php
<?php //framework/src/app.php
use Symfony\Component\Routing;
use Symfony\Component\HttpFoundation\Response;
function is_leap_year($year = null) {
if (null === $year) {
$year = date('Y');
}
@rodrigoSyscop
rodrigoSyscop / front.php
Created March 10, 2018 17:33
framework/web/front.php
<?php //framework/web/front.php
require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing;
function render_template($request)
{
@rodrigoSyscop
rodrigoSyscop / front.php
Created March 10, 2018 17:24
framework/web/front.php
<?php //framework/web/front.php
// ...
try {
$request->attributes->add($matcher->match($request->getPathInfo()));
$response = call_user_func('render_template', $request);
} catch (Routing\Exception\ResourceNotFoundException $exception) {
$response = new Response('Not Found', 404);
} catch (Exception $exception) {
$response = new Response('An error occurred', 500);
@rodrigoSyscop
rodrigoSyscop / app.php
Created March 3, 2018 14:16
framework/src/app.php
<?php //framework/src/app.php
use Symfony\Component\Routing;
$routes = new Routing\RouteCollection();
$routes->add(
'hello',
new Routing\Route(
'/hello/{name}',
array('name' => 'World')
@rodrigoSyscop
rodrigoSyscop / hello.php
Created March 3, 2018 14:15
framework/src/pages/hello.php
<!-- example.com/src/pages/hello.php -->
Hello <?php echo htmlspecialchars($name, ENT_QUOTES, 'UTF-8') ?>
@rodrigoSyscop
rodrigoSyscop / front.php
Created March 3, 2018 14:12
framework/web/front.php
<?php //framework/web/front.php
require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing;
$request = Request::createFromGlobals();
$routes = include __DIR__.'/../src/app.php';
@rodrigoSyscop
rodrigoSyscop / hello.php
Created March 3, 2018 13:20
framework/src/pages/hello.php
<!-- framework/src/pages/hello.php -->
Hello <?php echo htmlspecialchars(isset($name) ? $name : 'World', ENT_QUOTES, 'UTF-8') ?>