How to remove “public/index.php” from URL generated in Laravel

Option 1: Use .htaccess

If it isn’t already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)

Edit the .htaccess file so that it contains the following code:

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteRule ^(.*)$ public/$1 [L]

Now you should be able to access the website without the “/public/index.php/” part.

Read more

How to bound gameobject within screen Unity

C# code to keep player or gameobject within the Screen view

[1] This will bound gameobject within screen unity and keep the pivot point a game object visible:

using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour {

 void Update() {
    Vector3 pos = Camera.main.WorldToViewportPoint (transform.position);
    pos.x = Mathf.Clamp01(pos.x);
    pos.y = Mathf.Clamp01(pos.y);
    transform.position = Camera.main.ViewportToWorldPoint(pos);

You can clamp it tighter if needed. Example:

pos.x = Mathf.Clamp(pos.x, 0.1, 0.9);
Viewport coordinates start at (0,0) in the lower left of the screen and go to (1,1) in the upper right. This code forces an object to have a viewport coordinate in the (0,0) to (1,1) range, and therefore to be on the screen.

[2] This will clamp the movement; i.e. it will feel like an invisible wall around the edges of the screen.

Just make sure this code happens after any physics movement adjustments, and you should be able to keep your rigidbody  stuff. If you encounter jitter, consider changing the code to something like this:

Vector3 pos = Camera.main.WorldToViewportPoint (ship.transform.position);
pos.x = Mathf.Clamp01(pos.x);
pos.y = Mathf.Clamp01(pos.y);

Vector3 speed = ship.rb.velocity;
if(pos.x == 0 || pos.x == 1)
    speed.x = 0;
if(pos.y == 0 || pos.y == 1)
    speed.y = 0;

ship.transform.position = Camera.main.ViewportToWorldPoint(pos);
ship.rb.velocity = speed;


  • How to keep an object within the camera view?
  • Limiting x and y movement so you can’t go off camera
  • Keeping a rigidbody within the screen bounds?
  • how to make the player stay within screen in a simple 2d game. C#
  • how to limit rigidbody to stay on screen


1. How to keep an object within the camera view? By: Ashky

2. Limiting x and y movement so you can’t go off camera By: Ketura

How to undo Git Commits

It is always been said that learning curve of Git can pose a challenge. However, Git has always been an exciting tool, that has enhanced developers ability to work together and ship faster. In the mean time, developers are challenged to undo what they did in past. Likewise, undo-ing commits already made on Git. Here’s a solution, we have put together some useful ways on How to Undo Git Commits.

Undo a git commit and redo
$ git commit -m "Something terribly misguided" (1)
$ git reset HEAD~ (2)
<< edit files as necessary >> (3)
$ git add ... (4)
$ git commit -c ORIG_HEAD (5)
  1. So, you’ve made a commit and now it has to be removed.
  2. This leaves your working tree (the state of your files on disk) unchanged but undoes the commit and leaves the changes you committed unstaged (so they’ll appear as “Changes not staged for commit ” in git status  and you’ll need to add them again before committing). If you only want to add more changes to the previous commit, or change the commit message [1], you could use git reset –soft HEAD~  instead, which is like git reset HEAD~  but leaves your existing changes staged.
  3. Make corrections to working tree files.
  4. git add  anything that you want to include in your new commit.
  5. Commit the changes, reusing the old commit message. reset copied the old head to .git/ORIG_HEAD;  commit with -c ORIG_HEAD  will open an editor, which initially contains the log message from the old commit and allows you to edit it. If you do not need to edit the message, you could use the -C  option.

1 Note, however, that you don’t need to reset to an earlier commit if you just made a mistake in your commit message. The easier option is to git reset (to unstage any changes you’ve made since) and then git commit –amend , which will open your default commit message editor pre-populated with the last commit message.

Beware however that if you have added any new changes to the index, using commit –amend will add them to your previous commit.

How to undo a local git commits

Let’s say a commit is made locally, but now that local commit has to be removed, here’s how to undo git commits is they are in local repo.

git log
    commit 101: bad commit    # latest commit, this would be called 'HEAD'
    commit 100: good commit   # second to last commit, this is the one we want

To restore everything back to the way it was prior to the last commit, we need to reset to the commit before HEAD:

git reset --soft HEAD^     # use --soft if you want to keep your changes
git reset --hard HEAD^     # use --hard if you don't care about keeping the changes you made

Now git log will show that the last commit has been removed.

How to undo a public git commits

If you have already made your commits public, you will want to create a new commit which will “revert” the changes you made in your previous commit (current HEAD).

git revert HEAD

Your changes will now be reverted and ready for you to commit:

git commit -m 'restoring the file I removed by accident'
git log
    commit 102: restoring the file I removed by accident
    commit 101: removing a file we dont need
    commit 100: adding a file that we need


Authored by: StackOverflow/CommunityMark Amery , Andrew StackOverflow User

Refrence: How to undo last commit