Skip to content

Instantly share code, notes, and snippets.

@codeadamca
Last active September 5, 2026 16:43
Show Gist options
  • Select an option

  • Save codeadamca/bc3dcb6fc768ee1714918aa15cf13fad to your computer and use it in GitHub Desktop.

Select an option

Save codeadamca/bc3dcb6fc768ee1714918aa15cf13fad to your computer and use it in GitHub Desktop.
Setting up your username.github.io page

Setting up your username.github.io Page

When you setup GitHub pages, by default your content is available at https://<GITHUB_USERNAMNE>.github.io/<REPO_NAME>/.

However, if you create a repo with the exact name <GITHUB_USERNAME>.github.io, GitHub will automatically turn GitHub Pages on, and make this content avialable at https://<GITHUB_USERNAME>.github.io/. Kind of like your GitHub home page!

For example, I set up a sample at:
https://github.com/codeadamca/codeadamca.github.io

The repo is avilable as a website at:
https://codeadamca.github.io

This also works for organizations using a repo named <GITHUB_ORGANIZATION>.github.io.

For example BrickMMO has a page at:
https://brickmmo.github.io/

This setup also has the added benefit that your <GITHUB_USERNAME>.github.io website is the root of your other websites using GitHub Pages. So you can place a favicon (or other shared root files) in your <GITHUB_USERNAME>.github.io repo and it will be used by sites such as https://<GITHUB_USERNAMNE>.github.io/<REPO_NAME>/.

This GitHub Pages site uses my favicon.ico file from my codeadamca.github.io site:
https://codeadamca.github.io/about-me/

@nicfv

nicfv commented Oct 6, 2023

Copy link
Copy Markdown

I can't create a pull request, but there is a minor typo here: 😃

Kind of like your GutHub home page!

@AS-EBaiden

AS-EBaiden commented Mar 25, 2024 •

Copy link
Copy Markdown

im curious, can we do something like this? [repo-name].[username].github.io ?

@tahayparker

Copy link
Copy Markdown

@AS-EBaiden did you figure it out? is it possible to do so?

im curious, can we do something like this? [repo-name].[username].github.io ?

@codeadamca

Copy link
Copy Markdown
Author

im curious, can we do something like this? [repo-name].[username].github.io ?

I do not think this is possible.

@AS-EBaiden

Copy link
Copy Markdown

☹ it is not possible

@HimalEranganaOfficial

HimalEranganaOfficial commented Jan 8, 2025 •

Copy link
Copy Markdown

I tried to set this up, but I wasn't able to get it working. Can someone please help me identify where I might be making a mistake?😔

My username is @HimalEranganaOfficial .

Here's the page I created: https://himaleranganaofficial.github.io/HimalEranganaOfficial/

However, it doesn't seem to be working at https://himaleranganaofficial.github.io/

@codeadamca

Copy link
Copy Markdown
Author

@HimalEranganaOfficial Change the name of the repo to "HimalEranganaOfficial.github.io" (include ".github.io" in the repo name). For example, here is mine:

https://github.com/codeadamca/codeadamca.github.io

You won't have to turn on GitHub Pages.

@HimalEranganaOfficial

Copy link
Copy Markdown

@codeadamca, thanks for clarifying that! (I asked it from several AIs and searched Stack Overflow questions, but I couldn't find a solution to my problem.)

I knew that creating a repo named "username" would display its README.md in the profile. That's why I thought the correct repo to put the index.html file in was there, since GitHub treats it specially (GitHub showed a special notification after I created it, mentioning editing README.md to display it in profile view).
image

By the way, thanks again for pointing me in the right direction. I really appreciate it! 😄

@gibbok

gibbok commented Mar 1, 2026

Copy link
Copy Markdown

@codeadamca Thanks for this! It was super helpful!

@TurboDelights

Copy link
Copy Markdown

1

@piyushsaha986-hash

Copy link
Copy Markdown

// VirtualJoystick.cs
using System;
using UnityEngine;
using UnityEngine.EventSystems;

[RequireComponent(typeof(RectTransform))]
public class VirtualJoystick : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUpHandler
{
[Header("References")]
[SerializeField] RectTransform handle;

[Header("Behavior")]
[Tooltip("If true, joystick appears where the user touches the screen.")]
public bool dynamic = false;
[Tooltip("Pixels the handle can move from joystick center.")]
public float handleRange = 80f;
[Tooltip("Deadzone (0..1) for the normalized input magnitude.")]
[Range(0f, 0.9f)] public float deadZone = 0.12f;
[Tooltip("Speed at which the handle returns to center when released.")]
public float returnSpeed = 8f;
[Tooltip("If true, background is hidden when not dragging (for dynamic mode).")]
public bool hideOnRelease = true;

// runtime state
RectTransform baseRect;
Canvas parentCanvas;
int pointerId = -1;
Vector2 input = Vector2.zero;
bool dragging = false;
Vector2 joystickCenter = Vector2.zero; // anchoredPosition of base

// public read-only accessors
public float Horizontal => input.x;
public float Vertical => input.y;
public Vector2 Direction => input.normalized;
public float Magnitude => input.magnitude;
public bool IsDragging => dragging;

void Awake()
{
    baseRect = GetComponent<RectTransform>();
    parentCanvas = GetComponentInParent<Canvas>();
    if (handle == null) Debug.LogError("VirtualJoystick: handle is not assigned.", this);
}

void Start()
{
    // initial visibility
    if (dynamic && hideOnRelease)
        SetVisible(false);
    joystickCenter = handle.anchoredPosition;
}

public void OnPointerDown(PointerEventData eventData)
{
    // lock to this pointer for multi-touch
    if (pointerId != -1) return;

    pointerId = eventData.pointerId;
    dragging = true;
    SetVisible(true);

    if (dynamic)
    {
        // move base to the touch position
        Vector2 localPoint;
        RectTransformUtility.ScreenPointToLocalPointInRectangle(
            baseRect,
            eventData.position,
            eventData.pressEventCamera,
            out localPoint);
        baseRect.anchoredPosition = localPoint;
        joystickCenter = Vector2.zero; // handle anchoredPosition zero means center
        handle.anchoredPosition = Vector2.zero;
    }
    else
    {
        // ensure center is correct base anchored position
        joystickCenter = handle.anchoredPosition;
    }

    OnDrag(eventData);
}

public void OnDrag(PointerEventData eventData)
{
    if (eventData.pointerId != pointerId) return;

    Vector2 localPoint;
    RectTransformUtility.ScreenPointToLocalPointInRectangle(
        baseRect,
        eventData.position,
        eventData.pressEventCamera,
        out localPoint);

    Vector2 diff = localPoint - joystickCenter;
    Vector2 clamped = Vector2.ClampMagnitude(diff, handleRange);
    handle.anchoredPosition = clamped;

    // normalized input (x,y) in -1..1 range based on handleRange
    Vector2 norm = clamped / handleRange;

    // apply deadzone
    if (norm.magnitude <= deadZone)
        input = Vector2.zero;
    else
        input = norm;
}

public void OnPointerUp(PointerEventData eventData)
{
    if (eventData.pointerId != pointerId) return;

    pointerId = -1;
    dragging = false;

    // hide or reset
    if (dynamic && hideOnRelease)
        SetVisible(false);

    // start return-to-center (instant or smoothed in Update)
    if (!dynamic || !hideOnRelease)
    {
        // reset anchored positions smoothly in Update()
    }
}

void Update()
{
    if (!dragging)
    {
        // smooth return of handle to center
        if (handle.anchoredPosition != Vector2.zero)
        {
            handle.anchoredPosition = Vector2.Lerp(handle.anchoredPosition, Vector2.zero, Time.deltaTime * returnSpeed);
            // update input accordingly during return
            Vector2 norm = handle.anchoredPosition / handleRange;
            input = (norm.magnitude <= deadZone) ? Vector2.zero : norm;
        }
        else
        {
            input = Vector2.zero;
        }
    }
}

void SetVisible(bool visible)
{
    CanvasGroup cg = GetComponent<CanvasGroup>();
    if (cg == null)
    {
        cg = gameObject.AddComponent<CanvasGroup>();
    }
    cg.alpha = visible ? 1*

@piyushsaha986-hash

Copy link
Copy Markdown

এই গেমটি দিন

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment