query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Type a given keyword on the search input | def search_for_keyword(keyword)
find_and_type NAVBAR_SEARCH_INPUT_LOCATOR, keyword
Log.step "Typing '#{keyword}' onto navbar search input "
end | [
"def enter_keyword(string)\n logger.info \"Searching for keyword '#{string}'\"\n wait_for_element_and_type(keywords_input_locator, string)\n end",
"def search(keyword, type)\n click(:search_icon)\n click(:find_freelancers_lnk) if type == FREELANCERS_TYPE\n click(:find_jobs_lnk) unless type == FREE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines if provided mount point is remote. | def fs_remote?(mount)
fs_type(mount) == 'nfs'
end | [
"def fs_remote?(mount)\n fs_type(mount) == 'nfs' ? true : false\n end",
"def ssh_remote?(remote = @remote)\n remote_url(remote).is_a? URI::SshGit::Generic\n end",
"def remote?\n _remote_url = remote_url\n \n _remote_url and !_remote_url.empty?\n end",
"def using_remoter?\n !@rem... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines if the user's shell is valid on the machine, otherwise returns the default of /bin/sh | def shell_is_valid?(shell_path)
return false if shell_path.nil? || !File.exist?(shell_path)
# AIX is the only OS that has the concept of 'approved shells'
return true unless platform_family?('aix')
begin
File.open('/etc/security/login.cfg') do |f|
f.each_line do |l|
... | [
"def shell_cmd\n if !config[:shell].nil?\n config[:sudo] ? \"sudo #{config[:shell]}\" : \"#{config[:shell]}\"\n elsif windows_os?\n \"powershell\"\n else\n config[:sudo] ? \"sudo pwsh\" : \"pwsh\"\n end\n end",
"def tcsh_shell?\n # once run a single t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the appropriate base user home directory per platform | def home_basedir
if platform_family?('mac_os_x')
'/Users'
elsif platform_family?('solaris2')
'/export/home'
else
'/home'
end
end | [
"def home_basedir\n if platform_family?('mac_os_x')\n '/Users'\n else\n '/home'\n end\n end",
"def get_user_puppetlabs_dir(user_home, platform)\n File.join(user_home, '.puppetlabs')\n end",
"def user_home_path\n `echo $HOME`.gsub(\"\\n\", \"\") # This will resolve the abso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the type of the public key or rsa | def pubkey_type(pubkey)
%w(ed25519 ecdsa dss rsa dsa).filter { |kt| pubkey.split.first.include?(kt) }.first || 'rsa'
end | [
"def rsa?\n @spki.public_key.kind_of?(OpenSSL::PKey::RSA)\n end",
"def rsa?\n @spki.public_key.kind_of?(OpenSSL::PKey::RSA)\n end",
"def rsa?\n self.key.is_a?(OpenSSL::PKey::RSA)\n end",
"def rsa?\n @priv.is_a? OpenSSL::PKey::RSA\n end",
"def public_key_ssh()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a bool, deciding wether a username group must be created for a user | def creates_user_group?(user)
!(platform_family?('suse', 'mac_os_x') || user[:no_user_group])
end | [
"def creatable_by? (user)\n user.has_permission?(Permission.register_user_group) && !sealed?\n end",
"def creates_primary_group?(user)\n user[:gid] && !username_is_primary?(user) && !primary_gid(user).is_a?(Numeric)\n end",
"def may_create_groups?\n\t\t\tmay_administrate?\n\t\tend",
"def may_creat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a bool, deciding wether a custom primary group must be created for a user | def creates_primary_group?(user)
user[:gid] && !username_is_primary?(user) && !primary_gid(user).is_a?(Numeric)
end | [
"def primary_group?\n !primary_user.nil?\n end",
"def creatable_by? (user)\n user.has_permission?(Permission.register_user_group) && !sealed?\n end",
"def username_is_primary?(user)\n if user[:gid]\n user[:gid].is_a?(Numeric) && user[:primary_group].nil? && creates_user_group?(user)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a bool, deciding whether a users primary group is its username group based on their user hash | def username_is_primary?(user)
if user[:gid]
user[:gid].is_a?(Numeric) && user[:primary_group].nil? && creates_user_group?(user)
else
creates_user_group?(user)
end
end | [
"def primary_group?\n !primary_user.nil?\n end",
"def creates_primary_group?(user)\n user[:gid] && !username_is_primary?(user) && !primary_gid(user).is_a?(Numeric)\n end",
"def ldap_is_primary_windows_group?(group)\n user_filter = Net::LDAP::Filter.eq(\"objectclass\", \"user\")\n\n @ld... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the name of a users primary group or an integer gid if a string isnt provided If a user hash contains an integer gid it defaults to the username group, assigning that gid. If a primary group is also passed than that group will be assigned the gid instead. | def primary_gid(user)
if user[:gid].is_a?(Numeric)
user[:primary_group] || user[:gid].to_i
else
user[:gid]
end
end | [
"def gid\n return group.is_a?(Integer) ? group : Etc.getgrnam(group.to_s).gid if group\n return Etc.getpwuid(uid).gid if using_login?\n\n nil\n end",
"def group\n if attributes[:gid] && !attributes[:group]\n require 'etc'\n attributes[:group] = Etc.getgrgid(attributes[:gid].to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the default user group based on os. On linux this group is the username group | def get_default_group(user)
case node['platform_family']
when 'suse'
'users'
when 'mac_os_x'
'staff'
else
user[:username] || user[:id]
end
end | [
"def get_default_group\n return get_group(nil)\n end",
"def current_group(options = {})\n if platform_family? 'windows'\n return \"#{::ENV['COMPUTERNAME']}\\\\None\" unless Pathname.new(install_dir).exist?\n\n require 'chef/win32/security'\n security_descriptor = Chef::ReservedNa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Execute the cascading deletion for the relation if it already exists. This should be optimized in the future potentially not to load all objects from the db. | def cascade
if relation
if relation.is_a?(Enumerable)
relation.entries
relation.each { |doc| doc.destroy }
else
relation.destroy
end
end
end | [
"def delete\n self.class.db.delete_with_id(self.class.collection_name, id).to_promise_then do\n @deleted = true\n if cache && !cache.includes?(self.class, id)\n msg = \"#{__FILE__}[#{__LINE__}] : #{self.class.name} : expected model with id #{id} to be in cache - cannot delete\"\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts a camel case string to a snake case string. | def camel_case_to_snake_case(camel_case)
camel_case.to_s.gsub(/([a-z])([A-Z])/, '\1_\2').gsub(/([A-Z])([A-Z])([a-z])/, '\1_\2\3').downcase
end | [
"def snake_case(string)\n string.scan(/(^|[A-Z])([^A-Z]+)/).map! { |word| word.join.downcase }.join('_')\n end",
"def snake_case(str); end",
"def snakecase(string); end",
"def snake_case(camel_cased_word)\n # if all caps, just downcase it\n if camel_cased_word =~ /^[A-Z]+$/\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check length of users string if == 1 call endConvo strategy if > 1 check if a key from chatResponseHash is in userString if yes then matchStratgy else if no match but userString ends with ? then QuestionStratgey else ChangeSubject strategy | def update(chat_bot, user_string)
#puts "In Update"
using_match = false
user_string = user_string.downcase
#Even if the user string is a greeting of one word like "Hey", we end the
#the conversation. It is assumed that the user will use more than one word
#when responding to the bots.
... | [
"def generateResponse(userString)\r\n response_array = @chat_Response_Hash[\"change subject\"]\r\n to_return = response_array[@index]\r\n if @index == response_array.length - 1\r\n @index = 0\r\n else\r\n @index += 1\r\n end\r\n return to_return\r\n end",
"def generateResponse(user_St... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allows watchers to be added via RT_Client::add_watcher You need to pass :id, :addr, and optionally :type | def add_watcher(struct)
struct.remapkeys!
if struct.has_key? :user and struct.has_key? :pass
rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])
struct.delete(:user)
struct.delete(:pass)
else
rt = RT_Client.new
end
val = rt.add_watcher(struct)
rt = nil
... | [
"def add_watcher(*params)\n tid = params[0]\n addr = []\n type = \"cc\"\n addr = params[1] if params.size > 1\n type = params[2] if params.size > 2\n if params[0].class == Hash\n params = params[0]\n tid = params[:id] if params.has_key? :id\n addr = params[:addr] if params.has_key? ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run the parser on the repo; yield commits | def execute
cmd = FetchGitCommits.new(@from, @to, @repo, @author)
cmd.execute
@commits = cmd.commits
nil end | [
"def each_commit\n #commits_count = walker.count\n walker.each_with_index do |commit, index|\n # Format time as \"2016-12-31\"\n # puts \"#{index}/#{commits_count} for #{commit.time.strftime('%F')}\"\n yield commit\n end\n end",
"def execute\n result = `#{run_git_cmd}`\n @commits = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clean up the body and fix any hex formatting that Google does | def clean_response(body)
body.gsub!(/\/\//, '')
# Google sends hex encoded data, we need to fix that
(33..47).each do |char|
body.gsub!(/\\x#{char.to_s(16)}/, char.chr)
end
body
end | [
"def cleanup_body\n self.body = self.body.to_s.chomp.strip.gsub(\"\\n\", \" \")\n end",
"def clean_body(text)\n text = strip_bad_chars(text)\n text.gsub!(/(\\r)?\\n/, \"\");\n text.gsub!(/\\s+/, ' ');\n\n # clean start and end whitespace\n text = text.strip;\n return text\nend",
"def scrub(s)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tipoplatos GET /tipoplatos.json | def index
@tipoplatos = Tipoplato.all
end | [
"def index\n @tipps = Tipp.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipps }\n end\n end",
"def index\n @tipotermos = Tipotermo.all\n end",
"def index\n @tippers = Tipper.all\n json_response(@tippers)\n end",
"def index\n @tip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /tipoplatos POST /tipoplatos.json | def create
@tipoplato = Tipoplato.new(tipoplato_params)
respond_to do |format|
if @tipoplato.save
format.html { redirect_to @tipoplato, notice: 'Tipoplato was successfully created.' }
format.json { render :show, status: :created, location: @tipoplato }
else
format.html { ren... | [
"def create\n @tipomoneda = Tipomoneda.new(tipomoneda_params)\n\n respond_to do |format|\n if @tipomoneda.save\n format.html { redirect_to @tipomoneda, notice: 'Tipomoneda was successfully created.' }\n format.json { render :show, status: :created, location: @tipomoneda }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /tipoplatos/1 PATCH/PUT /tipoplatos/1.json | def update
respond_to do |format|
if @tipoplato.update(tipoplato_params)
format.html { redirect_to @tipoplato, notice: 'Tipoplato was successfully updated.' }
format.json { render :show, status: :ok, location: @tipoplato }
else
format.html { render :edit }
format.json { r... | [
"def update\n respond_to do |format|\n if @tip.update(tip_params)\n format.html { redirect_to @tip, notice: 'Tip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tip.errors, status: :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /tipoplatos/1 DELETE /tipoplatos/1.json | def destroy
@tipoplato.destroy
respond_to do |format|
format.html { redirect_to tipoplatos_url, notice: 'Tipoplato was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @tip_so = TipSo.find(params[:id])\n @tip_so.destroy\n\n respond_to do |format|\n format.html { redirect_to tip_sos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tiposuario.destroy\n respond_to do |format|\n format.html { redirect_to tiposua... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
array of company_id investment chains | def chains
if directs == []
[[self.id]]
else
directs.map(&:c).map(&:chains).reduce(:+).map{|i| [self.id]+i}
end
end | [
"def chains\n @@api.get(endpoint: \"chains\")\n end",
"def fetch_trades trades\n\t\tsymbols = []\n\t\tdata_array = []\n\t\tdata_hash = {}\n\t\ttrades.select { |t| symbols << [t.company.symbol,t.company.name,t.company.id,t.id]}\n\t\tsymbols.each_with_index do |symbol,i|\n\t\t\tcurrent_rate = FinnhubApi::fe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
investment pathway(s) to company having target_id | def pathways(target_id)
if (target_id && indirects.include?(target_id))
hits = chains.select{|chain| chain.include? target_id}
paths = hits.map{|chain| chain.first(chain.index(target_id)+1)}
paths.uniq
end
end | [
"def each_optimal_path(source, target)\n # Do a depth-first enumeration through the backtrace.\n paths = [OptimalPath[target]]\n until paths.empty?\n path = paths.pop\n node = path.first\n optimal_cost = optimal_cost(node)\n # The optimal cost into the last node is the tot... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
total indirect percentage in target_id | def indirect_percent(target_id)
(pathways(target_id).map(&:make_pairs).map(&:chain_link_percent).sum)*100.0
end | [
"def percent_progress\n ((@last_measure.value.to_i - @baseline.to_i).to_f /\n (@target.to_i - @baseline.to_i).to_f * 100)\n end",
"def percent\n advanced(0)\n end",
"def percent_complete\n max = 3\n result = 0\n result += 1 if notes && notes != \"\"\n result += 1 if location_id\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
total liquidation preference of all securities and entities | def liq_pref
securities.uniq.map(&:liq_payout).sum
end | [
"def profitability\n # based on \n # @pools.map { |p| }.sum\n end",
"def shares_common\n securities.uniq.map(&:shares_common).sum\n end",
"def liq_pref(s_id = nil)\n if s_id\n security = s_id.s\n if security.composites.length > 0 # is it part of a composite?\n composites = securi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
total participation cap of all securities and entities | def cap
securities.uniq.map(&:cap).sum
end | [
"def spent_per_person \n count = real_participants.size\n return (cost / count).round(2)\n end",
"def cost\n cost_from_shared_groups + cost_from_shared_meetings\n end",
"def participant_capacity\n return @participant_capacity\n end",
"def support_sc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
number of common shares in company on fully diluted basis | def shares_common
securities.uniq.map(&:shares_common).sum
end | [
"def total_common_shares_outstanding\n float_shares\n end",
"def common_percent_of(corporation)\n return 0 unless corporation\n\n shares_by_corporation[corporation].reject(&:preferred).sum(&:percent)\n end",
"def common_percent\n @common_percent ||= @shares.reject(&:preferred).sum(&:percen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
security_id of company's common stock | def common_id
securities.where('name' == 'common').first.id
end | [
"def private_company(entity)\n return entity if entity.company?\n\n @companies.find { |company| company.sym == entity.id }\n end",
"def sic_code\n fetch('company.sic_code')\n end",
"def security_identifier\n return @security_identifier\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
array of exit prices to be used when integrating security payouts. | def exit_price_array(n = 100)
min = liq_pref
max = equilibrium_price
range = max - min
dx = range/n
(1..n).to_a.map{|i| min + i*dx}
end | [
"def price_valleys #=> [[100000], [150000, 90000, 120000, 80000]]\n close_prices.each_with_index.map do |price, i|\n previous_peak_price = close_prices[0]\n close_prices.shift(i) if new_peak_price?(previous_peak_price, price)\n end.compact\n end",
"def total_prices\n return [] unle... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
array of total payouts used only to help confirm that the payouts method is working properly | def total_payout_diffs(n = 100)
num_sec = securities.size
num_sec_arr = (0...num_sec).to_a
p = payouts(n)
temp = num_sec_arr.map{|i| p[i][1]}
tot_pay = (0...n).to_a.map{|i| num_sec_arr.map{|j| temp[j][i]}.sum}
e_p_a = exit_price_array(n)
diff = (0...n).to_a.map{|i| e_p_a[i] - tot_pay[i]}
... | [
"def total_payoff\n payoffs.inject {|sum, n| sum + n } \n end",
"def payout_amounts\n game.players.map do |player|\n [player, (run_amount * player.percentage_owned(company)).to_int]\n end\n end",
"def check_out\n\t\ttotal_to_pay = 0\n\t\t@list.each do |milkshake| \n\t\t\ttotal_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
most recent purchase price to be used in debt conversion cap table calculations | def most_recent_price
pricing_transactions = transactions.uniq.select{|t| t.dollars && t.shares}
last_date = pricing_transactions.map{|t| t.date}.max
pricing_transactions.select{|t| t.date == last_date}.map{|tt| tt.dollars/tt.shares.to_f}.first
end | [
"def last_price\n quote.lastTrade\n end",
"def get_order_lastest_bid_price(order)\n bid_history_count = order.order_price_histories.count\n bid_price = order.order_price_histories[bid_history_count-1] ? \n order.order_price_histories[bid_history_count-1].price : nil\n return bid_price\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
creates a current percentage chart by entity see the PercentageChart class in lib directory | def ent_percentage_chart
p_c = PercentageChart.new
p_ents = entities.uniq.map(&:id)
total_shares_common = shares_common.to_f
p_ents.each do |p_ent|
if (p_ent.e.shares_common > 0)
p_c.push [p_ent, 100*(p_ent.e.shares_common.to_f/total_shares_common)]
end
end
p_c.descend
end | [
"def percentage_chart\n p_c = PercentageChart.new\n p_secs = securities.uniq.map(&:id)\n total_shares_common = company.shares_common.to_f\n p_secs.each do |p_sec|\n p_c.push [p_sec, 100*(shares_common(p_sec).to_f/total_shares_common)]\n end\n p_c\n end",
"def percent_earning\n cache_unt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /paldemic_files POST /paldemic_files.json | def create
@paldemic_file = PaldemicFile.new(paldemic_file_params)
if(paldemic_file_params["file"] != nil)
@paldemic_file.file = paldemic_file_params["file"].read
validFile = PaldemicFile.validFile?(@paldemic_file.file)
else
validFile = false
end
respond_to do |format|
if v... | [
"def upload_image_file(args = {}) \n post(\"/files.json/captiveportal/images\", args)\nend",
"def post_attachment(file_s)\n setup\n @req = Net::HTTP::Post.new(\"/uploads.json\")\n auth\n @req[\"Content-Type\"] = \"application/octet-stream\"\n @req[\"Content-Length\"] = file_s.length\n @req.body ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tabs/1 GET /tabs/1.xml | def show
@tab = Tab.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @tab }
end
end | [
"def index\n @tabs = Tab.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tabs }\n end\n end",
"def index\n json_response(@session.tabs)\n end",
"def index\n @test_tabs = TestTab.all\n\n respond_to do |format|\n format.html #... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tabs/new GET /tabs/new.xml | def new
@tab = Tab.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @tab }
end
end | [
"def new\n @test_tab = TestTab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_tab }\n end\n end",
"def new\n @tab = Tab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tab }\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /tabs POST /tabs.xml | def create
@tab = Tab.new(params[:tab])
respond_to do |format|
if @tab.save
format.html { redirect_to(@tab, :notice => 'Tab was successfully created.') }
format.xml { render :xml => @tab, :status => :created, :location => @tab }
else
format.html { render :action => "new" }
... | [
"def create\n @session.tabs.create!(tab_params)\n json_response(@session, :created)\n end",
"def create\n @test_tab = TestTab.new(params[:test_tab])\n\n respond_to do |format|\n if @test_tab.save\n flash[:notice] = 'TestTab was successfully created.'\n format.html { redirect_to(@te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /tabs/1 PUT /tabs/1.xml | def update
@tab = Tab.find(params[:id])
respond_to do |format|
if @tab.update_attributes(params[:tab])
format.html { redirect_to(@tab, :notice => 'Tab was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { r... | [
"def update\n @tab = Tab.find(params[:id])\n\n respond_to do |format|\n if @tab.update_attributes(params[:tab])\n flash[:notice] = \"<strong>#{@tab.title}</strong> was successfully updated.\"\n format.html { redirect_to(@tab) }\n format.xml { head :ok }\n else\n format.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /tabs/1 DELETE /tabs/1.xml | def destroy
@tab = Tab.find(params[:id])
@tab.destroy
respond_to do |format|
format.html { redirect_to(tabs_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @test_tab = TestTab.find(params[:id])\n @test_tab.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_tabs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @fdbtab = Fdbtab.find(params[:id])\n @fdbtab.destroy\n\n respond_to do |format|\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns album artist or "Compilation" if there are more than one TODO: | def artist
artists = tracks.map{|t| t.artist}.compact
if artists.uniq.size == 1
artists.first
else
"Compilation"
end
end | [
"def album_artist\n album_artist = nil\n if unique?(@tracks, \"artist\" )\n album_artist = @tracks[0].artist\n else\n album_artist = 'Various Artists'\n end\n return album_artist\n end",
"def find_album(artist_name, album_title)\n compilation = (album_title == 'Compila... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
process redio mouse click event. | def process_redio_mouse_click(input)
if input[:type] == :left_pressed
list_item = @item_ys.find_index input[:pos][:y]
print_redio list_item if list_item
@redio_loop = false
end
end | [
"def clicked(mouse_event)\n end",
"def handle_mouse_down mouse_x, mouse_y\n # empty base implementation\n end",
"def handle_mouse_down(_key, _x, _y) end",
"def click_mouse(button)\n XDo::FFILib.xdo_click @_xdo_pointer, @_window, button\n end",
"def click\n Bewildr::Mouse.click(cl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
process redio keyboard input event. | def process_redio_keyboard_input(key)
case key
when :enter then @redio_loop = false
when /\d/ then print_redio(key.to_s)
when :tab, :down, :left, :space then print_redio(@redio_res.succ)
when :up, :right then print_redio(@redio_res.pred)
end
end | [
"def on_key(ch)\n end",
"def read_keypress\n question.echo false\n question.raw true\n question.evaluate_response(read_input).tap do |key|\n raise Interrupt if key == \"\\x03\" # Ctrl-C\n end\n end",
"def drb_input!\n Vedeu.bind(:_drb_input_) do |data, type|\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method is used to distinguish protected scope against private scope The purpose is to show that one instance can access anothers protected methods, but not their private methods. | def private_vs_protected_argument_method(scope)
"Protected method of passed object says: " + scope.protected_method_string
#The below line will result in an error, as we cannot call another instances
#protected methods.
#"Private method of pass object: " + scope.private_method_string
end | [
"def protected_method\n\tend",
"def a_private_method\n\tend",
"def protected_methods(all=true) end",
"def test_protected_readers_are_in_fact_private\n -> { @foo.prot_read1 }.must_raise NoMethodError\n -> { @foo.prot_read2 }.must_raise NoMethodError\n -> { @foo.prot_read3 }.must_raise NoMethodError\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /talks POST /talks.xml | def create
@talk = Talk.new(params[:talk])
respond_to do |format|
if @talk.save
flash[:notice] = 'Talk was successfully created.'
format.html { redirect_to(@talk) }
format.xml { render :xml => @talk, :status => :created, :location => @talk }
else
format.html { rende... | [
"def create\n @talk = Talk.new(params[:talk])\n\n respond_to do |format|\n if @talk.save\n# format.html { redirect_to(@talk, :notice => 'Talk was successfully created.') }\n format.html { redirect_to(talks_path, :notice => 'Talk was successfully created.') }\n format.xml { render :x... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /talks/1 DELETE /talks/1.xml | def destroy
@talk = Talk.find(params[:id])
@talk.destroy
respond_to do |format|
format.html { redirect_to(talks_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @click_to_talk = ClickToTalk.find(params[:id])\n @click_to_talk.destroy\n\n respond_to do |format|\n format.html { redirect_to(click_to_talks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @talk = Talk.find(params[:id])\n @talk.destroy\n\n respond_to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /projetos/1 PATCH/PUT /projetos/1.json | def update
respond_to do |format|
if @projeto.update(projeto_params)
format.html { redirect_to @projeto, notice: 'Projeto alterado com sucesso.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @projeto.errors, statu... | [
"def update\n @projeto = Projeto.find(params[:id])\n\n respond_to do |format|\n if @projeto.update_attributes(params[:projeto])\n format.html { redirect_to @projeto, notice: 'Projeto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /projetos/1 DELETE /projetos/1.json | def destroy
@projeto.destroy
respond_to do |format|
format.html { redirect_to projetos_url }
format.json { head :no_content }
end
end | [
"def destroy\n @projeto = Projeto.find(params[:id])\n @projeto.destroy\n\n respond_to do |format|\n format.html { redirect_to projetos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @projeto_ti.destroy\n respond_to do |format|\n format.html { redirect_to pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new MealFinder with empty restaurants. The restaurants attribute is SortedSet object that will be filled by the MealFinder.addRestaurant method. | def initialize()
@restaurants = SortedSet.new
end | [
"def init\n # grab only the attributes that exist to populate the filters\n @cuisines = Restaurant.select(:cuisine).distinct.map(&:cuisine) # {|r| r.cuisine } == (&:cuisine)\n @distances = Restaurant.select(:distance).distinct.map(&:distance) # {|r| r.cuisine } == (&:cuisine)\n @costs = Restaurant.selec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a restaurant to the MealFinder. This method receive an Restaurant Object | def addRestaurant(restaurant)
@restaurants << restaurant
end | [
"def add\n puts \"\\n-- ADD RESTAURANT --\\n\"\n restaurant = Restaurant.build_info\n if restaurant.save\n puts 'Restaurant added'\n else\n puts 'Save Error => cannot be added'\n end\n end",
"def add_food(food)\n food_meals.create(food_id: food.id)\n end",
"def create\n #IOnstan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The MealFinder.finder method, receive an OrderMeal object and scann the restaurants ordered by rating. It returns a Hash object with the restaurants and the meals delivered in order to complete the OrderMeal requirement. | def finder(order_meal)
result = Hash.new
meals = order_meal.meals
@restaurants.reverse_each do |restaurant|
restaurant_temp = restaurant
meals.keys.each do |name|
if ( restaurant.meals[name] && restaurant_temp.meals[name].quantity > 0 )
if ( meals[name].quantity <= restaurant_... | [
"def generate_restaurant(chomp_session)\n # algorithm to get recommendation\n # based on chompsession ID, get all responses\n # find the lowest budget, convert to integer 1,2,3 or 4\n # get frequency table of cuisines. Get the highest frequency cuisinse.\n # If no highest frequency\n # Get middleg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Receive the route of a file containing a valid json definition of the restaurants and the order. The method parse the json file, and fill the restaurants of the MealFinder. Also, creates the OrderMeal, and process the file. The result in case of success is a hash with the result of the MealFinder.finder method. | def process_file(filename)
structure = nil
begin
structure = JSON.parse( IO.read(filename, encoding:'utf-8') )
rescue
print "Error loading/parsing File: #{$!}"
return nil
end
begin
if( structure["restaurants"].count > 0 )
structure["restaurants"].each do |r_data|
... | [
"def parse_file\n File.open(\"FoodDB.txt\", \"r\") do |f|\n f.each_line do |line|\n line.chomp!\n command = line.split(\",\")\n name = command[0]\n type = command[1]\n info = command[2]\n #switches on type\n case type\n when \"b\"\n addFoo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Receives a Hash with the result of the MealFinder.finder method and prints their data. | def print_result(result)
puts "The result of the meal finder is: "
result.keys.each do |restaurant|
puts "Restaurant: #{restaurant}"
result[restaurant].keys.each do |meal|
puts "\t #{meal} #{result[restaurant][meal]}"
end
end
return
end | [
"def printFood(name)\n i = 0 #initializing i to zero\n # if the given food matches basicHash food name\n # look into basicHash and set i to 1 to mark found\n if @BasicHash.has_key? name\n i = 1\n basicfood = @BasicHash[name]\n puts \"#{basicfood.name} #{basicfood.calories} \"\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
variable globale bra_doc = bra_per_day(date) p $bra_doc = bra_per_day(date) ranges in the bra of meteo france per date | def ranges(date)
ranges =[]
bra_doc = bra_per_day(date)
bra_doc.each do |element|
ranges << element["massif"]
end
ranges
end | [
"def ranges(date)\n ranges =[]\n bra_doc = bra_per_day(date)\n bra_doc.each do |element|\n ranges << element[\"massif\"]\n end\n p ranges\n end",
"def bra_all_ranges_per_date(date)\n bra_all_ranges = []\n ranges(date).each do |range|\n bra_all_ranges << bra_per_range(bra_key(range,date... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
bra all ranges per date | def bra_all_ranges_per_date(date)
bra_all_ranges = []
ranges(date).each do |range|
bra_all_ranges << bra_per_range(bra_key(range,date))
end
bra_all_ranges
end | [
"def bra_all_ranges_per_date(date)\n bra_all_ranges = []\n ranges(date).each do |range|\n bra_all_ranges << bra_per_range(bra_key(range,date))\n end\n bra_all_ranges\n end",
"def ranges(date)\n ranges =[]\n bra_doc = bra_per_day(date)\n bra_doc.each do |element|\n ranges << ele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cron update mountain _ranges_cron | def update_mountain_ranges_cron
begin
date = Date.today.prev_day.to_s.delete("-").to_i
update_mountain_ranges(date)
rescue Exception => e
puts "bra_meteo_france indisponible "
end
end | [
"def schedule_updates\n end",
"def cron_tasks\n end",
"def cron_poller; end",
"def schedule_updates\n schedule_update_in(48.hours)\n end",
"def update_all_bra(date)\n bra_keys = get_bra_keys_for(date)\n\n bra_keys.each do |bra_key|\n begin\n bra = get_bra_info_for_this_range(br... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin This Method to get the pending requests assigned to this member Author:Diab Committee/Project : Logistics =end | def get_pending_requests
r = Request.where(:assigned => self , :done => false).to_a
return r
end | [
"def pending_collaborators_project\n @project = Project.find(params[:project_id])\n @myrequests = all_collaboration_requests\n @pending_list = []\n\n @myrequests.each do |request|\n if request.project_id == @project.id\n @pending_list << request\n end\n end\n return @pending_list\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin This Method to get the done requests assigned to this member Author:Diab Committee/Project : Logistics =end | def get_done_requests
r = Request.where(:assigned => self , :done => true).to_a
return r
end | [
"def requests_to_join\n authorize! @organization, :manage_requests_to_join?\n\n @pending_requests = @organization.pending_requests_to_join\n end",
"def pending_collaborators_project\n @project = Project.find(params[:project_id])\n @myrequests = all_collaboration_requests\n @pending_list = []\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin This Method to reply to a pending request with the room that has been reserved Author:Diab Committee/Project : Logistics =end | def reply_request(request , assigned_room)
request.room = assigned_room
request.done = true
request.save
request.needers.each do |needer|
Notification.send_notification(needer,
2,
2,
("The Room ( " ... | [
"def request_closed_with_winner(the_request, the_proposal, to_owner)\n @request = the_request\n @proposal = the_proposal\n mail(:to => to_owner ? @request.user.email : @proposal.user.email,\n :subject => \"La richiesta #{@request.id} è chiusa\"\n )\n end",
"def loan_request_notification(ow... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the childSelectability property value. Indicates whether a single or multiple child tags can be associated with a document. Possible values are: One, Many. This value controls whether the UX presents the tags as checkboxes or a radio button group. | def child_selectability
return @child_selectability
end | [
"def child_selectability=(value)\n @child_selectability = value\n end",
"def child_tags\n return @child_tags\n end",
"def child_tags=(value)\n @child_tags = value\n end",
"def selected_child\n @children[ @selected_index ]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the childSelectability property value. Indicates whether a single or multiple child tags can be associated with a document. Possible values are: One, Many. This value controls whether the UX presents the tags as checkboxes or a radio button group. | def child_selectability=(value)
@child_selectability = value
end | [
"def child_selectability\n return @child_selectability\n end",
"def child_tags=(value)\n @child_tags = value\n end",
"def select(child)\n return unless child\n return if !deselectable && selected == child\n deselect if !multiple && selecte... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the childTags property value. Returns the tags that are a child of a tag. | def child_tags
return @child_tags
end | [
"def child_tags\n result = ElementCollection.new\n\n children.each do |child|\n if child.is_a?(Tag)\n result << child\n else\n result.concat child.child_tags\n end\n end\n\n result\n end",
"def child_tags=(value)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the childTags property value. Returns the tags that are a child of a tag. | def child_tags=(value)
@child_tags = value
end | [
"def child_tags\n return @child_tags\n end",
"def child_tags\n result = ElementCollection.new\n\n children.each do |child|\n if child.is_a?(Tag)\n result << child\n else\n result.concat child.child_tags\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Instantiates a new securityEdiscoveryReviewTag and sets the default values. | def initialize()
super
@odata_type = "#microsoft.graph.security.ediscoveryReviewTag"
end | [
"def initialize()\n super\n @odata_type = \"#microsoft.graph.security.amazonResourceEvidence\"\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.security.googleCloudResourceEvidence\"\n end",
"def initialize(ec2... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the parent property value. Returns the parent tag of the specified tag. | def parent=(value)
@parent = value
end | [
"def parent_reference=(value)\n @parent_reference = value\n end",
"def set_parent(node, val)\n node.send(:parent=, val)\n end",
"def set_Parent(value)\n set_input(\"Parent\", value)\n end",
"def parent=(value)\n if descendants_and_self.include?(value)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Loads user's profile data for given token. token The GoogleToken to access google user's profile. Returns user's profile. | def load_profile(token)
profile = GoogleService.user_info(token)
email_field = profile["emails"].select do |email|
email["type"] == "account"
end
email = email_field[0]["value"] if email_field && email_field.size > 0
{:displayName => profile["displayName"],
:image => prof... | [
"def get_profile_by_access_token(access_token)\n headers = {\n \"Authorization\" => \"Bearer #{access_token}\",\n }\n endpoint_path = \"/v2/profile\"\n get(oauth_endpoint, endpoint_path, headers)\n end",
"def get_profile(session, user_id)\n $client.authorization.upda... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /timesheets/new GET /timesheets/new.xml | def new
@timesheet = Timesheet.new
respond_to do |format|
format.html # new.html.erb
#format.xml { render :xml => @timesheet }
end
end | [
"def new\n @timesheet = Timesheet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @timesheet }\n end\n end",
"def new\n @timesheet = Timesheet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /timesheets/1 DELETE /timesheets/1.xml | def destroy
@timesheet = Timesheet.find(params[:id])
@timesheet.destroy
respond_to do |format|
format.html { redirect_to(admin_timesheets_url) }
#format.xml { head :ok }
end
end | [
"def destroy\n @timesheet = Timesheet.find(params[:id])\n @timesheet.destroy\n\n respond_to do |format|\n format.html { redirect_to(timesheets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @timesheet = Timesheet.find(params[:id])\n @timesheet.destroy\n respond_to d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method that finds creature by id | def show
id = params[:id]
@creature = Creature.find(id)
end | [
"def show\n \t# find creature to show by id\n \t@creature = Creature.find(params[:id])\n end",
"def show\n\t\t#get the selected creature\n\t\tcreature_id = params[:id]\n\n\t\t#fid said creature and save it\n\t\t@creature = Creature.find_by_id(creature_id)\n\t\trender :show\n\tend",
"def find(id)\n fet... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method that find creature by id and renders edit.html.erb | def edit
id = params[:id]
@creature = Creature.find(id)
end | [
"def edit\n\t\t#save id param to variable\n\t\tid = params[:id]\n\t\t#find creature with that id and save to instance variable of Creature\n\t\t@creature = Creature.find(id)\n\t\t#render the edit form view with access to @creature variable\n\t\trender :edit\n\tend",
"def edit\n # save the id parameter to a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subroutines Check that the current version of GEDitCOM II is new enough for this script Also check if a document is open Return 0 to abort script or 1 if OK to continue | def CheckAvailable(gedit)
if gedit.versionNumber()<1.29
puts "This script requires GEDitCOM II, Version 1.3 or newer."
return 0
elsif gedit.documents().count()<1
print "You have to open a document in GEDitCOM II to use this script"
return 0
end
return 1
end | [
"def CheckAvailable(gedit,sName,vNeed)\n if gedit.versionNumber()<vNeed\n errMsg = \"The script '\" + sName + \"' requires GEDitCOM II, Version \"\\\n + vNeed.to_s + \" or newer.\\nPlease upgrade and try again.\"\n puts errMsg\n return 0\n end\n\n if gedit.documents().count()<1\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Metodo que da el nombre del logi bill | def logi_bill_name_bill
logi_bill ? logi_bill.name_bill : 'N/a'
end | [
"def getBatchProcessLogObjName\r\n\t\t\treturn \"mfiforce__Batch_Process_Log__c\"\r\n\t\tend",
"def getBatchProcessLogObjName\r\n\t\t\treturn \"Batch_Process_Log__c\"\r\n\t\tend",
"def getJournalObjName\r\n\t\t\treturn \"mfiforce__Journal__c\"\r\n\t\tend",
"def name_bill\n \"#{name}:#{endNumber}\"\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Metodo que da el nombre consecutivo (id) del movimiento anterior En caso que no exista el movimiento anterior retorna "N/a" | def previous_bill_movement_id
previous_bill_movement ? previous_bill_movement.id : 'N/a'
end | [
"def previous_move_reference\n previous_move&.reference\n end",
"def incrementa_contador_tipo_imovel\n \n # So incrementa o contador do tipo de imovel se for no cadastro.\n # Traz o imovel cujo id é igual ao do campo tipo_imovel_id do imovel \n tipo_imovel = TipoImovel.find(tipo_imovel_id)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Metodo que da el nombre del tipo de movimiento | def type_name_bill
type_movement ? type_movement.name : 'N/a'
end | [
"def get_modo()\r\n\t\treturn \"tipo\"\r\n\tend",
"def get_movement_type_name(verbose_level = :short)\n if movement_type && movement_type.code == MovementType::CODE_FULL\n ''\n elsif movement_type # Retrieve the movement_scope_type only if it is defined and it's not \"full\"\n if verbose_level.to_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
WordPress Version Identification via Generator Meta Tag Returns version on success, nil otherwise... | def wp_generator_version_check(site=@site, verbose=true)
@wp_paths.each do |p|
link = site.sub(/\/$/, '') + p
link += '/' if p == ''
res = @http.get(site)
if res[0] =~ /<meta name="generator" content="(WordPress \d+.\d+?.?\d+)" \/>/i
wp_version = $1.chomp
print_good("Generato... | [
"def wordpress_version\n # detect version from generator\n version = wordpress_version_helper(normalize_uri(target_uri.path), /<meta name=\"generator\" content=\"WordPress #{WORDPRESS_VERSION_PATTERN}\" \\/>/i)\n return version if version\n\n # detect version from readme\n version = wordpress_version... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
WordPress Version Identification via default INSTALL.html file Returns version on success, nil otherwise... | def wp_install_version_check(site=@site, verbose=true)
@wp_paths.each do |p|
installer = site.sub(/\/$/, '') + p + '/INSTALL.html'
res = @http.get(installer)
if res[0] =~ /for (WordPress \d+.\d+?.?\d+)<\/title>/i
wp_version = $1.chomp
print_good("#{p}/INSTALL.html Found!") if verbo... | [
"def wordpress_version\n # detect version from generator\n version = wordpress_version_helper(normalize_uri(target_uri.path), /<meta name=\"generator\" content=\"WordPress #{WORDPRESS_VERSION_PATTERN}\" \\/>/i)\n return version if version\n\n # detect version from readme\n version = wordpress_version... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
WordPress Version Identification via default readme.html file Returns version on success, nil otherwise... | def wp_readme_version_check(site=@site, verbose=true)
@wp_paths.each do |p|
readme = site.sub(/\/$/, '') + p + '/readme.html'
res = @http.get(readme)
if res[0] =~ /for (WordPress \d+.\d+?.?\d+)<\/title>/i
wp_version = $1.chomp
print_good("#{p}/readme.html Found!") if verbose
... | [
"def wordpress_version\n # detect version from generator\n version = wordpress_version_helper(normalize_uri(target_uri.path), /<meta name=\"generator\" content=\"WordPress #{WORDPRESS_VERSION_PATTERN}\" \\/>/i)\n return version if version\n\n # detect version from readme\n version = wordpress_version... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
WordPress Version Identification via RSS Feed's generator tag Returns version on success, nil otherwise... | def wp_rss_version_check(site=@site, verbose=true)
@wp_paths.each do |p|
feed = site.sub(/\/$/, '') + p + '/feed/'
res = @http.get(feed)
wp_frontpage_check(res[0]) if verbose
if res[0] =~ /<generator>(.+)<\/generator>/i
wp_version = $1.chomp.sub('http://wordpress.org/?v=', '')
... | [
"def wordpress_version\n # detect version from generator\n version = wordpress_version_helper(normalize_uri(target_uri.path), /<meta name=\"generator\" content=\"WordPress #{WORDPRESS_VERSION_PATTERN}\" \\/>/i)\n return version if version\n\n # detect version from readme\n version = wordpress_version... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse Response Body from Frontend Page Check for active Theme & Plugins | def wp_frontpage_check(resp_body)
body = Nokogiri::HTML(resp_body)
plugins = []
themes = []
links = []
rpc = []
begin
generator_tag = body.at("meta[name='generator']")['content'].encode('UTF-8')
rescue
generator_tag = 'N/A'
end
# Grab href links...
if not body.search(... | [
"def parse_response_body(body)\r\n case body\r\n when SUCCESS_REGEXP\r\n log :success, $1\r\n $1\r\n when FAILURE_REGEXP \r\n log :failure, $1.gsub(\"<BR>\", \"\\n\")\r\n nil\r\n else \r\n raise \"unparseable response: #{body}\"\r\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Simple check for rssfunctions.php This file contains function call that triggers verbose error w/path EX: Fatal error: Call to undefined function _deprecated_file() in /var/www/rssfunctions.php on line 8 | def wp_rss_fpd(site=@site, verbose=true)
res = @http.get(site.sub(/\/$/, '') + '/wp-includes/rss-functions.php')
if res[0] =~ /<b>(\/.+\/.+)<\/b> on line/ # Capture the path from error
fpd = $1.strip.chomp.split('/')[0..-2].join('/') << '/' # drop rss-functions.php
return fpd
end
return nil
... | [
"def wp_rss_version_check(site=@site, verbose=true)\n @wp_paths.each do |p|\n feed = site.sub(/\\/$/, '') + p + '/feed/'\n res = @http.get(feed)\n wp_frontpage_check(res[0]) if verbose\n if res[0] =~ /<generator>(.+)<\\/generator>/i\n wp_version = $1.chomp.sub('http://wordpress.org/?v=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
WP Plugins Enumerator Checks for Indexed Plugins Directory Simply calls out the plugins found... | def wp_plugin_enumerator(site=@site, verbose=true)
@wp_paths.each do |p|
plugins_dir = site.sub(/\/$/, '') + p + '/wp-content/plugins/'
res = @http.get(plugins_dir)
if res[0] =~ /<title>Index of.+\/wp-content\/plugins<\/title>|<h1>Index of.+\/wp-content\/plugins<\/h1>/i
p1 = res[0].scan(/h... | [
"def directory_listing?(plugin)\n\n listing = false\n\n response = Typhoeus::Request.get(@url.to_s + '/plugins/' + plugin + '/')\n\n if response.body[%r{<title>Index of}]\n listing = true\n end\n\n listing\n\n end",
"def directory_plugin_entries\n return @directory_plugin_entries if @direc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
WP Theme Enumerator Checks for Indexed Themes Directory Simply calls out the themes found... | def wp_theme_enumerator(site=@site, verbose=true)
@wp_paths.each do |p|
theme_dir = site.sub(/\/$/, '') + p + '/wp-content/themes/'
res = @http.get(theme_dir)
if res[0] =~ /<title>Index of.+\/wp-content\/themes<\/title>|<h1>Index of.+\/wp-content\/themes<\/h1>/i
t1 = res[0].scan(/href="(.+... | [
"def themes\n [THEME_DEFAULT] + THEMES\n end",
"def themes()\n source = \"./themes/\"\n \n cluster = []\n \n if File.directory? source\n Dir.foreach(source) do |cf|\n unless cf == '.' || cf == '..' \n cluster << cf.split('... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Quick Dirbuster Style Check Looks for common backup & configuration files | def wp_backup_configs_check(site=@site, verbose=true)
found = []
test_urls = []
dirs = [ '', '/wp-content', '/wp-content/includes', '/backup', '/backups' ]
juicy = [ '/wp-config.php', '/wp-config.php~', '/#wp-config.php#', '/wp-config.php.save', '/wp-config.php.swp', '/wp-config.php.swo', '/wp-config.ph... | [
"def check_files\n @config[\"promised_files\"] ||= {} \n # do not yet have any defaults\n # but if there were some, here you would ensure they were included\n # unless explicitly removed\n \n end",
"def check_setup\n set_config_file_options\n check_project_name\n check... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Forceful Check for Known TimThumb.php instances File is known to be vulnerable to remote command execution Returns array of found files, or nil | def wp_timthumbs_check(thumbs_list=nil, site=@site, verbose=true)
found = []
test_urls = []
if thumbs_list.nil?
thumbs_list = HOME + 'fuzz/wp_timthumbs.txt'
end
if File.exists?(thumbs_list.strip.chomp)
thumbz = File.open(thumbs_list.strip.chomp).readlines
thumbz.each { |thumb| test... | [
"def check_files\n process_files.each do |result|\n URL_TYPES.each do |url_type|\n type = :\"#{url_type}_urls\"\n ivar_name = \"@#{type}\"\n ivar = instance_variable_get(ivar_name)\n\n if ivar.empty?\n instance_variable_set(ivar_name, result[type])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Try to enumerate WP Users Leverages the /author?=[id] trick Helpful if you want to bruteforce login later | def wp_users_check(site=@site, verbose=true)
usernames=[]
test_urls = []
(0..10).each {|x| test_urls << site.sub(/\/$/, '') + "/?author=#{x}" }
$config['HTTP']['PROGRESS'] = true # Enable progressbar
mresponses = @http.multi_get(test_urls) # Curl Multi Mode Makes the Checks Faster
$con... | [
"def apply_user_filter\n return if params[:author].blank?\n User.find(params[:author]).tap do |user|\n @posts = @posts.where author: user\n add_breadcrumb \"by author \\\"#{user.humanize}\\\"\"\n end\n end",
"def get_author_posts_url(author_id, author_nicename = '')\n # global $wp_rewrite;\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if /xmlrpc.php is present | def wp_xmlrpc_check(site=@site, verbose=true)
xmlrpc_file = site.sub(/\/$/, '') + '/xmlrpc.php'
res = @http.get(xmlrpc_file)
if res[1] == 200 or res[1] == 403
print_good("XML-RPC: #{xmlrpc_file}") if verbose
return true
else
print_error("No XML-RPC Found!")
end
return false
e... | [
"def get_xmlrpc_path()\r\n unless @xmlrpc_location \r\n meta_regexp = /<link rel=\"pingback\" href=\"(.*)\\/(.*)\" \\/>/\r\n pingback = @body.scan(meta_regexp).flatten\r\n if pingback.size == 2\r\n meta_url = URI.parse(pingback[0])\r\n \r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
WP Login Check Check if credentials work or not Returns true on success, false otherwise | def wp_login_check(user='admin', pass='password', path=nil, site=@site, verbose=true)
if path.nil?
path = '/wp-login.php'
end
if $config['HTTP']['HTTP_HEADERS_ADD']
flip=false
else
$config['HTTP']['HTTP_HEADERS_ADD']=true
flip=true
end
$config['HTTP']['HTTP_HEADERS'].stor... | [
"def wp_login?(url)\n \t\tsite=url_2_site(url)\n \t\tlogin_url=site + \"wp-login.php\"\n k=Wmap::UrlChecker.new\n if k.response_code(login_url) == 200\n k=nil\n doc=open_page(login_url)\n links=doc.css('link')\n if links.to_s =~ /login.min.css/i\n return true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Simple WordPress Login Bruter Pass in username and Dictionary to use (& custom path if needed) Will loop through list and try all possibilities Leverages Curl Multi for fast POST requests Sends in chunks of 10 at a time, checks results on receipt of all responses Displays results when found and exits request loop Nothi... | def wp_login_bruter(user='admin', wordlist=nil, path='/wp-login.php', site=@site)
if File.exists?(wordlist.strip.chomp)
if path.nil?
path = '/wp-login.php'
end
if $config['HTTP']['HTTP_HEADERS_ADD']
flip=false
else
$config['HTTP']['HTTP_HEADERS_ADD']=true
flip... | [
"def wp_users_check(site=@site, verbose=true)\n usernames=[]\n test_urls = []\n (0..10).each {|x| test_urls << site.sub(/\\/$/, '') + \"/?author=#{x}\" }\n $config['HTTP']['PROGRESS'] = true # Enable progressbar\n mresponses = @http.multi_get(test_urls) # Curl Multi Mode Makes the Checks Fa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Generate a Jekyll configuration Hash by merging the default options with anything in _config.yml, and adding the given options on top. override A Hash of config directives that override any options in both the defaults and the config file. See Jekyll::Configuration::DEFAULTS for a list of option names and their... | def configuration(override = {})
config = Configuration[Configuration::DEFAULTS]
override = Configuration[override].stringify_keys
unless override.delete('skip_config_files')
config = config.read_config_files(config.config_files(override))
end
# Merge DEFAULTS < _config.yml < over... | [
"def configuration(override = Hash.new)\n config = Configuration[Configuration::DEFAULTS]\n override = Configuration[override].stringify_keys\n unless override.delete('skip_config_files')\n config = config.read_config_files(config.config_files(override))\n end\n\n # Merge DEFAULTS < ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Set the log writer. New log writer must respond to the same methods as Ruby's interal Logger. writer the new Loggercompatible log transport Returns the new logger. | def logger=(writer)
@logger = LogAdapter.new(writer, (ENV["JEKYLL_LOG_LEVEL"] || :info).to_sym)
end | [
"def logger=(writer)\n @logger = LogAdapter.new(writer)\n end",
"def logger=(writer)\n @logger = LogAdapter.new(writer, (ENV[\"BRIDGETOWN_LOG_LEVEL\"] || :info).to_sym)\n end",
"def writer!\n writer_class = @writer_class || qualified_const_get(settings[\"writer_class_name\"])\n writer_clas... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: An array of sites Returns the Jekyll sites created. | def sites
@sites ||= []
end | [
"def sites\n return @sites\n end",
"def sites\n\t\t\t @sites ||= load_site_collections\n\t\t\tend",
"def sites()\n sql = \"SELECT sites.* FROM sites WHERE city_id = $1;\"\n values = [@id]\n site_list = SqlRunner.run(sql, values)\n return site_list.map{|site| Site.new(site)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Ensures the questionable path is prefixed with the base directory and prepends the questionable path with the base directory if false. base_directory the directory with which to prefix the questionable path questionable_path the path we're unsure about, and want prefixed Returns the sanitized path. | def sanitized_path(base_directory, questionable_path)
return base_directory if base_directory.eql?(questionable_path)
clean_path = File.expand_path(questionable_path, "/")
clean_path = clean_path.sub(/\A\w\:\//, '/')
if clean_path.start_with?(base_directory.sub(/\A\w\:\//, '/'))
clean_... | [
"def sanitized_path(base_directory, questionable_path)\n return base_directory if base_directory.eql?(questionable_path)\n\n clean_path = questionable_path.dup\n clean_path.insert(0, \"/\") if clean_path.start_with?(\"~\")\n clean_path = File.expand_path(clean_path, \"/\")\n\n return clean_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Stop Guard listening to file changes. | def stop
setup unless running
within_preserved_state do
::Guard::UI.debug 'Guard stops all plugins'
runner.run(:stop)
::Guard::Notifier.turn_off
::Guard::UI.info 'Bye bye...', reset: true
listener.stop
@running = false
end
end | [
"def stop_listening\n if @file_listener\n Process.kill(\"HUP\", @file_listener)\n end\n end",
"def stop\n detach_source_watchers\n \n @config_watcher.detach\n @helper_watcher.detach\n \n @loop.stop\n end",
"def stop\n within_preserved_state(false) do\n ::... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reload Guardfile and all Guard plugins currently enabled. If no scope is given, then the Guardfile will be reevaluated, which results in a stop/start, which makes the reload obsolete. | def reload(scopes = {})
setup unless running
within_preserved_state do
::Guard::UI.clear(force: true)
::Guard::UI.action_with_scopes('Reload', scopes)
if scopes.empty?
evaluator.reevaluate_guardfile
else
runner.run(:reload, scopes)
end
end
... | [
"def reload(scopes = {})\n scopes = convert_scopes(scopes)\n\n within_preserved_state do\n ::Guard::UI.clear(:force => true)\n ::Guard::UI.action_with_scopes('Reload', scopes)\n\n if scopes.empty?\n ::Guard::Dsl.reevaluate_guardfile\n else\n runner.run(:reload... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pause Guard listening to file changes. | def pause
if listener.paused?
::Guard::UI.info 'Un-paused files modification listening', reset: true
listener.unpause
else
::Guard::UI.info 'Paused files modification listening', reset: true
listener.pause
end
end | [
"def pause\n if listener.paused?\n ::Guard::UI.info 'Un-paused files modification listening', :reset => true\n listener.unpause\n else\n ::Guard::UI.info 'Paused files modification listening', :reset => true\n listener.pause\n end\n end",
"def pause\n if listener... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /reads GET /reads.json | def index
@reads = Read.all
end | [
"def get_read(id)\n resp = @conn.get 'reads/'+id.to_s+'.json'\n resp.body\n end",
"def index\n @readers = Reader.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @readers }\n end\n end",
"def index\n @readings = Reading.all\n\n res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /reads POST /reads.json | def create
@read = Read.new(read_params)
respond_to do |format|
if @read.save
format.html { redirect_to @read, notice: 'Read was successfully created.' }
format.json { render :show, status: :created, location: @read }
else
format.html { render :new }
format.json { re... | [
"def create\n @read = Read.new(read_params)\n\n respond_to do |format|\n if @read.save\n format.html { redirect_to @read, notice: \"Read was successfully created.\" }\n format.json { render :show, status: :created, location: @read }\n else\n format.html { render :new, status: :u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /reads/1 PATCH/PUT /reads/1.json | def update
respond_to do |format|
if @read.update(read_params)
format.html { redirect_to @read, notice: 'Read was successfully updated.' }
format.json { render :show, status: :ok, location: @read }
else
format.html { render :edit }
format.json { render json: @read.errors,... | [
"def update\n @read = Read.find(params[:id])\n\n respond_to do |format|\n if @read.update_attributes(params[:read])\n format.html { redirect_to @read, notice: 'Read was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /reads/1 DELETE /reads/1.json | def destroy
@read.destroy
respond_to do |format|
format.html { redirect_to reads_url, notice: 'Read was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @read = Read.find(params[:id])\n @read.destroy\n\n respond_to do |format|\n format.html { redirect_to reads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @read.destroy\n respond_to do |format|\n format.html { redirect_to reads_url, notice: \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the next token whether it's a single char or a group of enclosed chars "(abc)" removes the () and returns "abc" | def next_token(w)
if w[0] != '('
return w.slice!(0)
end
w.slice!(0) #remove that leading '('
token = ""
while true
c = w.slice!(0)
if c == ')'
break
end
token << c
end
return token
end | [
"def unparen( str )\n match = str.match(/^\\((.*?)\\)$/)\n match ? match[1] : str\n end",
"def unparen(str); end",
"def consume(str, char)\n raise AssertionError.new(\"Expected '#{char}'\") unless str[0] == char\n return str[1..-1].strip\n end",
"def scan_single_char()\n\t\tresult = if met... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /code_factors GET /code_factors.xml | def index
@code_factors = CodeFactor.all(:order => "id DESC")
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @code_factors }
format.json {
@returns = []
@code_factors.each do |code_factor|
@returns << mapping_to_hash(code_factor, CodeFactor.jso... | [
"def show\n @code_factor = CodeFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @code_factor }\n format.json { \n\t \trender :xml => mapping_to_hash(@code_factor, CodeFactor.json_mapping_table)\n\t }\n end\n end",
"def ind... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /code_factors/1 GET /code_factors/1.xml | def show
@code_factor = CodeFactor.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @code_factor }
format.json {
render :xml => mapping_to_hash(@code_factor, CodeFactor.json_mapping_table)
}
end
end | [
"def index\n @code_factors = CodeFactor.all(:order => \"id DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @code_factors }\n format.json { \n\t \t@returns = []\n\t \t@code_factors.each do |code_factor|\n\t \t\t@returns << mapping_to_hash(code... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /code_factors/new GET /code_factors/new.xml | def new
@code_factor = CodeFactor.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @code_factor }
end
end | [
"def new\n @what_factor = WhatFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @what_factor }\n end\n end",
"def new\n @when_factor = WhenFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.