For homebrew version 0.9.5.
brew -v # => Homebrew 0.9.5
Install the current version of mysql.
# Install current mysql version
brew install mysql
List all php modules | |
$ yum search php- | |
Details of a module | |
$ yum info <module name> | |
Install the module | |
$ sudo yum install <module name> |
$fp = fopen("file.csv", 'rb'); | |
$stream = new \Slim\Http\Stream($fp); // create a stream instance for the response body | |
return $res->withHeader('Content-Type', 'application/force-download') | |
->withHeader('Content-Type', 'application/octet-stream') | |
->withHeader('Content-Type', 'application/download') | |
->withHeader('Content-Description', 'File Transfer') | |
->withHeader('Content-Transfer-Encoding', 'binary') | |
->withHeader('Content-Disposition', 'attachment; filename="file.csv"') |
sudo lsof -n -i :<PORT_NUMBER> | grep LISTEN |
To find locations in your markers table that are within a certain radius distance of a given latitude/longitude, you can use a SELECT statement based on the Haversine formula. The Haversine formula is used generally for computing great-circle distances between two pairs of coordinates on a sphere. An in-depth mathemetical explanation is given by Wikipedia and a good discussion of the formula as it relates to programming is on the Movable Type Scripts website. | |
Here's the SQL statement that finds the closest 20 locations within a radius of 25 miles to the -33, 151 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371. | |
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * si |
Redirect | |
return $res->withRedirect("/login"); | |
Get GET parameters | |
$jobId = $req->getQueryParams()['jobId']; //checks _GET [IS PSR-7 compliant] | |
Get POST parameters | |
$filename = $req->getParsedBody()['filename']; | |
Sanitize query param | |
$jobId = filter_var($jobId, FILTER_SANITIZE_NUMBER_INT); |
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update && brew upgrade
brew doctor (see everything is ok)
Review Unit Tests | |
Is the code in the right place? | |
Does the name space make sense? http://blogs.msdn.com/brada/articles/361363.aspx | |
Is the class / procedure / variable scope correct. | |
Are the Classes, methods, and variables named correctly? http://blogs.msdn.com/brada/articles/361363.aspx | |
Are the methods, and variables typed correctly? | |
Look at the code. | |
Review for OCP (open closed principle - Open for extension closed for modification) | |
Review for DRY Principle (Don't Repeat Yourself - abstract common things and put in single place). | |
Review for SRP (Single Responsibility Principle - every object has a single responsibility. All the object's services should be focused on that responsibility). |
FROM php:7.2-fpm | |
RUN apt-get update && apt-get install -y \ | |
libfreetype6-dev \ | |
libjpeg62-turbo-dev \ | |
libpng-dev \ | |
&& docker-php-ext-install -j$(nproc) iconv \ | |
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ | |
&& docker-php-ext-install -j$(nproc) gd \ | |
&& docker-php-ext-install -j$(nproc) pdo pdo_mysql | |
&& docker-php-ext-install -j$(nproc) bcmath |
http://ropenscilabs.github.io/r-docker-tutorial/04-Dockerhub.html | |
precondition: docker should be installed and you should be logged in in your system. | |
precondition2: use .dockerignore file near the Dockerfile as: | |
* | |
!Dockerfile | |
in the folder where Docker file resides, run: | |
docker build . |