Switchable “Camera Follows a Player” accross mutliple scenes in Unity

This is a Unity package file, if you download it and import it on your empty Unity project, you will see a demonstration about a camera that follows an object, and this camera (it’s position) is switchable, you can click a button to switch between multiple camera positions and angles. Plus there are two buttons to open two empty scenes, but when you open it the player object and cameras will be there too.

The purpose of this demonstration is to show you how an object like player, camera, etc can be used on multiple scenes without reloading them in each scenes, by adding one line script to make those objects undestroyable when you change scenes.

How to switch between camera positions and angles in Unity by C# script

The script inside this package allows you to switch between camera positions so you can switch between camera angles and positions easily with single click button.

In this example, there were 3 camera positions that we can switch between them. In this video I also tried to add another camera position (the 4th position).

You will also be able to adjust camera switching speed to be fast or slow.

One line PHP code to remove characters except numbers and letters

I found this few lines of PHP script useful to sanitize user input, it removes characters except numbers and letters:

$clean_code = preg_replace('/[^\w]/', '', $string);

Or this one:

$clean_code = preg_replace('/[^a-zA-Z0-9]/', '', $string);

Original post is here: https://coderwall.com/p/bn47ka/remove-all-characters-except-letters-and-numbers-in-php

How to send POST request to another website from a PHP script

Let’s say we have a website like somewebsite.com and there is an input form, but we don’t want to submit that form from that website, instead we send POST request to that page from another website. Here is a handy PHP script to do so:

<?php

$url = 'https://somewebsite.com/';
$data = array('key1' => 'value1', 'key2' => 'vaue2');

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }

var_dump($result);

?>

Save Android Webview Content as PDF File

Hello everybody!

What you are seeing here is an Android app that shows a local html file inside a Web View.

Then on top of the web view there is a button to save web view contents as a pdf file.

Pdf file is saved localy after you tapped the button and you can open it using your favorite pdf viewer app in your phone.

How to make objects facing towards player in Unity

Some of elements in our game probably need to always face towards the player or player’s camera.

With this script we can make any object that this script attached on it, to look at a specific object, like player object or a camera.

How to resize QR Code image generated by phpqrcode library

In this tutorial I will show you how to modify the phpqrcode library to generate more bigger and larger QR Code image.

By default if we generate a QR Code of short text or string, we will get a small QR Code image approximately less than 100 pixels. But we can multiply by any number we like.

How to make an HTML5 Note Taking Program

HTML5 is amazing to me it and I have fun to do coding with JavaScript because it runs on web browser just like that, so we don’t have to install anything, its just running on web browser.

In this tutorial I will share with you how to create a web program, this time, a note taking program.

By watching this tutorial you will know how to store note data, how to retrieve it back and how to delete each one of notes we saved.

We don’t use any database to make this note taking program, we only use what so-called Local Storage on web browser, so our notes are saved on web browser.

Adding html file inside assets folder (Creating HTML5 Android WebApp)

Now we are ready to add our html file inside assets folder. Create a folder named assets and put your html file there. Then build the app. You will see your app is running displaying that html page.

This code is for html sample page used in this tutorial:

<!DOCTYPE html>
<html>
	<head>
		<title>LightWeight NoteTaker</title>
	</head>
	<body>
		<h1>Hello!</h1>
		<p>This is a LightWeight NoteTaker HTML5 Android app</p>
	</body>
</html>