Cara simpan tiap halaman file word sebagai sebuah file html terpisah secara otomatis – Script macro Microsoft Word

Misalnya kita punya sebuah file word ratusan halaman, lalu kita ingin menconvert tiap halaman file tersebut sebagai satu file html terpisah, kita bisa menggunakan script macro di bawah ini:

Sub SaveAsHtmls()
'
' SaveAsHtmls Macro
'
'

    Dim orig As Document
    Dim page As Document
    Dim numPages As Integer
    Dim idx As Integer
    Dim fn As String
    
       
    ' Keep a reference to the current document.
    Set orig = ActiveDocument
    
    ' Calculate the number of pages
    numPages = ActiveDocument.BuiltInDocumentProperties("Number of Pages")
    
    For idx = 1 To numPages
        ' Make sure the document is active
        orig.Activate
               
        ' Go to the page with index idx
        Selection.GoTo What:=wdGoToPage, Name:=idx
    
        ' Select the current page
        Selection.GoTo What:=wdGoToBookmark, Name:="\page"
               
        ' Copy the selection
        Selection.Copy
        
        ' Create a new document
        Set page = Documents.Add
        
        ' Activate it
        page.Activate
               
        ' Paste the selection
        Selection.Paste
        
        ' Generate the file name
        fn = "C:\converted\page_" + CStr(idx) + ".html"
        
        ' Save the document as HTML
        page.SaveAs FileName:=fn, FileFormat:=wdFormatHTML, AddToRecentFiles:=False
        
        ' Close the document
        page.Close
        
    Next

End Sub

Cara menggunakan script di atas akan Om Puter tunjukin di video di bawah ini:

Cara mengatasi warning Unity WebGL yang berbunyi: HTTP Response Header “Content-Type” configured incorrectly on the server for file Build/xxx.wasm , should be “application/wasm”. Startup time performance will suffer.

Kalian bisa menambahkan sebuah file bernama .htaccess di lokasi yang sama dengan file html game Unity yang dibuild oleh Unity, yang isinya adalah kode ini guys:

# This configuration file should be uploaded to the server as "<Application Folder>/Build/.htaccess"
# This configuration has been tested with Unity 2020.1 builds, hosted on Apache/2.4
# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.
<IfModule mod_mime.c>

# The following lines are required for builds without decompression fallback, compressed with gzip
RemoveType .gz
AddEncoding gzip .gz
AddType application/octet-stream .data.gz
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz

# The following lines are required for builds without decompression fallback, compressed with Brotli
RemoveType .br
RemoveLanguage .br
AddEncoding br .br
AddType application/octet-stream .data.br
AddType application/wasm .wasm.br
AddType application/javascript .js.br
AddType application/octet-stream .symbols.json.br

# The following line improves loading performance for uncompressed builds
AddType application/wasm .wasm

# Uncomment the following line to improve loading performance for gzip-compressed builds with decompression fallback
# AddEncoding gzip .unityweb

# Uncomment the following line to improve loading performance for brotli-compressed builds with decompression fallback
# AddEncoding br .unityweb

Script car controller sederhana untuk menjalankan mobil di Unity

Di postingan ini ingin saya share sebuah script car controller sederhana untuk menjalankan mobil.

Seperti apa penggunaannya bisa kalian lihat di video di bawahnya ya. Berikut scriptnya (Controller.cs):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Controller : MonoBehaviour
{
    //Adding audio source 
    //public AudioSource audioSourceIddle;
    //public float minimumPitchIdle = 0.5f;
    //public AudioSource audioSourceAcc;
    //public float minimumPitchAcc = 0.5f;




    //Making reference to wheel colliders
    [SerializeField] WheelCollider FrontRight;
    [SerializeField] WheelCollider FrontLeft;
    [SerializeField] WheelCollider BackRight;
    [SerializeField] WheelCollider BackLeft;

    //Getting Reference to phisycal wheel meshes
    [SerializeField] Transform FrontRightTransform;
    [SerializeField] Transform FrontLeftTransform;
    [SerializeField] Transform BackRightTransform;
    [SerializeField] Transform BackLeftTransform;


    public float acceleration = 30000f;
    public float BreakingForce = 8000f;
    public float MaxTurnAngle = 30f;


    private float CurrentAcceleration = 0f;
    private float CurrentBreakingForce = 0f;
    private float CurrentTurnAngle = 0f;
    private float CurrentAccSound = 0f;

    

    private void FixedUpdate()
    {
        //Making reference to the audio
        //audioSourceIddle = GetComponent<AudioSource>();
        //audioSourceAcc = GetComponent < AudioSource>();
        //audioSource.pitch = minimumPitch;

        //Get forward /backward acceleration from the vertical axis (W and S keys)
        CurrentAcceleration = acceleration * Input.GetAxis("Vertical")*(-1);
        CurrentAccSound = Input.GetAxis("Vertical");
        //setting up sound
        //if (CurrentAccSound < 0.0)
        //{
            //audioSourceIddle.pitch = (float)(minimumPitchIdle-0.1);
        //}
        //else if (CurrentAccSound > 0.7)
        //{
          //  audioSourceAcc.volume = minimumPitchAcc;
        //
        //else
        //{
         //   audioSourceIddle.pitch = minimumPitchIdle;
        //}
        
        

        //give CurrentBreakForce a value if space key is being pressed
        if (Input.GetKey(KeyCode.Space))
            CurrentBreakingForce = BreakingForce;
            //audioSource.pitch = minimumPitch;
        else
            CurrentBreakingForce = 0;
        //Front wheels acceleration
        FrontRight.motorTorque = CurrentAcceleration;
        FrontLeft.motorTorque = CurrentAcceleration;
        BackRight.motorTorque = CurrentAcceleration;
        BackLeft.motorTorque = CurrentAcceleration;
        //Apply braking to the four wheels
        FrontRight.brakeTorque = CurrentBreakingForce;
        FrontLeft.brakeTorque = CurrentBreakingForce;
        BackRight.brakeTorque = CurrentBreakingForce;
        BackLeft.brakeTorque = CurrentBreakingForce;

        //Stearing
        CurrentTurnAngle = MaxTurnAngle * Input.GetAxis("Horizontal");
        FrontRight.steerAngle = CurrentTurnAngle;
        FrontLeft.steerAngle = CurrentTurnAngle;

        //Update position and rotation of wheel meshes
        UpdateWheel(FrontRight, FrontRightTransform);
        UpdateWheel(FrontLeft, FrontLeftTransform);
        UpdateWheel(BackRight, BackRightTransform);
        UpdateWheel(BackLeft, BackLeftTransform);

    }

    void UpdateWheel(WheelCollider col, Transform trans) {
        //Get state of collider
        Vector3 position;
        Quaternion rotation;
        col.GetWorldPose(out position, out rotation);
        //Set wheel to the same state as collider
        trans.position = position;
        trans.rotation = rotation;
    }
}

Ini videonya:

Koleksi fungsi-fungsi PHP favorit OmPuter

Di bawah ini adalah snippet kode function-function PHP yang saya buat dan sebagian saya ambil dari internet, saya kumpulkan dalam sebuah file bernama functions.php dan sering saya gunakan di tutorial-tutorial saya di channel YouTube saya.

Silahkan jika ingin copy paste, berikut ini source nya:

<?php

//Make table if not exists
function maketable($table){
	global $connection;
    mysqli_query($connection, "CREATE TABLE IF NOT EXISTS $table (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY
    )");
}

//Check column and make it if not exist
function makecolumn($columnname, $tablename, $ctype){
	global $connection;
    if(!mysqli_query($connection, "SELECT $columnname FROM $tablename")){
        mysqli_query($connection, "ALTER TABLE $tablename ADD $columnname $ctype");
    }
}

//Esc sql
function escsql($data){
	global $connection;
	return mysqli_real_escape_string($connection, $data);
}

//Query
function query($q){
	global $connection;
	return mysqli_query($connection, $q);
}

//Make option data
function getoption($optionname){
	global $connection;
	global $tableoptions;
	$sql = "SELECT optionvalue FROM $tableoptions WHERE optionname = '$optionname'";
	$result = mysqli_query($connection, $sql);
	if($result){
		if(mysqli_num_rows($result) > 0){
			return mysqli_fetch_assoc($result)["optionvalue"];
		}else{
			return false;
		}
	}else{
		return false;
	}
}

//Set option data
function setoption($optionname, $optionvalue){
	global $connection;
	global $tableoptions;
	
	//check if row exists
	$sql = "SELECT * FROM $tableoptions WHERE optionname = '$optionname'";
	$result = mysqli_query($connection, $sql);
	if($result){
		if(mysqli_num_rows($result) > 0){
			//update
			mysqli_query($connection, "UPDATE $tableoptions SET optionvalue = '$optionvalue' WHERE optionname = '$optionname'");
		}else{
			//add
			mysqli_query($connection, "INSERT INTO $tableoptions (optionname, optionvalue) VALUES ('$optionname', '$optionvalue')");
		}
	}
}

//Secure input
function secureinput($text){
	$text = str_replace("<", "*", $text);
	$text = str_replace(">", "*", $text);
	$text = str_replace("script", "*", $text);
	return $text;
}

//Generate random numbers
function randnum($count){
    return substr(str_shuffle(str_repeat("0123456789", 5)), 0, $count);
}

//Generate random characters
function randchar($count){
    return substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyz", 5)), 0, $count);
}

//Mil to date
function miltodate($mil){
	if(is_numeric($mil)){
    $seconds = $mil / 1000;
		$date = date("d-m-Y", $seconds); 
		$time = date("h:i:sa", $seconds);
		return $date . " " . $time . "<br>(" . humanTiming($seconds) . " yang lalu)";
	}else{
		return "-";
	}
}


//Readable human timing
function humanTiming ($time){
    $time = time() - intval($time); // to get the time since that moment
    $time = ($time<1)? 1 : $time;
    $tokens = array (
        31536000 => 'tahun',
        2592000 => 'bulan',
        604800 => 'minggu',
        86400 => 'hari',
        3600 => 'jam',
        60 => 'menit',
        1 => 'detik'
    );

    foreach ($tokens as $unit => $text) {
        if ($time < $unit) continue;
        $numberOfUnits = floor($time / $unit);
        return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'':'');
    }
}

//Get current millisecond
function getCurrentMillisecond(){
    return round(microtime(true) * 1000);
}

//Space separator
function spacesep($content, $digits){
	return chunk_split($content . "", $digits, " ");
}

//New new lines
function nonewline($text){
	return trim(preg_replace('/\s\s+/', '', $text));
}

//Get user ip address
function getuserip() {
    $ipaddress = '';
    if (isset($_SERVER['HTTP_CLIENT_IP']))
        $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
    else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
        $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
    else if(isset($_SERVER['HTTP_X_FORWARDED']))
        $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
    else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
        $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
    else if(isset($_SERVER['HTTP_FORWARDED']))
        $ipaddress = $_SERVER['HTTP_FORWARDED'];
    else if(isset($_SERVER['REMOTE_ADDR']))
        $ipaddress = $_SERVER['REMOTE_ADDR'];
    else
        $ipaddress = 'UNKNOWN';
    return $ipaddress;
}

//Get Today date
function todaydate(){
	return date("m/d/Y");
}

//Slugify
function slugify($text, string $divider = '-')
{
  // replace non letter or digits by divider
  $text = preg_replace('~[^\pL\d]+~u', $divider, $text);

  // transliterate
  $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

  // remove unwanted characters
  $text = preg_replace('~[^-\w]+~', '', $text);

  // trim
  $text = trim($text, $divider);

  // remove duplicate divider
  $text = preg_replace('~-+~', $divider, $text);

  // lowercase
  $text = strtolower($text);

  if (empty($text)) {
    return 'n-a';
  }

  return $text;
}

Selain itu, ada juga snippet yang sering saya pakai sebagai setingan koneksi database MySQL yang bentuknya seperti ini:

<?php

$baseurl = "http://localhost/DM/donasi/";
date_default_timezone_set('Asia/Jakarta');

//Database connection
$host = "localhost";
$dbuser = "root";
$dbpassword = "";
$databasename = "mydatabase";

$connection = mysqli_connect($host, $dbuser, $dbpassword, $databasename);
$connection->set_charset("utf8"); 

Itu biasanya saya simpan sebagai file dbconnection.php dan ketika diinclude kita akan mempunyai variable $connection yang dapat kita pakai untuk konek ke database jika ingin menjalankan perintah-perintah query.

Ada juga snippet ini yang isinya snippet yang jika dijalankan dia akan men-generate tabel-tabel database yang diperlukan aplikasi web kita:

<?php


//Table Prefix
$tableprefix = "mysite_";

//Table Names with Prefix
$tableoptions = $tableprefix . "options";

//Table Options -> don't modify
maketable($tableoptions);
makecolumn("optionname", $tableoptions, "VARCHAR (300) NOT NULL");
makecolumn("optionvalue", $tableoptions, "VARCHAR (2000) NOT NULL");
//--> don't modify

Biasanya saya simpan snippet ini dalam sebuah file bernama dbinit.php