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
# Given a set of documents this method returns a list of tags associated with | |
# ordered by the ones occuring on the most documents. Tags that only appear o | |
# If the user supplies a specific tag to exclude it will not be included in t | |
def self.related_tags(docs,exclude = nil) | |
related = {} | |
docs.each_with_index do |doc, i| | |
break if i >= 20 # only consider the first 10 docs | |
doc.word_tags.each do |tag| # count num times each tag occurs | |
next if exclude && tag.name == exclude # if caller specified a tag to e |
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
# Given a set of documents this method returns a list of tags associated with | |
# those documents ordered by the ones occuring on the most documents. Tags th | |
# only appear on one doc are excluded from the list. | |
# If the user supplies a specific tag to exclude it will not be included | |
# in the list. | |
def self.related_tags(docs, exclude = nil) | |
doc_ids = docs[0, 20].map { |doc| doc.id }.join(',') | |
tags = self.connection.select_all( | |
"SELECT word_tag_id, COUNT(word_tag_id) FROM word_documents_word_tags | |
WHERE word_document_id IN (#{doc_ids}) GROUP BY word_tag_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
# Redefines const value during block execution. | |
# | |
# Usage example: | |
# SOMECONST = 1 # SOMECONST == 1 | |
# redefine_const(:SOMECONST, 'hello') do | |
# puts SOMECONST # SOMECONST == 'hello' | |
# end | |
# # SOMECONST == 1 | |
def redefine_const(const, value, &block) | |
if const_defined = Object.const_defined?(const) |
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
# Usage: | |
# >> User.random | |
# => #<User login: ... | |
class ActiveRecord::Base | |
def self.random | |
find(rand(count)) | |
rescue ActiveRecord::RecordNotFound | |
retry |
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
alias ga="git add" | |
alias gb="git branch" | |
alias gc="git checkout" | |
alias gd="git diff" | |
alias gci="git commit" | |
alias gg='git log --graph --pretty=format:"%Cred%h%Creset — %s %Cgreen(%cr)%Creset" --abbrev-commit --date=relative' | |
alias gl="git pull" | |
alias gm="git merge" | |
alias gp="git push" | |
alias gs="git status" |
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
# Bash completition for Git | |
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh | |
export LANG=ru_RU.UTF-8 | |
export QTDIR=/opt/local/lib/qt3 | |
# Add ~/bin, /opt/local/bin and /opt/local/sbin to path | |
export PATH=$HOME/bin:/opt/local/bin:/opt/local/apache2/bin:/opt/thrift/bin:/opt/local/sbin:/opt/jruby/bin:$PATH | |
# Setup some environment variables | |
export PS1='\w$(__git_ps1 " (\[\e[0;32m\]%s\[\e[0m\])")$ ' |
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
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking www.scribd.com (be patient).....done | |
Server Software: nginx/0.7.61 | |
Server Hostname: www.scribd.com | |
Server Port: 80 |
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/bash | |
# | |
# Usage: cqd [QAID] [BRANCH] | |
# When QAID is missing, 1 will be used | |
# When BRANCH is missing, current one will be used for deploy | |
# Example 1: cqd | |
# Deploy to qa01.scribd.com, deployment branch is master (if current one is master) | |
# Example 2: cqd 5 lazy_carousel | |
# Deploy to qa05.scribd.com, deployment branch is lazy_carousel | |
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
namespace :deploy do | |
desc 'Bundle and minify the JS and CSS files' | |
task :precache_assets, :roles => :app do | |
root_path = File.expand_path(File.dirname(__FILE__) + '/..') | |
jammit_path = Dir["#{root_path}/vendor/gems/jammit-*/bin/jammit"].first | |
yui_lib_path = Dir["#{root_path}/vendor/gems/yui-compressor-*/lib"].first | |
assets_path = "#{root_path}/public/assets" | |
# Precaching assets | |
run_locally "ruby -I#{yui_lib_path} #{jammit_path}" |
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
Feature: Nagios | |
In order stop SMS flood in case of emergency | |
As an admin | |
I want to be able to enable or disable SMS notifications | |
Scenario: Disable SMS notifications | |
Given Nagios SMS notifications enabled | |
And I am logged in as an admin user | |
When I go to the path "/nagios" | |
And I press "Disable" |
OlderNewer