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 / 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 / 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 / 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 / symlink_win10.bat
Last active October 21, 2016 20:59
Sym link Windows 10
@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 / 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 / align_with_flexbox.html
Created October 13, 2015 12:31
Aligning items using flexbox
<style type="text/css">
.wrap {
display: flex;
align-items: center;
justify-content: center;
}
.item {
max-width: 50%;
}
@matheus-santos
matheus-santos / tar.gz.cheat_sheet
Last active September 24, 2015 17:14
Managing tar files
tar stores relative paths by default. GNU tar even says so if you try to store an absolute path:
# Create .tar file (with gzip)
tar -zcvf foo.tar /home/foo
# Have a look at what's in the tar file:
tar -tvf foo.tar
# Extracting file from tar file
tar -xvf foo.tar home/foo/bar # Note: no leading slash
@matheus-santos
matheus-santos / timer.py
Created September 21, 2015 03:05
Simple timer class for benchmark python programs
import time
class Timer(object):
verbose = False # Debug mode
start_value = 0 # Start time
msecs = 0 # Diff in milliseconds
def __init__(self, verbose=False):
@matheus-santos
matheus-santos / kill_task
Created April 24, 2015 14:35
Kill mysql-workbench task on Linux
# Killing task 'mysql-workbench'
kill $(ps -A | awk '/[m]ysql-workbench/ {print $1}')