Skip to content

Instantly share code, notes, and snippets.

View kkosuge's full-sized avatar
🐇
busy

Kosuge Kazuya kkosuge

🐇
busy
View GitHub Profile
@soramugi
soramugi / Gemfile
Last active February 20, 2016 22:27
GoogleAnalyticsに登録してるサイト全ての昨日のPV数出すやつ
source "https://rubygems.org"
gem "google-api-client", "0.8.6"
gem "pry"
gem "oauth2"
@rummelonp
rummelonp / application.rb
Last active August 29, 2015 14:06
Rails のジェネレータで使わない奴生成しないようにするやつ
# これを config/application.rb 内にコペピする
# 参考: http://guides.rubyonrails.org/generators.html#customizing-your-workflow-by-changing-generators-templates
config.generators do |g|
g.controller helper: false, assets: false
g.rspec view_specs: false, helper_specs: false
end
@rummelonp
rummelonp / grep.rb
Last active August 29, 2015 13:56
Homebrew で grep 2.18 入れるやつ
require 'formula'
class Grep < Formula
url 'http://ftp.gnu.org/gnu/grep/grep-2.18.tar.xz'
sha1 'fdb12580714966745635da7d9db55060f88db28b'
version '2.18'
depends_on 'pcre'
def install
@Shinpeim
Shinpeim / 00.md
Last active January 16, 2020 13:08
Scala 入学式の資料

Better Java としての Scala

Hello World

  • src/main/scala/Main.scala
object Main {
  def main(args: Array[String]): Unit = {
    println("hello scala!")
require 'active_support/core_ext'
require 'minitest/unit'
String.instance_eval do
define_method :method_missing do |method, *args|
ActiveSupport::StringInquirer.new(self).send(method)
end
end
Symbol.instance_eval do
@rummelonp
rummelonp / user.rb
Last active December 20, 2015 10:59
ActiveRecord でバリデーションをコンテキスト毎に分けるやつ
class User < ActiveRecord::Base
include ValidationContext
with_context :first do |context|
context.validates_presence_of :name
end
with_context :second do |context|
context.validates_presence_of :email
end
@owainlewis
owainlewis / java7.yml
Created July 24, 2013 10:45
Install Java 7 with Ansible on Ubuntu Linux
---
- name: ensure required packages are installed for Java 7
apt: name=$item state=latest update_cache=yes
with_items:
- python-software-properties
- name: Add Java repository to sources
action: apt_repository repo='ppa:webupd8team/java'
OmniAuth.config.full_host = ->(env) {
scheme = if env['HTTPS'] == 'on' or env['HTTP_X_FORWARDED_SSL'] == 'on'
'https'
elsif env['HTTP_X_FORWARDED_PROTO'].present?
env['HTTP_X_FORWARDED_PROTO'].split(',').first.strip
else
env['rack.url_scheme']
end
hostname = env['HTTP_X_FORWARDED_HOST'].present? ? env['HTTP_X_FORWARDED_HOST'] : env['HTTP_HOST']
@futoase
futoase / gist:5798113
Created June 17, 2013 16:10
物件について気をつけてることです

31年、人生で生きてきて一人暮らし歴が長く、避けたほうが良い物件は以下の形になる

  • 台所が部屋と同じ
    • ウォーターハンマー音との戦いになりがち
  • 分譲賃貸じゃない
    • 作りがやばい
  • 大通り沿い
    • これは条件によるかもしれないが、あんま便利じゃない
  • 地下鉄の真上
@tatat
tatat / user.rb
Last active December 16, 2015 21:09
Rails4(くらい)で has_secure_password のバリデーションをスキップしたり
class User < ActiveRecord::Base
has_secure_password validations: false
validates :password,
presence: {if: :password_required?, on: :create},
confirmation: {if: :password_required?}
validates :password_confirmation,
presence: {if: :password_present?}