Remove receipts from Photos App

Here goes a great way to remove, but safe keep payment, account transfer receipts.

I know, Photos app is meant for keep camera photos only. But in iOS, receipts and screenshots are also saved in photos app. And when receipts are cluttered with receipts it does not look pretty.

Using iOS shortcuts there is an easier way to move those receipts to a folder in your iCloud, Dropbox or Google Drive and remove them from Photos app.

Since iOS 13, Apple released a new app called Shortcuts, (If you cannot find the app you can install from the App Store) which can be really handy for simple automatons and merging tasks that includes multiple steps to be just done by a single tap.

Let’s get started

Search for / Open Shortcuts app on your iPhone.

Create a new shortcut, let’s name it Remove Receipts. (You can name is anything you want)

Click the + Add Action button at the bottom to add new action.

Search for Photos and tap Photos. You will see more actions that you can perform using photos app.

Tap Select Photos

Tap the drop down arrow to see more options. From here then on multiple select option so that you can select multiple receipts at once. Tap the include option and uncheck Live photos and Videos, since we are only be using photos.

Click the + button at the bottom to add new action.

Search for Save File

Tap the drop down arrow to see more options. From there you can select whether to overwrite files if they are duplicating by name, choose a location to save the photos.

Click the + button at the bottom to add new action.

Search and select for Delete photos

By default Shortcut assumes you are referring to the output of the previous action. But in this case we referring to the output of the selected photos. Therefore we need to change the referencing.

Select Saved File and tap clear to remove the currently selected Saved File.

Now select the place holding text which will prompt a menu to select the preferred variable.

Tap Select Magic Variable and on the next screen select photos.

At this point we have built the shortcut. Now we need to run and test the shortcut.

So what does the shortcut do?

When you click the play button, the shortcut will start running.

First It will let you choose receipts (photos) from from the camera roll. You can select multiple photos at the same time.

Then the chosen photos will be uploaded to the selected location (iCloud, Dropbox or Google drive).

Then you will be prompt to agree whether to remove the selected photos from the camera roll. You can select yes to remove them.

Deserialize / Decode JSON string to an Object

Following will explain how to deserialize JSON string in Javascript and PHP.

PHP

The following function will return the string as an object.

<?php 

  json_decode("JSON_STRING_GOES_HERE");

?>

If you want to return the decoded JSON string as an array, you can parse TRUE as the second argument.

<?php 

  json_decode("JSON_STRING_GOES_HERE", true);

?>

Javascript

Let assume you are making an API call from some kind of service, and you are receiving a JSON string as a response. You can use the following function to decode the JSON string which will return the string as an object.

let jsonObject = JSON.parse("RESPONSE_FROM_API")

The above code will store the object in jsonObject variable.

A simple PHP function to read an .env file

.env or Environment files are basically a configuration file which contains required and most important configurations of an application. It is just a file which holds key and value pair of variables.

Below is an example of an environment (.env) file.

APP_NAME=Your application name
APP_ID=application_id

DB_HOST=localhost
DB_USER=user
DB_PASS=password
DB_NAME=databasename

So the content above has been saved in a file named .env

Below is the PHP function that will be used across the whole application to fetch variables from the environment file.

<?php 
function env($var) {

 $config = [];
 // Location of the $env_file file depends on where the function is located at.
 // In this case the function is located in the same folder as the .env file
 $env_file = __DIR__ . '/.env';

 try {

  // Check if environment type 
  if( file_exists($env_file) == false ) { throw new Exception('Environment file not found.'); }

  $lines = file($env_file);
  if( empty($lines) ){ throw new Exception('Environment file is empty. O.o'); }

  // Loop all the environment file variables
  foreach( $lines as $line ) {
   // Validate Line by checking if there is an equal sign
   if( strpos($line, '=') > 0 ) {
      list($f, $l) = explode('=', $line);
      $value = trim($line, $f);
      $value = ltrim($value, '=');
      $config[$f] = trim($value);
    }
  }

   // Return the value, or return false
   return ( array_key_exists($var, $config) ? $config[$var] : false );

 } catch( Exception $e ) {
    die( $e->getMessage() );
 }
}
?>

iOS Shortcuts : Create an automated instant shopping list

We always like to make things easy by making the easy things more easier. Like so I have created the following Shortcut on iOS which also used Wunderlist to make the list.

An Overview

Firstly current date is adjusted by adding 10 minutes to the current date and time.

Secondly a list of items are set. This list can be modified in the workflow. Then it is prompted to the user to choose from. User can select multiple items.

Thirdly, all the selected items are looped and each time is added to the Wunderlist.

Finally, a text message is composed and a contact can be set to send automatically once all the items are added to the list.

Virtual Hosts on MAMP (for Mac)

Here is how to setup the vhosts on MAMP.

Allow Virtual Hosts

In Finder, goto Applications > MAMP > conf > apache and open httpd.conf file with text editor of your choice.

Find and uncomment the following line.

Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

Allow SymLink Override

Find the following line in the httpd.conf file.

<Directory />
    Options Indexes FollowSymLinks
    AllowOverride None
</Directory>

Change the line AllowOverride None to AllowOverride All

Add the virtual host path

All the way at the end of the extra/httpd-vhosts.conf file, you’re going to place a code that signifies a virtual host and specifies the path. Place this code at the end of the document.

<VirtualHost *:80> 
    ServerName example.dev 
    DocumentRoot "/path/to/directory" 
</VirtualHost>

After updating the httpd-vhosts.conf file, you will need to restart apache. Open MAMP application and restart the services.

Allow your computer to identify the Domain Name

Technically when an address such as www.example.com is entered into the web browser address bar, the computer first checks hosts file for the address and redirects the route to the identified IP Address. If the requested address was not found in the hosts file, then the computer connects to the internet to find the IP addresses.

So we are going to trick the computer to find our virtual host.

Open the hosts file located at /etc/hosts. In terminal type the following command.

sudo vim /etc/hosts

For this to work you will need to have administrative user rights. When the command is entered terminal will prompt you to enter your password.

Vim is my favourite text editor for terminal. You can use any editor you want. Nano is also a choice.

Add the following file to the hosts file.

127.0.0.1      example.com

127.0.0.1 is the IP address for localhost. Basically what we are doing is mapping example.com to 127.0.0.1. Now when you enter example.com in browser, it will forward the visit to 127.0.0.1. And since we have setup the virtual host accordingly, it will show the website set in Virtual Host’s Document Root.

This article was written for a self reference, original article was from www.taniarascia.com » Setting Up Virtual Hosts