This file contains hidden or 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
| # ======================================== | |
| # Testing n-gram analysis in ElasticSearch | |
| # ======================================== | |
| curl -X DELETE localhost:9200/ngram_test | |
| curl -X PUT localhost:9200/ngram_test -d ' | |
| { | |
| "settings" : { | |
| "index" : { | |
| "analysis" : { |
This file contains hidden or 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 Person | |
| # include SearchableModel | |
| # include SearchableModel::SearchMethods | |
| # | |
| # ... | |
| # | |
| # end | |
| module SearchableModel |
This file contains hidden or 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 | |
| # This program has two feature. | |
| # | |
| # 1. Create a disk image on RAM. | |
| # 2. Mount that disk image. | |
| # | |
| # Usage: | |
| # $0 <dir> <size> | |
| # |
This file contains hidden or 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
| # encoding: utf-8 | |
| require 'test_helper' | |
| class Users::OmniauthCallbacksControllerTest < ActionController::TestCase | |
| context "Facebook callback" do | |
| setup do | |
| # This a Devise specific thing for functional tests. See https://github.com/plataformatec/devise/issues/closed#issue/608 | |
| request.env["devise.mapping"] = Devise.mappings[:user] | |
| end | |
This file contains hidden or 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 BaseParticipant | |
| include Ruote::LocalParticipant | |
| def consume( workitem ) | |
| @workitem = workitem | |
| begin | |
| _, method, *args = workitem.fields['command'].split('/') | |
| if arg | |
| send( method, *args ) | |
| else |
This file contains hidden or 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 Item < ActiveRecord::Base | |
| def self.find_the_id(id) | |
| items = Item.find_by_sql("call find_the_id(#{id})") | |
| items[0] | |
| end | |
| end | |
This file contains hidden or 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
| DELIMITER $$ | |
| CREATE PROCEDURE find_the_id(IN the_id INT) | |
| BEGIN | |
| SELECT name FROM items WHERE id = the_id; | |
| END $$ | |
| DELIMITER ; |
This file contains hidden or 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
| STORED_PROCEDURE = 'find_the_id' | |
| STORED_PROCEDURE_FILE = 'StoredProcedure.sql' | |
| class AddStoredProcedure < ActiveRecord::Migration | |
| def self.up | |
| sql_directory = File.join(File.dirname(__FILE__), 'sql') | |
| conf = Rails::Configuration.new.database_configuration[RAILS_ENV] | |
| sql_file = File.join(sql_directory, STORED_PROCEDURE_FILE) | |
| host = conf['host'] ? conf['host'] : 'localhost' | |
| database = conf['database'] | |
| username = conf['username'] ? conf['username'] : 'root' |
This file contains hidden or 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
| # Rails ActiveRecord aware fork() wrapper | |
| $child_pids = [] | |
| def wait_for_child(pid=nil) | |
| begin | |
| pid, child_result = (pid.nil? ? Process.wait2 : Process.waitpid2(pid)) | |
| unless child_result.exitstatus.zero? | |
| $child_pids.each {|child_pid| Process.kill('TERM', child_pid) rescue true} | |
| raise "Child PID:#{pid} exited with status #{child_result.exitstatus} - batch aborting" | |
| end | |
| rescue Errno::ECHILD |