Skip to content

Instantly share code, notes, and snippets.

View adrianorsouza's full-sized avatar
🏠
Working from home

Adriano Rosa adrianorsouza

🏠
Working from home
View GitHub Profile
@adrianorsouza
adrianorsouza / MOZJPEG.md
Created June 7, 2020 22:42
BUILDING MOZJPEG ON LINUX

BUILDING MOZJPEG ON LINUX

Link: https://calendar.perfplanet.com/2014/mozjpeg-3-0/

cd /usr/local/src

sudo curl -LO https://github.com/mozilla/mozjpeg/releases/download/v3.1/mozjpeg-3.1-release-source.tar.gz
sudo tar -xzvf mozjpeg-3.1-release-source.tar.gz

cd mozjpeg

@adrianorsouza
adrianorsouza / text-overflow-ellipsis.css
Created March 29, 2020 15:17
CSS to make a text overflow collapse with ellipsis
.title {
display: block;
width: 100%;
text-overflow: ellipsis;
white-space: nowrap;
pointer-events: auto;
overflow: hidden;
}
@adrianorsouza
adrianorsouza / fix-laravel-conn-php7.4-mysql8.md
Last active January 12, 2020 19:30
Fix PHP 7.4 + MySQL 8 errors with server has gone away

Fix PHP 7.4 + MySQL 8 errors with server has gone away

PHP 7.4 is now released, and it comes with support for MySQL 8's new password authentication plugin: caching_sha2_password.

1. Connect to the database as root

Depending on your root username, you will be prompted to enter the password, a hostname, etc. By default, typing mysql in your server terminal should work. If you have trouble logging in, try mysql -p -u root, and entering the root password when asked.

2. Check existing authentication plugin:

Replace USERNAME and YOUR_PASSWORD with your application database username and the password.

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@adrianorsouza
adrianorsouza / indeterminate.js
Last active November 13, 2019 23:29
react checkbox indeterminate
// https://davidwalsh.name/react-indeterminate
// To add the indeterminate property to the checkbox, I needed to take advantage of the ref attribute:
const { value, checked, indeterminate } = this.props
return render(
<input
type="checkbox"
value={value}
checked={checked}
<!-- https://www.w3.org/2005/10/howto-favicon -->
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
<head profile="http://www.w3.org/2005/10/profile">
<link rel="icon"
type="image/png"
href="http://example.com/myicon.png">
@adrianorsouza
adrianorsouza / webpack.config.js
Created August 28, 2019 05:20
Full Webpack configuration for Laravel, ReactJS and Bootstrap + LiveServer.
const fs = require('fs');
const os = require('os');
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const postcssNormalize = require('postcss-normalize');
@adrianorsouza
adrianorsouza / connect.js
Created July 23, 2019 01:57 — forked from gaearon/connect.js
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@adrianorsouza
adrianorsouza / createUUID.js
Last active May 6, 2019 17:49
Javascript to generate UUID
function createUUID() {
// http://www.ietf.org/rfc/rfc4122.txt
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
@adrianorsouza
adrianorsouza / nginx.conf
Created August 2, 2018 03:52 — forked from micho/nginx.conf
nginx config for http/https proxy to localhost:3000
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf: