Skip to content

Instantly share code, notes, and snippets.

@aaoliveira
aaoliveira / utf8-regex.js
Created September 30, 2016 00:39 — forked from chrisveness/utf8-regex.js
Utf8 string encode/decode using regular expressions
/**
* Encodes multi-byte Unicode string into utf-8 multiple single-byte characters
* (BMP / basic multilingual plane only).
*
* Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars.
*
* Can be achieved in JavaScript by unescape(encodeURIComponent(str)),
* but this approach may be useful in other languages.
*
* @param {string} unicodeString - Unicode string to be encoded as UTF-8.
@aaoliveira
aaoliveira / index.html
Created September 15, 2016 12:54
Novo exemplo
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@aaoliveira
aaoliveira / index.html
Created September 14, 2016 20:24
Checkout
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@aaoliveira
aaoliveira / auth3.php
Created September 14, 2016 00:31
Terceiro exemplo de auth
curl_setopt_array($curl, array(
CURLOPT_URL => "https://apic1.hml.stelo.com.br/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "utf-8",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"authorization: Basic Y2Y4ZGI2ZmU2MWJjMWVmZWJjNmFlNGY1YWI0YWY2MGM6ZjUzOGI3M2ExMWVhYzQ5ODI3ZjZkYTY3OGU4NTlmYTc=",
@aaoliveira
aaoliveira / auth2.php
Created September 14, 2016 00:07
Segundo exemplo de auth
try {
$clientId ='cf8db6fe61bc1efebc6ae4f5ab4af60c';
$clientSecret = 'f538b73a11eac49827f6da678e859fa7';
$auth_token = base64_encode($clientId . ':' . $clientSecret);
$target_url = 'https://apic1.hml.stelo.com.br';
$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId . ':' . $clientSecret);
$headers = array('Authorization=Basic ' . $auth_token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
@aaoliveira
aaoliveira / auth.php
Created September 13, 2016 23:40 — forked from anonymous/auth.php
Exemplo autenticação http basic
$login = 'hjk3kj3h534h53kj4j345';
$password = '3k45jh3k4j5h3k4j5h34kh5k34';
$url = 'https://apic1.hml.stelo.com.br/';
$encode = base64_encode("$login:$password");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
@aaoliveira
aaoliveira / git_meld_install.sh
Created April 27, 2016 16:49 — forked from MarcosX/git_meld_install.sh
Install Meld as the default git diff tool. Must be executed as sudo
#!/bin/bash
echo "Installing meld..."
apt-get install meld -y -qq
echo "Meld [OK]"
echo "Creating meld custom script..."
rm ~/.config/git_meld_diff.sh
touch ~/.config/git_meld_diff.sh
echo "#!/bin/bash" >> ~/.config/git_meld_diff.sh
@aaoliveira
aaoliveira / sgments.php
Created March 7, 2016 01:11
Controller atual
public function store(Request $request)
{
try {
DB::beginTransaction();
$data = $request->input();
$validator = Validator::make($data, [
'razao_social' => 'required',
'nome_fantasia' => 'required',
'telefone_1' => 'required',
'cnpj' => 'required',
@aaoliveira
aaoliveira / Segment.php
Created March 7, 2016 01:10
Model Sement
<?php
namespace app\Models;
use Exception;
use Illuminate\Database\Eloquent\Model;
/**
* Class Segment.
*/
@aaoliveira
aaoliveira / company.php
Created March 7, 2016 00:52
Controller Company
// Metodo no meu controller
public function store(Request $request)
{
try {
DB::beginTransaction();
$data = $request->input();
$validator = Validator::make($data, [
'razao_social' => 'required',
'nome_fantasia' => 'required',
'telefone_1' => 'required',