Skip to content

Instantly share code, notes, and snippets.

View gist:0e5ce8a0757c1f2220f3b5aa3c28bd26
# TDD good habits
## Principles
- tests should test one thing only
- test one logical assertion
- don't mix assertions of state and collaboration in the same test
- modifications of production code should only break related test cases
- each test should be self-contained, including data
- ensure tests are independent of each other
- don't refactor with a failing test
matheus-santos /
Last active May 21, 2019
Regex to add key name as value of property 'id' in object
Search: /^    ([a-zA-Z]+): {\n( +)/
Replace: /    $1: {\n$2id: '$1',\n$2/


{                             =>   {
 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.

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.


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 / 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 / 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
command: "/tmp/"
mode: "000755"
owner: root
group: root
content: |
matheus-santos / get_query_log.php
Last active Mar 4, 2019
See last executed queries in Laravel
View get_query_log.php
// Laravel query operation here ...
print_r(\DB::getQueryLog()); exit;
matheus-santos / vagrant + docker + windows
Created Oct 17, 2016 — forked from eibreans/vagrant + docker + windows
Passo a passo docker rodando sobre o vagrant no windows 10
View vagrant + docker + windows

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

  2. Instalar virtual box

  3. Instalar o vagrant

matheus-santos / symlink_win10.bat
Last active Oct 21, 2016
Sym link Windows 10
View symlink_win10.bat
You can’t perform that action at this time.