Skip to content

Instantly share code, notes, and snippets.

@penguin2716
penguin2716 / find_max_mtu.sh
Created December 12, 2023 01:36
A shell script to find the maximum MTU size to the destination IP address by binary search
#!/bin/bash
# Copyright 2023 Takuma Nakajima
# This software is released under the MIT license.
# https://opensource.org/license/mit/
# This shell script finds the maximum MTU size to the destination IP address by binary search.
#
# Example:
# $ ./find_max_mtu.sh 1.1.1.1
@penguin2716
penguin2716 / battery_info.rb
Created August 4, 2017 07:37
ruby script to check battery status
#!/usr/bin/env ruby
# coding: utf-8
require 'highline'
def ac_status
print "AC: "
if open("/sys/class/power_supply/AC/online", 'r').read.to_i == 1
puts "Online"
else
@penguin2716
penguin2716 / pdf2outline.sh
Created August 1, 2016 04:42
convert a PDF file to outline PDF
#!/bin/bash
if [ "x$1" = "x" -o "x$2" = "x" ]; then
echo Usage: `basename "$0"` "<input.pdf>" "<output.pdf>" >&2
exit 1
fi
# change 'ps2write' to 'pswrite' if errors
gs -sDEVICE=ps2write -dNOCACHE -sOutputFile=- -q -dbatch \
-dNOPAUSE -dQUIET "$1" -c quit | ps2pdf - "$2"
@penguin2716
penguin2716 / masquerade-curry-ukiuki.rb
Created February 13, 2016 09:55
マスカレード・カレー・ウキウキ
# coding: utf-8
Plugin.create :masquerade_curry_ukiuki do
Thread.new {
loop do
Plugin.call(:update, nil, [Message.new(:message => "マスカレード・カレー・ウキウキ", :system => true)])
sleep 120
end
}
end
@penguin2716
penguin2716 / conoha.rb
Last active January 6, 2016 11:44
ConoHaのAPIを簡単に叩くためのスクリプト.環境変数に必要な認証情報をセットして使ってね.
#!/usr/bin/env ruby
#-*- coding: utf-8 -*-
require 'net/http'
require 'uri'
require 'json'
require 'pp'
require 'optparse'
PRINT_CREDENTIALS = false
@penguin2716
penguin2716 / toast-alc.rb
Last active September 29, 2015 20:16
クリップボードにある文字列を英辞郎で検索してポップアップ通知で結果を表示してくれるプログラム.xbindkeys等でショートカットキーを設定すると良い.(MIT License)
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
require 'clipboard'
require 'cgi'
require 'sqlite3'
dbname = File.join(ENV['HOME'], '.toast-alc.db')
table_name = 'query_result'
@penguin2716
penguin2716 / mikutter_disable_rayban_spam.rb
Created May 3, 2015 04:22
レイバンのサングラスのspamを検知して表示しないようにするmikutterプラグイン
#-*- coding: utf-8 -*-
Plugin.create :disable_rayban_spam do
filter_show_filter do |messages|
messages.reject! do |message|
message.to_s =~ /^@|^RT/ and
message.to_s.include? "レイバンのサングラス" and
message.to_s =~ /\d+円/
end
[messages]
@penguin2716
penguin2716 / auto_favorite_sushi514_shio.rb
Last active August 29, 2015 14:18
@sushi514 のツイートがしょっぱかったら即座にふぁぼるmikutterプラグイン
#-*- coding: utf-8 -*-
Plugin.create :auto_favorite_sushi514_shio do
@target_username = "sushi514"
@regexp = /しお|塩|sh?io|salt/
on_appear do |messages|
messages.each do |m|
next unless m.user.to_s == @target_username
@penguin2716
penguin2716 / ssh
Created February 6, 2015 14:54
~/.ssh/conf.d の中の設定ファイルを結合してからsshを叩くシェルスクリプト
#!/bin/bash
#
# ssh (concatenating split config file)
#
# Copyright (c) 2014 Takuma Nakajima
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
#
@penguin2716
penguin2716 / auto_retweet_previous_tweet.rb
Created December 23, 2014 18:09
「いまのなし」ってつぶやいた人の直前のツイートをRTするmikutterプラグイン
# -*- coding: utf-8 -*-
Plugin.create :auto_retweet_previous_tweet do
tweet_before = {}
on_appear do |ms|
ms.each do |m|
if tweet_before[m.user]
tweet_before[m.user].retweet if m.to_s == "いまのなし"