Public

Public Documentation

Reset Repo Commits

Linux

export GIT_RESET_USER=yourUserNameOrOrgName
export GIT_RESET_REPO=yourRepoName
export bypassCF="git"
export bypassCF2="@"
export bypassCF3="github.com"
rm -rf .git
git init
git add .
git checkout -b main
git commit -m "Initial Commit"
git remote add origin $bypassCF$bypassCF2$bypassCF3github.com:$GIT_RESET_USER/$GIT_RESET_REPO.git
git remote set-url origin https://github.com/$GIT_RESET_USER/$GIT_RESET_REPO.git
git push -u --force origin main

Windows

set GIT_RESET_USER=yourUserNameOrOrgName
set GIT_RESET_REPO=yourRepoName
set bypassCF=git
:: set bypassCF2 = @ (remove spaces)
set bypassCF2=@
set bypassCF3=github.com
rd /s /q .git
git init
git add .
git checkout -b main
git commit -m "Initial Commit"
git remote add origin %bypassCF%%bypassCF2%%bypassCF3%:%GIT_RESET_USER%/%GIT_RESET_REPO%.git
git remote set-url origin https://github.com/%GIT_RESET_USER%/%GIT_RESET_REPO%.git
git push -u --force origin main

GitHub API: Organization Membership

This simple curl command will set your membership to public/private for any organization.

A use case would be an organization so big you can't search for yourself.

For this to work, you need a GitHub Personal Access Token.

# To make an org private, replace PUT with DELETE
curl \
  -X PUT \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: token xxxxxxxxxxxxxxxx" \
  https://api.github.com/orgs/YourOrgUsernameHere/public_members/YourGitHubUsernameHere

GitHub API Docs

Saving chmod +x in a Git Repo

export fileType=.sh
git config core.fileMode true
find . -type f -iname "*$fileType" -exec chmod +x {} \;
find . -type f -iname "*$fileType" -exec git update-index --chmod=+x {} \;
git add . && git commit -am "Update Execute Permissions" && git push

Ghost Snippets

Place any of the following in your Code Injection settings.

Found in: Ghost Admin -> Settings -> Advanced -> Code Injection

Site Header

<style>
    /* Hide "Powered By Ghost" from Footer, granted this makes the footer look weird. */
    .site-footer .inner div {
        display: none;
    }

    /* Hide Footer entirely */
    footer {
        display: none;
    }
    
    /*
  		(Only use this if you remove the footer) 
  		Padding the bottom of page if CTA/Read More/etc is visible because removing footer causes it to hug bottom of page
  	*/
    .footer-cta,
    .read-more-wrap,
    .post-feed{
        margin-bottom: 35px;
    }
</style>
<script>
    // External Links Open in New Tab
    var links = document.querySelectorAll('a');
    links.forEach((link) =>
    {
        var a = new RegExp('/' + window.location.host + '/');
        if (!a.test(link.href))
        {
            link.addEventListener('click', (event) =>
            {
                event.preventDefault();
                event.stopPropagation();
                window.open(link.href, '_blank');
            });
        }
    });

    // Hide "Powered By Ghost" in Portal Popup
    window.onload = function ()
    {
        let portal = document.getElementById("ghost-portal-root");
        const interval = setInterval(() =>
        {
            let frame = portal.querySelector('[title="portal-popup"]');
            if (frame !== null)
            {
                const styleElement = document.createElement("style");
                styleElement.innerHTML = `.gh-portal-powered { display: none; }`;
                frame.contentDocument.head.appendChild(styleElement);
            } else
            {
                frame = null
            }
        }, 0)
    }

    // Inject a "Share this article" at the end of all posts
    async function copyToClip(text)
    {
        try
        {
            const protocol = window.location.protocol;
            await navigator.clipboard.writeText(`${ protocol }//${ text }`);
            var h4 = document.querySelector(`#c-share`);
            if (!h4.querySelector(`span`))
            {
                var span = document.createElement(`span`);
                span.innerHTML = ` (copied to clipboard)`;
                h4.appendChild(span);
                setTimeout(function ()
                {
                    span.remove();
                }, 2000);
            }
        } catch { }
    }
    var article = document.querySelector(`.article.post`);
    var section = article.querySelector(`.gh-content`);
    // Hacky workaround to only show on blog posts and not on pages like "About" (Blog Posts have a CTA when signed out, a read more section, or article comments)
    if (document.querySelector(`.footer-cta`) || document.querySelector(`.read-more-wrapper`) || document.querySelector(`.read-more-wrap`) || document.querySelector(`.article-comments`))
    {
        var hr = document.createElement(`hr`);
        section.appendChild(hr);
        var h4 = document.createElement(`h4`);
        h4.id = `c-share`;
        let url = `${ window.location.host }${ window.location.pathname }`;
        url = url.replace(/\/$/, ``);
        h4.innerHTML = `Share this post: <a href="#" onclick="copyToClip(\`${ url }\`); return false;">${ url }</a>`;
        section.appendChild(h4);
    }
</script>

Prune Docker

docker image prune -a -f
docker volume prune -f
docker network prune -f

Regex

Empty Lines after if/else/while/for

(if |else |else if |for |while ).+\n\n

Resources

HTML Redirects

Redirect to another site with HTML.

<!-- index.html -->
<meta http-equiv="refresh" content="0; url=https://example.com">
# .htaccess
ErrorDocument 404 https://example.com

Resizing HDD (Linux)

  1. Resize disk with any solution (GParted, etc).
  2. Use lsblk to get the partition you want to expand.
  3. sudo growpart /dev/sda 2 # 2 is the partition you want to increase in size.
  4. sudo resize2fs /dev/sda2

Restart Windows Audio Service Script

Place the following into a .bat file and run it.

@echo off

:: Run as Admin
set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || (  echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )

net stop audiosrv 
net start audiosrv 

exit

EmuDeck Systems List