Skip to content

Instantly share code, notes, and snippets.

View jhonata-menezes's full-sized avatar
🏠
Working ...

Jhonata Menezes jhonata-menezes

🏠
Working ...
View GitHub Profile
@jhonata-menezes
jhonata-menezes / mogodb_to_elasticsearch.sh
Created December 20, 2016 17:44
Exportar uma collection para json no formato de bulk insert do elasticsearch
#export mongodb to json with pattern elasticsearch bulk insert without _id (mongodb)
mongoexport -h 127.0.0.1 --port 27017 -d db -c collection -f fields | sed '/"_id":/s/"_id":[^,]*,//' | awk '{print "{\"index\": {\"_index\": \"index_name\", \"_type\": \"type_name\"}}\n"$0}' > elasticsearch.json
@jhonata-menezes
jhonata-menezes / guzzle_change_body.php
Last active August 29, 2019 06:11
Guzzle 6: change body response
<?php
/**
* sources:
* http://docs.guzzlephp.org/en/latest/handlers-and-middleware.html#middleware
* https://evertpot.com/222/
*
*/
use GuzzleHttp\Client;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
<?php
$logger = new Logger('name_app');
$logger->pushProcessor(function(array $record){
if($record['level_name'] >= Logger::ERROR){
$record['context'] = debug_backtrace();
}
$debug = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 10);
if(count($debug) >= 6 && isset($debug[6]['class'], $debug[6]['line'], $debug[6]['function'])){
{
"liga": {
"liga_id": 221014,
"time_dono_id": 1277,
"clube_id": null,
"nome": "A...",
"descricao": "...",
"slug": "a",
"tipo": "A",
"tipo_flamula": 1,
@jhonata-menezes
jhonata-menezes / api_sensor.html
Created June 27, 2017 17:57
Utilizando a API de sensor de luz com chrome e android
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
Sensor de Luz
This file has been truncated, but you can view the full file.
{
"rodada" : 3,
"atletas" : {
"37245" : {
"apelido" : "Guto Ferreira",
"pontuacao" : 0.94,
"scout" : {},
"foto" : "https://s.glbimg.com/es/sde/f/2017/02/21/f52648766ac7a16d0625f73fbb3daa12_140x140.png",
@jhonata-menezes
jhonata-menezes / ttfb.py
Created March 27, 2018 12:20
ttfb with python 3.6
import time
from urllib import request
host = "https://www.buscape.com.br/notebook"
opener = request.build_opener()
request = request.Request(host)
request.add_header('user-agent', 'firefox')
start = time.time()
resp = opener.open(request)
# read one byte
#pip install peewee
from peewee import *
db = MySQLDatabase('simplex', password='simplex',
user='root',
host='127.0.0.1',
port=3306)
class MonitoringLinks(Model):
id = PrimaryKeyField()
FROM nyanpass/php5.5:5-fpm
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mysql
RUN docker-php-ext-install mysqli
EXPOSE 9000
version: '2'
services:
mysql:
image: mysql:5.7
restart: always
# ports:
# - "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: mydb