Skip to content

Instantly share code, notes, and snippets.

View s-hiiragi's full-sized avatar

s_hiiragi s-hiiragi

View GitHub Profile
@s-hiiragi
s-hiiragi / while_and_for.hsp
Created January 6, 2022 03:59
break/continueを使えるwhile/for
#define global _while(%1) repeat : if (%1) == 0 : break
#define global _for(%1,%2=0,%3=0,%4=1) %1=(%2) %c repeat %c if cnt {%1+=(%4)} %c if (%1) == (%3) {break}
mes "break/continueを使えるwhileのサンプル"
i = 0
_while i < 4
mes i
i++
loop
@s-hiiragi
s-hiiragi / main.py
Created December 28, 2021 16:06
(Python) コマンドライン引数からログ出力レベルを変更するサンプル
# usage:
# python main.py --loglevel <level>
#
# level:
# CRITICAL
# ERROR
# WARNING
# INFO
# DEBUG
@s-hiiragi
s-hiiragi / conf.json
Created December 28, 2021 15:39
(Python) 外部ファイルからログレベルを変更するサンプル
{
"version": 1,
"disable_existing_loggers": false,
"formatters": {
"default": {
"format": "%(levelname)s:%(name)s:%(message)s"
}
},
"handlers": {
"console": {
@s-hiiragi
s-hiiragi / iterate_through_table_containing_merged_cells.bas
Created December 15, 2021 13:44
Iterate through a table containing merged cells
Sub IterateThroughTableContainingMergedCells()
Dim t As Table
Dim i As Long
Dim j As Long
For i = 1 To ActiveDocument.Tables.Count
Set t = ActiveDocument.Tables(i)
Debug.Print "Table(" & i & "): rows=" & t.Rows.Count & ", columns=" & t.Columns.Count
@s-hiiragi
s-hiiragi / busybox.cmd
Created September 13, 2021 21:40
busybox-w32のパスを通すコマンド
@echo off
if "%~1" == "addpath" goto ADDPATH
if "%~1" == "help" goto HELP
if "%~1" == "-h" goto HELP
if "%~1" == "--help" goto HELP
if "%~1" == "/?" goto HELP
if "%~1" == "-?" goto HELP
goto :EOF
@s-hiiragi
s-hiiragi / gomibako.bat
Created September 13, 2021 21:19
ごみ箱を開くバッチファイル
@explorer shell:RecycleBinFolder
@s-hiiragi
s-hiiragi / jump_to_sheet.bas
Created October 1, 2020 13:14
指定したシートにジャンプするExcel VBAマクロ
Sub 指定したシートにジャンプ()
Dim SheetPattern As String
Dim s As Variant
SheetPattern = LCase(InputBox("シート名を入力", "指定したシートにジャンプ", ""))
If SheetPattern = "" Then
Exit Sub
End If
For Each s In ActiveWorkbook.Sheets
@s-hiiragi
s-hiiragi / sample1.py
Created August 5, 2020 19:03
A generated sample code
from freestanding import homespun
from nightlong import toad as cartel
import sprung as venom
import inscrutable as scrip
from thermoelectric import infamy
import priming as dandle
from propylene import smashing
import accretion
from furring import crappy
@s-hiiragi
s-hiiragi / traceback_with_values.py
Created April 28, 2020 19:20
Display a traceback with variables in the statement where the error occurred
# coding: utf-8
r"""
Sample output:
C:\Users\USERNAME\repos\python3-exception-with-values>python traceback_with_values.py
Traceback (most recent call last):
File "traceback_with_values.py", line 45, in <module>
print(float(x) + y)
@s-hiiragi
s-hiiragi / longname2short.py
Created March 5, 2020 16:14
Convert long file names to short file names in current directory
import os
from ctypes import windll, create_unicode_buffer
dll = windll.LoadLibrary('kernel32.dll')
for longname in os.listdir('.'):
shortname = create_unicode_buffer(16)
dll.GetShortPathNameW(longname, shortname, 16)
if shortname.value.lower().endswith('2.csv'):
print('from:', longname)