Skip to content

Instantly share code, notes, and snippets.

View eccyan's full-sized avatar

eccyan eccyan

View GitHub Profile
@eccyan
eccyan / .vimrc
Created January 20, 2012 05:12
.vimrc for iOS Vim
syntax on
autoindent
number
tabstop=2
shiftwidth=2
expandtab
noremap <LeftMouse> : " Tap to command line mode
inoremap <LeftMouse> <ESC> " Tap to quit insert mode
@eccyan
eccyan / robots_controller.rb
Created January 25, 2012 05:18
Railsでデプロイ環境に合わせてrobots.txtを出力するコントローラ ref: http://qiita.com/items/1876
class RobotsController < ApplicationController
def index
render_text = File.read "#{::Rails.root}/public/robots.#{::Rails.env}.txt"
respond_to do |format|
format.text { render :text => render_text, :layout => false }
end
end
end
@eccyan
eccyan / index.html.erb
Created January 25, 2012 05:30
Rails/ERBで部分テンプレート毎にheadの内容を変える ref: http://qiita.com/items/1877
<% content_for :header do -%>
<meta property="og:title" content="title" />
<meta property="og:description" content="description" />
<% end -%>
...
@eccyan
eccyan / brainfuck.rb
Created February 8, 2012 16:44
Brainf*ck in Ruby
# -*- coding: utf-8 -*-
class String
def fuck(output=STDOUT, input=STDIN)
identity = lambda do |value|
return value
end
increment = lambda do |value|
return value+1
end
decrement = lambda do |value|
@eccyan
eccyan / log
Created March 17, 2012 02:57
Ruby 1.9.3p125 Rails 3.2.2 Rake 0.9.2.2 break db:migrate, assets:precompile and other task
$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
@eccyan
eccyan / file0.txt
Created September 18, 2013 08:03
Guard で起動時に一度実行するプラグインを作る ref: http://qiita.com/eccyan/items/767e7cf43a1a24ccd025
require 'guard/guard'
notification :growl
module ::Guard
# 起動時に同期を行う Guard のプラグイン
class SyncronizeAll < Guard
def start
hostname="172.0.0.1"
username="eccyan"
@eccyan
eccyan / file0.rb
Created October 25, 2013 17:33
ActiveRecord で MySQL のインデックスを指定して取得したい ref: http://qiita.com/eccyan/items/0641af416e6f9330f1e9
scope :use_index, lambda { |*indexes|
from("#{self.table_name} USE INDEX(#{indexes.join(', ')})")
}
@eccyan
eccyan / file0.txt
Created December 5, 2013 11:31
本日 Ruby でハマったカンマの罠 ref: http://qiita.com/eccyan/items/01333620a3a6d5675c85
id = 1,
name = "eccyan"
@eccyan
eccyan / play_sound.ino
Created January 3, 2014 06:03
Play sound with the serial communication Arduino
#define BUTTON_PIN 2
#define SPEAKER_PIN 3
#define CONTROLLER_PIN 9
#define FREQUENCY 440
#define DURATION 300
#define COMMAND_LENGTH_MAX 10
char current_command[COMMAND_LENGTH_MAX+1];
int command_index = 0;
#include <SPI.h>
const int MINIMUM = 1000;
const int X_MINUS_PIN = 7;
const int X_PLUS_PIN = 6;
const int Y_MINUS_PIN = 5;
const int Y_PLUS_PIN = 4;
const int Z_MINUS_PIN = 3;
const int Z_PLUS_PIN = 2;