- 株式会社万葉のRailsエンジニア
- 最近は案件でGoを書いています
- Rails Developers Meetup#5で日報共有アプリケーションについて話しました
- Railsでの活動履歴
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def authorize_user(record = nil) | |
record ||= controller_name.classify.constantize | |
authorize record, "#{action_name}?" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
# atom.workspace.observeTextEditors (editor) -> | |
# editor.onDidSave -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchForm | |
def initialize(posts) | |
@posts = posts | |
end | |
def search | |
# posts = とすると posts がローカル変数になるので nil になる | |
posts = posts.where ... | |
# attr_reader を public に定義すれば次のように書けるが不必要に公開したくない |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/kami-zh/go-capturer" | |
) | |
func ExampleCaptureStdout() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Class | |
def conform?(klass) | |
(klass.instance_methods - instance_methods).empty? | |
end | |
end | |
module Foo | |
def bar; end | |
def baz; end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rand; | |
use std::io; | |
use std::cmp::Ordering; | |
use rand::Rng; | |
fn main() { | |
println!("Guess the number!"); | |
let secret_number = rand::thread_rng().gen_range(1, 101); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_cpu_affinity auto; | |
worker_processes auto; | |
worker_rlimit_nofile 4096; | |
error_log /var/log/nginx.error.log; | |
pid /var/run/nginx.pid; | |
events { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_cpu_affinity auto; | |
worker_processes auto; | |
worker_rlimit_nofile 4096; | |
error_log /var/log/nginx.error.log; | |
pid /var/run/nginx.pid; | |
events { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
current_path = '/path/to/app/current' | |
shared_path = '/path/to/app/shared' | |
worker_processes 4 | |
working_directory current_path | |
listen "#{shared_path}/tmp/sockets/.unicorn.sock" | |
pid "#{shared_path}/tmp/pids/unicorn.pid" |
NewerOlder