Skip to content

Instantly share code, notes, and snippets.

@yoheia
yoheia / perl_oneliner_example
Last active August 26, 2024 05:55
Perlワンライナー&マルチライナー集
Perl ワンライナーサンプル集
■概要
障害解析のためのログの調査、非互換対応でのソースコードの調査といった
テキスト処理で使った Perl ワンライナーのサンプル集です。
Perl ワンライナーは以下の点が良いと思います。
・Perl は Oracle Database (10g以降) に同梱されている。
 従って、Windows プラットフォームでも使える。
@teramako
teramako / df.cmd
Last active August 29, 2015 13:56
Windows でディスク使用率等の一覧を表示する
@if(0)==(0) ECHO OFF
CScript //NoLogo //E:JScript "%~f0" %*
GOTO :EOF
@end
var COLUMN_INFOs = {
k: {
drive: { width: 5, align: "left" },
type: { width: 4, align: "left" },
total: { width: 14, align: "right" },
@saitoha
saitoha / Makefile
Last active January 16, 2023 13:16
SIXEL color graphics DEMO (xterm pl#301 and gnuplot)
#
# SIXEL color graphics DEMO
#
# xterm pl#301 with --enable-sixel-graphics option
# gnuplot with --with-bitmap-terminals option
#
# Now the color palette of xterm VT-340 mode is limited to 16.
# If you want to change it to 256, apply the following patch.
# https://gist.github.com/saitoha/7822989/raw/20727b88f0f826bfcb9d644907944b29a456b67f/graphics.c.diff
#
# 私が考える安全なプログラムを書くために必要なこと
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。
- ファイルを開こうとしたらコマンドを実行できてしまったり
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり
- SELECT文を発行するつもりがDELETE文を発行できてしまったり
こういったときに
- 入力値検証をしないと危険になる
@saitoha
saitoha / graphics.c.diff
Created December 6, 2013 12:29
xterm: enable 256-colored sixel graphics for vt340 mode (with "-ti vt340" option)
--- xterm-300/graphics.c 2013-12-06 21:26:36.000000000 +0900
+++ xterm-300/graphics.c 2013-12-06 21:26:13.000000000 +0900
@@ -418,7 +418,7 @@
graphic->valid_registers = 4;
break;
case 340:
- graphic->valid_registers = 16;
+ graphic->valid_registers = 256;
break;
default:
@saitoha
saitoha / penetrate.py
Last active August 3, 2021 13:31
cat sixel file with penetrating GNU Screen
% screen
% cat test.png | pngtopnm | pnmquant 256 | ppmtosixel | ./penetrate.py && cat
% cat test.png | sixelconv | ./penetrate.py && cat
@shirou
shirou / ssh_keyscan.yml
Last active March 6, 2025 06:47
run ssh-keyscan to add keys to known_hosts. This is a playbook for ansible
---
- hosts: all
gather_facts: no
sudo: no
tasks:
- name: run ssh-keyscan to add keys to known_hosts
local_action: shell ssh-keyscan {{ ansible_ssh_host }} >> ~/.ssh/known_hosts
@saitoha
saitoha / left-right-margin.vim
Created June 12, 2013 16:10
Accelerate vim vsplit scrolling on pangoterm/xterm/tanasinn/RLogin.
let &t_ti = &t_ti . "\e[?6h\e[?69h"
let &t_te = "\e[?69l\e[?6l" . &t_te
let &t_CV = "\e[%i%p1%d;%p2%ds"
let &t_CS = "y"
@saitoha
saitoha / screen-ttymouse.diff
Created May 20, 2013 15:05
vim ttymouse auto detection for GNU Screen/tmux
diff -r e56bf2af53c0 src/os_unix.c
--- a/src/os_unix.c Wed May 15 23:13:10 2013 +0200
+++ b/src/os_unix.c Tue May 21 00:04:11 2013 +0900
@@ -2190,6 +2190,7 @@
|| STRNICMP(name, "kterm", 5) == 0
|| STRNICMP(name, "mlterm", 6) == 0
|| STRNICMP(name, "rxvt", 4) == 0
+ || STRNICMP(name, "screen", 6) == 0
|| STRCMP(name, "builtin_xterm") == 0);
}
@saitoha
saitoha / vim-detect-ambiguous-state
Last active December 12, 2015 01:38
Detect east-asian-ambiguous-width state of the terminal automatically (vim).
diff -cr vim.ba8835947b8b/runtime/doc/options.txt vim/runtime/doc/options.txt
*** vim.ba8835947b8b/runtime/doc/options.txt 2013-02-10 14:03:58.000000000 +0900
--- vim/runtime/doc/options.txt 2013-02-10 14:03:58.000000000 +0900
***************
*** 699,704 ****
--- 699,709 ----
when the system locale is set to one of CJK locales. See Unicode
Standard Annex #11 (http://www.unicode.org/reports/tr11).
+ Vim may set this option automatically at the startup time.