Private gyazo server on sinatra

Project aoimotoya/gyazo * GitHub What is this? This is a private gyazo server works on sinatra. It provides not only gyazo server function but also image gallery. Requirements Sinatra (includes WEBrick) Rack (interface between sinatra and nginx) Nginx (or other reverse-proxy/web-server) Procedure Gyazo server Nginx only works as a reverse proxy. Image gallery Dynamic contents and static contents are provided by sinatra and nginx respectively. Difference between official and mine File name Official gyazo names image files based on MD5 hash....

2014-04-22 · aoi

[Ruby] Sinatra アプリを Rack でデーモン化する際の注意点

結論 ソースコード中のパスをすべて絶対パスで記述しないとエラーとなる. 経緯 デーモン化したら動かない Sinatra で作ったアプリを rackup -D コマンドによりデーモン...

2014-04-21 · aoi

[Ruby] rbenv でシステム全体の Ruby を管理する

rbenv はユーザ個人に対して Ruby 環境の設定を行う.しかし,どうせならシステム全体の Ruby を管理したい.というわけで以下の記事を見ながら設定を行った. rb...

2014-04-18 · aoi

[Ruby] 62 進数のランダム文字列を出力する

背景 短縮 URL 等で使われているようなランダム文字列を生成したい. 62 進数は半角英数字 0-9a-zA-Z で表現することとする. コード STR_LENGTH = 3 table = [('0'..'9'), ('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten hash = STR_LENGTH.times.map {...

2014-04-16 · aoi

zsh-completions

What is this? zsh-users/zsh-completions * GitHub This projects aims at gathering/developing new completion scripts that are not available in Zsh yet. The scripts are meant to be contributed to the Zsh project when stable enough. Installation % mkdir ~/.zsh % cd ~/.zsh % git clone git://github.com/zsh-users/zsh-completions.git % vim ~/.zshrc fpath=(~/.zsh/zsh-completions/src $fpath) autoload -U compinit compinit % source ~/.zshrc How it works (on FreeBSD)? % pkg [Tab] add -- Registers a package and installs it on the system audit -- Reports vulnerable packages autoremove -- Removes orphan packages backup -- Backs-up and restores the local package database check -- Checks for missing dependencies and database consistency clean -- Cleans old packages from the cache convert -- Convert database from/to pkgng create -- Creates software package distributions fetch -- Fetches packages from a remote repository help -- Displays help information info -- Displays information about installed packages install -- Installs packages from remote package repositories query -- Queries information about installed packages register -- Registers a package into the local database remove delete -- Deletes packages from the database and the system repo -- Creates a package repository catalogue rquery -- Queries information in repository catalogues search -- Performs a search of package repository catalogues set -- Modifies information about packages in the local database shell -- Opens a debug shell shlib -- Displays which packages link against a specific shared library stats -- Displays package database statistics update -- Updates package repository catalogues updating -- Displays UPDATING information for a package upgrade -- Performs upgrades of packaged software distributions version -- Displays the versions of installed packages which -- Displays which package installed a specific file It shows not only commands but help documents....

2014-04-15 · aoi

[FreeBSD] Routing table

How to view % netstat -rn Default gateway We can specify the IP address of the default gateway by below command. % sudo route add default 10.20.30.1 Reference 30.2. Gateways and Routes, Chapter 30. Advanced Networking, FreeBSD Handbook

2014-04-09 · aoi

[FreeBSD] Root-on-ZFS recovery by using snapshots

Introduction An HDD for a rootFS of my FreeBSD machine has broken. I installed a new HDD and recovered the rootFS from ZFS snapshots. Partitioning The new HDD is recognized as /dev/da1. In this section, da1 is conformed to a broken disk. # gpart destroy -F da1 da1 destroyed # gpart create -s gpt /dev/da1 da1 created # gpart add -s 64K -b 34 -t freebsd-boot -l /boot/boot0 /dev/da1 da1p1 added # gpart add -s 1G -t freebsd-swap -l swap0 /dev/da1 da1p2 added # gpart add -t freebsd-zfs -l disk0 /dev/da1 da1p3 added # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 /dev/da1 bootcode written to da1 Create zpool for rootFS I named a new zpool rpool2....

2014-03-28 · aoi

[FreeBSD] Several installations and settings

What I installed are listed below. sudo Installation # pkg install sudo Settings # visudo %wheel ALL=(ALL) ALL zsh Installation % sudo pkg install zsh Settings % vi ~/.zshrc % whereis zsh zsh: /usr/local/bin/zsh /usr/local/man/man1/zsh.1.gz /usr/ports/shells/zsh % chsh Shell: /usr/local/bin/zsh % zsh ipfw % sudo vi /etc/rc.conf firewall_enable="YES" firewall_script="/etc/ipfw.rules" firewall_logging="YES" % sudo vi /etc/ipfw.rules % sudo /etc/rc.d/ipfw start ntp % sudo vi /etc/ntp.conf server yourNtpServer % sudo /etc/rc.d/ntpd restart ssmtp % sudo /etc/rc....

2014-03-27 · aoi

[FreeBSD] Using the ports collection

Initial process To download a compressed snapshot into /var/db/portsnap # portsnap fetch # du -sh /var/db/portsnap/ 153M /var/db/portsnap/ To extract the snapshot into /usr/ports # portsnap extract # du -sh /usr/ports/ 860M /usr/ports/ After the first steps shown above, /usr/ports can be updated by running # portsnap fetch && portsnap update Cron setting To keep a ports tree latest, it is recommended to set cron jobs. # crontab -e 0 3 * * * /usr/sbin/portsnap cron && /usr/sbin/portsnap update >/dev/null portsnap cron executes portsnap fetch after random (from 1 to 3600) seconds....

2014-03-27 · aoi

[FreeBSD] SSH settings

Notice: during the installation of FreeBSD, I enabled sshd. Configuration # cp /etc/ssh/sshd_config /etc/ssh/sshd_config.org # vi /etc/ssh/sshd_config PermitRootLogin no RSAAuthentication yes PubkeyAuthentication yes PasswordAuthentication no PermitEmptyPasswords no ChallengeResponseAuthentication no AllowUsers yourUserName Key generation % mkdir ~/.ssh % chmod 700 ~/.ssh % cd ~/.ssh % vi ssh-key.pub yourPublicKey # ssh-keygen -i -f ssh-key.pub > authorized_keys # chown yourUserName:yourGourp authorized_keys # chmod 600 authorized_keys % rm -f ssh-key.pub Confirmation # /etc/rc.d/sshd restart % netstat -a | grep LISTEN tcp4 0 0 *....

2014-03-27 · aoi