住所というシステムは脆弱でクソだ
- 住所は住んでいる場所を一意に特定するための一次情報だ
- 文字列を知るだけで脅迫状でも爆弾でも送り放題
- 受取の拒否をコントロールしづらい
- その脆弱な文字列を色々なサービスに登録しないといけない
package main | |
import ( | |
"code.google.com/p/go-tour/pic" | |
"image" | |
"image/color" | |
) | |
type Image struct{} |
def self.register_url(name, url) | |
uri = URI.parse(url) | |
define_method("#{name}_url") do |options = {}| | |
anchor = options.delete(:anchor) if options | |
ActionDispatch::Http::URL.full_url_for(host: uri.host, scheme: uri.scheme, path: uri.path, anchor: anchor, params: options) | |
end | |
end | |
register_url :google, 'https://google.com/' |
function checkBrowser(){ | |
var a=''; | |
var b={}; | |
b.name=window.navigator.userAgent.toLowerCase(); | |
b.platform=window.navigator.platform.toLowerCase(); | |
b.isMac=(b.platform.indexOf('mac')>=0); | |
b.isWin=(b.platform.indexOf('win')>=0); | |
b.isCrOS=(b.platform.indexOf('linux')>=0 && b.name.indexOf('cros')>=0); | |
b.isIE=(b.name.indexOf('msie')>=0||b.name.indexOf('trident')>=0); | |
b.isSafari=b.name.indexOf('safari')>=0; |
cat /etc/passwd | cut -f 1 -d : | grep -v $USER > ~/death_note.txt |
module PhpValue | |
def self.indent(depth) | |
' ' * depth * 4 | |
end | |
def self.output(value, depth = 0) | |
case value | |
when true, false | |
value.to_s | |
when nil |
It's easy to 'nil guard' for normal variable.
def user
@user ||= User.find(1)
end
but it's not simple for generated variable name.
# | |
# extension for rspec | |
# this extension enables to check should_receive in stub_chain | |
# you must require this file in 'spec/spec_helper.rb' | |
# | |
# | |
# Example: | |
# in controller, | |
# | |
# def index |