Skip to content

Instantly share code, notes, and snippets.

Matheus Santos matheus-santos

Block or report user

Report or block matheus-santos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@matheus-santos
matheus-santos / inject_key_in_object.md
Last active May 21, 2019
Regex to add key name as value of property 'id' in object
View inject_key_in_object.md
Search: /^    ([a-zA-Z]+): {\n( +)/
Replace: /    $1: {\n$2id: '$1',\n$2/

Example:

{                             =>   {
 name: {                      =>     name: {
   property1: 'Property 1'    =>       id: 'name', // Added
View my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
View install_mysql.md

Used brew's remove & cleanup commands, unloaded the launchctl script, then deleted the mysql directory in /usr/local/var, deleted my existing /etc/my.cnf (leave that one up to you, should it apply) and launchctl plist

Updated the string for the plist. Note also your alternate security script directory will be based on which version of MySQL you are installing.

Step-by-step:

brew remove mysql
brew cleanup
launchctl unload -w /usr/local/Cellar/mysql/8.0.16/homebrew.mxcl.mysql.plist
View duplicate_row_in_mysql.sql
-- 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 / lodash__black_list_white_list.js
Created Oct 2, 2018
Lodash: Delete unwanted properties from the javascript object
View lodash__black_list_white_list.js
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 Oct 1, 2018 — forked from vsviridov/01_add_cors.config.yaml
Add CORS to Nginx on AWS Elastic Beanstalk
View 01_add_cors.config.yaml
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 / get_query_log.php
Last active Mar 4, 2019
See last executed queries in Laravel
View get_query_log.php
\DB::enableQueryLog();
// Laravel query operation here ...
print_r(\DB::getQueryLog()); exit;
@matheus-santos
matheus-santos / vagrant + docker + windows 10.md
Created Oct 17, 2016 — forked from eibreans/vagrant + docker + windows 10.md
Passo a passo docker rodando sobre o vagrant no windows 10
View vagrant + docker + windows 10.md

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 Oct 21, 2016
Sym link Windows 10
View symlink_win10.bat
@matheus-santos
matheus-santos / database_size.sql
Last active Aug 25, 2016
Database size in mysql
View database_size.sql
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;
You can’t perform that action at this time.