This file contains 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 ChangeIdsFromIntegerToBigint < ActiveRecord::Migration[5.1] | |
def up | |
do_migrate :integer, :bigint | |
end | |
def down | |
do_migrate :bigint, :integer | |
end | |
private |
This file contains 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 Article < ActiveRecord::Base | |
scope :full_text_search, -> (query, highlight = false) { | |
operator = query.count('"') > 0 || extract_keywords(query).size > 1 ? '@@' : '%%' | |
quoted_table_name = connection.quote_table_name(table_name) | |
articles = select("#{quoted_table_name}.*, pgroonga.score(#{quoted_table_name}) AS pgroonga_score") | |
.where("title #{operator} ? OR body #{operator} ?", query, query) | |
.reorder('pgroonga_score DESC') | |
return articles unless highlight |
This file contains 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 AddFullTextSearchIndexToArticles < ActiveRecord::Migration | |
def change | |
add_index :articles, [:id, :title, :body], using: 'pgroonga' | |
end | |
end |
This file contains 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 EnablePGroonga < ActiveRecord::Migration | |
def change | |
reversible do |r| | |
current_database = select_value('SELECT current_database()') | |
r.up do | |
enable_extension('pgroonga') | |
execute("ALTER DATABASE #{current_database} SET search_path = '$user',public,pgroonga,pg_catalog;") | |
end |
This file contains 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
require 'net/imap' | |
HOST = '' | |
USER = '' | |
PASSWORD = '' | |
imap = Net::IMAP.new(HOST, 993, true) | |
imap.authenticate('LOGIN', USER, PASSWORD) | |
imap.select('INBOX') | |
imap.search(['UNSEEN']).each do |message_id| |
This file contains 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
#!/bin/sh | |
RBENV_HOME="$HOME/.rbenv" | |
if [ "$1" = 'init' ]; then | |
git clone https://github.com/rbenv/rbenv.git $RBENV_HOME | |
mkdir $RBENV_HOME/plugins | |
if [ $? -eq 0 ]; then | |
cd $RBENV_HOME/plugins | |
git clone https://github.com/rbenv/ruby-build.git |
This file contains 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
--- Library/Formula/id3lib.rb.orig 2012-08-28 23:09:06.000000000 +0900 | |
+++ Library/Formula/id3lib.rb 2012-09-20 22:51:43.000000000 +0900 | |
@@ -12,6 +12,7 @@ | |
p << DATA unless build.head? | |
# Fix main defined with unsigned int instead of int | |
p << "https://trac.macports.org/export/90780/trunk/dports/audio/id3lib/files/id3lib-main.patch" | |
+ p << "http://svn.cross-lfs.org/svn/repos/patches/id3lib/id3lib-3.8.3-UTF16_writing_bug-1.patch" | |
end | |
fails_with :llvm do |
This file contains 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
module OmniAuth | |
module Strategies | |
class Facebook | |
def client | |
# https://developers.facebook.com/apps にてアプリを登録 | |
# | |
# apps = { | |
# 'サイトURL' => {id: 'App ID', secret: 'App Secret'} | |
# } | |
apps = { |
This file contains 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
name | kana | slug | display_order | |
---|---|---|---|---|
北海道 | ほっかいどう | hokkaido | 1 | |
青森県 | あおもりけん | aomori | 2 | |
岩手県 | いわてけん | iwate | 3 | |
宮城県 | みやぎけん | miyagi | 4 | |
秋田県 | あきたけん | akita | 5 | |
山形県 | やまがたけん | yamagata | 6 | |
福島県 | ふくしまけん | fukushima | 7 | |
茨城県 | いばらきけん | ibaraki | 8 | |
栃木県 | とちぎけん | tochigi | 9 |
This file contains 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
require 'socket' | |
require 'autotest/tmux' | |
Autotest.add_hook :ran_command do |at, *args| | |
next false unless Autotest::Tmux.execute? | |
output = at.results.join | |
result = Autotest::Tmux.parse_output(output, at.class.name) | |
TCPSocket.open('localhost', 12345) do |s| |
NewerOlder