Skip to content

Instantly share code, notes, and snippets.

View vinyvicente's full-sized avatar
🎯
Focusing

Vinicius vinyvicente

🎯
Focusing
View GitHub Profile
@vinyvicente
vinyvicente / create_kinesis_stream.sh
Created February 16, 2023 14:58 — forked from etspaceman/create_kinesis_stream.sh
Local Kinesis Setup w/ LocalStack
#!/usr/bin/env bash
export $(cat .env | xargs)
KINESIS_STREAM_SHARDS=${KINESIS_STREAM_SHARDS:-1}
export USE_SSL=true
awslocal kinesis create-stream --shard-count ${KINESIS_STREAM_SHARDS} \
--stream-name ${KINESIS_STREAM_NAME}
@vinyvicente
vinyvicente / consumer.php
Created February 13, 2023 11:25 — forked from fbrnc/consumer.php
AWS Kinesis Example for PHP (using the AWS SDK for PHP)
<?php
// curl -sS https://getcomposer.org/installer | php
// php composer.phar require aws/aws-sdk-php
// export AWS_ACCESS_KEY_ID=...
// export AWS_SECRET_ACCESS_KEY=...
$streamName = '<INSERT_YOUR_STREAMNAME_HERE>';
$numberOfRecordsPerBatch = 10000;
@vinyvicente
vinyvicente / QEMU-Silicon-Mac-Virtualization.md
Created September 14, 2021 16:09 — forked from nrjdalal/QEMU-Silicon-Mac-Virtualization.md
Create Virtual Machines using QEMU on Silicon based Apple Macs

Install QEMU on Silicon based Apple Macs (June 2021)

Option 1 - Automatically

zsh -c "$(curl -fsSL https://raw.githubusercontent.com/nrjdalal/silicon-virtualizer/master/install-qemu.sh)"

Option 2 - Manually

  • Install Xcode command line tools

xcode-select --install
@vinyvicente
vinyvicente / references_go.txt
Created January 26, 2021 18:04
Go path references
https://golang.org/
https://go.dev/
https://pkg.go.dev/
https://go-proverbs.github.io/
https://golang.org/doc/effective_go.html
https://blog.golang.org/errors-are-values
https://github.com/golang/go/wiki/CodeReviewComments
https://golang.org/doc/faq
https://golang.org/ref/spec
https://blog.golang.org/constants
@vinyvicente
vinyvicente / results.md
Last active May 15, 2019 17:05
Benchmark PHP 7.3.5 vs Node 12.1.0

PHP

Last login: Wed May 15 10:34:29 on ttys001
Vinicius-MacBook:~ vinyvicente$ wrk -t4 -c400 -d10s http://127.0.0.1:1337/
Running 10s test @ http://127.0.0.1:1337/
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.78ms    1.55ms  23.47ms   82.95%
    Req/Sec     0.90k   458.32     1.57k    69.44%
@vinyvicente
vinyvicente / 1_Laravel_state-machine.md
Created February 6, 2018 18:23 — forked from iben12/1_Laravel_state-machine.md
Laravel: State-machine on Eloquent Model

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.

<?php
$json = json_decode('[
{
"id":1,
"descricao":"Tipo de Registro 01",
"status_op":"status de op 01",
"status_atividade":"status de atividade 01",
"exige_atividade":false,
"acao_op":"Nenhum",
@vinyvicente
vinyvicente / symfony3-rest-api.md
Last active March 19, 2018 08:13 — forked from diegonobre/symfony3-rest-api.md
Basic RESTful API with Symfony 3 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 3 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authenticationu
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 3 framework. The following SF2 bundles are used :

@vinyvicente
vinyvicente / compile-nginx-from-source.sh
Created September 14, 2017 19:55 — forked from nurrony/compile-nginx-from-source.sh
All configuration files needed to install nginx on Ubuntu 16.04 Compile Nginx from source with nginx-rtmp-module, pagespeed and cache-purge module.
#change it to latest version
NPS_VERSION=1.11.33.0;
echo "Changing Directory to $HOME..."
cd $HOME;
echo "Nginx version to install: " && \
read NGINX_VERSION && \
echo "Downloading nginx-$NGINX_VERSION..." && \
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && \
echo "Installing Nginx Dependencies..." && \
@vinyvicente
vinyvicente / nginx-tuning.md
Created September 10, 2017 19:33 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.