Skip to content

Instantly share code, notes, and snippets.

$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') {
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
// Only send the token to relative URLs i.e. locally.
xhr.setRequestHeader("X-CSRF-Token", $('meta[name="csrf-token"]').attr('content'));
}
}
}
### sample1
Kernel.private_instance_methods.grep /hoge/ # => []
Object.private_instance_methods.grep /hoge/ # => []
self.private_methods.grep /hoge/ # => []
self # => main
self.class # => Object
def hoge
'moge'
end
### sample1
Kernel.private_instance_methods.grep /hoge/ # => []
Object.private_instance_methods.grep /hoge/ # => []
self.private_methods.grep /hoge/ # => []
self # => main
self.class # => Object
def hoge
'moge'
# -*- encoding: utf-8 -*-
require 'curses'
def main
Curses.init_screen
@map = [
[0, 0, 0, 0, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
"hello, ruby" # => "hello, ruby"
# -*- encoding: utf-8 -*-
require 'curses'
def main
Curses.init_screen
begin
@y = Curses.lines / 2
@x = Curses.cols / 2
while true
# -*- encoding: utf-8 -*-
class BlankSlate < BasicObject
def method_missing(name, *args)
"BlankSlate##{name} called"
end
def respond_to?(name)
name.to_s == 'hoge'
end
# -*- encoding: utf-8 -*-
def main
Module.nesting # => []
c = A::B::C.new
c.b_method
c.c_method
end
module A

Bower概要

Bowerとは?

  • JavaScriptモジュールをダウンロード、管理するプログラム。
  • JavaScript版のBundlerみたいな感じ。
  • node.jsが必要
  • 似たプロダクトの中では、軽量な管理ツールらしい。(競合はComponentやBrowserify)
  • ダウンロードするだけ。モジュールの配備はしない。
  • require() は提供しない。htmlから<script src="bower_component/jquery/dist/jquery.js">みたいにする必要がある。
  • ファイルの配備をしない。bower_component/jquery/dist/jquery.js みたいなファイルにアクセスする必要がある。配備をするには他のツールと連携する必要あり。(grunt-bower-taskを使うなどすればいいらしい。 http://yosuke-furukawa.hatenablog.com/entry/2013/06/04/085537)
function peco_and_writeback() {
BUFFER=$($LBUFFER | peco)
CURSOR=$#BUFFER
zle -R -c
}
zle -N peco_and_writeback
bindkey '^K' peco_and_writeback