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 / selection_sample.js
Last active February 7, 2017 15:56
選択範囲をレイアウト座標とロジック座標で相互変換するサクラエディタマクロのサンプル
/**
* @file sakura_selection_sample.js
*
* 注:Shift_JISで保存してください (サクラエディタマクロの制約事項)
*/
/**
* 選択範囲(レイアウト座標)
*
* @param {number} lineFrom 選択開始行(レイアウト座標)
@s-hiiragi
s-hiiragi / ast_practice_1.py
Created April 16, 2018 17:11
ast practice 1
import ast
source = """
name = "Inu"
age = 10
print("Hello, {}({})!".format(name, age))
"""
tree = ast.parse(source)
@s-hiiragi
s-hiiragi / b.txt
Created July 17, 2019 19:12
study gist
b
@s-hiiragi
s-hiiragi / shortcutkey_settings.json
Last active July 17, 2019 19:21
Settings of 'Shortkeys' google chrome extension for DOVA-SYNDROME (dova-s.jp)
[{"action":"javascript","blacklist":"whitelist","code":"iframe = document.querySelector('#YouTube > iframe')\nid = iframe.src.match(/([0-9a-zA-Z]+)?$/)[0]\nhistory.go(id?-1:-2)","customName":"Go back","exported":true,"key":"a","open":false,"sites":"https://dova-s.jp/bgm/play*","sitesArray":["https://dova-s.jp/bgm/play*"]},{"action":"javascript","blacklist":"whitelist","code":"console.log('-- Play youtube movie')\niframe = document.querySelector('#YouTube > iframe')\nid = iframe.src.match(/([0-9a-zA-Z]+)?$/)[0]\nif (id) {\n\tiframe.src += `?autoplay=1&playlist=${id}&muted=1&`\n playedBgms = JSON.parse(localStorage.getItem('playedBgms')) || {}\n \ttitle = document.querySelector('#titleYouTube > h2').firstChild.textContent.trim()\n playedBgms[location.pathname] = title\n localStorage.setItem('playedBgms', JSON.stringify(playedBgms))\n console.log(playedBgms)\n} else {\n \thistory.go(-2)\n}","customName":"Play bgm","exported":true,"key":"space","open":false,"sites":"https://dova-s.jp/bgm/play*","sit
@s-hiiragi
s-hiiragi / KingBladeX10V.puml
Created January 9, 2020 12:09
State machine diagram of KING BLADE X10 V
@startuml "State machine diagram of KING BLADE X10 V"
[*] --> ColorChange : A0.5秒押し(電源ON)
[*] --> ColorChange : A1.5秒押し(色1で電源ON)
[*] --> MemorySetA : B長押し
[*] --> MemorySetB : A&B長押し
ColorChange --> ColorChange : A/B(次/前の色を選択)
ColorChange --> ColorChange : C長押し(推し色を設定)
ColorChange --> HotButton : C(推し色に変更)
@s-hiiragi
s-hiiragi / genfile2.py
Created March 5, 2020 15:03
Generate files with random names
# > python --version
# Python 3.8.2
# > python genfile2.py -n 100000 --max 200
# > attrib *2.csv
import sys
import random
import argparse
from pathlib import Path
@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)
@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 / momonga-aa.txt
Created December 23, 2015 08:22
mOmonga Ascii Art
f L;;i0
f;1 i;;;;;L
L;;;1 G;;;;;;;;L
f;;;;;iG f;;;;;;;;;;C
1;;;;;;;;;tCG00GCCCCfi;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ii11tt;;;;;;;;;;;;;G
0i;;;;;;;;;;;;;;;;;1CCL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1
t;;;;;;;;;;;;;;;;;;iCCLi;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;f
G;;;;;;;;;;;;;;;;;;;iLCCi;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G
t;;;;;;;;;;;;;;;;;;;;LCC1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1
G;;;;;;;;;;;;;;;;;;;;;fCCt;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C
@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)