Skip to content

Instantly share code, notes, and snippets.

# Start the old vagrant
$ vagrant init centos-6.3
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
# this machine, please update the guest additions and repackage the
# box.
@satooshi
satooshi / hello.swift
Created June 5, 2014 17:19
hello Swift
protocol Greeter {
func greet() -> String
}
protocol エンジニャー {
func meo()
}
class Person: Greeter {
var name: String = "kitamura"
@satooshi
satooshi / gist:07101df80354db75c6b8
Created October 10, 2014 08:02
php 5.5.9 ubuntu 14.04 segmentation fault
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x000000000070ff48 in zend_std_object_get_class (object=0x35cfb78) at /build/buildd/php5-5.5.9+dfsg/Zend/zend_object_handlers.c:1499
1499 /build/buildd/php5-5.5.9+dfsg/Zend/zend_object_handlers.c: No such file or directory.
@satooshi
satooshi / notify.rb
Created October 27, 2014 09:02
Send a message to Mac OSX notification center.
def changed(file_path)
notify File.open(file_path, "rb").read
end
def notify(result)
messages = result.split("\n")
title = messages.shift
group = messages.shift
info = messages.join("\n")
@satooshi
satooshi / gist:b310ca78f1f26d24cae1
Last active October 30, 2015 15:27
tcp通信する場合のnginxの設定
upstream backend {
server 127.0.0.1:3001;
}
# http://henteco-labs.com/labs/2014/04/14/rails-nginx/
server {
location / {
try_files $uri @proxy;
}
@satooshi
satooshi / gist:608fd70c19cff35f4981
Last active October 30, 2015 15:28
unix socketを使う場合のnginxの設定
upstream backend {
server unix:/home/vagrant/prj/blog/tmp/sockets/puma.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /home/vagrant/prj/blog/public;
index index.html;
@satooshi
satooshi / VietnameseUnicodeNormalizationFormCAndD.php
Last active January 18, 2016 09:52
Get NFC and NFD string of Vietnamese characters.
<?php
# http://www.unicode.org/charts/PDF/U1E00.pdf
$targets = [
'aắằặấầẩậẳẵạàáâãảăẫ',
'eẽẹếềểễệèéêẻ',
'oốồổỗộờởơớỡòóôõỏọợ',
'iịìíĩỉ',
'uứừửưữựụùúũủ',
'yỳỷỹỵý'
@satooshi
satooshi / docker introduction
Last active December 24, 2016 05:40
docker introduction
mkdir mydockerbuild
cd mydockerbuild
vi Dockerfile
FROM library/ubuntu:16.04
RUN apt-get -y update && apt-get install -y build-essential git silversearcher-ag python libssl-dev
CMD date
docker build -t echo-date .
docker images
@satooshi
satooshi / node installation on docker
Last active December 24, 2016 09:36
node installation on docker
# Dockerfile
------------------
FROM library/ubuntu:16.04
RUN apt-get -y update && apt-get install -y build-essential git python libssl-dev curl
# install nodebrew, node
ENV NODEBREW_ROOT=/usr/local/nodebrew
ENV PATH=/usr/local/nodebrew/current/bin:$PATH
RUN export NODE_VERSION=v4.3.2 && curl -L git.io/nodebrew | perl - setup \
&& nodebrew install-binary $NODE_VERSION \
# spec/models/cat_spec.rb
require 'rails_helper.rb'
RSpec.describe Cat, type: :model do
# this is a test target model
let(:cat) { Cat.new(status: status) }
# this block describes Cat#nyan instance method
# when you reference an instance method, write `Class#method`
# and for a class method, write 'Class.method'