1. Open the Chrome developer tools (press F12 key)
2. Click on "Customize and Control DevTools" menu
3. Select "Settings" option
4. From Preferences -> Appearance section, select Theme = Dark
5. Enjoy debugging
"Quality is free, but only to those who are willing to pay heavily for it." -- DeMarco and Lister
Friday, September 29, 2017
Monday, July 31, 2017
Accessing MySQL Server from Docker Container.
For this example we will be using an image from Docker Hub.
You can list the available images by executing:
and download it with:
If you want to list your local images, just type:
Now in order to create the container we can execute a command with the following options:
where:
Then if you want to see the containers currently running:
But, How can I start working with the MySQL of the docker container?
Via terminal (accessing the container bash):
Or just pointing your favorite Database Client to the container configuration:
You can list the available images by executing:
docker search mysql
and download it with:
docker pull mysql
If you want to list your local images, just type:
docker images
Now in order to create the container we can execute a command with the following options:
docker run -p <port>:<port> --name <container-name> -v <local-folder>:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=<root-password> -d mysql:<tag>
where:
| -p | Publish a container’s port(s) to the host |
| --name | Assign a name to the container |
| -v | Bind mount a volume |
| -e | Sets the MYSQL_ROOT_PASSWORD environment variable |
| -d | Run container in background and print container ID |
| tag | Tag specifying the MySQL version you want. |
Then if you want to see the containers currently running:
docker ps
But, How can I start working with the MySQL of the docker container?
Via terminal (accessing the container bash):
docker exec -it <container-name> bash
Or just pointing your favorite Database Client to the container configuration:
Sunday, July 23, 2017
How to show current Git Branch in the Terminal.
Adding (replacing) the following code to your .bashrc file will do the trick:
How it looks your bash prompt:
See the original post here.
# Add git branch if its present to PS1 parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' fi
How it looks your bash prompt:
See the original post here.
Thursday, June 8, 2017
Change the Browser User-Agent by using Chrome DevTools
Either you are testing an app which verifies the User-Agent or you just want to see your app rendered in a different one. There is an option included in the Chrome Developer Tools which allows you to change this value without having to install any additional third-party software for this.
Steps:
1. In Chrome, open the DevTools (by pressing F12 key)
2. Display the "Customize and control DevTools" options menu:
3. Select the "Show console drawer" option
4. From the new Console section, display the options menu:
5. Select "Network conditions" option
6. Observe the new tab is added to the Console section
7. Look for "User agent" and uncheck the "Select automatically" option
8. Now you are able to select a different agent from the list:
9. Refresh the page so the changes take effect.
Steps:
1. In Chrome, open the DevTools (by pressing F12 key)
2. Display the "Customize and control DevTools" options menu:
3. Select the "Show console drawer" option
4. From the new Console section, display the options menu:
5. Select "Network conditions" option
6. Observe the new tab is added to the Console section
7. Look for "User agent" and uncheck the "Select automatically" option
8. Now you are able to select a different agent from the list:
9. Refresh the page so the changes take effect.
Friday, January 20, 2017
How to integrate ESLint with Sublime Text 3
In order to evaluate your code using eslint, you first need to have it installed in your system.
To test it, you can simple execute eslit <filename>.js from the command line.
1. Now, we can proceed to install the Sublime Text pluging by going through Preferences -> Package Control -> Install Package
2. Select "SublimeLinter-contrib-eslint".
3. And, finally just copy a .eslintrc file (with the rules definitions) to the root path of your project.
or generate it by typing eslint --init
npm install -g eslint
To test it, you can simple execute eslit <filename>.js from the command line.
1. Now, we can proceed to install the Sublime Text pluging by going through Preferences -> Package Control -> Install Package
2. Select "SublimeLinter-contrib-eslint".
3. And, finally just copy a .eslintrc file (with the rules definitions) to the root path of your project.
or generate it by typing eslint --init
And that's it!, now you will be highlighted for every syntax error detected in your files (based on your .eslintrc configuration) while editing them.
Tuesday, August 16, 2016
MySQL: Import CSV file data into temporary tables.
Sometimes is needed to query the database based on an external data file (.csv).
So we could consider to import this data to a temporary table to achieve this, and to ensure not to alter the database schema at all.
Let's say we have a table like this:
And a CSV file which content some ids:
Now, assume we have the following scenario:
"Given a list of User IDs (CSV file), we want to know the name and sport of these people."
Steps:
1. Create a temporary table:
2. Import data from the CSV file:
3. Finally you can build the query and work like it is one more table in the database, e.g:
So we could consider to import this data to a temporary table to achieve this, and to ensure not to alter the database schema at all.
Let's say we have a table like this:
mysql> SELECT * from User; +------+----------+-------------+------------+ | id | name | last_name | sport | +------+----------+-------------+------------+ | 1000 | Oscar | Soliz | cycling | | 1001 | Wendy | Cornejo | athletics | | 1002 | Karen | Torrez | swimming | | 1003 | Rosemary | Quispe | marathon | | 1004 | Stefany | Coronado | athletics | | 1005 | Jose | Quintanilla | swimming | +----+------------+-----------+--------------+
And a CSV file which content some ids:
id 1002 1004 1005
Now, assume we have the following scenario:
"Given a list of User IDs (CSV file), we want to know the name and sport of these people."
Steps:
1. Create a temporary table:
CREATE TEMPORARY TABLE user_ids (id INT(11));
2. Import data from the CSV file:
LOAD DATA INFILE "/file_path/user_ids.csv" INTO TABLE user_ids COLUMNS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES; # To ignore headers (first row)
3. Finally you can build the query and work like it is one more table in the database, e.g:
SELECT CONCAT(u.name, ' ', u.last_name) name, u.sport FROM User u WHERE u.id IN (SELECT id FROM user_ids);
+------------------+------------+ | name | sport | +------------------+------------+ | Karen Torrez | swimming | | Stefany Coronado | athletics | | Jose Quintanilla | swimming | +------------------+------------+
Tuesday, April 19, 2016
MySQL: How to export query results to a CSV file
You can use the following query, making sure you have write permission over the destination path.
Including headers:
SELECT field1, field2 FROM table_name INTO OUTFILE '/destination_path/result.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
Including headers:
(SELECT 'label_field1','label_field2') UNION (SELECT field1, field2 FROM table_name INTO OUTFILE '/destination_path/result.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n');
Subscribe to:
Posts (Atom)















