Skip to content

Instantly share code, notes, and snippets.

View cp-shen's full-sized avatar

cp-shen

  • Beijing, China
View GitHub Profile
@cp-shen
cp-shen / cheatsheet.ps1
Created February 4, 2024 13:02 — forked from pcgeek86/cheatsheet.ps1
PowerShell Cheat Sheet / Quick Reference
Get-Command # Retrieves a list of all the commands available to PowerShell
# (native binaries in $env:PATH + cmdlets / functions from PowerShell modules)
Get-Command -Module Microsoft* # Retrieves a list of all the PowerShell commands exported from modules named Microsoft*
Get-Command -Name *item # Retrieves a list of all commands (native binaries + PowerShell commands) ending in "item"
Get-Help # Get all help topics
Get-Help -Name about_Variables # Get help for a specific about_* topic (aka. man page)
Get-Help -Name Get-Command # Get help for a specific PowerShell function
Get-Help -Name Get-Command -Parameter Module # Get help for a specific parameter on a specific command
@cp-shen
cp-shen / cheatsheet.ps1
Created February 4, 2024 13:02 — forked from pcgeek86/cheatsheet.ps1
PowerShell Cheat Sheet / Quick Reference
Get-Command # Retrieves a list of all the commands available to PowerShell
# (native binaries in $env:PATH + cmdlets / functions from PowerShell modules)
Get-Command -Module Microsoft* # Retrieves a list of all the PowerShell commands exported from modules named Microsoft*
Get-Command -Name *item # Retrieves a list of all commands (native binaries + PowerShell commands) ending in "item"
Get-Help # Get all help topics
Get-Help -Name about_Variables # Get help for a specific about_* topic (aka. man page)
Get-Help -Name Get-Command # Get help for a specific PowerShell function
Get-Help -Name Get-Command -Parameter Module # Get help for a specific parameter on a specific command
@cp-shen
cp-shen / ExampleWindow.cs
Last active October 13, 2020 07:10
Unity Editor Window Example
// https://docs.unity3d.com/ScriptReference/EditorBuildSettings-scenes.html
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class ExampleWindow : EditorWindow
{
List<SceneAsset> m_SceneAssets = new List<SceneAsset>();
@cp-shen
cp-shen / setup.ps1
Created June 28, 2020 06:35
Fzf PowerShell integration
# First make sure fzf.exe is in your PATH
# install modules frome PowerShell Gallery
Install-Module -Name PSReadLine
Install-Module -Name PSFzf
# Add this line to $env:UserProfile\Documents\WindowsPowerShell\profile.ps1
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'
@cp-shen
cp-shen / cpu_freq.sh
Created May 20, 2020 17:00
watch cpu freq in realtime
watch -n.1 "cat /proc/cpuinfo | grep \"^[c]pu MHz\""
# from https://unix.stackexchange.com/questions/264632/what-is-the-correct-way-to-view-your-cpu-speed-on-linux
@cp-shen
cp-shen / readme.md
Created May 20, 2020 15:55
How to combine xfce desktop enviroment and i3wm
@cp-shen
cp-shen / gist.md
Created January 6, 2020 04:14 — forked from honza/gist.md
Clojure vs Haskell

Haskell vs Clojure

The JSON data is in the following format

{
    "Genesis": {
        "1": {
            "1": "In the beginning..." ,
            "2": "..."
@cp-shen
cp-shen / check_file_exists.zsh
Created November 19, 2019 12:30 — forked from fhuitelec/check_file_exists.zsh
[Check file exists] Cheatsheet to check if file exists #zsh #shell #cheatsheet
#!/usr/bin/env zsh
#
# Check file exists
#
if [ ! -f /tmp/foo.txt ]; then
echo "File not found!" >&2
exit 1
fi
@cp-shen
cp-shen / swapkey.ps1
Created June 14, 2019 08:33
Swap Control and Caps Lock on Windows
# https://www.mavjs.org/post/swap-ctrl-and-capslock-on-windows/
$hexified = "00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00".Split(",") | % { "0x$_"};
$kbLayout = 'HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout';
New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified)

Modern Linux desktop environments (Gnome 3, Ubuntu Unity, Docky) use the WMClass property to associate windows with the owning application. Many Java-based applications have the problem where the windows created by the application are not associated with the shortcut used to start the application (so the dock contains multiple copies of the same icon).

So the field called StartupWMClass is a string that defines in which class the application is grouped in the Unity Launcher at startup.

You can find out which WM_CLASS your window has got when you type in a terminal:

xprop WM_CLASS and then click at the window. In case of the gnome terminal the output is as follows:

WM_CLASS(STRING) = "gnome-terminal", "Gnome-terminal"