Skip to content

Instantly share code, notes, and snippets.

module ApplicationHelper
# 私がやるとこうなる(ごたごたしてる)
def without_whitespaces(options = {})
captured = capture &Proc.new
captured = captured.gsub(%r{\A\s+|\s+\Z}, '').gsub(%r{(>)\s+(<)}, '\1\2')
captured = captured.gsub(%r{(>)\s*(.*?)\s*(<)}, '\1\2\3') if options[:trim]
captured.html_safe
end
@tatat
tatat / devise.ja.yml
Last active August 29, 2015 13:57 — forked from kawamoto/devise.ja.yml
とある案件用にカスタマイズさせていただきましたやつ
#SOURCE https://gist.github.com/tatat/9526513
ja:
devise:
confirmations:
confirmed: 'アカウントを登録しました。'
# confirmed: 'Your account was successfully confirmed. You are now signed in.'
send_instructions: '登録方法を数分以内にメールでご連絡します。'
# send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
send_paranoid_instructions: 'もしあなたのEメールアドレスが見つかった場合、本人確認についてのメールが数分以内に送られます。'
@tatat
tatat / proxy.js
Last active August 29, 2015 13:58
かんたん http proxy
#!/usr/bin/env node
var fs = require('fs')
, http_proxy = require('http-proxy')
, http = require('http')
, https = require('https')
, cert_file_path = '/path/to/server.crt'
, key_file_path = '/path/to/server.key';
var proxy = http_proxy.createProxyServer();
@tatat
tatat / e.rb
Last active August 29, 2015 14:00
こういうのやりたい
class Parent
enumerize :nyan, in: [:a, :b, :c], scope: true
end
class Child1 < Parent
enumerize :nyan, in: [:a], default: :a
end
class Child2 < Parent
enumerize :nyan, in: [:a, :b], default: :b
Array::forEachAsync = (each, context) ->
copy = @slice()
index = -1
do next = ->
return if copy.length == 0
process.nextTick ->
item = copy.shift()
index += 1
require 'active_model'
class ActiveModel::Errors
module HiddenEntity
attr_accessor :_entity
end
def generate_message_with_format(attribute, type = :invalid, options = {})
message = generate_message_without_format attribute, type, options
#!/usr/bin/env ruby
require "json"
require "open-uri"
class LoveLiveQuiz
API_URL = 'https://lovelive-quiz-api.herokuapp.com/quiz'
def initialize
fetch
require 'active_model'
class ActiveModel::Errors
module WithSymbol
attr_accessor :symbol_value
end
def add_with_symbol(attribute, message = :invalid, options = {})
add_without_symbol(attribute, message, options).tap do |messages|
(function(g, undefined) {
var __index_of = !Array.prototype.indexOf ? function (array, search) {
var len = array.length
, from = Number(arguments[1]) || 0;
from = from < 0 ? Math.ceil(from) : Math.floor(from);
if (from < 0) from += len;
@tatat
tatat / twimg.rb
Created February 15, 2012 20:44
Twitterで OAuth + SSL + まるちぱぁと してみた時の
require 'mime/types'
require 'net/https'
require 'net/http/post/multipart' # sudo gem install multipart-post
require 'oauth' # sudo gem install oauth
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
ACCESS_TOKEN_SECRET = ''