Skip to content

Instantly share code, notes, and snippets.

@ser1zw
ser1zw / crawler.sh
Last active December 11, 2023 02:05
#!/bin/bash
set -euo pipefail
WAIT_SECONDS=1
USER_AGENT='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0'
logger_info() {
echo "$(LANG=C date --rfc-3339=seconds) [INFO] ${1}"
}
@ser1zw
ser1zw / update-allenv.py
Last active December 11, 2023 00:53
update-allenv
#!/usr/bin/env python
import os
import subprocess
HOMEDIR = os.getenv('HOME')
GIT_COMMAND = 'git pull --rebase origin master'
git_clone_dirs = ['.rbenv', '.rbenv/plugins/ruby-build', '.pyenv']
brew_commands = ['perlbrew self-upgrade', 'perlbrew -f install-cpanm', 'nodebrew selfupdate']
@ser1zw
ser1zw / send.ps1
Created December 23, 2012 21:59
Send E-mail from eml file in PowerShell
################################################################################
# Send E-mail from eml file in PowerShell
# Tested on PowerShell 2.0
#
# Usage:
# 1. Configure the variables defined in Main()
# $server = "localhost"
# $port = "25"
# $mailfrom = "from@example.com"
# $rcptto = "to@example.com"
@ser1zw
ser1zw / PLSQL_WWW_GET_SAMPLE.sql
Created September 20, 2012 19:03
PL/SQL sample for HTTP access
/*
PL/SQL sample for HTTP access (Oracle 11g R2)
1. Execute /u01/app/oracle/product/11.2.0/xe/rdbms/admin/utlhttp.sql to use UTL_HTTP package
Run the following command in shell in the DB server
$ cd /u01/app/oracle/product/11.2.0/xe/rdbms/admin/
$ sqlplus SYS/passwd@localhost:1521/XE AS SYSDBA @utlhttp.sql
2. Grant the connect and resolve privileges for all hosts to the user 'SCOTT'
Run the following commands in SQL*Plus
@ser1zw
ser1zw / _tmuxinator
Created March 29, 2012 19:43
zsh completion for tmuxinator
#compdef tmuxinator mux
# zsh completion for tmuxinator
# Install:
# $ mkdir -p ~/.tmuxinator/completion
# $ cp _tmuxinator ~/.tmuxinator/completion
# $ vi ~/.zshrc # add the following codes
# fpath=($HOME/.tmuxinator/completion ${fpath})
# autoload -U compinit
@ser1zw
ser1zw / Emacs.ahk
Last active November 16, 2021 09:37
AutoHotKey Emacs keybind script
;; AutoHotKey_LでEmacsキーバインドにするスクリプト
;;
;; 使い方
;; ・AutoHotKey_L(http://l.autohotkey.net/)をインストール
;; ・Emacs.ahkをAutoHotkeyをインストールしたフォルダ(デフォルトならC:\Program Files\AutoHotkey)に保存
;; ・タスクバーにあるAutoHotkeyのアイコン([H])を右クリックし、"Edit This Script"を選択
;; ・メモ帳でAutoHotkey.ahkが開くので、最後に以下の行を追加
;; #include Emacs.ahk
;; ・AutoHotkeyアイコンを右クリックして"Reload This Script"を選択してリロード
;;
@ser1zw
ser1zw / dragdrop.ps1
Created March 22, 2012 17:48
PowerShell Drag & Drop sample
# PowerShell Drag & Drop sample
# Usage:
# powershell -sta -file dragdrop.ps1
# (-sta flag is required)
#
Function DragDropSample() {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object Windows.Forms.Form
$form.text = "Drag&Drop sample"
$listBox = New-Object Windows.Forms.ListBox
@ser1zw
ser1zw / rpn.rb
Created December 6, 2018 09:29
逆ポーランド記法の練習
require 'set'
class RPN
def initialize(exp)
@exp = exp.split(/\s+/)
@stack = []
@operators = Set['+', '-', '*', '/', '%'].freeze
end
def eval
@ser1zw
ser1zw / priorityqueue.rb
Created November 16, 2018 08:02
Priority Queueの練習
# Priority Queueの練習
#
# 参考
# - https://ufcpp.net/study/algorithm/col_heap.html
class PriorityQueue
attr_reader :data, :test_function
def initialize(test_function = ->(a, b) { a <=> b })
@data = []
@ser1zw
ser1zw / heapsort.rb
Created November 12, 2018 11:32
ヒープソートの練習
# ヒープソートの練習
#
# 参考
# - https://ufcpp.net/study/algorithm/col_heap.html
# - https://ufcpp.net/study/algorithm/sort_heap.html
def make_heap(array, last_index)
while (last_index > 0)
parent = ((last_index - 1) / 2).floor
break unless (array[last_index] > array[parent])