Skip to content

Instantly share code, notes, and snippets.


Thiago Vieira Thivieira

View GitHub Profile
Thivieira /
Created Jun 27, 2021 — forked from nichtich/
How to automatically deploy from GitHub

Deploy your site with git

This gist assumes:

  • you have an online remote repository (github / bitbucket etc.)
  • you have a local git repo
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by Apache
  • the Apache user is named www-data (may be apache on other systems)
Thivieira /
Created Jun 28, 2020 — forked from BFTrick/
Download & Install WordPress via Curl
curl -O
mv wordpress site

Utilizando Faker em pt-BR

Acesse o seu arquivo app/Providers/AppServiceProvider.php, e no método register adicione o seguinte :

 * Register any application services.
 * @return void
Thivieira /
Created May 24, 2018
Sequelize + Express + Migrations + Seed Starter
Thivieira / install-comodo-ssl-cert-for-nginx.rst
Created May 15, 2018 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.
View install-comodo-ssl-cert-for-nginx.rst

Setting up a SSL Cert from Comodo

I use as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert



Not Web Security...

Auth Basics

We check passwords against the records in our database.

Authentication – Is this person who they say they are?

How do people stay logged in?

Thivieira /
Created May 5, 2018 — forked from zcaceres/
Using `Returning` with Sequelize and Postgres

Using Returning with Sequelize and Postgres

Some Sequelize commands don't return anything (or at least not anything useful) by default. Sequelize uses an option called returning to specify which data returns from a commands like .destroy() or update().

Let's look at three common Sequelize commands and see how to handle the data returned by each.


By default, .create() returns the newly created instance. This is convenient, because we can then send data to the user:


'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

Thivieira / nearby-coordinates.sql
Created Apr 19, 2018 — forked from statickidz/nearby-coordinates.sql
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
View nearby-coordinates.sql
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
Thivieira / index.html
Created Mar 2, 2018
React Redux modals with portals(3/3)
View index.html
<!-- What our app will be rendered into -->
<div id="app"></div>