Skip to content

Instantly share code, notes, and snippets.

View Himura2la's full-sized avatar
💭
Nya?

Himura Kazuto Himura2la

💭
Nya?
View GitHub Profile

Keybase proof

I hereby claim:

  • I am himura2la on github.
  • I am himura (https://keybase.io/himura) on keybase.
  • I have a public key ASD5ZI3tpOcl-caQlSaudadLWq9To5Jdt6sAov_wJ7wrBAo

To claim this, I am signing this object:

@Himura2la
Himura2la / control-snippet.py
Last active April 1, 2018 09:19
cloud4rpi-wol
# ...
def wake_pc(value):
if value:
return wol.wake()
def ping_pc(value):
return wol.ping()
def main():
@Himura2la
Himura2la / PowerShell Launcher.bat
Last active November 10, 2021 11:02
Run PowerShell scripts
@if "%~1" == "" (
@echo Drop a *.ps1 file onto this script.
) else (
@echo --- launching %~1 ---
@powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~1'; echo ""--- %~1 returned $LastExitCode ---"""
)
@pause
@Himura2la
Himura2la / scp.ps1
Created December 27, 2018 14:18
Copy a file from a remote server using PowerShell and WSMan
Copy-Item -FromSession (New-PSSession remote-server-hostname) -Path "C:\DataDir" -Destination "D:\Backpus\DataDir" -Recurse
docker run --rm \
-v volume-name:/data \
-v ~/backups:/bkp \
alpine \
tar cf /bkp/volume-bkp.tar /data
@Himura2la
Himura2la / StringRunner.cs
Created June 25, 2019 15:11
StringRunner
public static string StringRunner(string s) {
var output = new StringBuilder();
for(int i = 0; i < s.Length; i++) {
char prevCh = i > 0 ? s[i - 1] : '\0';
char thisCh = s[i];
char nextCh = i < s.Length - 1 ? s[i + 1] : '\0';
switch(thisCh) {
// Do the replacements
default:
output.Append(thisCh);
@Himura2la
Himura2la / GetUWPApps.ps1
Created July 16, 2019 15:51
List All UWP Apps
Get-AppxPackage | Select PackageFamilyName, InstallLocation
# Run command: shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App
@Himura2la
Himura2la / LowLevelReplace.cs
Created August 21, 2019 14:44
Replaces matches using string.Remove().Insert()
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace LowLevelReplace {
class Program {
static readonly Regex template = new Regex(@"({(.*?)})", RegexOptions.Compiled);
static readonly Dictionary<string, string> values = new Dictionary<string, string>() {
{ "meow", "nya" },
@Himura2la
Himura2la / WhoIsOnline.ps1
Created August 26, 2019 08:46
Get logged in users
qwinsta /server:ServerName
@Himura2la
Himura2la / install-pwsh.sh
Last active October 15, 2019 13:17
Install PowerShell on Debian-based distro (based on official docs)
sudo apt-get update
sudo apt-get install -y wget gnupg apt-transport-https lsb-release
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-$(. /etc/os-release && echo $ID)-$(lsb_release -sc)-prod $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/microsoft.list
sudo apt-get update
sudo apt-get install -y powershell