Skip to content

Instantly share code, notes, and snippets.

View dizys's full-sized avatar
🎯
Focusing

Ziyang dizys

🎯
Focusing
View GitHub Profile
@dizys
dizys / SSAO OpenGL Shader
Created May 14, 2020 19:20
OpenGL shader for achieving Screen Space Ambient Occlusion
/*
SSAO GLSL shader v1.2
assembled by Martins Upitis (martinsh) (devlog-martinsh.blogspot.com)
original technique is made by Arkano22 (www.gamedev.net/topic/550699-ssao-no-halo-artifacts/)
changelog:
1.2 - added fog calculation to mask AO. Minor fixes.
1.1 - added spiral sampling method from here:
(http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere)
*/
@dizys
dizys / MakePowerShellRememberSSHPassphrase.md
Created August 9, 2020 13:19 — forked from danieldogeanu/MakePowerShellRememberSSHPassphrase.md
How to make Powershell remember the SSH key passphrase.

You should not use the Open SSH client that comes with Git for Windows. Instead, Windows 10 has its own implementation of Open SSH that is integrated with the system. To achieve this:

  1. Start the ssh-agent from Windows Services:
  • Type Services in the Start Menu or Win+R and then type services.msc to launch the Services window;
  • Find the OpenSSH Authentication Agent in the list and double click on it;
  • In the OpenSSH Authentication Agent Properties window that appears, choose Automatic from the Startup type: dropdown and click Start from Service status:. Make sure it now says Service status: Running.
  1. Configure Git to use the Windows 10 implementation of OpenSSH by issuing the following command in Powershell: git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe;

  2. Configure SSH to automatically add the keys to the agent on startup by editing the config file found at C:\Users\%YOUR_USERNAME%\.ssh\config, and add the following lines:

@dizys
dizys / wt.reg
Created August 31, 2020 16:07
Add "Open Windows Terminal here" to explorer menu. Get `wt_32.icon` [here](https://github.com/yanglr/WindowsDevTools/tree/master/awosomeTerminal/icons)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Open Windows Terminal here"
"Icon"="C:\\Users\\<YOUR USERNAME>\\AppData\\Local\\Microsoft\\WindowsApps\\wt_32.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\<YOUR USERNAME>\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe -d ."
@dizys
dizys / vscode-to-monaco-theme-converter.js
Last active March 5, 2024 22:52
Convert VSCode theme JSON to Monaco editor theme JSON
// Taken from https://github.com/Nishkalkashyap/monaco-vscode-textmate-theme-converter/blob/master/src/index.ts
const input = {
// ...vscode theme json
};
function convertTheme(theme) {
const monacoThemeRule = [];
const returnTheme = {
inherit: false,
@dizys
dizys / github-actions-go-docker-private-repo.md
Last active August 4, 2021 09:45
Github Actions + Build go app with private repo in Docker

Passing GitHub secrets in Actions step

      - name: Build domain service image
        uses: docker/build-push-action@v2
        with:
          push: true
          context: domain-service
          tags: |
 dizy/ambassador-test-domain-service:latest
@dizys
dizys / Fix-Windows-FileSystem-ACL.ps1
Created September 16, 2021 18:17
Lost edit permissions of files (Access Denied, I know) after reinstalling your Windows? Copy this file to the folder where you want all the subfolders and files to be in your control again. Run it in PowerShell with administrator privileges, then delete or edit them again!
foreach ($file in Get-ChildItem . -Recurse)
{
$path = Get-Item -LiteralPath $file.FullName
$acl = $path.GetAccessControl()
$permission = "Everyone","FullControl","Allow"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($rule)
$path.SetAccessControl($acl)
}
@dizys
dizys / powershell-setup-guide.md
Last active September 23, 2021 23:37
My PowerShell setup guide: Oh-My-Posh + render symbols properly + fix Ctrl+Backspace issue for Visual Studio Code.

My PowerShell Setup Guide

1. Find your PowerShell profile location

This shows your PowerShell profile location:

$Profile
@dizys
dizys / VisualEffectBackground.swift
Created January 24, 2022 21:09
An extension to add visual effect (translucent background) to SwiftUI view. Meant for MacOS.
import SwiftUI
struct VisualEffectMaterialKey: EnvironmentKey {
typealias Value = NSVisualEffectView.Material?
static var defaultValue: Value = nil
}
struct VisualEffectBlendingKey: EnvironmentKey {
typealias Value = NSVisualEffectView.BlendingMode?
static var defaultValue: Value = nil
@dizys
dizys / brightspace-assignment-print-mode.js
Last active February 14, 2022 23:35
Print mode for Brightspace Contents and Assignments
function setPrintMode(on) {
let hidden = on;
document
.querySelector(
"#d2l_body > header > nav > d2l-navigation > d2l-navigation-main-header"
)
.shadowRoot.querySelector("div").hidden = hidden;
document
.querySelector(
@dizys
dizys / get-time-difference.js
Created February 12, 2022 23:34
Describe the time difference between a timestamp and now
function getTimeDifference(timestamp) {
let now = new Date();
let difference = now.getTime() - timestamp;
let seconds = Math.floor(difference / 1000);
let minutes = Math.floor(seconds / 60);
let hours = Math.floor(minutes / 60);
let days = Math.floor(hours / 24);
let time = "";
if (days > 0) {