Single Wicket Cricket – A 3D Game

I tried my hand at a low-poly 3D game development with ‘Single Wicket Cricket’ game. This is not a typical Cricket where two teams play against each other. In this game you are the main player – the batsman, playing against a team.

Video demo of Single Wicket Cricket game

Tap/click Bowl to start bowling action. You will be able to ‘Hit’ the ball once it is released by the bowler. You will be able take a ‘Run’ only if bat touches the bat, so there are no byes or leg-byes.

By moving different sliders you can control position, rotation of the batsman, strength and direction (up/down) of the stroke. Tap/click ‘Help’ button for more details.

The game is available to run in Web Browser or as a standalone application on Android devices.

Click here to play the browser based version of this game. Or type http://ramkulkarni.com/Games/Cricket in the address bar. Make sure to run the game in Landscape mode for the best experience.

Click here to go to Google Play listing of this app. Or search ‘Single Wicket Cricket’ in the Google Play app.

-Ram Kulkarni

Third Edition of My Book ‘Java EE 8 Development with Eclipse’ Published

 

Third edition of my book ‘Java EE 8 Development with Eclipse‘ is now published.

I had completely re-written the previous edition of this book. The third (current) edition has three new chapters –

Chapter 12Microservices, describes how to develop and deploy microservices. It also covers the deployment of microservices in Docker container.

Chapter 13Deploying JEE Applications in the Cloud, describes how to deploy JEE applications in Amazon and Google Cloud platforms. Specifically, it describes the deployment of applications in AWS EC2, Beanstalk, Google Compute Engine, and Google App Engine. It also describes Eclipse tools that can be used for deployment to the Cloud.

Chapter 14Securing JEE Applications, describes how to secure JEE applications using authentication and authorization features of JEE containers. It also covers some of the JEE 8 security enhancements.

You can find more information about outline of each chapter at https://www.packtpub.com/mapt/book/application_development/9781788833776

– Ram Kulkarni

Fixing “:CFBundleIdentifier, Does Not Exist” Error in React Native iOS build

After spending a couple of hours trying to debug this issue, I thought I would write about the solution that worked for me. Here are some of the possible solutions I found on the web –

  1. Make sure 8081 port is free and not taken by any application. On Mac you can check this by running command lsof -i :8081. If any process is running then kill it – kill -9 <pid>
  2. Remove spaces from the folder path of the project
  3. Run react-native upgrade in the project folder

In my case the problem was #1. However simple lsof command did not show any process. But sudo lsof -i :8081did show the process. It turned out that McAfee agent was running on the same port. Killing the agent is not an option for me. So the next thing to do was find a way to change the port of Ract-Native packager.

Following steps worked for me –

  1. Opne node_modules/react-native/local-cli/server/server.js and change port 8081 to the port you want to run the packager on. In the version of React-Native I am using, it is in the following code –
    module.exports = {
      name: 'start',
      func: server,
      description: 'starts the webserver',
      options: [{
        command: '--port [number]',
        default: 8090,
        parse: (val: string) => Number(val),
      },
    
  2. Change references to port 8081 in following files –
    1. node_modules/react-native/Libraries/Core/Devtools/getDevServer.js
    2. node_modules/react-native/React/React.xcodeproj
    3. node_modules/react-native/React/ReactLegacy.xcodeproj
    4. node_modules/react-native/React/Base/RCTBundleURLProvider.m

If above changes do not fix the problem, you may want to try replacing all references to port 8081 in the files in node_modules/react-native folder.

Wish Facebook makes changing packaging port easier than the above process.

-Ram Kulkarni

Setting up and Debugging PHP7 in Docker

Before developing applications in any new language/platform I make sure that the debugger works in the set up. I had been working on some projects in Python and PHP recently and I have already shared my notes on setting up and debugging Python (Django) application in Docker and how to debug the application.

In this post I will describe how to setup PHP7 in Docker and debug the application. You can checkout the project from this Github repo.

Here is the Docker file for this setup –

FROM php:7.0.17-apache

RUN apt-get update
RUN apt-get install -y apt-utils vim curl sqlite3
RUN pecl install xdebug
# copy test db file
ADD ./db/employee.db /employee.db
# The base image does not have php.ini. 
# Copy our own, with xdebug settings
ADD ./php.ini /usr/local/etc/php/

EXPOSE 80

The container is based on php image from docker hub. The version number is 7.0.17-apache. This example uses Sqlite3 database, so the package is installed.

To debug PHP applications, you need to install xdebug. In the docker file it is installed using pecl. Then employee.db (Sqlite3 DB) is copied from the project folder to the root of docker container.

Continue reading “Setting up and Debugging PHP7 in Docker”

Remote Debugging Django Project in Docker

In the last post I described how to setup Django and Apache in Docker container. In this post I will describe how to remote debug the Django application running in the same setup. If you look at the Dockerfile of the project (in the last post), you would see that it installs ptvsd package – this package helps to debug Django applications running remotely using Visual Studio Code.

Install Visual Studio Code, if you haven’t installed it already. Then install VS Code extension for Python. I have installed this extension by Don Jayamanne, and it supports debugging of Python applications. If you don’t know how to install extensions in VS Code, this video might help you.

To enable remote debugging of Django application, or Python applications in general, you need to run ptvsd server on the machine where Django is configure, which in our case is a Docker container. You need to embed following code snippet in your Django app, and it needs to run only once, because it listens to a port.

import ptvsd

ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3500))

The above snippet starts ptsvd server, that listens on port 3500. We configured Python to run in Apache2 using mod-wsgi in the Docker container, but I haven’t found a way to embed the above code in a Django application in this setup, where it would run only once (if it is run multiple times, it will try to attach to the same port and that would fail). So far the best way I have found to debug Django application remotely in Docker is to start Django development server on a different port (than one where Apache is listening) and embed the debugger code in manage.py. You run the development server by running manage.py, for example – Continue reading “Remote Debugging Django Project in Docker”

Docker project for Python3, Django and Apache2 setup

I was working on a Django project and it took me some time to make Django work with Apache2. So I thought I would create a Docker project for this setup. You can find the project at https://github.com/ramkulkarni1/django-apache2-docker. It sets up Python3, Django, Apache2 and a sample Django site too.

All configurations for making Django work with Apache2 are created when you create a Docker container using this project. Simply run following command from the project folder.

$ docker-compose up

(See my post Docker Notes on information about setting up Docker and docker commands). One the container is up, browse to http://localhost:8005.

Here is a quick summary of what Dockerfile does – Continue reading “Docker project for Python3, Django and Apache2 setup”

Docker Notes

I recently started using Docker and am very impressed with how easily you can set up environment to develop, test and deploy applications. It provides a virtualization environment, but unlike some of the other virtualization solution, Docker container  (runtime environment for your application)  is a process instead of a complete OS. It runs natively on Linux and uses a single virtual machine on Windows and Mac in which Docker containers run.

Using Docker you can easily create containers required for your application to run, for example containers for database, application server etc and easily deploy them to test or production environment. You can create images of your set-up and re-create the same setup constantly from those images. When you create a Docker image, it has to be based on some variant of Linux base image. You can browse Docker images at Docker Hub.

This post is not meant to be tutorial or detailed information about Docker. You can refer to Docker web site for that. As many of my other posts, this post is meant to be reference for me – about some of the Docker commands I have used so far. Continue reading “Docker Notes”

Setting up Webpack + Babel + ReactJS

I started using Webpack module bundler recently and thought I would document some of my learning. In the past couple of posts I wrote about bundling JavaScript projects using Browserify module bundlers. Webpack can be used as a replacement for Browserify; but it has some nice additional features like bundling of static files and code splitting.

This post is not meant to be tutorial on Webpack, I just wanted to describe how to configure Webpack, specifically using Webpack loaders for Bablel and ReactJS. I will show how to build a JS project using standalone Webpack and also using Webpack APIs in Gulp. The project is available on Github at https://github.com/ramkulkarni1/WebpackBlitzReactStarter

Module Dependencies

Node packages required to build the project are, of course, in package.json. If you are using above starter project from Github, then run ‘npm install’ to install all the required packages. Else make sure you install all the packages listed in devDependencies of package.json . The list contains babel, required babel presets for ES6 and ReactJS, webpack and webpack-dev-server, webpack loaders for babel, LESS and CSS.

Webpack Configuration

Webpack configuration is specified in webpack.config.js. This config file is read when you run webpack or webpack-dev-server command. Optional gulpfile.js (to build the project using Gulp) also loads this file and passes to Webpack APIs.

Here is a brief description of some of the entries in the config file – Continue reading “Setting up Webpack + Babel + ReactJS”

Using ReactJS with Babel and ES6

I wanted to create this post shortly after the last post about Setting up ES6+Babel+Gulp, but it got delayed for some reasons. Anyways ..

Though it is not very complicated to setup ReactJS to work with Babel, there are a few non-obvious things you need to be aware of, specifically the absence of  auto-binding in ReactJS when coded in ES6. Let’s create a small NodeJS project using Gulp –

Install following packages –

npm install gulp gulp-connect vinyl-source-stream browserify babelify babel-preset-es2015 react react-dom babel-preset-react --save-dev

In addition to packages installed in the last post, here we are installing react, react-dom and babel-preset-react packages.

The directory structure is similar to one in the previous post, except that we add views folder for JSX files.

ES6ReactJSBabelTest
  -- build
  -- src
    -- js
       -- views
    -- html
  -- gulpfile.js

Gulp ‘build’ task is modified to add ‘react’ preset to babelify and add jsx extension to browserify (we want browserify to process .jsx files in addition to .js files) Continue reading “Using ReactJS with Babel and ES6”

Setting up ES6+Babel+Gulp

ECMAScript 6 (ES6, specification at http://www.ecma-international.org/ecma-262/6.0/) has many nice features, but presently not all browsers support ES6. However you can still develop your applications in ES6 and make it run in all browsers. For this you need what is called as transpiler – which converts ES6 code to ES5, which all browsers understand currently.

One of the popular transpiler is Babel . In this post we will see how to use Node.js (https://nodejs.org/), Gulp.js (https://gulpjs.com/), Browserify (http://browserify.org/)  to compile ES6 code to ES5.

Gulp is a build tool for Node.js applications. Browserify resovles ‘require’ modules of Node.js and bundles all modules in one file. We will first use browserify to combine all our JS code in one file and then feed the output to babelify to translate the code to ES5. Structure of this sample project is as follows –

ES6BabelTest
  -- build
  -- src
    -- js
    -- html
  -- gulpfile.js

Not all the files are folders are shown above, for example package.json and node_modules folder are not shown.

Continue reading “Setting up ES6+Babel+Gulp”

Social