With this snippet, we are able to check if a folder existed in device’s storage or not. If not, then we create it. Here is the snippet: File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + “/afolder”); if (! directory.exists()){ directory.mkdir(); }
Simple PHP read and write to a text file
This code snippet reads a text file that if it is not existed it will create one with some text in it. Next time this code is executed, if the file existed, PHP echoes the content of the file. <?php $settingfile = “settings.txt”; $filelink =...
Changing the skybox material programmatically in Unity
I’m using this simple script after attaching it to UI Buttons to change my skybox materials. Let’s say we have two skybox materials with two UI Buttons to switch between them. Here is the script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChangeSky :...
Unity click and drag script to rotate camera
Just googling around to find how to rotate camera with mouse click and drag. Thanks to this link: https://answers.unity.com/questions/1189946/click-and-drag-to-rotate-camera-like-a-pan.html This code is originally taken from that link: using System.Collections; using System.Collections.Generic; using UnityEngine; public class CamRotate : MonoBehaviour { public float speed = 3.5f; private float...
Unity iOS ‘GoogleMobileAds/GoogleMobileAds.h’ file not found
Another one of common errors on building Unity games in Mac when we compile it using XCode is this error that states: ‘GoogleMobileAds/GoogleMobileAds.h’ file not found The quick solution is to reimport GoogleMobileAds plugin. That’s it.
Solving mach-o linker error on publishing Unity – XCode
One of common error when we want to build our Unity game from XCode is this mach-o linker error. There are many solutions on internet but in my case, the solution is this simple one: Change target build to 8.0 On Build Settings, set Enable...
JavaScript random numbers examples
Generating random numbers is a common thing in programming. Here is some examples in JavaScript: //Basic Random Math.random(); //From 0 to specific number Math.random() * 10; //Removing decimals Math.floor(Math.random() * 10); //Random between 5 and 10 Math.floor(Math.random() * 5) + 5; //Random between 5 and...
Creating Depth of Field Effect in Blender
Depth of Field effect in 3D rendering adds realism to it. It’s easy how to create this effect in Blender. To create DOF effect in Blender first we need to adjust our camera’s focus distance, then add defocus effect on render node as I’ll show...
Showing Poly and Vert Statistics in 3Ds Max
If you sell 3D models online, sometimes marketplaces require poly count or triangles count of your object. In 3Ds Max, it’s easy to show that statistics. Press 7 and it will appear in your viewport. If you need more stat details, go to Views >...
PHP & MySQL useful snippets
For us, working with database in web development is a mandatory task. Here in this post I’m going to list, as much as I know, PHP & MySQL snippets that I frequently use.
Inserting Arabic text with PHP into MySQL Database
We need to set the encoding of texts we store into database to UTF-8 if we work with Arabic texts. Otherwise, Arabic texts appear like ?????????? in our database.
Using Command Prompt to render Blender animations
We don’t need to open Blender to render our animation to make rendering progress faster. After you set everything, close your Blender and run Command Prompt (in Windows), then navigate to your Blender program directory:
Blender quick tips and shortcuts
Working with blender is much faster and easier if you know most of it’s keyboard shortcuts. Here in this post I’m going to list them as much as I can:
Very easy and simple .htaccess & PHP tutorial
If you work with PHP, you notice that this URL: http://yoursite.com/index.php?post=2 is not pretty at all. There is term “Pretty URL” and a lot of tutorials how to make your URL prettier. In this post I’m going to share a few line of .htaccess codes...
How to hide or show previous or next div with jQuery
Imagine if we have some divs, and we want to show them one by one like a gallery, by providing users two buttons to navigate to previous or next div. How do we code it? In this tutorial I’ll share how I do it by...
How to generate random text using JavaScript
In this post I’m going to share a JavaScript function, if you call it (and assign some number as length of randomized text you want), it will return random text.
JavaScript codes to only accept alphabet letters and numbers from your users
Sometimes we ask our users to type in something and we only accept alphabet numbers and/or letters, so they should not type something like #$%!@$&%(…
Picking an Image and Taking Photo in Android – Java source code
This is Java source code for Android, providing you with two functions: to take a photo using camera and to pick an image from gallery.
Getting user’s latitude and longitude in Android – Java source code
In this example, user’s device is showing it’s current latitude and longitude every 5 seconds. Coordinates are displayed inside Android Toast.
Pick an Image from Android device and upload it to server using PHP
To upload an image from Android device to online server using PHP, first we need to create a PHP script to handle “post” request and store the image to a folder. So write this simple script on your server: