Skip to content

Instantly share code, notes, and snippets.

View esilvajr's full-sized avatar

Edison Silva Jr esilvajr

  • Arquivei
  • Jaboticabal/São Carlos, SP
View GitHub Profile
@esilvajr
esilvajr / Makefile
Created August 21, 2017 12:01 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config
configfile=config.env
ifdef cnf
configfile=$(cnf)
endif
include $(configfile)
export $(shell sed 's/=.*//' $(configfile))
# import deploy config
deployfile=deploy.env

Lumen and naming transactions into NewRelic

Problem: How to build transaction name for NewRelic in Lumen.

Description: NewRelic tries to group similar transaction into group, to be able easier watch for them later on Extra-Problem: NewRelic has an issue and becuase of that they can not group following transactions:

  • /orders/zzZfN0kZ6F1PtFdQ4Baq
  • /orders/aaZDd0k43D1GtFeG5cCe ...
@esilvajr
esilvajr / escape_eloquent.php
Last active May 26, 2017 21:55
search with \\ escape in laravel eloquent in mysql
<?php
$name = "Léo";
$name = json_encode($name);
if (strpos($name, '\\u00') !== false) {
//the first bar is the escape and the second is the real bar
//so we have one bar in search
//and in replace 8 bars, because laravel will scape this bars again and we need 4 to select works in mysql :)

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

@esilvajr
esilvajr / ConvertArrayOfObjectSample.php
Last active May 23, 2020 06:49
This is a basic solution when we need to convert a array of objects into a multidimensional array in PHP.
<?php
/**
* This is just a class for our tests
*/
class Foo
{
/**
* @var foo
*/
public $foo = 'foo';
@esilvajr
esilvajr / latest-widevine.sh
Created February 9, 2017 12:06 — forked from ruario/intro-latest-widevine.md
Fetches Chrome and extracts out Widevine so that it can be used by Vivaldi. Also works with other Chromium-based browsers, see guide below.
#!/usr/bin/env bash
available () {
command -v $1 >/dev/null 2>&1
}
# Make sure we have wget or curl
if available wget; then
SILENT_DL="wget -qO-"
LOUD_DL="wget"
<html>
<head>
<title>Hello PHP Form</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style type="text/css">
<!--
body {
background: #eee !important;
}
<?php
class Connect
{
private $host = "127.0.0.1"; //localhost
private $database = "academia_hello_php";
private $username = "root";
private $password = "root";
private $driver = "mysql";
// Configuração
// Método 1
// Você pode definir suas credenciais de acesso, entre outras configurações, editando o arquivo
// PagSeguroLibrary/config/PagSeguroConfig.php
$PagSeguroConfig = array();
$PagSeguroConfig['environment'] = "production"; // production, sandbox
$PagSeguroConfig['credentials'] = array();
$PagSeguroConfig['credentials']['email'] = "your_pagseguro_email";
$PagSeguroConfig['credentials']['token']['production'] = "your_production_pagseguro_token";