Friday, July 20, 2018

c# asp.net - simple aspx file to upload a file to server

Save below as an .aspx file in IIS.

<%@ Page Language="C#" AutoEventWireup="true" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test Upload file</title>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
 <input type="file" id="myFile" name="myFile" />
 <asp:Button runat="server"
   ID="btnUpload" OnClick="btnUploadClick" Text="Upload" />
</form>
<script runat=server>
protected void btnUploadClick(object sender, EventArgs e)
{
    HttpPostedFile file = Request.Files["myFile"];

    //check file was submitted
    if (file != null && file.ContentLength > 0)
    {
        string fname = System.IO.Path.GetFileName(file.FileName);
        file.SaveAs((System.IO.Path.Combine("C:/Temp/", fname)));
    }
}
</script>
</body>
</html>

Thursday, July 19, 2018

Unity VR (XR) camera not located at the position you add it in the scene


The camera is directly controlled by the engine and you may not be able to specify its position. What you have to do is to center the camera in the scene (0,0,0) and then put this inside a empty object. You can then position this camera containing object to where you want the player camera to be located


It may be a good practice to call below just to be sure camera is initialized and centered just before your scene starts
UnityEngine.XR.InputTracking.Recenter();

Wednesday, July 11, 2018

Batch convert using ffmpeg

Say you have some folder and sub-folders full of .wav files and want to convert them all to .mp3 at a single shot, try the below



  1. Get ffmpeg
  2. Copy the below command from down below and save it in a .bat file
  3. Make sure the ffmpeg path is correct in the command
  4. Make sure the file is saved in the root folder where you want the files to be converted.
  5. Run the bat file you have created

for /R %%g in (*.wav) do start /b /wait "" "C:\ffmpeg-4.0.1-win64-static\bin\ffmpeg" -threads 16 -i "%%g" -acodec libmp3lame "%%~dpng.mp3" && del "%%g"



Turn on Windows 11 Fast Boot

If windows starting is slow, to enable windows 11 fast startup/boot,  Press Windows + R, type powercfg.cpl, and hit Enter.  This will direct...