SSH Login

Create a EC2 Key Pair http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#having-ec2-create-your-key-pair Open the Amazon EC2 console: https://console.aws.amazon.com/ec2/ Navigation pane > Network & Security > Key Pairs Create Key Pair Enter a name for the key pair and press Create You will be prompted to save the private key file on your local machine, save it in a safe place. Creating Instance That Will Use […]

Read More

File locations

Your zipped up application files During deployment: /tmp/deployment/application folder Once running: /var/app/current This is for boith worker and web server environments.  A good way to prove it is to use this php in a page: die("All done, path to api: " . getcwd(). ", PHP executible path: " . PHP_BINDIR); Logs /var/log/

Read More

Indexes

Basically an index on a table works like an index in a book.  They are a way to avoid scanning the full table to obtain the result that you’re looking for.  Say you have a book and you want to find some information about something particular. Without an index you’d have to go through the […]

Read More

Count – Get number of results

How many rows in a table Count and Group Combined List the number of customers in each country Adding values returned as a the total Use SUM() Counting multiple things in a single query

Read More

Bitwise Operators

PHP Integers Integer size is platform-dependent, safest is to assume a maximum value of about two billion (32 bits signed). 64-bit platforms usually have a maximum value of about 9E18 Unsigned integers are not supported in PHP If PHP encounters a number, or the result of an operation, that is beyond the bounds of the […]

Read More

Temporary File

Creating a temporary file //Create temporary file destination if (!is_dir('temp/')) { mkdir('temp', 0777, true); } $decrypted_filename = 'temp/' . uniqid(rand(), true) . '.txt'; //Use it… //Delete the file unlink($decrypted_filename);  

Read More

Console

Issuing Linux console commands from PHP See http://www.raspberry-projects.com/pi/programming-in-c/tcpip/web-interfaces

Read More

Converting Values in PHP

Convert Boolean Text To Boolean Strings always evaluate to boolean true unless they have a value that's considered "empty" by PHP.  FILTER_VALIDATE_BOOLEAN provides a solution though: $UploadsEnabled = "false"; $UploadsEnabled = filter_var($UploadsEnabled, FILTER_VALIDATE_BOOLEAN); Convert Bytes To UInt32 $handle = fopen("myfile.bin", "rb"); $Contents = fread($handle, 20); $FileByteArray = unpack("C*",$Contents); //<<<Warning the outputted array starts from [1] […]

Read More

FTP into an Elastic Beanstalk environment

Elastic Beanstalk isn't designed for FTP because the point of it is that it can create and dump instances whenever it needs and when an instance is dumped everything in it is lost.  If you need to FTP then its better to use a EC2 instance

Read More