@RestController
@RequestMapping("/api/inventory")
@RequiredArgsConstructor
@Slf4j
public class InventoryController {
private final InventoryService inventoryService;
// http://localhost:8082/api/inventory/iphone-13,iphone13-red
// http://localhost:8082/api/inventory?skuCode=iphone-13&skuCode=iphone13-red
@GetMapping
@ResponseStatus(HttpStatus.OK)
public List<InventoryResponse> isInStock(@RequestParam List<String> skuCode) {
log.info("Received inventory check request for skuCode: {}", skuCode);
return inventoryService.isInStock(skuCode);
}
}
Code language: PHP (php)
How to Install the PostGIS Extension for PostgreSQL
Introduction
PostGIS is a full-fledged Geographic Information System (GIS) data modeling tool. It has many GIS-specific data types and functions. PostGIS is available as an extension for the PostgreSQL database; it is not a standalone software. This guide shows how to install PostGIS on PostgreSQL when installed on a Vultr cloud server or a Vultr Managed Database.
Prerequisites
Before starting with this guide, you should have:
- Either PostgreSQL installed on a Vultr cloud server, or a Vultr Managed Database for PostgreSQL
psql
, which is an interactive terminal for PostgreSQL. It’s installed on the database server by default, or you can install PostgreSQL on a local workstation.- Experience with basic SQL commands.
- PostGIS is available only in the database where it has been loaded. Before loading the PostGIS extension, ensure that you are connected to the database in which you want to use PostGIS. To connect to a specific database, use: =# \c DATABASE_NAME
By default, a standalone PostgreSQL installation connects to the postgres
database as the user postgres
. An instance of Vultr Managed Databases for PostgreSQL connects to the defaultdb
database as the user vultradmin
. Following this guide without explicitly connecting to a specific database will load PostGIS into the default database.
Note that =#
refers to the PostgreSQL psql
prompt, #
refers to the root prompt on the operating system, and $
refers to a regular user prompt.
Compatibility
The instructions in this guide are based on PostgreSQL version 14 and PostGIS 3.2 running on Ubuntu 22.04 and Vultr Managed Databases for PostgreSQL. They should be compatible with all recent versions of the software and operating systems. Note that in the case of standalone servers, you need to have only one version of PostgreSQL installed. Handling two or more versions installed on the same system is beyond the scope of this guide
Step 1: Install Packages for PostGIS
Assuming that PostgreSQL is already available, PostGIS installation consists of 2 steps:
- Install
postgis
, the PostGIS package, from the operating system’s package manager. - Load PostGIS into a PostgreSQL database.
While this guide demonstrates the first step for Ubuntu, the general procedure is the same for all operating systems. The second step is the same for both standalone servers as well as Vultr Managed Databases for PostgreSQL.
Option 1 – Install on Ubuntu
Optional – Check Compatibility
In general, there should be no compatibility issues on Ubuntu. Check the version of PostgreSQL installed on your operating system. On the PostgreSQL command line, enter:
=# SELECT version();
Code language: PHP (php)
Check the version of PostGIS available on the apt
package manager:
$ apt search ^postgis$
Check the compatibility page to ensure the available version of PostGIS is compatible with the installed version of PostgreSQL.
Install the Package
Install the postgis
package on Ubuntu using the apt
package manager.
# apt install postgis
Code language: PHP (php)
This will install the latest version of PostGIS available for the operating system.
Option 2 – Install on Vultr Managed Databases for PostgreSQL
On Vultr Managed Databases for PostgreSQL, the PostGIS extension package is already installed. You only need to load it (as shown in the next step).
Step 2: Load the PostGIS Extension
The second step of the installation is the same across both standalone servers and managed databases. Log in to the PostgreSQL command line using the psql tool, pgAdmin, or another front-end tool that allows you to issue queries to the PostgreSQL server. For Vultr Managed Databases for PostgreSQL, find the credentials from the Connection Details page of your instance.
Check Availability
Check if the extension is available to be loaded:
=# SELECT * FROM pg_available_extensions;
Code language: PHP (php)
After installing PostGIS on the operating system, it should be included in this list.
Load the Extension
Use the CREATE EXTENSION
command of PostgreSQL to create a new extension for PostGIS:
=# CREATE EXTENSION postgis ;
Code language: PHP (php)
The PostGIS extension should now be loaded into the database.
Check Installation
Check that the PostGIS extensions are loaded:
=# SELECT * FROM pg_extension ;
Code language: PHP (php)
The above command shows the list of all loaded extensions. You can also check the version of PostGIS installed:
=# SELECT postgis_version();
Code language: PHP (php)
Conclusion
PostGIS has now been loaded into your PostgreSQL database. The PostGIS documentation is a good starting point to learn more about how to handle GIS data in PostgreSQL.
Xcode is not running the application
sometimes xcode if configured to build a framework as well as an app. If it builds your project fine but does not run it then try this
To fix it I had to go to the menu Product > Edit Scheme… > Select “Run ” (in the sidebar) > Info (tab). In here is a drop down box labeled Executable, select it and choose your app that you wish to launch when the Run button is clicked.
Linux cheat sheet
Linux find largest file in directory recursively using find
- Open the terminal application.
- Login as root user using the sudo -i command.
- Type du -a /dir/ | sort -n -r | head -n 20.
Folder size in linux
sudo du -sh /var
Code language: JavaScript (javascript)
Git cheat sheet
Install
GitHub Desktop
Git for All Platforms
Configure tooling
Configure user information for all local repositories
$ git config --global user.name "[name]"
Sets the name you want attached to your commit transactions
$ git config --global user.email "[email address]"
Sets the email you want attached to your commit transactions
$ git config --global color.ui auto
Enables helpful colorization of command line output
Branches
Branches are an important part of working with Git. Any commits you make will be made on the branch you’re currently “checked out” to. Use git status
to see which branch that is.
$ git branch [branch-name]
Creates a new branch
$ git checkout [branch-name]
Switches to the specified branch and updates the working directory
$ git merge [branch]
Combines the specified branch’s history into the current branch. This is usually done in pull requests, but is an important Git operation.
$ git branch -d [branch-name]
Deletes the specified branch
Create repositories
When starting out with a new repository, you only need to do it once; either locally, then push to GitHub, or by cloning an existing repository.
$ git init
After using the git init
command, link the local repository to an empty GitHub repository using the following command:
$ git remote add origin [url]
Turn an existing directory into a Git repository
$ git clone [url]
Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits
The .gitignore file
Sometimes it may be a good idea to exclude files from being tracked with Git. This is typically done in a special file named .gitignore
. You can find helpful templates for .gitignore
files at github.com/github/gitignore.
Synchronize changes
Synchronize your local repository with the remote repository on GitHub.com
$ git fetch
Downloads all history from the remote tracking branches
$ git merge
Combines remote tracking branches into current local branch
$ git push
Uploads all local branch commits to GitHub
$ git pull
Updates your current local working branch with all new commits from the corresponding remote branch on GitHub. git pull
is a combination of git fetch
and git merge
Make changes
Browse and inspect the evolution of project files
$ git log
Lists version history for the current branch
$ git log --follow [file]
Lists version history for a file, including renames
$ git diff [first-branch]...[second-branch]
Shows content differences between two branches
$ git show [commit]
Outputs metadata and content changes of the specified commit
$ git add [file]
Snapshots the file in preparation for versioning
$ git commit -m "[descriptive message]"
Records file snapshots permanently in version history
Redo commits
Erase mistakes and craft replacement history
$ git reset [commit]
Undoes all commits after [commit]
, preserving changes locally
$ git reset --hard [commit]
Discards all history and changes back to the specified commit
CAUTION! Changing history can have nasty side effects. If you need to change commits that exist on GitHub (the remote), proceed with caution. If you need help, reach out at github.community or contact support.
Get your local Git repository on Bitbucket
Step 1: Switch to your repository’s directory
cd /path/to/your/repo
Step 2: Connect your existing repository to Bitbucket
git remote add origin https://ahmed@bitbucket.org/ahmed/flickerupload.gitgit push -u origin master
Changing Android Studio editor font
Its a bit tricky and I couldn’t figure it out immediately how to do that. To do that go to File->Settings->Editor-> Colors and Fonts->Font. You will notice the font size is greyed out. There you press the save as button on the default or Darcula Scheme. Then press OK, once you do that a copy of the existing profiles is made then you can edit font size.
Hope it helps..
How to show line numbers in android studio
Tip of the day
I don’t know the key to success, but the key to failure is trying to please everybody.