Skip to content

Instantly share code, notes, and snippets.

View mauricios's full-sized avatar
🎯
Focusing

Mauricio Sánchez mauricios

🎯
Focusing
View GitHub Profile
@mauricios
mauricios / curl_time_format.txt
Last active February 17, 2022 18:21
CURL format file to summarize loading times results of a page
Content Type: %{content_type}\n
HTTP Code: %{http_code}\n
HTTP Connect: %{http_connect}\n
Number Connects: %{num_connects}\n
Number Redirects: %{num_redirects}\n
Redirect URL: %{redirect_url}\n
Size Download: %{size_download}\n
Average speed download: %{speed_download}\n
Size Upload: %{size_upload}\n
SSL Verify: %{ssl_verify_result}\n
@mauricios
mauricios / varnish_useful_commands.sh
Last active October 14, 2017 01:09
Varnish useful commands
#!/bin/sh
# Check configuration file
sudo varnishd -C -f /path/to/default.vcl -p vcl_dir=/path/to/vcl_dir
# Ban/Purge a URL
sudo varnishadm "ban req.http.host ~ ^<hostname>$ && req.url ~ ^<url>$"
# Change configuration
## Show list of configurations
@mauricios
mauricios / aws_cloudwatch_logs_iam_policy.json
Last active May 30, 2017 22:00
AWS CloudWatch Logs IAM policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
@mauricios
mauricios / atom-config.cson
Last active August 27, 2017 14:32
Atom preferences file
"*":
"ansible-vault":
vault_automatic_de_and_encrypt: true
"atom-beautify":
php: {}
"autocomplete-ansible":
pythonPaths: "/usr/local/Cellar/ansible/2.3.2.0_1/libexec/bin/python2.7"
autosave:
enabled: true
core:
@mauricios
mauricios / Preferences.sublime-settings
Last active May 15, 2017 18:01
SublimeText 3 User preferences
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Lighter.tmTheme",
"font_options":
[
"gray_antialias",
"subpixel_antialias",
"bold",
"no_round"
# Create a CSV with query results and save it to a file
SELECT * FROM table INTO OUTFILE '/var/lib/mysql-files/table.csv' FIELDS ENCLOSED BY '"' TERMINATED BY ',' ESCAPED BY '"' LINES TERMINATED BY '\r\n';
# Get selected fields and include a related field from other table
SELECT tableA.filed1, tableA.field2, tableB.filed1, tableB.field2 FROM tableA INNER JOIN tableB ON tableA.id = tableB.id;
# Filter fields with wildcard and order by a cetain field
SELECT * FROM table WHERE field1 LIKE '%@example.com' ORDER BY field2
# Find unique duplicated records of a certain field
@mauricios
mauricios / git_useful_tasks.sh
Last active February 2, 2018 20:36
Git usefull tasks
#!/bin/sh
# Delete last commit already pushed to a remote repository
git reset HEAD^ --hard;
git push origin -f;
# Change remote URL
git remote set-url origin <repo_url>
# Revert local changes to move back to the origin is
@mauricios
mauricios / aws_ec2_user_data_hostname.yml
Created November 14, 2016 20:45
AWS EC2 User Data setting hostname
#cloud-config
apt_upgrade: false
preserve_hostname: true
runcmd:
- hostname "Hostname-`ec2metadata --instance-id`"
- echo "127.0.0.1 Hostname-`ec2metadata --instance-id`" >> /etc/hosts
- echo "Hostname-`ec2metadata --instance-id`" > /etc/hostname
@mauricios
mauricios / apache-redirect.conf
Last active November 30, 2016 20:50
Apache Rewrite rules to redirect hostnames
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect to WWW all domain variants but wwww variant
# Redirect all domains that include the keywords target-domain, redirect-domain1, redirect-domain2
# Excluding www.target-domain.com, www.no-redirect-domain1.com and www.no-redirect-domain2.com
# To www.target-domain.com
RewriteCond %{HTTP_HOST} ^(?!www\.target-domain\.com|.*\.no-redirect-domain1\.com)(.*\.|)(target-domain|redirect-domain1|redirect-domain2)\..*$ [NC]
RewriteRule ^(.*)$ http://www.target-domain.com$1 [R=301,L]
@mauricios
mauricios / macOS-tweaks.sh
Created September 13, 2016 15:31
macOS tweaks
#!/bin/bash
# Tweaks for macOS
# Disable ruber band bouncing scrolling
sudo defaults write -g NSScrollViewRubberbanding -int 0
# Disable all animations
sudo defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
# Enable press and hold key to repeat