x-ite's diary

覚え書きです。想定読者は俺

ec2 cloud-init LAMP例

MySQLはRDSを使うのでmysql-serverは入れない

#cloud-config
repo_upgrade: all
packages:
- httpd
- httpd-devel
- mysql
###- mysql-server
- memcached
- php
- php-devel
- php-mysql
- php-pecl-apc
- php-gd
- php-pecl-memcache
- php-mbstring
- php-pdo
- php-mcrypt


runcmd:
- [cp, /usr/share/zoneinfo/Asia/Tokyo, /etc/localtime]
- [sed, -i, 's/LANG="en_US.UTF-8"/LANG="ja_JP.UTF-8"/', /etc/sysconfig/i18n]
- [/sbin/chkconfig, httpd, on]
- [/sbin/chkconfig, memcached, on]
- [/etc/init.d/httpd, start]
- [/etc/init.d/memcached, start]

vimrc smartindent ruby python

autocmd FileType python setl autoindent
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python setl tabstop=8 expandtab shiftwidth=4 softtabstop=4

autocmd FileType ruby setl autoindent
autocmd FileType ruby setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType ruby setl tabstop=2 expandtab shiftwidth=2 softtabstop=2

C++0x C++11 random

#include <iostream>
#include <random>
#include <chrono>

using namespace std;

int main()
{

  std::mt19937 engine(std::chrono::system_clock::now().time_since_epoch().count());
  std::uniform_int_distribution<int> distribution( 1, 100000000 ) ; 

  int array[1000000 + 1]; 

  for (int i = 0; i < 1000000; i++) {
    array[i] = distribution(engine);
  }

  for (int j = 0; j < 100; j++) {
    cout << array[j] << endl;
  }

  return 0;
}