Skip to content

Instantly share code, notes, and snippets.

curl -sLJ https://github.com/grafana/k6/releases/download/v0.50.0/k6-v0.50.0-linux-amd64.tar.gz | tar xvzf - -C /tmp
curl -sLJ https://github.com/derailed/k9s/releases/download/v0.32.4/k9s_linux_amd64.tar.gz | tar xvzf - -C /tmp
curl -sLJ https://github.com/Versent/saml2aws/releases/download/v2.36.16/saml2aws_2.36.16_linux_amd64.tar.gz | tar xvzf - -C /tmp
@tknhs
tknhs / disconnect.bat
Created September 19, 2022 04:21
セッションを別ユーザに渡す
@echo off
setlocal enabledelayedexpansion
cd %~dp0
for /f "usebackq tokens=4*" %%a in (`tasklist /v ^| findstr RDP`) do (
set SessionNumber=%%a
)
tscon !SessionNumber! /dest:console
@tknhs
tknhs / session_checker.ps1
Last active May 21, 2022 15:05
ユーザセッションがアクティブでない場合にLINEへ通知を送る
<#
.SYNOPSIS
セッション状態を確認するスクリプト
.DESCRIPTION
対象ユーザのセッションがアクティブでない場合にLINEへ通知を送る
.EXAMPLE
PS C:\Users> .\session-checker.ps1 -token xxxx -server test-server -user Administrator
...
@tknhs
tknhs / windows_update_switcher.ps1
Created March 13, 2022 01:27
Windows Updateの有効/無効化を実施して更新する
$windows_module_installer = "TrustedInstaller"
$windows_update = "wuauserv"
Get-Service -Name $windows_module_installer
Get-Service -Name $windows_update
$answer = (Read-Host "Windows Update 有効化/無効化 (e/d)")
if($answer -eq "e"){
Set-Service -Name $windows_module_installer -StartupType "Manual"
PECO_VERSION="v0.5.11"
curl -LOk https://github.com/peco/peco/releases/download/${PECO_VERSION}/peco_linux_amd64.tar.gz
tar -xf peco_linux_amd64.tar.gz
sudo chmod +x peco_linux_amd64/peco
sudo cp peco_linux_amd64/peco /usr/local/bin/peco
@tknhs
tknhs / install_tmux.sh
Last active April 22, 2022 17:14
for Amazon Linux 2
LIBEVENT_VERSION="2.1.12-stable"
TMUX_VERSION="3.2a"
sudo yum install -y gcc kernel-devel make ncurses-devel openssl-devel
curl -LOk https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz
tar -xf libevent-${LIBEVENT_VERSION}.tar.gz
cd libevent-${LIBEVENT_VERSION}
./configure --prefix=/usr/local
make -j4
@tknhs
tknhs / fileencoding_checker.sh
Last active May 17, 2020 17:39
拡張子.mqh がバイナリファイルとして扱われることを防ぐために .git/hooks/pre-commit でコミットしていいかチェックする
#!/bin/bash
ok=true
for file in $(git diff --name-only --cached | grep .mqh); do
if [ "`nkf --guess $file | grep 'Shift_JIS'`" ]; then
:
else
ok=false
echo "$file is not Shift_JIS"
fi
@tknhs
tknhs / FizzBuzz.py
Created August 25, 2014 23:39
FizzBuzz
# output: 1 - 100
# don't use "if" and "for"
print "\n".join(map(lambda x: [["FizzBuzz", "Fizz"], ["Buzz", str(x)]][bool(x%3)][bool(x%5)], range(1, 101)))
@tknhs
tknhs / leap_year.py
Last active August 29, 2015 14:02
うるう年チェック
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# if文禁止
print([i%j == 0 for i, j in zip([int(input())]*3, [4, 100, 400])].count(True) % 2 == 1)
# if文・for文禁止
print(sum(list(map(lambda x, y: x%y == 0, [int(input())]*3, [4, 100, 400]))) % 2 == 1)
@tknhs
tknhs / extract_dict.py
Created February 19, 2014 16:15
Extract the duplicate values from dictionary
from collections import Counter
my_dict = {'F': 200, 'G': 500, 'D': 100, 'E': 400, 'B': 200, 'C': 300, 'A': 500}
# duplicate values list
dup_list = [k for k, v in Counter(my_dict.values()).items() if v > 1] # [200, 500]
print({k: v for k, v in my_dict.items() if v in dup_list}) # {'F': 200, 'G': 500, 'B': 200, 'A': 500}