Skip to content

Instantly share code, notes, and snippets.

View matheus-santos's full-sized avatar
🏠
Working from home

Matheus Santos matheus-santos

🏠
Working from home
View GitHub Profile
@matheus-santos
matheus-santos / git_url_shortener.md
Created June 1, 2016 14:46
Git.io: GitHub URL Shortener

Do you have a GitHub URL you'd like to shorten? Use Git.io!

$ curl -i https://git.io -F "url=https://github.com/..."
HTTP/1.1 201 Created
Location: https://git.io/abc123

$ curl -i https://git.io/abc123
HTTP/1.1 302 Found
Location: https://github.com/...
@matheus-santos
matheus-santos / database_size.sql
Last active August 25, 2016 20:06
Database size in mysql
SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;
show variables where variable_name = 'general_log';
set global general_log = 0;
select count(*) from mysql.general_log;
@matheus-santos
matheus-santos / symlink_win10.bat
Last active October 21, 2016 20:59
Sym link Windows 10
@matheus-santos
matheus-santos / vagrant + docker + windows 10.md
Created October 17, 2016 23:50 — forked from eibreans/vagrant + docker + windows 10.md
Passo a passo docker rodando sobre o vagrant no windows 10

A ideia é ter um Linux virtualizado no windows, que dê para rodar o docker e usar o vagrant como um sistema sobre o Windows. Para não precisar de fazer dual boot, já que tudo o que eu preciso é um terminal Linux que eu posso instalar qualquer coisa com apt-get :)

  1. Instalar no windos o cmder, um emulador de console http://cmder.net/

  2. Instalar virtual box https://www.virtualbox.org/wiki/Downloads

  3. Instalar o vagrant

@matheus-santos
matheus-santos / 01_add_cors.config.yaml
Created October 1, 2018 11:26 — forked from vsviridov/01_add_cors.config.yaml
Add CORS to Nginx on AWS Elastic Beanstalk
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
@matheus-santos
matheus-santos / lodash__black_list_white_list.js
Created October 2, 2018 12:59
Lodash: Delete unwanted properties from the javascript object
You can approach it from either a white list or black list way:
// Black list
// Remove the values you don't want
var result = _.omit(credentials, ['age']);
// White list
// Only allow certain values
var result = _.pick(credentials, ['fname', 'lname']);
If it's reusable business logic, you can partial it out as well:
@matheus-santos
matheus-santos / duplicate_row_in_mysql.sql
Last active October 11, 2018 21:22
Duplicate row in MySQL
-- Replace `{{TABLE_NAME}}` to desired table
-- Replace `{{ID}}` to desired row you want to replace
create temporary table `temp` select * from `{{TABLE_NAME}}` where id = {{ID}};
update `temp` SET id = (select id from {{TABLE_NAME}} order by id desc limit 1) + 1 where id = {{ID}};
insert into `{{TABLE_NAME}}` select * from `temp`;
drop TEMPORARY table if exists `temp`;
@matheus-santos
matheus-santos / banks_BR.json
Created April 13, 2016 15:32
Lista de bancos que operam no Brasil
[
{
"code": "001",
"name": "Banco do Brasil",
"short_name": "BB",
"jurisdiction": "Federal",
"website": "www.bb.com.br"
},
{
"code": "002",
@matheus-santos
matheus-santos / get_query_log.php
Last active March 4, 2019 13:00
See last executed queries in Laravel
\DB::enableQueryLog();
// Laravel query operation here ...
print_r(\DB::getQueryLog()); exit;
@matheus-santos
matheus-santos / cheat_sheet_socketio
Last active May 1, 2019 19:23
SocketIO cheat sheet to emit messages through sockets
// SocketIO cheat sheet
// SocketIO is a library that makes websockets communications easier.
// Page: http://socket.io/
// ref: http://stackoverflow.com/a/10099325
// send to current request socket client
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.sockets.emit('message', "this is a test");