Skip to content

Instantly share code, notes, and snippets.

View lorentzca's full-sized avatar
🏕️
In the Woods.

Kohta Kunishima lorentzca

🏕️
In the Woods.
View GitHub Profile
@lorentzca
lorentzca / what_is_my_mac_model_number.rb
Created August 21, 2015 01:59
what is my mac model number?
#!/usr/bin/env ruby
mode_identifier = `system_profiler SPHardwareDataType | awk '/Model Identifier:/ {print $3}'`
`open http://www.everymac.com/ultimate-mac-lookup/?search_keywords=#{mode_identifier}`
@lorentzca
lorentzca / w9n.rb
Last active September 15, 2015 07:08
what quarter now
#!/usr/bin/env ruby
def what_quarter_now
month = Time.now.strftime("%-m")
if month == 6 || 7 || 8
puts "1Q"
elsif month == 9 || 10 || 11
puts "2Q"
elsif month == 12 || 1 || 2
@lorentzca
lorentzca / vault.sh
Created September 4, 2015 05:20
Install vault by HashiCorp
#!/bin/bash
#
# Install vault by HashiCorp
cd /usr/local/bin
wget -O vault.zip https://dl.bintray.com/mitchellh/vault/vault_0.2.0_linux_amd64.zip
yum install -y unzip
unzip vault.zip
rm vault.zip
@lorentzca
lorentzca / public_ip.rb
Created October 5, 2015 06:03
Ohai plug-in to get the public ip address
Ohai.plugin(:PublicIp) do
provides 'public_ip'
collect_data do
public_ip Mash.new
public_ip[:public_ip] = `curl -s http://whatismyip.akamai.com/`
end
end
@lorentzca
lorentzca / cookman
Last active October 8, 2015 02:26
複数のホストにcookするやつ
#!/usr/bin/env ruby
require 'thor'
class CookMan < Thor
desc "prepare", "Prepare to one or more hosts"
option :hostname, :required => true, :aliases => :h, :type => :array
def prepare
options[:hostname].each do |h|
system "bundle exec knife solo prepare #{h}"
@lorentzca
lorentzca / sample.json
Created October 28, 2015 03:07
virtualbox image -> vagrant box
{
"builders": [
{
"type": "virtualbox-ovf",
"source_path": "/path/to/sample.ova",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -h now"
}
],
@lorentzca
lorentzca / ks.cfg
Created December 1, 2015 03:17
centos kickstart config file
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
cdrom
lang en_US.UTF-8
keyboard jp106
network --onboot yes --device eth0 --bootproto dhcp --noipv6
network --onboot no --device eth1 --bootproto dhcp --noipv6
rootpw --iscrypted <暗号化されたパスワード>
@lorentzca
lorentzca / Dockerfile
Created December 11, 2015 01:07
オフィシャルのcentosのosバージョン指定はこんな感じ
FROM centos:5.11
RUN \
yum install -y httpd && \
chkconfig httpd on && \
/etc/init.d/httpd start
@lorentzca
lorentzca / my_box.json
Created January 7, 2016 02:03
Create a Vagrant Box from an existing Virtualbox image
{
"builders": [
{
"type": "virtualbox-ovf",
"source_path": "my_box.ova",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -h now"
}
],
@lorentzca
lorentzca / my_ami.json
Created January 7, 2016 03:19
create ami with packer
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",