Skip to content

Instantly share code, notes, and snippets.

View 328's full-sized avatar

328 328

View GitHub Profile
@328
328 / dovecot-attak-drop.sh
Created August 16, 2016 14:26
dovecotに攻撃してくるやつを片っ端からdropするやつ
grep -R 'pam_unix(dovecot:auth): authentication failure' /var/log/secure | cut -d ' ' -f 14 | sed -e 's/rhost=/firewall-cmd --zone=drop --permanent --add-source=/' | sort | uniq
@328
328 / 0sim_get_use_month.rb
Last active September 30, 2016 13:52
0simの今月の使用量を取ってくるrubyスクリプト
require 'nokogiri'
require 'mechanize'
loginid = ''
password = ''
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari 4'
agent.get('https://www.so-net.ne.jp/retail/u/userMenu/') do |page|
login = page.form_with(:name => 'Login') do |form|
@328
328 / zero-padding.rb
Created July 27, 2016 03:03
数字の0パディング (4桁に揃えたい)
CODE = '111'
format("%04d", CODE)
@328
328 / delhypen.rb
Created July 27, 2016 02:19
電話番号からハイフンを取るruby script
hoge = '000-0000-0000'
hoge.delete('-')
@328
328 / address-perse.rb
Created July 27, 2016 01:15
住所を'都道府県市町村'と'番号'に分けるrubyコード
require 'zip_code_jp'
post_code = '903-2123' #郵便番号
input_address = '沖縄県なんとか市なんとか町3-121' #住所
address = ZipCodeJp.find post_code
string = "#{address.prefecture}#{address.city}#{address.town}"
if input_address.include?(string) == true then
input_address.slice!(string)
p input_address
else
@328
328 / mime-check.rb
Created July 26, 2016 04:41
mime type check script for ruby
require 'shared-mime-info'
path = 'hoge.xls'
p MIME.check_magics(path) #'application/x-ole-storage
@328
328 / swift
Created March 16, 2016 14:02
extentswift
internal func ImageResizer(ImgPath: String) -> (CGFloat,CGFloat) {
let ImportImage:UIImage? = UIImage(named: ImgPath)
var width = ImportImage?.size.width
var height = ImportImage?.size.height
print(width,height)
if Int(myBoundSize.height) == iPhone4s {
print("iPhone4s")
} else if Int(myBoundSize.height) == iPhone5 {
print("iPhone5")
@328
328 / virt-install-vyos.sh
Created February 21, 2015 04:06
KVMにVyOSいれるやつ
#!/bin/sh
NAME=vyos
qemu-img create -f raw vyos.img 2G
virt-install \
--connect qemu:///system \
--name ${NAME} \
--vcpus 1 \
--ram 512 \
--network bridge=br0 \
--file /var/lib/libvirt/images/${NAME}.img \
@328
328 / ffmpeg
Created January 22, 2015 09:04
ffmpeg
```
ffmpeg -i 入力ファイル名.mkv -vcodec copy 出力ファイル名.mp4
```
create procedure hoge()
begin
declare counter int;
declare hogehoge int;
set @counter = 1;
while @counter < 100 do
set @hogehoge = ceil(RAND()*30000);
update kadai1 set id=1 where id=@hogehoge;
set @counter = @counter +1;
select @hogehoge;