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
before :deploy, "solr:stop" | |
after :deploy, "solr:start" | |
namespace :solr do | |
task :stop, :roles => :app do | |
run "#{sudo} monit stop solr" | |
end | |
task :start, :roles => :app do | |
run "#{sudo} monit start solr" |
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
# The ASF licenses this file to You under the Apache License, Version 2.0 | |
# (the "License"); you may not use this file except in compliance with | |
# the License. You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and |
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
module Nameable | |
# Assuming first_name and last_name are accessors. | |
def name=(name) | |
self.first_name, *_, self.last_name = name.split | |
end | |
def name | |
[first_name, last_name].compact.join(" ") | |
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 Array | |
def count(elem) | |
length - (self - [elem]).length | |
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
module Averageable | |
def mean(&block) | |
sum(&block) / length.to_f | |
end | |
def count(elem) | |
length - (self - [elem]).length | |
end | |
def mode |
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
require 'benchmark' | |
class Array | |
def count_with_loop(elem) | |
enum = 0 | |
each { |e| enum += 1 if elem == e } | |
enum | |
end | |
def count_without_loop(elem) |
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
$COMMAND_WITH_OUTPUT_TO_SUPPRESS >/dev/null 2>&1 |
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
GIT_VERSION=`git --version | awk '{print $3}'` | |
curl -O http://www.kernel.org/pub/software/scm/git/git-manpages-${GIT_VERSION}.tar.bz2 | |
sudo tar xjv -C /usr/local/share/man -f git-manpages-${GIT_VERSION}.tar.bz2 |
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
find /path_to_search -type f -name "*the_pattern*" -exec rm {} \; |
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 Object | |
# Test if the object is an integer. | |
# | |
# "54".is_i? #=> true | |
# "54_000".is_i? #=> true | |
def is_i? | |
!!Integer(self) rescue false | |
end | |
OlderNewer