Skip to content

Instantly share code, notes, and snippets.

View 328's full-sized avatar

328 328

View GitHub Profile
@328
328 / update-alternatives
Created November 29, 2014 00:38
エディタ設定の変更. nanoエディタからviに変更できます
sudo update-alternatives --config editor
@328
328 / rails-column
Last active August 29, 2015 14:10
rails カラムの追加
```
rails g migration AddカラムToテーブル カラム:型
```
AddカラムToテーブルのカラムとテーブルの頭文字は大文字じゃないとダメなので注意
なぜかmasterブランチでやらないとコケる
@328
328 / virt-install.sh
Created December 22, 2014 07:11
virt-install.sh
#!/bin/sh
virt-install \
--name ubuntu14-test-template \
--vcpus 2 \
--ram 1024 \
--hvm \
--virt-type kvm \
--os-type=linux \
--os-variant ubuntusaucy \
--network bridge=br0 \
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;
@328
328 / ffmpeg
Created January 22, 2015 09:04
ffmpeg
```
ffmpeg -i 入力ファイル名.mkv -vcodec copy 出力ファイル名.mp4
```
@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 / 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 / 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 / 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 / delhypen.rb
Created July 27, 2016 02:19
電話番号からハイフンを取るruby script
hoge = '000-0000-0000'
hoge.delete('-')