export GOPATH=$HOME/golang export GOROOT=/usr/local/opt/go/libexec export PATH=$PATH:$GOPATH/bin export PATH=$PATH:$GOROOT/bin
How to configure phpStorm with EditorConfig and PHPMD: | |
----------------------------------------------------- | |
PHPMD: | |
------ | |
phpmd (PHP Mess Detector) is a static analysis tool that will find issues in your code you never knew you had. Your code will still run, follow a few of phpmd's recommendations though and it will be better! | |
phpmd is already bundled and enabled in phpstorm, but in order to more easily manage versions and add custom rulesets, you should do the following: |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the\
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
- Follow standard conventions.
- Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
- Boy scout rule. Leave the campground cleaner than you found it.
- Always find root cause. Always look for the root cause of a problem.
#!/bin/bash | |
cd /tmp || exit | |
echo "Downloading sonar-scanner....." | |
if [ -d "/tmp/sonar-scanner-cli-3.2.0.1227-linux.zip" ];then | |
sudo rm /tmp/sonar-scanner-cli-3.2.0.1227-linux.zip | |
fi | |
wget -q https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.5.0.2216-linux.zip | |
echo "Download completed." |
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle
The API we are creating in this gist will follow these rules :
- The API only returns JSON responses
- All API routes require authentication
- Authentication is handled via OAuth2 with
password
Grant Type only (no need for Authorization pages and such). - API versioning is managed via a subdomain (e.g.
v1.api.example.com
)
The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :
#!/bin/bash - | |
export AWS_ACCESS_KEY=<your aws access key> | |
export AWS_SECRET_KEY=<your aws secret> | |
date_current=`date -u +%Y-%m-%d` | |
aws rds describe-db-snapshots --snapshot-type "automated" --db-instance-identifier <db_instance_name> | grep `date +%Y-%m-%d` | grep rds | tr -d '",' | awk '{ print $2 }' > /tmp/sandbox-snapshot.txt | |
snapshot_name=`cat /tmp/<db_instance_name>-snapshot.txt` | |
target_snapshot_name=`cat /tmp/<db_instance_name>-snapshot.txt | sed 's/rds://'` |
FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.
- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/
for bucket in `cat list-of-s3-buckets.txt`; do | |
aws s3api put-bucket-lifecycle \ | |
--bucket $bucket \ | |
--lifecycle-configuration '{"Rules":[{"ID":"cleanup","Status":"Enabled","Prefix":"","Expiration":{"Days":1}}]}'; | |
done |
#!/bin/bash | |
# | |
# A script to create a daily mysqldump for crashplan | |
# Defaults | |
# Override them in /etc/default/mysqlbackupforcrashplan | |
OUTPUTFILE=/var/local/full-backup.sql | |
STATEFILE=/var/local/full-backup.sql.state | |
CRONFILE=/etc/cron.d/mysqlbackupforcrashplan | |
MYSQLDUMPBIN=/usr/bin/mysqldump |