query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
print the lyrics of the song 99 bottles of beer on the wall make sure you use the singular when you have one bottle of beer on the wall, and print 'no more bottles of beer on the wall' at the end. (there's no RSpec test for this one) | def ninety_nine_bottles_of_beer
for i in 1..98
puts "#{100 - i} bottles of beer on the wall, #{100 - i} bottles of beer."
puts "Take one down and pass it around, #{99 - i} bottles of beer on the wall."
puts ""
end
puts "1 bottle of beer on the wall, 1 bottle of beer."
puts "Take one down and pass it around, no more bottles of beer on the wall."
puts ""
puts "No more bottles of beer on the wall, no more bottles of beer."
puts "Go to the store and buy some more, 99 bottles of beer on the wall."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_song\n\t\tif self.bottles == 0 then return \"\" end\n\t\twhile self.bottles > 0\n\t\t\tstanza(self.bottles)\n\t\t\tself.bottles -= 1\n\t\tend\n\tend",
"def print_song\n\n num = @bottles\n\n if num == 0\n puts \"\"\n elsif num == 1\n puts \"One bottle of beer on the wall,\"\n puts \"One bott... | [
"0.7100537",
"0.6841236",
"0.6788246",
"0.6681107",
"0.6646972",
"0.65891635",
"0.65801334",
"0.6550958",
"0.65374565",
"0.6484345",
"0.6484114",
"0.64753926",
"0.6439706",
"0.6392282",
"0.636274",
"0.6360116",
"0.6341565",
"0.6331063",
"0.627703",
"0.6227187",
"0.62054807",
... | 0.59791833 | 35 |
load_and_authorize_resource GET /posts GET /posts.json | def index
@posts = Post.page(params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.all\n #authorize! if can? :read, @post\n @title = @post.title\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n... | [
"0.7285531",
"0.7121138",
"0.6741289",
"0.6726479",
"0.67069036",
"0.66941696",
"0.6657481",
"0.6622464",
"0.6617242",
"0.66149354",
"0.6581608",
"0.65553236",
"0.6516225",
"0.65131253",
"0.6491973",
"0.6455954",
"0.64554954",
"0.645401",
"0.64259475",
"0.6409517",
"0.6406877... | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
... | [
"0.77110183",
"0.73537844",
"0.73433185",
"0.73379177",
"0.73228735",
"0.7293139",
"0.7275997",
"0.7256934",
"0.7161576",
"0.7158913",
"0.71552676",
"0.71552676",
"0.7119547",
"0.7094749",
"0.7094749",
"0.7094749",
"0.70943594",
"0.7071599",
"0.70607626",
"0.70452625",
"0.703... | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = current_user.posts.build(post_params)
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @po... | [
"0.74463975",
"0.73221767",
"0.73072433",
"0.7123966",
"0.7015686",
"0.701327",
"0.69841874",
"0.6939327",
"0.69313824",
"0.69053805",
"0.68196476",
"0.6812792",
"0.6793222",
"0.6792862",
"0.6779654",
"0.6779654",
"0.67625546",
"0.67602354",
"0.67515427",
"0.6735786",
"0.6698... | 0.0 | -1 |
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json | def update
respond_to do |format|
if @post.update(post_params)
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
format.json { render :show, status: :ok, location: @post }
else
format.html { render :edit }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n forma... | [
"0.71867543",
"0.7042899",
"0.6774105",
"0.67672604",
"0.6669961",
"0.6649129",
"0.657972",
"0.6556958",
"0.6551495",
"0.6549005",
"0.6535034",
"0.6531995",
"0.6497553",
"0.64958835",
"0.6468818",
"0.64319825",
"0.6428907",
"0.64275557",
"0.64273673",
"0.64193714",
"0.6419366... | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param... | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def post_params
params.require(:post).permit(:title, :content, :budget, :d_day, :image, :user_id, :category_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
This was the old way we called .to_html just doing the get_variables and includes. This means the includes are done and the includes with variables as input are all done recursively. The downside of not doing this recursively is that we will probably have some problems with relative paths. | def to_format(format)
if format == :html
text = @text
get_variables(text)
text = includes(text)
text = output_variables(text)
text
end
# Second way: #{parse(@text)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_html\n @binding = get_binding #use the same binding throughout\n do_include(@layout)\n end",
"def insert_includes\n # match all variables, every variable begins with an at (@).\n # variables can also end with a semicolon to have a safe declaration.\n @output = @output.gsub(/\\<(.+)\\>/) {\... | [
"0.61628956",
"0.60477006",
"0.60139257",
"0.5842196",
"0.57703906",
"0.5748096",
"0.5600238",
"0.5600238",
"0.5546468",
"0.5546468",
"0.55124843",
"0.547048",
"0.5460318",
"0.54558325",
"0.543175",
"0.5422597",
"0.5407043",
"0.5407043",
"0.5345391",
"0.5339459",
"0.5250579",... | 0.0 | -1 |
Take a bunch of CSS or JS files and combine them into one 10981cd72e39481a723.js digest file. | def add_file_from_files(files, format)
return false if files == []
@@minified_files.concat files
# return false if files.collect(&:error) != []
contents = []
key = files.join(':') + ":#{format}"
return @@cached_files[key] if @@cached_files[key]
files.each do |file|
# TODO: We need a better way of getting the compiled contents of a file.
contents << parse_file(file, format)
if format == :js
contents << ";"
end
end
contents = contents.join("\n\n\n\n")
if format == :css
engine = Sass::Engine.new(contents, syntax: :scss, style: :compressed)
contents = engine.render
elsif format == :js
contents = Uglifier.compile(contents, mangle: false)
end
filename = Digest::MD5.hexdigest(contents)
assets_directory = "#{output_directory}/assets"
Dir.mkdir(assets_directory) unless Dir.exist?(assets_directory)
file = add_file("assets/#{filename}.#{format}", contents, files)
# file.source_files = files # TODO
@@cached_files[key] = file
file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_js_files\n\tjavascript_compile_list.map { |f| File.read(f) }.join\nend",
"def all_js_into_one_file\n File.open(base_js_file, 'w') do |file|\n js_files.each do |js_file|\n file.write('/* file: ' + js_file + \" */\\n\") if development?\n file.write(File.read... | [
"0.7327831",
"0.65061164",
"0.6501341",
"0.6422812",
"0.63901407",
"0.63707274",
"0.6300991",
"0.62427086",
"0.6217888",
"0.62110955",
"0.6128346",
"0.6071885",
"0.6022873",
"0.5998191",
"0.59951186",
"0.59239596",
"0.5895667",
"0.58816844",
"0.58493054",
"0.58490056",
"0.584... | 0.5815693 | 24 |
Used for both Javascript and stylesheet tags! | def replace_header_tags(text, regex, format, &block)
@header_tags ||= {}
@header_tags[regex] ||= []
replace(text, regex) do |tagged_path, line_number|
results, tags, hammer_files, paths = [], [], [], [], []
filenames = tagged_path.gsub(regex.to_s[/<!-- (.*?) /], "").gsub("-->", "").strip.split(" ")
filenames.each do |filename|
filename = get_variable(filename) if filename.split("")[0] == "$"
matching_files = find_files_with_dependency(filename, format.to_s)
name = regex.to_s[/ (.*?) /].strip.gsub("@", "").capitalize
raise "#{name} tags: <b>#{h filename}</b> couldn't be found." if matching_files.empty?
hammer_files += matching_files
end
hammer_files_to_tag = []
hammer_files.each do |file|
# We don't want this if it's a compiled file, or if it's only an include!
# next if file.is_a_compiled_file # TODO
next if File.basename(file).start_with?("_")
path = path_to(file)
# TODO: WTF do these do
next if @header_tags[regex].include?(path)
@header_tags[regex] << path
paths << path
hammer_files_to_tag << file
end
if optimized
file = add_file_from_files(hammer_files_to_tag, format)
paths = [path_to(file)]
end
paths.map { |path| block.call(path) }.compact.join("\n")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inject_js; end",
"def javascript_tag(content_or_options_with_block = T.unsafe(nil), html_options = T.unsafe(nil), &block); end",
"def stylesheet; end",
"def js_tag(script) #:nodoc:\r\n \"<script type=\\\"text/javascript\\\">#{script}</script>\"\r\nend",
"def js_tag(script) #:nodoc:\r\n \"<script type... | [
"0.64920557",
"0.6476996",
"0.6467022",
"0.6463921",
"0.6463921",
"0.6457399",
"0.6457399",
"0.6457399",
"0.63566357",
"0.6248561",
"0.611856",
"0.6103453",
"0.6093017",
"0.59992003",
"0.5977666",
"0.5977666",
"0.5977666",
"0.59644294",
"0.59489995",
"0.58839136",
"0.58821905... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_order
@order = @company.orders.find(params[:id])
authorize @order
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
acc + num end => 6 | def reduce(arr, accum=0)
counter = 0
while counter < arr.size
accum = yield(accum, arr[counter])
counter += 1
end
accum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summation(num)\r\n puts 1.upto(num).reduce(0, :+)\r\nend",
"def SimpleAdding(num\n total = 1.upto(num).reduce(&:+)\n total \nend",
"def even_reduce(acc)\n raise 'Implement me'\n end",
"def addition(number)\n (1..number).reduce(:+)\nend",
"def reduce(arr, accumulator = 0 )\n\n arr.each d... | [
"0.6527238",
"0.6413488",
"0.6135854",
"0.61304325",
"0.6122117",
"0.6073372",
"0.6047476",
"0.604341",
"0.6026368",
"0.6019047",
"0.5997901",
"0.5981425",
"0.5981425",
"0.5981425",
"0.5981425",
"0.5981425",
"0.5981425",
"0.5970296",
"0.5969556",
"0.59548885",
"0.59421384",
... | 0.0 | -1 |
make what should be 'meaningless' increments of both clean_version and dirty_version but if the increments fail, we know we have a lock conflict I should probably just add a lock_version column to invoice instead of doing this ... but I havn't thought it through far enough and this passes the tests... so I'm happy with it for now. | def ensure_atomic_update!
quoted_col_name_clean = connection.quote_column_name('clean_version')
quoted_col_name_dirty = connection.quote_column_name('dirty_version')
affected_rows = connection.update(<<-end_sql, "#{self.class.name} Update with 'clean/dirty version' locking")
UPDATE #{self.class.quoted_table_name}
SET dirty_version = dirty_version + 1, clean_version = clean_version + 1
WHERE #{self.class.primary_key} = #{quote_value(id)}
AND #{quoted_col_name_clean} = #{quote_value(self.clean_version)}
AND #{quoted_col_name_dirty} = #{quote_value(self.dirty_version)}
end_sql
unless affected_rows == 1
raise AlreadyCleaned,
"Attempted to update clean_version on an invoice already cleaned up to that version"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_without_attributes_does_not_only_update_lock_version\n assert_nothing_raised do\n p1 = Person.create!(first_name: \"anika\")\n lock_version = p1.lock_version\n p1.save\n p1.reload\n assert_equal lock_version, p1.lock_version\n end\n end",
"def revert\n version =... | [
"0.5728855",
"0.57256335",
"0.5600869",
"0.55544883",
"0.5484138",
"0.54651266",
"0.54610544",
"0.5439806",
"0.54193515",
"0.5403359",
"0.53612673",
"0.53612614",
"0.5347249",
"0.53426665",
"0.5342125",
"0.5300984",
"0.5295147",
"0.5282315",
"0.5277365",
"0.5270459",
"0.52664... | 0.7531613 | 0 |
TODO: test this method | def count_of_sku(sku)
count = 0
self.orders.each do |o|
o.invoice_line_items.each do |iv|
if iv.sku_number == sku.number
count += iv.quantity
end
end
end
return count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def probers; end",
"def refutal()\n end",
"def implementation; end",
"def implementation; end",
"def weber; end",
"def suivre; end",
"def identify; end",
"def custom; en... | [
"0.77996397",
"0.6679279",
"0.6679279",
"0.6679279",
"0.6679279",
"0.65430844",
"0.6515965",
"0.62961674",
"0.6226717",
"0.6226717",
"0.61181945",
"0.6072291",
"0.6031457",
"0.59520406",
"0.59520406",
"0.59326774",
"0.59326774",
"0.59027195",
"0.58771056",
"0.58771056",
"0.58... | 0.0 | -1 |
Defining the display board | def display_board(board=[" "," "," "," "," "," "," "," "," "])
def dash
puts "-----------"
end
puts " #{board[0]} | #{board[1]} | #{board[2]} "
dash
puts " #{board[3]} | #{board[4]} | #{board[5]} "
dash
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_board\n\n puts \" #{@board[0].mark} | #{@board[1].mark} | #{@board[2].mark} \"\n puts \"-----------\"\n puts \" #{@board[3].mark} | #{@board[4].mark} | #{@board[5].mark} \"\n puts \"-----------\"\n puts \" #{@board[6].mark} | #{@board[7].mark} | #{@board[8].mark} \"\n end",
... | [
"0.78981555",
"0.7741457",
"0.7704205",
"0.7701724",
"0.7686912",
"0.7669155",
"0.7621593",
"0.75988734",
"0.75830734",
"0.7580181",
"0.7580181",
"0.75737274",
"0.75709313",
"0.7536639",
"0.75259453",
"0.75259453",
"0.75259453",
"0.75259453",
"0.75259453",
"0.75259453",
"0.75... | 0.0 | -1 |
Converting user input to index | def input_to_index(user_input)
user_input.to_i - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_to_index(user_input)\n index = user_input.to_i - 1\n end",
"def input_to_index(user_input)\n index = user_input.to_i - 1\n end",
"def input_to_index(user_input)\n index=(user_input .to_i) -1\nend",
"def input_to_index(user_input)\n index = (user_input.to_i - 1)\n end",
"def input_to_... | [
"0.8334154",
"0.8334154",
"0.83195746",
"0.82510436",
"0.8120723",
"0.81101847",
"0.81101847",
"0.81101847",
"0.81101847",
"0.8107388",
"0.80723125",
"0.8050673",
"0.7981378",
"0.7920384",
"0.7890992",
"0.78586274",
"0.7847712",
"0.7824098",
"0.78059196",
"0.7804314",
"0.7795... | 0.7599682 | 79 |
Defining the move to fill the board with character | def move(board, index, character)
board[index] = character
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move (board, position, character = \"X\")\n board[(position.to_i - 1)] = character\n return board\nend",
"def move(position, char)\n @board[position] = char\n end",
"def make_move(square,char)\n @win_vecs[(square-1)/3].squares[(square-1)%3].fill=char\n end",
"def move(board,cell,char=... | [
"0.7620594",
"0.7539258",
"0.7480635",
"0.74479514",
"0.74126565",
"0.74121034",
"0.74053335",
"0.73686415",
"0.73686415",
"0.73542297",
"0.7350726",
"0.7305769",
"0.72834426",
"0.7282619",
"0.72796905",
"0.7269716",
"0.7269661",
"0.72657955",
"0.72648215",
"0.7258126",
"0.72... | 0.7045138 | 35 |
Defining if the position to be occupied if filled or empty | def position_taken?(board, index)
board[index] != " " && board[index] != ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_an_empty_position?(position_choice)\n\t\t@cell_status[position_choice]==0?true:false\n\tend",
"def check_full? \n \t\treturn true if @size==16 #size increase by 1 with every turn so when it reaches 16 we know that all cells are full\n\tend",
"def occupied?(x,y) # board position !nil\n !self.board.gr... | [
"0.72058624",
"0.7147937",
"0.70490223",
"0.69311136",
"0.6899678",
"0.6894738",
"0.6861111",
"0.6847676",
"0.6846618",
"0.683492",
"0.6828043",
"0.68039584",
"0.68028104",
"0.6773766",
"0.6772599",
"0.6767854",
"0.675322",
"0.67462957",
"0.6712014",
"0.671017",
"0.6673807",
... | 0.0 | -1 |
Checks if the move requested is valid or not | def valid_move?(board, index)
index.between?(0,8) && !position_taken?(board, index)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_move?\n\t\tvalid_1 = (0..2).include? (@take_from)\n\t\tvalid_2 = (0..2).include? (@move_to)\n\t\tif valid_1 == false || valid_2 == false\n\t\t\tputs \"I'm sorry, please input your move in a 'x,y' format, ensuring that you are selecting numbers between 1 and 3!\"\n\t\t\tmove_input\n\t\telsif @pegs[@take_f... | [
"0.8327186",
"0.8214931",
"0.8179706",
"0.8162107",
"0.81472427",
"0.81310487",
"0.81024486",
"0.80536425",
"0.8036537",
"0.8027883",
"0.80188966",
"0.80000347",
"0.79668707",
"0.7955568",
"0.7927337",
"0.79161245",
"0.7900299",
"0.78781146",
"0.78588",
"0.78464097",
"0.78420... | 0.0 | -1 |
Fills in the move requested by the player on the board | def turn(board)
puts "Please enter 1-9:"
input = gets.strip
index = input_to_index(input)
character = current_player(board)
if valid_move?(board, index)
move(board, index, character)
display_board(board)
else
turn(board)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_on_board(move, player)\n\n\t\t@board[move[0]][move[1]] = player\n\n\t\treturn @board\n\n\tend",
"def move\n puts \"The computer is playing...\".cyan\n sleep(0.5) #computer \"thinks\" for half a second, this seemed more realistic\n return if @game.game_over?\n space = (@game.available... | [
"0.7997088",
"0.72359765",
"0.7180002",
"0.7172852",
"0.7109906",
"0.71011883",
"0.708715",
"0.70796007",
"0.7052709",
"0.7051643",
"0.70199144",
"0.70152694",
"0.7003463",
"0.7001066",
"0.6991253",
"0.6973871",
"0.6946452",
"0.69383466",
"0.69156295",
"0.6900662",
"0.6888045... | 0.0 | -1 |
Counts the number of turns carried out by counting filled positions | def turn_count(board)
turns = 0
board.each do |x|
if x != " "
turns+=1
end
end
turns
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_count(board)\n\n\toccupied_spaces = 0\n\n\tcounter = 0\n\twhile counter < board.size\n\t if position_taken?(board, counter)\n\t\t occupied_spaces += 1\t\t \nend \ncounter += 1\nend\noccupied_spaces\nend",
"def turn_count()\n count = 0\n index = 0\n loop do\n if position_taken?(index)\n ... | [
"0.7670863",
"0.7544029",
"0.7502128",
"0.7307551",
"0.72926486",
"0.729183",
"0.72083664",
"0.7083471",
"0.7063659",
"0.70452017",
"0.70327395",
"0.7022601",
"0.7022532",
"0.7000755",
"0.6973598",
"0.69657",
"0.6961876",
"0.69603175",
"0.69421387",
"0.69345015",
"0.6923276",... | 0.0 | -1 |
Determines the current character by judging the number of plays made | def current_player(board)
turns = turn_count(board)
if turns.odd?
return "O"
else
return "X"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_win\n @player_win += 1\n end",
"def current_player\n turns_played = turn_count()\n if turns_played % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def player_win\n @player.won_bet\n pu... | [
"0.721406",
"0.69887614",
"0.6952332",
"0.69475585",
"0.69351083",
"0.69351083",
"0.69351083",
"0.68913627",
"0.68913627",
"0.6883294",
"0.6836899",
"0.68048036",
"0.67743456",
"0.6730168",
"0.6728662",
"0.67120105",
"0.6701709",
"0.6700532",
"0.66905594",
"0.66879517",
"0.66... | 0.0 | -1 |
define a method to check for winning combinations | def won?(board)
win_combo = nil
WIN_COMBINATIONS.each do |win_combination|
# win_index_1 = win_combination[0] alternative method to do using variable assign
# win_index_2 = win_combination[1]
# win_index_3 = win_combination[2]
position_1 = board[win_combination[0]] # load the value of the board at win_index_1
position_2 = board[win_combination[1]] # load the value of the board at win_index_2
position_3 = board[win_combination[2]] # load the value of the board at win_index_3
if position_1 == "X" && position_2 == "X" && position_3 == "X"
win_combo = win_combination # return the win_combination indexes that won.
elsif position_1 == "O" && position_2 == "O" && position_3 == "O"
win_combo = win_combination
end
end
win_combo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def won?\ntokens = [\"X\", \"O\"]\nwon = false\n@x_win = false\n@o_win = false\nwinning_combo = []\n\nWIN_COMBINATIONS.each do |combination|\n @x_win = combination.all?{|index| @board[index] == tokens[0]} if true\n @o_win = combination.all?{|index| @board[index] == tokens[1]} if true\n if @x_win || @o_win\n ... | [
"0.782276",
"0.7682764",
"0.7666739",
"0.7629689",
"0.7553151",
"0.75236124",
"0.7508516",
"0.75081295",
"0.7501456",
"0.74926996",
"0.74796754",
"0.74493176",
"0.74454147",
"0.74369985",
"0.7430226",
"0.7417399",
"0.74087197",
"0.7400103",
"0.73874706",
"0.7386351",
"0.73762... | 0.0 | -1 |
Checks if the board is full or not | def full?(board)
board.all? {|x| x != " "}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full?\n @board.all?{|occupied| occupied != \" \"}\n end",
"def board_full?\r\n @game_board.count(\"\") == 0\r\n end",
"def isBoardFull()\n #\n # TO DO: add your code below\n #\n for i in 0...@size\n for j in 0...@size\n if (@board[i][j]==EMPTY)\n ... | [
"0.86382467",
"0.8612064",
"0.8611818",
"0.8601976",
"0.8597748",
"0.8491167",
"0.84050363",
"0.8385482",
"0.8272694",
"0.8272694",
"0.8226835",
"0.8218833",
"0.8215472",
"0.8215472",
"0.8189562",
"0.8182087",
"0.81543094",
"0.81430227",
"0.81430227",
"0.8048146",
"0.8028008"... | 0.7267413 | 78 |
Checks if the board is draw | def draw?(board)
if won?(board) == nil && full?(board) == true
return true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw?(board)\n !won?(board) && full?(board)\n end",
"def draw?\n @board.full? && !won?\n end",
"def draw?\n @board.full? && !won?\n end",
"def draw?\n @board.full? && !won?\n end",
"def draw?\n self.board.full? && !self.won?\n end",
"def draw?\n board.full_board?\... | [
"0.86310774",
"0.8612615",
"0.85847217",
"0.85847217",
"0.8564462",
"0.8528417",
"0.85185146",
"0.8507374",
"0.84964764",
"0.84939176",
"0.84713066",
"0.8433252",
"0.84291524",
"0.8424264",
"0.8401406",
"0.83615965",
"0.8341304",
"0.8259662",
"0.82582724",
"0.8229427",
"0.822... | 0.7996465 | 68 |
Checks if the game is over | def over?(board)
if won?(board) != nil || draw?(board) == true || full?(board) == true
return true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def over?\n \t@game_over = true\n end",
"def game_over?\n true\n end",
"def gameIsOver\n\t\treturn frameNumber() > @lastFrameNumber\n\tend",
"def game_is_over?\n (won? || draw? || full?) ? true : false\n end",
"def is_game_over?\n @guesses_left == 0 ? true : false\n end",... | [
"0.88333607",
"0.8590218",
"0.8151043",
"0.79258764",
"0.79219586",
"0.77985543",
"0.7792691",
"0.7785024",
"0.7776543",
"0.77477103",
"0.77462107",
"0.7735486",
"0.77299714",
"0.7725193",
"0.76903224",
"0.7660192",
"0.76473826",
"0.7635126",
"0.76190454",
"0.760411",
"0.7598... | 0.0 | -1 |
Determines the winner character | def winner(board)
token = nil
if won?(board) != nil
win_combo = won?(board)
token = board[win_combo[0]]
end
token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winner\r\n if self.won? != false\r\n if self.current_player == \"X\"\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end\r\n end",
"def winner\n if current_player.marker == \"X\"\n return \"O\"\n else\n return \"X\"\n end\n end",
"def winner\n ... | [
"0.7656798",
"0.76513386",
"0.76442194",
"0.7624948",
"0.7580807",
"0.75474226",
"0.7494515",
"0.7490645",
"0.7487504",
"0.7467412",
"0.7466128",
"0.7454474",
"0.74538106",
"0.7447728",
"0.74302",
"0.7422771",
"0.7404239",
"0.739298",
"0.738655",
"0.7369488",
"0.73688936",
... | 0.0 | -1 |
Defines the play method | def play(board)
until over?(board)
turn(board)
end
if won?(board)
puts "Congratulations #{winner(board)}!"
elsif draw?(board)
puts "Cats Game!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play; end",
"def play \n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n \n end",
"def play\n\tend",
"def get_play() \n # \n end",
"def play\n #calls to all the methods that produce game!\n end",
"def play\n ... | [
"0.8788136",
"0.8709318",
"0.8707516",
"0.8707516",
"0.8707516",
"0.8707516",
"0.86887085",
"0.8660832",
"0.84757596",
"0.81392974",
"0.7930098",
"0.79007024",
"0.78883415",
"0.78712845",
"0.7645855",
"0.74786764",
"0.74786764",
"0.73652244",
"0.73410594",
"0.7333225",
"0.732... | 0.0 | -1 |
Get a string representation of the hash. | def inspect
redacted_string(:inspect)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_str\n digest.to_str\n end",
"def to_s\n digest.to_s\n end",
"def to_s\n return \"#{name} (#{hash})\"\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.t... | [
"0.76881814",
"0.7676476",
"0.7428819",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74127287",
"0.7412003",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
... | 0.0 | -1 |
Get a string representation of the hash. | def to_s
redacted_string(:to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_str\n digest.to_str\n end",
"def to_s\n digest.to_s\n end",
"def to_s\n return \"#{name} (#{hash})\"\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.to_s\n end",
"def to_s\n to_hash.t... | [
"0.76881814",
"0.7676476",
"0.7428819",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74208325",
"0.74127287",
"0.7412003",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
"0.74112666",
... | 0.0 | -1 |
=begin input: string output: return: hash with 3 keys (symbolss), each with an integer value Rules: 1. neither includes spaces, numbers, and any non alphabetic character (an else case) 2. Mental Model: The method should take a string, determine how many characters in tehs tring fall into the following catagories: lowercase uppercase neither and then return its findings in a hash. High level Plan: 1. Have to iterate through the string 2. For each character, determine if it is currently uppercase, currently lowercase, or neither 3. Tally results to variables made in the method: lowercase, uppercase, neither 4. Return a hash with the results converted into percentages =end | def letter_percentages(string)
lowercase = 0.0
uppercase = 0.0
neither = 0.0
string.each_char do |char|
if char.upcase == char && char.downcase == char
neither += 1
elsif char.downcase == char
lowercase += 1
else
uppercase += 1
end
end
l_perc = ((lowercase / string.size) * 100).round(2)
u_perc = ((uppercase / string.size) * 100).round(2)
n_perc = ((neither / string.size) * 100).round(2)
{ lowercase: l_perc, uppercase: u_perc, neither: n_perc }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def letter_percentages(string)\n chars = string.split('')\n\n hash_of_percentages = { lowercase: 0.0, uppercase: 0.0, neither: 0.0}\n hash_of_percentages = calculate_chars(chars, hash_of_percentages)\n\n total_chars = chars.length\n hash_of_percentages = calculate_percentages(hash_of_percentages, total_chars)... | [
"0.7751008",
"0.774902",
"0.76793355",
"0.75069875",
"0.7474926",
"0.7473952",
"0.7456342",
"0.7409821",
"0.73228246",
"0.72809136",
"0.72513366",
"0.7246369",
"0.72456235",
"0.7237192",
"0.72351784",
"0.72312474",
"0.72057855",
"0.7199952",
"0.7182809",
"0.7176739",
"0.71724... | 0.72262347 | 16 |
return nil if nothing is possible return [] if we already are at the solution return [] if it leads to the solution | def solve
return [] if @current_state.achieved?(@objective)
return nil if @remaining_rounds <= 0
possible_transformations = @transformations.select { |transformation| @current_state.can_apply?(transformation) }
sorted_transformations = possible_transformations.sort_by do |transformation|
future_state = @current_state.dup.apply(transformation)
future_state.distance_of(@objective)
end
return nil if sorted_transformations.empty?
sorted_transformations.lazy.map do |transformation|
elapsed_rounds = @opts[:max_rounds] - @remaining_rounds - 1
future_state = apply(transformation, elapsed_rounds)
return nil unless future_state # apply can returns nil in case of error
world = World.new(@transformations, @objective, @remaining_rounds - 1, future_state, @opts)
res = world.solve
[transformation] + res if res
end.select(&:itself).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve\n loop { break if !shift }\n return @solutions\n end",
"def solve\n\t\tres = solveRec()\n\t\treturn res if res == [-1]\n\t\twhile ((nextIter = solveRec()) != [])\n\t\t\tres += nextIter\n\t\tend\n\n\t\treturn res;\n\tend",
"def find_solution(possibilities, *rest)\n return [possibilit... | [
"0.7391831",
"0.68832344",
"0.6861673",
"0.6827363",
"0.6776612",
"0.6646918",
"0.6512193",
"0.6473017",
"0.64394724",
"0.6401718",
"0.6400589",
"0.6383608",
"0.63076025",
"0.62394106",
"0.62035704",
"0.61917174",
"0.61199754",
"0.6081624",
"0.60518235",
"0.6049477",
"0.60404... | 0.5888968 | 28 |
Internal method to set 'onpopstate' | def setup_navigation_listener
`window.onpopstate = function(e){#{navigated}}`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_PopState(value)\n set_input(\"PopState\", value)\n end",
"def prePopListener\n end",
"def push_state(url)\n `history.pushState(null,null,#{url})`\n end",
"def back_url\n @back_marked ? session[:back_url] : session[:prev_url]\n end",
"def multicast_redirect_state\n ... | [
"0.6689151",
"0.56181216",
"0.50969064",
"0.50283486",
"0.4995608",
"0.49832082",
"0.4951244",
"0.48994693",
"0.4841977",
"0.47716087",
"0.47504368",
"0.470891",
"0.46988901",
"0.46798736",
"0.46726328",
"0.46726328",
"0.46647143",
"0.4662074",
"0.46310505",
"0.4630788",
"0.4... | 0.7459193 | 0 |
Replace the current location in the web browsers history | def replace_state(url)
`history.replaceState(null,null,#{url})`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_location(target)\n @history.push target\n #TODO change used accessor\n end",
"def change_curr_location(new_location)\n @curr_location = new_location\n end",
"def push path\n `window.history.pushState({}, '', path)`\n end",
"def redirection_history; end",
"def set_current_p... | [
"0.68766177",
"0.6436953",
"0.64049697",
"0.62973773",
"0.62397057",
"0.6188672",
"0.6053626",
"0.60106784",
"0.60071504",
"0.60071504",
"0.60071504",
"0.60071504",
"0.60071504",
"0.60071504",
"0.5996739",
"0.599672",
"0.59691626",
"0.5968651",
"0.5962516",
"0.59584826",
"0.5... | 0.7051933 | 0 |
Add a location to the web browsers history | def push_state(url)
`history.pushState(null,null,#{url})`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_history(page); end",
"def change_location(target)\n @history.push target\n #TODO change used accessor\n end",
"def add_to_history(page)\n @agent.history.push(page, @agent.resolve(page.uri))\n @history_added.call(page) if @history_added\n end",
"def store(location, option = nil)\n ... | [
"0.7358138",
"0.73202723",
"0.7159604",
"0.66620755",
"0.6657427",
"0.63116765",
"0.6284438",
"0.6283216",
"0.62277114",
"0.61940104",
"0.6190323",
"0.61058635",
"0.60785097",
"0.60785097",
"0.60785097",
"0.60785097",
"0.60785097",
"0.60785097",
"0.6009456",
"0.60036004",
"0.... | 0.6133373 | 11 |
Internal method to get the new location | def get_location
Native(`new URL(window.location.href)`)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_location\n\n end",
"def getNewLocation\n @Called = true\n return @Directory\n end",
"def full_location; end",
"def location\n @location\n end",
"def location\n @location\n end",
"def location\n @location\n end",
"def location\n ... | [
"0.75592613",
"0.7244358",
"0.72065985",
"0.7080862",
"0.7080862",
"0.70761865",
"0.7072167",
"0.7043917",
"0.7043654",
"0.69251513",
"0.68816125",
"0.6875807",
"0.68553215",
"0.6784828",
"0.6749976",
"0.6733662",
"0.6712214",
"0.66829103",
"0.6661618",
"0.66544217",
"0.66505... | 0.0 | -1 |
Internal method to split a path into components | def path_to_parts(path)
path.
downcase.
split('/').
map { |part| part.empty? ? nil : part.strip }.
compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_path(path)\n path.split(\"/\", -1)\n end",
"def split_path(path)\n path.strip.split(/[,;:\\ \\n\\t]/).map{|s| s.strip}\n end",
"def split_path; end",
"def split(path)\n array = path.kind_of?(String) ? path.split(\"/\") : path.dup\n array.shift if nil_or_empty_strin... | [
"0.8181835",
"0.8012873",
"0.7936164",
"0.78685725",
"0.7781073",
"0.77353567",
"0.74137187",
"0.7302921",
"0.7302921",
"0.7288107",
"0.72157747",
"0.72128475",
"0.7164902",
"0.71617126",
"0.70750594",
"0.69802403",
"0.69752395",
"0.69627494",
"0.69430786",
"0.69430786",
"0.6... | 0.75469774 | 6 |
URI decode a value | def decode(value)
`decodeURI(#{value})`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_uri(uri)\n return uri unless uri\n CGI::unescape(uri)\n end",
"def urldecode\n _rfc2396_parser.unescape(self)\n end",
"def decode_uri(string)\n string.split(/%2F|%2f/, -1).map { |part| Rack::Utils.unescape(part) }.join('%2F')\n end",
"def url_decode\n Ra... | [
"0.78177595",
"0.76980495",
"0.7338702",
"0.72276324",
"0.71806175",
"0.715031",
"0.7049089",
"0.7049089",
"0.6991325",
"0.6807483",
"0.6807483",
"0.6586104",
"0.6573357",
"0.65445083",
"0.6514469",
"0.64646053",
"0.6422441",
"0.6256452",
"0.62502307",
"0.62445444",
"0.623592... | 0.90954477 | 0 |
Internal method called when the web browser navigates | def navigated
url = get_location
@params = []
idx = match(path_to_parts(decode(url.pathname)), decode(url.search))
if idx
@routes[idx][:callback].call(@params)
else
@page404.call(url.pathname)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_next_page(browser_handle)\n browser_handle.forward\nend",
"def goto_previous_page(browser_handle)\n browser_handle.back\nend",
"def setup_navigation_listener\n `window.onpopstate = function(e){#{navigated}}`\n end",
"def go_back_and_wait\n go_back\n assert_page_loaded\n end",
... | [
"0.64246225",
"0.6381777",
"0.63323754",
"0.62816536",
"0.6242241",
"0.6233357",
"0.6193333",
"0.6177964",
"0.6163251",
"0.6047625",
"0.6047625",
"0.60436213",
"0.6039052",
"0.6030638",
"0.60145897",
"0.60061365",
"0.5994637",
"0.59430635",
"0.592936",
"0.59048367",
"0.589016... | 0.5459341 | 68 |
Internal method to match a path to the most likely route | def match(path, search)
matches = get_matches(path)
if matches.length > 0
match = matches.sort { |m| m[1] }.first
@params = match[2]
add_search_to_params(search)
match[0]
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_for(path)\n @routes.select { |rt| rt.match?(path) }.first\n end",
"def match(path, *rest, &block); end",
"def check candidate_path\n # Convert dynamic segments into regexp captures\n matchable_path = candidate_path.gsub(/:\\w+/, '([^/]+)')\n\n # Don't match a partial segment. For e... | [
"0.7646242",
"0.7139779",
"0.7116168",
"0.7093084",
"0.7071202",
"0.7019358",
"0.7014666",
"0.6884297",
"0.68567955",
"0.6810452",
"0.67491645",
"0.65962106",
"0.658601",
"0.65680826",
"0.6534539",
"0.65337455",
"0.6518144",
"0.6467003",
"0.6368182",
"0.6366013",
"0.6366013",... | 0.60532457 | 45 |
Internal method to match a path to possible routes | def get_matches(path)
matches = []
@routes.each_with_index do |route, i|
score, pars = score_route(route[:parts], path)
matches << [i, score, pars] if score > 0
end
matches
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check candidate_path\n # Convert dynamic segments into regexp captures\n matchable_path = candidate_path.gsub(/:\\w+/, '([^/]+)')\n\n # Don't match a partial segment. For example,\n # don't match /widget for /widgets.\n path.match(Regexp.new(\"^/?#{matchable_path}(?:/|$)\"))\n end",... | [
"0.71672994",
"0.71613914",
"0.7019543",
"0.70165735",
"0.6961692",
"0.6934979",
"0.67968506",
"0.6786419",
"0.6754469",
"0.6751632",
"0.6729685",
"0.66113025",
"0.659491",
"0.65254074",
"0.65252364",
"0.6485615",
"0.6449708",
"0.64435697",
"0.6424552",
"0.642138",
"0.6378447... | 0.0 | -1 |
Internal method to add a match score | def score_route(parts, path)
score = 0
pars = {}
if parts.length == path.length
parts.each_with_index do |part, i|
if part[0] == ':'
score += 1
pars["#{part[1..-1]}"] = path[i]
elsif part == path[i].downcase
score += 2
end
end
end
return score, pars
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_match_results(match)\n if match[0][1] == match[1][1]\n team1 = @teams.find { |team| team.name == match[0][0] }\n team2 = @teams.find { |team| team.name == match[1][0] }\n\n team1.score += 1\n team2.score += 1\n else\n winner = match.max_by { |x| x[1] }\n losser = match.m... | [
"0.75789565",
"0.750347",
"0.7116417",
"0.7053863",
"0.7007865",
"0.7006398",
"0.69690615",
"0.68768346",
"0.68204165",
"0.67341065",
"0.67019635",
"0.6662096",
"0.6658695",
"0.66121",
"0.66076255",
"0.6602516",
"0.6588831",
"0.6580574",
"0.6569579",
"0.65183246",
"0.64988536... | 0.0 | -1 |
Internal method to split search parameters | def add_search_to_params(search)
if !search.empty?
pars = search[1..-1].split('&')
pars.each do |par|
pair = par.split('=')
@params[ pair[0] ] = pair[1] if pair.length == 2
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_params **params\n [\n INTERNAL_PARAMS.each_with_object({}) do |param, acc|\n acc[param] = params.delete(param)\n end.reject { |_, v| v.nil? },\n params\n ]\n end",
"def parse_into_search_elements(key, value)\n # separate value fo... | [
"0.67933905",
"0.65315926",
"0.65315926",
"0.64704525",
"0.6370153",
"0.6298883",
"0.6254132",
"0.6253917",
"0.6253439",
"0.6238441",
"0.62369764",
"0.6232648",
"0.6203322",
"0.6202477",
"0.61954033",
"0.6183716",
"0.6157605",
"0.61460274",
"0.61324835",
"0.61284846",
"0.6123... | 0.6580396 | 1 |
List of usable Geocoder results' methods score => [float] result relevance 0 to 1 location_id => [string] location's IGN UUID result_type => [string] housenumber / street / city / town / village / locality international_address => [string] full address with country code national_address => [string] full address with country code street_address => [string] housenumber + extra inf + street name street_number => [string] housenumber + extra inf (bis, ter, etc) street_name => [string] street's name city_name => [string] city's name city_code => [string] city's INSEE UUID postal_code => [string] city's postal code (used for mails) context => [string] city's department code, department name and region name demartment_name => [string] city's department name department_code => [string] city's department INSEE UUID region_name => [string] city's region name population => [string] city's inhabitants count administrative_weight => [integer] city's importance on a scale from 6 (capital city) to 1 (regular village) | def score
properties['score']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_locations(user_entered_location)\n if user_entered_location.include? \"Arat kilo\"\n user_entered_location = \"4 Kilo\"\n end\n location = user_entered_location.to_s + \" Addis Ababa Ethiopia\"\n location = location.gsub!(\" \", \"+\")\n @google_locations = HTTParty.get(URI... | [
"0.591063",
"0.5773608",
"0.5769401",
"0.5673902",
"0.56585217",
"0.56562275",
"0.55968493",
"0.55710566",
"0.5570537",
"0.55506337",
"0.55289775",
"0.5512404",
"0.54999065",
"0.5490499",
"0.54639167",
"0.54263663",
"0.5403021",
"0.54025173",
"0.53982526",
"0.5381029",
"0.535... | 0.0 | -1 |
Types housenumber street city town village locality | def result_type
properties['type']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spanish_citizen_number; end",
"def from_hospital\n\t\tif @random_number == 1\n\t\t\t@street_used = \"Fourth Ave.\"\n\t\t\t@location = \"Cathedral\"\n\t\telse\n\t\t\t@street_used = \"Foo St.\"\n\t\t\t@location = \"Hillman\"\n\t\tend\n\tend",
"def city number\n case number\n when 1\n 'Cochabamba'\n ... | [
"0.6158953",
"0.6091764",
"0.6055029",
"0.60463816",
"0.6026736",
"0.60184044",
"0.59996223",
"0.5931761",
"0.5886103",
"0.5848185",
"0.5799086",
"0.56939614",
"0.5679219",
"0.5663824",
"0.56569916",
"0.56269103",
"0.56035006",
"0.55884194",
"0.55828494",
"0.5581357",
"0.5572... | 0.0 | -1 |
toggle_snake_case_or_camelCase_or_PascalCase script from Textmate! Test Cases AFooBar > a_foo_bar > aFooBar > AFooBar URLString > url_string > urlString > UrlString TestURLString > test_url_string > testUrlString > TestUrlString test > Test > test test_URL_STRING > testUrlString > TestUrlString > test_url_string HotFlamingCats > hot_flaming_cats | def pascalcase_to_snakecase(word)
word.gsub(/\B([A-Z])(?=[a-z0-9])|([a-z0-9])([A-Z])/, '\2_\+').downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_camel_case\n raise NotImplementedError, 'Undecided as to whether to check camel case or not'\n end",
"def camel_to_snake_case input\n input = input.to_s.dup\n\n # handle camel case like FooBar => Foo_Bar\n while input.gsub!(/([a-z]+)([A-Z])(\\w+)/) { $1 + '_' + $2 + $3 }\n end\n\n # han... | [
"0.67991704",
"0.6782601",
"0.67729706",
"0.67468965",
"0.6700685",
"0.65751606",
"0.656899",
"0.65554976",
"0.6529451",
"0.652132",
"0.6507971",
"0.64878076",
"0.64878076",
"0.64878076",
"0.6487706",
"0.64610773",
"0.64522386",
"0.64181894",
"0.63991207",
"0.6391502",
"0.638... | 0.6521816 | 9 |
Instance method with a paramater obejct "array" | def find(array)
# sorts an array
array.sort! {|x, y| y <=> x}
return array.first.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_array(array)\n # your code here\nend",
"def mutliplied(array)\nend",
"def explore_array(method, *arguments)\n ['a', 'b', 'c'].send(method, *arguments)\nend",
"def array_method(input)\n\treturn \"thanks for the sweet array!\"\nend",
"def array_converter(*args)\n \nend",
"def initialize(arr... | [
"0.75098455",
"0.7253392",
"0.710615",
"0.69710135",
"0.69611764",
"0.69494116",
"0.68843526",
"0.68216336",
"0.67520654",
"0.66637343",
"0.66585475",
"0.66349363",
"0.66335887",
"0.657324",
"0.65386325",
"0.6477976",
"0.64549005",
"0.645464",
"0.6452587",
"0.6431951",
"0.643... | 0.0 | -1 |
Instance Method storing two paramters | def store(kingdom, species)
kingdom_hash= { kingdom[0] => species[0], kingdom[1] => species[1],}
kingdom_hash.each {|key, value| puts "#{key} #{value}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameters=(_); end",
"def params=(_); end",
"def ** other\n #This is a stub, used for indexing\n end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters;... | [
"0.6541865",
"0.64681095",
"0.6386364",
"0.63820666",
"0.63820666",
"0.63820666",
"0.63820666",
"0.63820666",
"0.63820666",
"0.63820666",
"0.63820666",
"0.63438123",
"0.63374305",
"0.63374305",
"0.62972856",
"0.62972856",
"0.62972856",
"0.62972856",
"0.62972856",
"0.62972856",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_coupon
@coupon = Coupon.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def coupon_params
params.require(:coupon).permit(:description, :minimum_value, :percent)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Set the path from the rakefile | def setup(value)
@path = Pathname.new(value.to_s).dirname
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_configure\n super\n @path = File.expand_path(path)\n end",
"def rakefile\n 'Rakefile'\n end",
"def set_path(path)\n path\n end",
"def rakefiles\n @rakefiles ||= ['merb-core/test/tasks/spectasks']\n end",
"def declare_rakefile\n @flavor.class.do_declare_res... | [
"0.65126497",
"0.6166687",
"0.6108955",
"0.5988656",
"0.5939154",
"0.5865694",
"0.58541024",
"0.58541024",
"0.58541024",
"0.5843652",
"0.5825298",
"0.58121264",
"0.5798939",
"0.57927483",
"0.5704158",
"0.567753",
"0.5668338",
"0.56604445",
"0.56075644",
"0.560675",
"0.5600805... | 0.5339577 | 43 |
this entity's humanreadable name. | def label
@params['label']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entity_name_for_human\r\n self.class.name.titleize\r\n end",
"def entity_name(entity)\n entity_value(entity, :full_name, :name, I18n.t('name_missing'))\n end",
"def human_name\n Base.human_attribute_name(@name)\n end",
"def display_name\n NAME\n end",
"def display_name\n... | [
"0.83153",
"0.8169901",
"0.79684806",
"0.79597276",
"0.79597276",
"0.7929305",
"0.7902255",
"0.7902255",
"0.7894623",
"0.786717",
"0.7829233",
"0.78171587",
"0.7815247",
"0.78145367",
"0.78145367",
"0.7725435",
"0.7722546",
"0.7701362",
"0.7672303",
"0.7669247",
"0.762163",
... | 0.0 | -1 |
the URL of this entity's HTML representation. | def html_link
@params['links']['html']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n @url.to_s\n end",
"def url\n uri.to_s\n end",
"def html_url\n self[:html_url]\n end",
"def to_s\n url\n end",
"def to_url\n\t\t\tto_uri.to_s\n\t\tend",
"def to_s; @url; end",
"def url\n uri.to_s\n end",
"def url\n \"http://#{self.do... | [
"0.782387",
"0.7528714",
"0.7508582",
"0.7433896",
"0.7377446",
"0.7310696",
"0.728755",
"0.72706485",
"0.72675604",
"0.722908",
"0.722908",
"0.72110915",
"0.7199622",
"0.7176492",
"0.715977",
"0.715977",
"0.7159447",
"0.71589607",
"0.71510446",
"0.71277046",
"0.71268076",
... | 0.0 | -1 |
the URL of this entity's Contract Collection | def contracts_link
@params['links']['contracts']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collection_url\n super_url(with_chain(resource_class))\n end",
"def url_template\n collection.url_template\n end",
"def serialize_collection(collection)\n url_for(collection)\n end",
"def collection_url\n send route_prefix_to_method_name(\"#{class_name.model_name.ro... | [
"0.7310448",
"0.6837277",
"0.67403346",
"0.6717394",
"0.6703572",
"0.6588721",
"0.65770924",
"0.6541655",
"0.64790326",
"0.64530826",
"0.6445347",
"0.6413919",
"0.6413919",
"0.6404485",
"0.6385168",
"0.6369511",
"0.6368363",
"0.634237",
"0.634237",
"0.6287132",
"0.62852",
"... | 0.6565126 | 7 |
retrieves this entity's Contract Collection | def get_contracts
response = @client.get(contracts_link)
raise Inkdit::Error.new(response) unless response.status == 200
response.parsed['resources'].map do |contract_params|
Contract.new @client, contract_params
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contract; Contract.get(self.contract_id); end",
"def get_contracts\n Contract.where(clan_id: id).order('start_date_time desc')\n end",
"def getCollection\n return @coll\n end",
"def index\n @contracts = Contract.all\n end",
"def index\n @contracts = Contract.all\n end",
"def index... | [
"0.6941805",
"0.6739418",
"0.62141174",
"0.61976844",
"0.61976844",
"0.61976844",
"0.61976844",
"0.61976844",
"0.61777633",
"0.61267436",
"0.61177576",
"0.6097807",
"0.6076897",
"0.60213786",
"0.59947544",
"0.5974277",
"0.5973837",
"0.5880304",
"0.58454317",
"0.58323437",
"0.... | 0.6867404 | 1 |
GET /bookings/1 GET /bookings/1.xml | def show
@booking = Booking.find(params[:id])
church = ( @booking.church_id? ) ? Church.find_by_id(@booking.church_id) : nil
booking = {
'website' => @booking.deputation.missionary.website || '',
'last-modified' => @booking.updated_at.strftime('%Y%m%d'),
'status' => @booking.status,
'date' => @booking.date_of.strftime('%Y%m%d'),
'time' => (@booking.time_of) ? @booking.time_of.strftime('%l:%M %P') : nil,
'email' => @booking.deputation.missionary.email || '',
'outreach' => church.outreach_cities || '',
'church_address' => church.physical_address || church.mailing_address || '',
'church_name' => church.church_name || '',
'pastor' => church.pastor || '',
'fm_deputation_id' => @booking.deputation_id,
'poster' => @booking.deputation.missionary.poster || '',
'labor' => @booking.deputation.missionary.labor,
'church_id' => @booking.church_id,
'name' => @booking.deputation.missionary.name,
'phone' => @booking.deputation.missionary.phone,
'church_phone' => church.phone || '',
'book_id' => @booking.id,
'church_city' => church.physical_city || church.mailing_city,
'meridian' => @booking.meridian,
}
respond_to do |format|
format.xml { render :xml => booking }
format.js { render :json => booking.to_json }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @booking = Booking.find(params[:id])\n \n respond_to do |format|\n format.html \n format.xml { render :xml => @booking }\n end\n end",
"def show\n @booking = @room.bookings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml ... | [
"0.7260729",
"0.72165346",
"0.7115621",
"0.6876188",
"0.6834933",
"0.6826264",
"0.6602576",
"0.6589019",
"0.6587072",
"0.65697455",
"0.6543948",
"0.6543948",
"0.6543948",
"0.6543948",
"0.6543948",
"0.6543948",
"0.6543948",
"0.6543948",
"0.6538266",
"0.6538266",
"0.6538266",
... | 0.0 | -1 |
GET /tire_stores GET /tire_stores.json | def index
#@tire_stores = TireStore.paginate(page: params[:page])
####@tire_stores = TireStore.search(params)
####@tire_stores = @tire_stores.paginate(page: params[:page]) unless @tire_stores.nil?
begin
if session[:showed_mobile_notice].blank? || session[:showed_mobile_notice].to_i < 10
@show_mobile_notice = true
session[:showed_mobile_notice] = session[:showed_mobile_notice].to_i + 1
else
@show_mobile_notice = false
end
rescue Exception => e
@show_mobile_notice = true
end
@location = keywords = ""
@radius = 0
@location = params[:Location] if !params.nil?
if @location.nil?
if session[:location].blank?
# let's try to set based on geoip
begin
loc = []
i = 0
while loc.empty? && i <= 5
loc = Geocoder.search(request.remote_ip)[0]
i += 1
end
if loc && !loc.city.blank?
@location = loc.city + ', ' + loc.state
session[:location] = @location
end
rescue
puts "**** EXCEPTION"
end
else
@location = session[:location]
end
end
@radius = params[:Radius] if !params.nil?
if @radius.nil?
if session[:radius].blank?
@radius = 10
else
@radius = session[:radius]
end
end
keywords = params[:Keywords] if !params.nil?
if keywords.nil?
keywords = ""
end
@lc = LearningCenter.new
@brand_seo = @lc.seo_tires_stores_search_results_page_posts
# DG 7/22/15 - New functionality to change how the page looks when searching on a city and state.
@page_mode = 'location'
unless @location.blank?
city_match = /\A([[:alpha:]](?:[[:alpha:]]|[-. ])+),\s+([A-Za-z]{2})\z/.match(@location.strip)
if city_match
@page_mode = 'city'
@city = city_match[1].strip
@state = city_match[2].upcase
@location = "#{@city}, #{@state}"
end
end
session[:location] = @location
session[:radius] = @radius
if !params.nil? && !params[:th_only].nil? && params[:th_only].downcase == "true"
@tire_stores = TireStore.search(params)
if @tire_stores.nil? || @tire_stores.size == 0
@tire_stores = ScrapeTireStore.search_all_stores_by_location(@location, @radius, keywords, params[:page], 50)
end
else
@tire_stores = ScrapeTireStore.search_all_stores_by_location(@location, @radius, keywords, params[:page], 50)
end
@tire_stores = @tire_stores.paginate(page: params[:page]) unless @tire_stores.nil?
if !@tire_stores.nil? && @tire_stores.size == 1 && @tire_stores.first.th_customer
redirect_to @tire_stores.first
else
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tire_stores }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @stores = Store.all\n render json: @stores\n end",
"def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end",
"def index\n if current_user.admin?\n @stores = Store.all\n else\n @stores = current_user.stores\n end\n\n render json: @store... | [
"0.7146562",
"0.6988783",
"0.6805394",
"0.66338974",
"0.6581642",
"0.6547985",
"0.6525458",
"0.6482716",
"0.6482286",
"0.6469146",
"0.64388716",
"0.6427096",
"0.64051324",
"0.6402812",
"0.6402812",
"0.6402812",
"0.6402812",
"0.6402812",
"0.63842523",
"0.6351903",
"0.6330536",... | 0.0 | -1 |
GET /tire_stores/1 GET /tire_stores/1.json | def show
@search_mode = false #true if we came here from a tire search
@default_tab = 1
# DG 7/16/15 - commented this out since it no longer applies
#if (!session[:diameter].blank?)
# @default_tab = 2
#else
# @default_tab = 1
#end
# we don't currently have an in-house review system...
@th_reviews_available = false
if !params[:inline_search].blank?
if params[:inline_search].downcase == "true"
session[:inline_search] = "true"
else
session[:inline_search] = nil
end
end
@diameters = TireSize.all_diameters
@ratios = TireSize.all_ratios(session[:diameter])
@wheeldiameters = TireSize.all_wheeldiameters(session[:ratio])
Rack::MiniProfiler.step("load store and get params") do
@tire_store = TireStore.find(params[:id]) unless @tire_store
@tire_store.tire_size_id = params[:tire_size_id]
impressionist(@tire_store)
# DG 7/16/15 - commented this out since it no longer applies
#get_search_params_and_store_defaults() # if params[:auto_search] || params[:size_search] || params[:tire_size_id]
@reservations = @tire_store.reservations.paginate(page: params[:page])
if params[:ajax_mode]
@ajax_mode = params[:ajax_mode].to_s.to_bool
else
@ajax_mode = true
end
end
# find nearby stores with reviews.
### @nearby_google_stores = TireStore.near([@tire_store.latitude, @tire_store.longitude], 20).limit(2).where("(EXIST(google_properties, 'google_place_id')=TRUE)'))")
# DG 7/16/15 - For now, ignore any search params unless they came with a tire_search id.
#We might use the id to provide a link back to the tire search results page.
if !params[:tire_search].blank?
#We've arrived on the tire store page from a tire search.
#Rack::MiniProfiler.step("get tire search params") do
@search_mode = true
@tire_search_id = params[:tire_search].to_i
get_search_params_and_query_string()
#end
end
Rack::MiniProfiler.step("load tirelistings from db") do
if params[:tab] && params[:tab].downcase == "used" && @tire_store.has_new_and_used?
@tire_listings = @tire_store.used_tirelistings
elsif params[:tab] && params[:tab].downcase == "new" && @tire_store.has_new_and_used?
@tire_listings = @tire_store.new_tirelistings
else
@tire_listings = @tire_store.tire_listings
end
end
# DG 7/16/15 - commented this out since it no longer applies
#@refine_tire_search = TireSearch.new
#@auto_manufacturers = AutoManufacturer.order("name")
#@models = AutoModel.where(:auto_manufacturer_id => session[:manufacturer_id])
#@years = AutoYear.where(:auto_model_id => session[:auto_model_id])
#@options = AutoOption.where(:auto_year_id => session[:auto_year_id])
Rack::MiniProfiler.step("mapping stuff a") do
@tire_stores, @quantities, @tire_manufacturers, @categories, @sellers, @pictures, @conditions, @wheelsizes = create_mappings_turbo(@tire_listings)
#@tire_stores, @quantities, @tire_manufacturers, @categories, @sellers, @pictures, @conditions, @wheelsizes = create_mappings(@tire_listings)
@can_edit = edit_access
end
Rack::MiniProfiler.step("mapping stuff b") do
if @tire_store.storefront_assets.count > 0
@photos = @tire_store.storefront_assets.map{ |x| {:img => x.image.to_s, :caption => x.caption, :url => x.url}}
end
end
Rack::MiniProfiler.step("mapping stuff c") do
if @tire_store.promotion_assets.count > 0
@promotions = @tire_store.promotion_assets.map{ |x| {:img => x.image.to_s, :caption => x.caption, :url => x.url}}
end
end
Rack::MiniProfiler.step("phone image") do
if @tire_store.private_seller?
t = TextToGIF.new()
@phone_image = t.create_phone_gif_for_tire_store(@tire_store)
end
end
Rack::MiniProfiler.step("loading search data (not anymore) and branding") do
# DG 7/16/15 - commented this out since it no longer applies
#load_default_search_data
@branding = Branding.find_or_create_by_tire_store_id(@tire_store.id)
if @branding.slogan.to_s.size > 0 && @branding.slogan_description.to_s.size > 0
@slogan = @branding.slogan
@slogan_description = @branding.slogan_description
else
@slogan = "Featured Tires"
@slogan_description = "Here are some of the tires we feature at #{@tire_store.name}."
end
end
@contact_seller = ContactSeller.new(:id => 1,
:email => signed_in? ? current_user.email : '',
:sender_name => signed_in? ? current_user.first_name + ' ' + current_user.last_name : "",
:tire_store_id => @tire_store.id)
if @tire_store.private_seller?
if signed_in? && (super_user? or current_user.account_id == @tire_store.account_id) then
@submenu = Hash.new
@submenu[:menu] = "Edit"
@submenu[:items] = []
@submenu[:items] << {href: "/tire_listings/new?tire_store_id=" + @tire_store.id.to_s, link: "Create a new listing"}
@submenu[:items] << {href: "/tire_stores/#{@tire_store.id}/edit", link: "Edit Seller Information"}
render :show_private
return
else
redirect_to '/', :notice => "You do not have permission to view this page."
return
end
end
if signed_in? && (super_user? or current_user.account_id == @tire_store.account_id) then
@submenu = Hash.new
@submenu[:menu] = "Create Listings"
@submenu[:items] = []
@submenu[:items] << {href: "/tire_listings/new?tire_store_id=" + @tire_store.id.to_s, link: "Create a new listing"}
if !@tire_store.private_seller?
@submenu[:items] << {href: "/new_multiple?tire_store_id=" + @tire_store.id.to_s, link: "Create Multiple New Tire Listings"}
@submenu[:items] << {href: "/generic_tire_listings/new?tire_store_id=" + @tire_store.id.to_s, link: "Create Bulk Used Tire Listings"}
@submenu[:items] << {href: edit_tire_store_path(@tire_store), link: "Edit Store Information"}
end
end
# DG 8/6/15 - Setup appointment object for appointment modal
@appointment = Appointment.new
if !current_user.nil?
@appointment.user_id = current_user.id if @appointment.user_id.blank?
@appointment.buyer_name = current_user.name if @appointment.buyer_name.blank?
@appointment.buyer_email = current_user.email if @appointment.buyer_email.blank?
@appointment.buyer_phone = current_user.phone if @appointment.buyer_phone.nil?
@appointment.buyer_address = "" # current_user.address if @appointment.buyer_address.nil?
@appointment.buyer_city = "" # current_user.city if @appointment.buyer_city.nil?
@appointment.buyer_state = "" # current_user.state if @appointment.buyer_state.nil?
@appointment.buyer_zip = "" # current_user.zipcode if @appointment.buyer_zip.nil?
end
if !params[:auto_options_id].blank?
option = AutoOption.find(params[:auto_options_id])
if option
@appointment_auto = option.auto_year.modelyear + ' ' +
option.auto_year.auto_model.auto_manufacturer.name + ' ' +
option.auto_year.auto_model.name + ' ' +
option.name
@appointment.auto_option_id = option.id
@appointment.auto_year_id = option.auto_year_id
@appointment.auto_model_id = option.auto_year.auto_model_id
@appointment.auto_manufacturer_id = option.auto_year.auto_model.auto_manufacturer_id
end
end
@appointment.request_hour_primary = '12:00' #default to 12 noon (if available)
@appointments = {}
@appt_counts = Appointment.store_appointments_by_day(@tire_store.id, Date.today, Date.today + 30.days)
@primary_hours = @tire_store.hours_array_for_date(@appointment.request_date_primary)
@secondary_hours = @tire_store.hours_array_for_date(@appointment.request_date_secondary)
@ar_months = Date::MONTHNAMES.each_with_index.collect{|m, i| [m, i.to_s.rjust(2, '0')]}
@ar_years = [*Date.today.year..Date.today.year + 8]
# 3/6/13 ksi Clean this mess up...
if in_storefront?
if @tire_search && @branding.template_number == 4
ourtires()
respond_to do |format|
format.html {redirect_to params.merge!(:action => :ourtires) }
end
else
respond_to do |format|
case @branding.template_number
when 1
format.html
when 2
format.html { render :show_storefront } #, :layout => 'storefront' }
when 3
format.html { render :show_storefront_slidetabs } #, :layout => 'storefront' }
else
format.html { render :show_storefront_traditional } #, :layout => 'storefront' }
end
end
end
else
@turbo_mode = true # (params[:turbo].to_s > "")
if @turbo_mode && !@ajax_mode
Rack::MiniProfiler.step("JSONify") do
@json = @tire_listings.to_json(:root => true,
#:except => [:price, :teaser, :description],
:only => [:id, :is_new, :tire_manufacturer_id, :treadlife, :quantity],
#:include => [:tire_manufacturer],
:methods => [:cost_per_tire, :tire_category_id, :wheelsize]
)
end
else
@json = ''
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @tire_store, :methods => [:sunday_open, :sunday_close, :monday_open, :monday_close, :tuesday_open, :tuesday_close, :wednesday_open, :wednesday_close, :thursday_open, :thursday_close, :friday_open, :friday_close, :saturday_open, :saturday_close, :closed_all_day_array, :open_all_day_array, :realtime_quote_distributors, :logo_url, :th_customer] }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end",
"def index\n @stores = Store.all\n render json: @stores\n end",
"def show\n\t\t\t\t @store = Spree::Store.find(params[:id])\n\t\t\t\t respond_to do |format|\n\t\t\t\t format.html # show.html.erb\n\t\t\... | [
"0.70283157",
"0.68286145",
"0.6551209",
"0.64995664",
"0.64995664",
"0.64995664",
"0.64995664",
"0.64448446",
"0.6416645",
"0.6416391",
"0.640845",
"0.6400594",
"0.6354719",
"0.63399225",
"0.63331324",
"0.6265134",
"0.62006927",
"0.61958295",
"0.6168858",
"0.61637276",
"0.61... | 0.0 | -1 |
GET /tire_stores/new GET /tire_stores/new.json | def new
if params[:account].nil? || params[:account] == ''
if current_user.nil? || current_user.account.nil?
redirect_to '/', :notice => "You do not have permission to create a storefront."
else
redirect_to current_user.account, :notice => "You must create a store from an account page."
end
return
end
@account = Account.find(params[:account])
if !@account.tire_stores.first.nil? && @account.tire_stores.first.private_seller?
redirect_to '/myTreadHunter', :notice => "Private sellers cannot create storefronts."
return
end
@tire_store = TireStore.new
@tire_store.account_id = @account.id
@tire_store.name = @account.name
@tire_store.address1 = @account.address1
@tire_store.address2 = @account.address2
@tire_store.phone = @account.phone
@tire_store.city = @account.city
@tire_store.state = @account.state
@tire_store.zipcode = @account.zipcode
unless @account.nil?
@tire_store.affiliate_id = @account.affiliate_id
@tire_store.affiliate_time = @account.affiliate_time
@tire_store.affiliate_referrer = @account.affiliate_referrer
end
@branding = Branding.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @tire_store }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store }\n end\n end",
"def new\n @store = Store.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @store }\n end\n end"... | [
"0.7590489",
"0.7590489",
"0.7590489",
"0.7590489",
"0.7590489",
"0.75457627",
"0.7528746",
"0.73114103",
"0.7265047",
"0.70079035",
"0.6979102",
"0.6951111",
"0.6949274",
"0.6922726",
"0.68970406",
"0.6870072",
"0.68540627",
"0.68535376",
"0.68499583",
"0.68463695",
"0.68415... | 0.6513707 | 78 |
POST /tire_stores POST /tire_stores.json | def create
@tire_store = TireStore.new(params[:tire_store].except(:account_id))
@tire_store.account_id = params[:tire_store][:account_id]
respond_to do |format|
begin
if has_create_access && @tire_store.save
@branding = Branding.find_or_create_by_tire_store_id(@tire_store.id)
if !@branding.nil? && params[:branding] && !params[:branding][:logo].blank?
@branding.update_attributes(params[:branding])
@branding.save
end
format.html { redirect_to @tire_store, notice: 'Tire store was successfully created.' }
format.json { render json: @tire_store, status: :created, location: @tire_store }
else
puts '**** CREATE has_create_access failed or save failed'
if params[:ajax_input]
else
format.html { render action: "new" }
format.json { render json: @tire_store.errors, status: :unprocessable_entity }
end
end
if params[:ajax_input]
format.json { render json: "OK"}
else
redirect_to @tire_store, notice: 'Tire store was successfully created.'
return
end
rescue Exception => e
puts "Error creating tire store."
puts "Exception: #{e.message}"
e.backtrace.each do |msg|
puts msg
end
format.html { redirect_to '/myTreadHunter', notice: 'Error creating tire store.'}
return
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(add_params = nil)\n params = {\n }\n api_call('/stores(.:format)',:post,params,add_params)\n end",
"def create\n @store = Store.new(params.require(:store).permit(:break_even, :capacity, :city, :county_id, :manager_id,\n :name, :number, :number_of_lifts, :pho... | [
"0.68744767",
"0.64386475",
"0.6425761",
"0.6405601",
"0.6397078",
"0.6384877",
"0.6331688",
"0.6312649",
"0.6300466",
"0.6300466",
"0.6265209",
"0.6245127",
"0.6195852",
"0.61646795",
"0.60620606",
"0.60449713",
"0.6021153",
"0.59524715",
"0.5896364",
"0.5874865",
"0.5867085... | 0.57033086 | 33 |
PUT /tire_stores/1 PUT /tire_stores/1.json | def update
if correct_ts_user
@tire_store = TireStore.find(params[:id]) unless @tire_store
respond_to do |format|
if @tire_store.update_attributes(params[:tire_store])
##puts "---->>>>> here <<<<<<------#{params[:closed_sunday]}"
if !params[:open_24_hrs_monday].blank?
@tire_store.monday_open = "00:00"
@tire_store.monday_close = "23:59"
elsif !params[:closed_monday].blank?
@tire_store.monday_open = ""
@tire_store.monday_close = ""
elsif params[:tire_store][:monday_open].blank? && params[:tire_store][:monday_closed].blank?
@tire_store.google_properties["monday_open"] = " "
@tire_store.google_properties["monday_close"] = " "
end
if !params[:open_24_hrs_tuesday].blank?
@tire_store.tuesday_open = "00:00"
@tire_store.tuesday_close = "23:59"
elsif !params[:closed_tuesday].blank?
@tire_store.tuesday_open = ""
@tire_store.tuesday_close = ""
elsif params[:tire_store][:tuesday_open].blank? && params[:tire_store][:tuesday_closed].blank?
@tire_store.google_properties["tuesday_open"] = " "
@tire_store.google_properties["tuesday_close"] = " "
end
if !params[:open_24_hrs_wednesday].blank?
@tire_store.wednesday_open = "00:00"
@tire_store.wednesday_close = "23:59"
elsif !params[:closed_wednesday].blank?
@tire_store.wednesday_open = ""
@tire_store.wednesday_close = ""
elsif params[:tire_store][:wednesday_open].blank? && params[:tire_store][:wednesday_close].blank?
@tire_store.google_properties["wednesday_open"] = " "
@tire_store.google_properties["wednesday_close"] = " "
end
if !params[:open_24_hrs_thursday].blank?
@tire_store.thursday_open = "00:00"
@tire_store.thursday_close = "23:59"
elsif !params[:closed_thursday].blank?
@tire_store.thursday_open = ""
@tire_store.thursday_close = ""
elsif params[:tire_store][:thursday_open].blank? && params[:tire_store][:thursday_close].blank?
@tire_store.google_properties["thursday_open"] = " "
@tire_store.google_properties["thursday_close"] = " "
end
if !params[:open_24_hrs_friday].blank?
@tire_store.friday_open = "00:00"
@tire_store.friday_close = "23:59"
elsif !params[:closed_friday].blank?
@tire_store.friday_open = ""
@tire_store.friday_close = ""
elsif params[:tire_store][:friday_open].blank? && params[:tire_store][:friday_close].blank?
@tire_store.google_properties["friday_open"] = " "
@tire_store.google_properties["friday_close"] = " "
end
if !params[:open_24_hrs_saturday].blank?
@tire_store.saturday_open = "00:00"
@tire_store.saturday_close = "23:59"
elsif !params[:closed_saturday].blank?
@tire_store.saturday_open = ""
@tire_store.saturday_close = ""
elsif params[:tire_store][:saturday_open].blank? && params[:tire_store][:saturday_close].blank?
@tire_store.google_properties["saturday_open"] = " "
@tire_store.google_properties["saturday_close"] = " "
end
if !params[:open_24_hrs_sunday].blank?
@tire_store.sunday_open = "00:00"
@tire_store.sunday_close = "23:59"
elsif !params[:closed_sunday].blank?
@tire_store.sunday_open = ""
@tire_store.sunday_close = ""
elsif params[:tire_store][:sunday_open].blank? && params[:tire_store][:sunday_close].blank?
@tire_store.google_properties["sunday_open"] = " "
@tire_store.google_properties["sunday_close"] = " "
end
if !params[:online_payments].blank? && params[:online_payments] == "0"
if !@tire_store.stripe_account_record.nil?
# need to update to no stripe record....
@tire_store.stripe_account_id = ""
end
elsif !params[:stripeAccountToken].blank?
if @tire_store.stripe_account_record.nil?
begin
@tire_store.update_stripe_recipient_data_bank_account(params[:stripeBusinessName],
params[:stripeBusinessType], params[:stripeTaxID], params[:stripeAccountToken])
rescue Exception => e
puts "got an error in update_stripe_recipient_data_bank_account"
flash[:alert] = e.to_s
end
else
# just need to update
@tire_store.update_stripe_recipient_data_bank_account(params[:stripeBusinessName],
params[:stripeBusinessType], params[:stripeTaxID], params[:stripeAccountToken])
end
end
@tire_store.save
# now do promotions
@promotions = Promotion.store_only_promotions(@tire_store, 'all').order('id')
if @promotions.nil?
@promotions = []
end
@deals = params[:deals]
if @deals.nil?
@deals = []
end
@promo_ids_to_delete = []
if @promotions.length != @deals.length
# if there are zero promotions, the @deals will have a blank deal first
if (@promotions.length == 0 && @deals.length == 1 && @deals.first.blank?)
# do nothing...there are no 'real' promotions
else
# there is a difference in size...so we need to update.
# process the ones that match up
(0..@promotions.length - 1).each do |i|
if @deals[i].blank?
# delete the promotion
@promo_ids_to_delete << @promotions[i].id
elsif @deals[i] != @promotions[i].promo_name
@promotions[i].update_attribute(:promo_name, @deals[i])
end
end
# process the ones that are existing promotions but no longer
# in deals (they were deleted)
(@deals.length..@promotions.length - 1).each do |i|
@promo_ids_to_delete << @promotions[i].id
end
# process the ones that are in deals but not in
# existing promotions (they were added)
(@promotions.length..@deals.length - 1).each do |i|
p = Promotion.new
p.promo_name = @deals[i]
p.promotion_type = "O"
p.promo_level = "A"
p.account_id = @tire_store.account_id
p.add_tire_store_id_to_promotion(@tire_store.id)
p.description = p.promo_name
p.start_date = Date.today
p.end_date = p.start_date + 1.year
p.new_or_used = "N"
p.save
end
end
else
# they are the same...update or delete as needed
(0..@promotions.length - 1).each do |i|
if @deals[i].blank?
# delete the promotion
@promo_ids_to_delete << @promotions[i].id
elsif @deals[i] != @promotions[i].promo_name
@promotions[i].update_attribute(:promo_name, @deals[i])
end
end
end
# delete the ones that need to go
@promo_ids_to_delete.each do |id|
Promotion.find(id).destroy
end
if @tire_store.private_seller?
store_type = 'Listing info'
else
store_type = 'Tire store'
end
begin
@tire_store.branding.update_attributes(params[:branding])
rescue
end
if params[:return_to_storefront].blank?
format.html { redirect_to @tire_store,
notice: "#{store_type} was successfully updated." }
else
format.html { redirect_to "/storefront/#{@tire_store.id}/edit",
notice: "Hours were successfully updated." }
end
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @tire_store.errors, status: :unprocessable_entity }
end
end
else
redirect_to root_path, :alert => "You do not have access to that page."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @store.update(store_params)\n render json: @store\n else\n render json: @store.errors, status: :unprocessable_entity\n end\n end",
"def update\n begin\n @api_v1_store.update!(api_v1_store_params)\n head :no_content\n rescue => ex\n json_response({error: ex... | [
"0.64617676",
"0.6383121",
"0.62021476",
"0.6176558",
"0.61430913",
"0.6140409",
"0.6140409",
"0.6140409",
"0.6140409",
"0.6131284",
"0.6108372",
"0.60702664",
"0.60459983",
"0.6019512",
"0.6019512",
"0.5958364",
"0.59274614",
"0.5925576",
"0.59149545",
"0.5909926",
"0.589479... | 0.0 | -1 |
DELETE /tire_stores/1 DELETE /tire_stores/1.json | def destroy
if correct_ts_user
@tire_store = TireStore.find(params[:id]) unless @tire_store
@tire_store.destroy
respond_to do |format|
ref_url = request.referer
if ref_url.include?("?")
ref_url += "&start_tab=my_stores"
else
ref_url += "?start_tab=my_stores"
end
format.html { redirect_to ref_url }
format.json { head :no_content }
end
else
redirect_to root_path, :alert => "You do not have access to that page."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\t\t\t\t @store = Store.find(params[:id])\n\t\t\t\t @store.destroy\n\n\t\t\t\t respond_to do |format|\n\t\t\t\t format.html { redirect_to stores_url }\n\t\t\t\t format.json { head :no_content }\n\t\t\t\t end\n\t\t\t\t end",
"def destroy\n @store = Store.find(params[:id])\n ... | [
"0.72023225",
"0.7201451",
"0.718442",
"0.718442",
"0.718442",
"0.718442",
"0.7155323",
"0.7155323",
"0.7155323",
"0.7155323",
"0.7058996",
"0.703534",
"0.70120156",
"0.7002063",
"0.69799566",
"0.697958",
"0.6975334",
"0.6954616",
"0.6950952",
"0.6894878",
"0.6894878",
"0.6... | 0.6921481 | 19 |
DG 7/16/15 New way of getting search params from a tire search page The query string is used for ajax pagination calls. Invalid parameters mean the search query will be ignored. | def get_search_params_and_query_string
if !params[:tire_model_id].blank?
@tire_store.tire_model_id = params[:tire_model_id]
@search_query = "tire_model_id=#{params[:tire_model_id].to_i}"
else
if !params[:auto_options_id].blank?
option = AutoOption.find(params[:auto_options_id])
@tire_store.tire_size_id = option.tire_size_id if option
elsif !params[:width].blank? && !params[:ratio].blank? && !params[:wheeldiameter].blank?
# check and make sure the size is valid
ts = TireSize.find_by_sizestr("#{params[:width].to_i}/#{params[:ratio].to_i}R#{params[:wheeldiameter].to_i}")
@tire_store.tire_size_id = ts.id if ts
end
if @tire_store.tire_size_id
@search_query = "tire_size_id=#{@tire_store.tire_size_id}"
#Don't include the manufacturer filter unless we have a valid size search going
if !params[:tire_manufacturer_id].blank?
@tire_store.tire_manufacturer_id_filter = params[:tire_manufacturer_id]
@search_query += "&tire_manufacturer_id_filter=#{params[:tire_manufacturer_id].to_i}"
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_param\n return unless search_query\n \"search=#{search_query}&phrase=true\"\n end",
"def search_params\n if params[:q] == nil\n params[:q] = session['search_key']\n end\n if params[:q]\n session['search_key'] = params[:q]\n end\n params[:q]\n end",
"def query_params\n... | [
"0.7348077",
"0.7065558",
"0.7010415",
"0.6956245",
"0.69451517",
"0.6905907",
"0.68617374",
"0.686162",
"0.6843477",
"0.6821251",
"0.6784119",
"0.67204905",
"0.6704062",
"0.6694109",
"0.6691044",
"0.6682516",
"0.667464",
"0.66576785",
"0.65980923",
"0.65980923",
"0.65980923"... | 0.79224753 | 0 |
DG 7/16/15 this method is no longer used | def get_search_params_and_store_defaults
# basic error checking
@tire_search = get_tire_search_from_params
size_search = false
auto_search = false
size_search = true if !params[:size_search].blank?
auto_search = true if !params[:auto_search].blank?
if !size_search && !auto_search
# let's figure out which one it actually is
if !params[:auto_manufacturer_id].blank? && !params[:auto_model_id].blank? &&
!params[:auto_year_id].blank? && !params[:option_id].blank?
auto_search = true
elsif !params[:width].blank? && !params[:ratio].blank? && !params[:wheeldiameter].blank?
size_search = true
# check and make sure the size is valid
ts = TireSize.find_by_sizestr("#{params[:width].to_i}/#{params[:ratio].to_i}R#{params[:wheeldiameter].to_i}")
if !ts
@tire_search = nil
return
end
elsif params[:tire_size_id].blank? && params[:tire_size_str].blank?
@tire_search = nil
return
end
end
begin
if auto_search
option = AutoOption.find(@tire_search.auto_options_id) unless @tire_search.auto_options_id.blank?
@tire_search.tire_size_id = option.tire_size_id if option
session[:manufacturer_id] = @tire_search.auto_manufacturer_id
session[:auto_model_id] = @tire_search.auto_model_id
session[:auto_year_id] = @tire_search.auto_year_id
session[:option_id] = @tire_search.auto_options_id
session[:diameter] = nil
@tire_search.tire_size.diameter = nil
session[:ratio] = nil
@tire_search.tire_size.ratio = nil
session[:wheeldiameter] = nil
@tire_search.tire_size.wheeldiameter = nil
else
unless @tire_search.tire_size.nil?
sizestr = sprintf('%g', @tire_search.tire_size.diameter.blank? ? 0 : @tire_search.tire_size.diameter) +
'/' + sprintf('%g', @tire_search.tire_size.ratio.blank? ? 0 : @tire_search.tire_size.ratio) +
'R' + sprintf('%g', @tire_search.tire_size.wheeldiameter.blank? ? 0 : @tire_search.tire_size.wheeldiameter)
end
ts = TireSize.find_by_sizestr(sizestr)
if ts
@tire_search.tire_size_id = ts.id
else
@tire_search.tire_size_id = 0
end
session[:manufacturer_id] = nil
@tire_search.auto_manufacturer_id = nil
session[:auto_model_id] = nil
@tire_search.auto_model_id = nil
session[:auto_year_id] = nil
@tire_search.auto_year_id = nil
session[:option_id] = nil
@tire_search.auto_options_id = nil
session[:diameter] = @tire_search.tire_size.diameter unless @tire_search.tire_size.nil?
session[:ratio] = @tire_search.tire_size.ratio unless @tire_search.tire_size.nil?
session[:wheeldiameter] = @tire_search.tire_size.wheeldiameter unless @tire_search.tire_size.nil?
end
@tire_store.tire_size_id = @tire_search.tire_size_id
session[:location] = @tire_search.locationstr unless @tire_search.locationstr.blank?
session[:radius] = @tire_search.radius unless @tire_search.radius.blank?
session[:quantity] = @tire_search.quantity.to_s
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def refutal()\n end",
"def suivre; end",
"def internal; end",
"def terpene; end",
"def celebration; end",
"def used?; end",
"def implementation; end"... | [
"0.7629267",
"0.64383227",
"0.6379205",
"0.61056393",
"0.61056393",
"0.61056393",
"0.61056393",
"0.6045718",
"0.59759706",
"0.5892773",
"0.5829105",
"0.58238846",
"0.5812003",
"0.5798607",
"0.5798607",
"0.57983345",
"0.57954717",
"0.57954717",
"0.57250935",
"0.57235736",
"0.5... | 0.0 | -1 |
I worked on this challenge [by myself, with: ]. 2. Review the simple assert statement | def assert
raise "Assertion failed!" unless yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_equal(actual, expected)\n\tif actual == expected\n\t\tputs \"pass\"\n\telse\n\t\tputs \"fail\"\nend\n \nassert_equal(1,1) #=> pass\nassert_equal(2,1) #=> fail\n \n# Use assert to test the following:\n \n# define a method to sum the values of an array. Make this method defend against nils and\n# other er... | [
"0.7760811",
"0.74990064",
"0.7297621",
"0.7297621",
"0.7297621",
"0.7297621",
"0.7297621",
"0.7273203",
"0.7273203",
"0.726893",
"0.7259826",
"0.72106665",
"0.72106665",
"0.7194669",
"0.71945566",
"0.71879447",
"0.71360546",
"0.7067064",
"0.7059411",
"0.7059411",
"0.70521176... | 0.0 | -1 |
4. Convert your driver test code from that challenge into Assert Statements | def assert
raise "Assertion failed" unless yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertions; end",
"def assertions; end",
"def assert_equal(actual, expected)\n\tif actual == expected\n\t\tputs \"pass\"\n\telse\n\t\tputs \"fail\"\nend\n \nassert_equal(1,1) #=> pass\nassert_equal(2,1) #=> fail\n \n# Use assert to test the following:\n \n# define a method to sum the values of an array. Ma... | [
"0.71450984",
"0.71450984",
"0.66363215",
"0.66334045",
"0.65089047",
"0.6507049",
"0.6484943",
"0.64710546",
"0.64510626",
"0.63685703",
"0.6352573",
"0.6350508",
"0.63477504",
"0.63431907",
"0.63406086",
"0.63406086",
"0.63406086",
"0.6322821",
"0.6317343",
"0.6276396",
"0.... | 0.0 | -1 |
Get Schedule Stopwatches Count | def time_schedulestopwatches_count_get(opts = {})
data, _status_code, _headers = time_schedulestopwatches_count_get_with_http_info(opts)
return data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_activitystopwatches_count_get(opts = {})\n data, _status_code, _headers = time_activitystopwatches_count_get_with_http_info(opts)\n return data\n end",
"def count\n key[:schedule].zcard\n end",
"def count\n run.count\n end",
"def cron_job_count\n\n @cron... | [
"0.67897135",
"0.65084827",
"0.64851224",
"0.6478964",
"0.646534",
"0.62853503",
"0.6283197",
"0.61711",
"0.61606044",
"0.61415374",
"0.6136663",
"0.6118688",
"0.6112629",
"0.60961574",
"0.6054738",
"0.60504067",
"0.59569556",
"0.5908908",
"0.59069693",
"0.59001154",
"0.58891... | 0.7608301 | 0 |
Get Schedule Stopwatches Count | def time_schedulestopwatches_count_get_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: ScheduleStopwatchesApi.time_schedulestopwatches_count_get ..."
end
# resource path
local_var_path = "/time/schedulestopwatches/count"
# query parameters
query_params = {}
query_params[:'conditions'] = opts[:'conditions'] if !opts[:'conditions'].nil?
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['BasicAuth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Count')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ScheduleStopwatchesApi#time_schedulestopwatches_count_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_schedulestopwatches_count_get(opts = {})\n data, _status_code, _headers = time_schedulestopwatches_count_get_with_http_info(opts)\n return data\n end",
"def time_activitystopwatches_count_get(opts = {})\n data, _status_code, _headers = time_activitystopwatches_count_get_with_http_info(... | [
"0.7608301",
"0.67897135",
"0.65084827",
"0.64851224",
"0.6478964",
"0.646534",
"0.62853503",
"0.6283197",
"0.61711",
"0.61606044",
"0.61415374",
"0.6136663",
"0.6118688",
"0.60961574",
"0.6054738",
"0.60504067",
"0.59569556",
"0.5908908",
"0.59069693",
"0.59001154",
"0.58891... | 0.6112629 | 13 |
Delete Schedule Stopwatch By Id | def time_schedulestopwatches_id_delete(id, opts = {})
time_schedulestopwatches_id_delete_with_http_info(id, opts)
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_time_entry(id)\n send(:delete, \"time_entries/#{id}\")\n end",
"def deleteschedule(scid)\r\n scrbslog(\"======Begin to delete a schedule======\")\r\n @schedule = Schedule.find(scid)\r\n @user = User.find(@schedule.user_id)\r\n scrbslog(\"Author:\" + @user.name)\r\n @status =... | [
"0.7466653",
"0.7231538",
"0.70607233",
"0.70083725",
"0.68959737",
"0.6701935",
"0.6663265",
"0.66529036",
"0.65749127",
"0.6553978",
"0.65420735",
"0.65356153",
"0.6497009",
"0.6469711",
"0.6465723",
"0.6452875",
"0.6443019",
"0.6429932",
"0.64014405",
"0.6395774",
"0.63926... | 0.6705797 | 5 |
Delete Schedule Stopwatch By Id | def time_schedulestopwatches_id_delete_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: ScheduleStopwatchesApi.time_schedulestopwatches_id_delete ..."
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ScheduleStopwatchesApi.time_schedulestopwatches_id_delete"
end
# resource path
local_var_path = "/time/schedulestopwatches/{id}".sub('{' + 'id' + '}', id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['BasicAuth']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ScheduleStopwatchesApi#time_schedulestopwatches_id_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_time_entry(id)\n send(:delete, \"time_entries/#{id}\")\n end",
"def deleteschedule(scid)\r\n scrbslog(\"======Begin to delete a schedule======\")\r\n @schedule = Schedule.find(scid)\r\n @user = User.find(@schedule.user_id)\r\n scrbslog(\"Author:\" + @user.name)\r\n @status =... | [
"0.7466653",
"0.7231538",
"0.70607233",
"0.70083725",
"0.68959737",
"0.6705797",
"0.6701935",
"0.6663265",
"0.66529036",
"0.65749127",
"0.6553978",
"0.65420735",
"0.65356153",
"0.6497009",
"0.6469711",
"0.6465723",
"0.6452875",
"0.6443019",
"0.6429932",
"0.64014405",
"0.63957... | 0.61988986 | 29 |
Get Schedule Stopwatch By Id | def time_schedulestopwatches_id_get(id, opts = {})
data, _status_code, _headers = time_schedulestopwatches_id_get_with_http_info(id, opts)
return data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_times_by_stop_id(stop_id)\n get \"/gtfs/stoptimes/stopid/#{stop_id}\"\n end",
"def time_entry(id:)\n ::TimeEntry.find_by(id: id)\n end",
"def time_schedulestopwatches_id_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"... | [
"0.6783249",
"0.63768536",
"0.63616765",
"0.6208666",
"0.613761",
"0.6033801",
"0.59485745",
"0.5874326",
"0.581934",
"0.57467324",
"0.57451177",
"0.57347554",
"0.57264215",
"0.56869966",
"0.5674025",
"0.56230676",
"0.56097907",
"0.5572637",
"0.55719256",
"0.55540437",
"0.553... | 0.649901 | 1 |
Get Schedule Stopwatch By Id | def time_schedulestopwatches_id_get_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: ScheduleStopwatchesApi.time_schedulestopwatches_id_get ..."
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ScheduleStopwatchesApi.time_schedulestopwatches_id_get"
end
# resource path
local_var_path = "/time/schedulestopwatches/{id}".sub('{' + 'id' + '}', id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['BasicAuth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'ScheduleStopwatch')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ScheduleStopwatchesApi#time_schedulestopwatches_id_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_times_by_stop_id(stop_id)\n get \"/gtfs/stoptimes/stopid/#{stop_id}\"\n end",
"def time_schedulestopwatches_id_get(id, opts = {})\n data, _status_code, _headers = time_schedulestopwatches_id_get_with_http_info(id, opts)\n return data\n end",
"def time_entry(id:)\n ::TimeEntry... | [
"0.6783249",
"0.649901",
"0.63768536",
"0.6208666",
"0.613761",
"0.6033801",
"0.59485745",
"0.5874326",
"0.581934",
"0.57467324",
"0.57451177",
"0.57347554",
"0.57264215",
"0.56869966",
"0.5674025",
"0.56230676",
"0.56097907",
"0.5572637",
"0.55719256",
"0.55540437",
"0.55373... | 0.63616765 | 3 |
Given an options hash, prerenders content for the header and footer sections to temp files and return a new options hash including the URLs to these files. | def prerender_header_and_footer(options)
[:header, :footer].each do |hf|
if options[hf] && options[hf][:html] && options[hf][:html][:template]
GeneratePdfTempfile.open("generate_pdf.html") do |f|
f << render_to_string(:template => options[hf][:html][:template],
:layout => options[:layout])
options[hf][:html].delete(:template)
options[hf][:html][:url] = "file://#{f.path}"
end
end
end
return options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prerender_header_and_footer(options)\n files_to_delete = []\n [:header, :footer].each do |hf|\n if options[hf] && options[hf][:html] && options[hf][:html][:template]\n File.open(\"/tmp/wicked_pdf_hf_#{rand}.html\", \"w\") do |f|\n \n options_for_render = {\n ... | [
"0.7553675",
"0.73462903",
"0.659394",
"0.54801977",
"0.52931964",
"0.51225775",
"0.51040554",
"0.5043241",
"0.5020587",
"0.5008087",
"0.4998131",
"0.4970944",
"0.49631178",
"0.4934486",
"0.49216786",
"0.4902866",
"0.48897803",
"0.48897803",
"0.48721692",
"0.48646265",
"0.484... | 0.74235487 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_and_authorize_user_role
@user_role = policy_scope(base_object).find(params[:id])
authorize @user_role
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Requirements Fill in the function such that it returns the sum of the digits of the passed in number Clarifications/Advice Think carefully about what the second argument needs to be to ensure the correct output is returned. | def digit_sum(num, digits)
if digits == 1
num
else
num % 10 + digit_sum(num / 10, digits - 1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_digits(num)\n\nend",
"def sum_digits(n)\n return n if n <= 9\n n % 10 + sum_digits(n / 10)\nend",
"def sum_of_factorial_digits(factorial)\r\n\tthe_factorial = (1..factorial).inject(1){ |milti, i| milti * i }\r\n\r\n\treturn the_factorial.to_s.split('').inject(0){ |sum, i| sum + i.to_i }\r\nend",
"... | [
"0.7577391",
"0.74077326",
"0.7172838",
"0.71620023",
"0.7155745",
"0.71129745",
"0.7106004",
"0.71031535",
"0.71031535",
"0.7024236",
"0.70238954",
"0.7021223",
"0.7014648",
"0.701285",
"0.7004926",
"0.69900984",
"0.69751894",
"0.6969059",
"0.6959411",
"0.693337",
"0.6922332... | 0.719072 | 2 |
Execute choreo synchronously and return results. params : +input_set+ > Optional Temboo input set containing input options for this run. Note that many choreographies will require inputs in order to run correctly. returns : +results+ > Temboo result set built from the response to this choreo execution. | def execute(input_set = nil)
# If the inputs are not configured, create a blank set.
if input_set == nil
input_set = InputSet.new()
end
param_map = {"source_id" => TembooSession.get_identifier()}
body = input_set.format_inputs()
results = @session.post_request(get_path(), body, param_map)
return results.body()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_async(input_set = nil)\n if input_set == nil\n input_set = InputSet.new()\n end\n param_map = {\"source_id\" => TembooSession.get_identifier(),\n \"mode\" => \"async\",\n \"store_results\" => \"true\"}\n body = input_set.format_inputs()\n results = @s... | [
"0.7295079",
"0.6729452",
"0.6563855",
"0.6509577",
"0.64910555",
"0.64910555",
"0.64910555",
"0.64910555",
"0.64910555",
"0.64910555",
"0.6445004",
"0.6426748",
"0.6426297",
"0.6410465",
"0.63993347",
"0.6392523",
"0.63920313",
"0.6368479",
"0.63459677",
"0.63386095",
"0.632... | 0.64817697 | 10 |
Execute choreo, without storing or retrieving results from the execution. params : +input_set+ > Optional Temboo input set containing input options for this run. Note that many choreographies will require inputs in order to run correctly. returns : +execution+ > Choreography execution object for this run. | def execute_no_results(input_set = nil)
if input_set == nil
input_set = InputSet.new()
end
param_map = {"source_id" => TembooSession.get_identifier(),
"mode" => "async"}
body = input_set.format_inputs()
results = @session.post_request(get_path(), body, param_map)
id = JSON.load(results.body())["id"]
execution = ChoreographyExecution.new(@session, id)
return execution
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_async(input_set = nil)\n if input_set == nil\n input_set = InputSet.new()\n end\n param_map = {\"source_id\" => TembooSession.get_identifier(),\n \"mode\" => \"async\",\n \"store_results\" => \"true\"}\n body = input_set.format_inputs()\n results = @s... | [
"0.67249864",
"0.6533158",
"0.59501106",
"0.5934407",
"0.5934407",
"0.5934407",
"0.5934407",
"0.5934407",
"0.5934407",
"0.587804",
"0.5850382",
"0.5827114",
"0.5791268",
"0.5789173",
"0.5749985",
"0.56858325",
"0.56560785",
"0.56556964",
"0.56555367",
"0.56555367",
"0.5655536... | 0.75064504 | 0 |
Execute choreo asynchronously and store results for retrieval upon choreo completion. params : +input_set+ > Optional Temboo input set containing input options for this run. Note that many choreographies will require inputs in order to run correctly. returns : +execution+ > Choreography execution object for this run. | def execute_async(input_set = nil)
if input_set == nil
input_set = InputSet.new()
end
param_map = {"source_id" => TembooSession.get_identifier(),
"mode" => "async",
"store_results" => "true"}
body = input_set.format_inputs()
results = @session.post_request(get_path(), body, param_map)
id = JSON.load(results.body())["id"]
execution = ChoreographyExecution.new(@session, id)
return execution
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_no_results(input_set = nil)\n if input_set == nil\n input_set = InputSet.new()\n end\n param_map = {\"source_id\" => TembooSession.get_identifier(),\n \"mode\" => \"async\"}\n body = input_set.format_inputs()\n results = @session.post_request(get_path(), body, param_... | [
"0.6982536",
"0.6177448",
"0.6177448",
"0.6177448",
"0.6177448",
"0.6177448",
"0.6177448",
"0.6083199",
"0.60620475",
"0.5922874",
"0.58725137",
"0.58325744",
"0.5827864",
"0.58222574",
"0.58088005",
"0.5799691",
"0.57895076",
"0.5768295",
"0.5768295",
"0.5768295",
"0.5752457... | 0.79644465 | 0 |
Return the session class's base path and the name of the collection. returns : +base_path+ > Path to choreos resource. | def get_base_path()
return TembooSession.get_base_path + "/choreos"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n @base\n end",
"def collection_path\n self.class.collection_path\n end",
"def collection_path\n @prefix + '/' + @resource.collection_path.to_s\n end",
"def base_path\n self.class.base_path\n end",
"def collection_path\n self.class.collection_path\n end",
"def... | [
"0.7017814",
"0.68945813",
"0.68298477",
"0.66332054",
"0.66293633",
"0.6618734",
"0.6391526",
"0.6383322",
"0.63533795",
"0.6248656",
"0.6211953",
"0.6209245",
"0.61984056",
"0.6181117",
"0.6178508",
"0.6157036",
"0.61186916",
"0.61159855",
"0.60892767",
"0.60409313",
"0.603... | 0.64067626 | 6 |
Set the value of an input. params : +name+ > String of the name of the input you wish to define. +value+ > String of value you wish to set for named input. | def set_input(name, value)
@inputs[name] = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(name, value)\n set_text_content(name, 'input-field', @klass, value)\n end",
"def set_Name(value)\n set_input(\"Name\", value)\n end",
"def input(name, value)\n Praline::browser.find_element(:name, name).send_keys(value)\n end",
"def set_field_value(name, value)\n... | [
"0.7576971",
"0.74357164",
"0.7358189",
"0.7341144",
"0.73080224",
"0.73080224",
"0.73080224",
"0.7307731",
"0.7307731",
"0.7307731",
"0.7307731",
"0.7306217",
"0.7040519",
"0.7023063",
"0.7023063",
"0.7023063",
"0.7023063",
"0.7023063",
"0.7023063",
"0.7023063",
"0.7023063",... | 0.8793461 | 0 |
Specify a credential object to use with the choreography execution. params : +target_credential+ > The URI of the credential object that you you wish to use. | def set_credential(target_credential)
@credential_name = target_credential
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def credentials=(target, scheme, username, password)\r\n\t\t\t`#{BITS::BITSADMIN} /setcredentials {#{@id}} #{target} #{scheme} #{username} #{password}`\r\n\t\tend",
"def set_credential\n # @credential = Credential.find(params[:id])\n end",
"def set_credential\n @credential = Credential.find(params... | [
"0.5903731",
"0.5836386",
"0.5782795",
"0.5782795",
"0.576697",
"0.576697",
"0.5636278",
"0.54667884",
"0.5442058",
"0.5376895",
"0.5339651",
"0.52550614",
"0.5236925",
"0.52238274",
"0.5183423",
"0.5146543",
"0.5123971",
"0.51029015",
"0.51015735",
"0.5072494",
"0.5072494",
... | 0.7659986 | 0 |
Format inputs and aliases as JSON for use in API requests. returns : +formatted_inputs+ > JSONformatted string representing inputs to be used in the current run. | def format_inputs()
full_inputs = Hash.new()
if @inputs.any?
input_array = Array.new()
@inputs.keys.each do |input|
input_props = {"name" => input, "value" => @inputs[input]}
input_array.push(input_props)
end
full_inputs["inputs"] = input_array
end
if @credential_name
full_inputs["preset"] = @credential_name
end
formatted_inputs = full_inputs.to_json()
return formatted_inputs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_inputs(inputs)\n @api.account_id = @options[:src]\n result = {}\n\n inputs.index.each do |input|\n # Array input format type isn't correct and must be changed to a json array.\n # More info here: http://reference.rightscale.com/api1.5/resources/ResourceInputs.html#multi_update\n if input.val... | [
"0.7301564",
"0.60508984",
"0.6015423",
"0.59906507",
"0.5784936",
"0.56788856",
"0.56712484",
"0.5648225",
"0.564779",
"0.5611404",
"0.5563973",
"0.55557084",
"0.5391276",
"0.53440356",
"0.53071284",
"0.5304144",
"0.5246945",
"0.516643",
"0.5157304",
"0.51238734",
"0.511286"... | 0.80216473 | 0 |
Get the final status of the execution (typically one of success or error). returns : +status+ > String of status value. | def get_completion_status()
return @status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status\n case @result.retval\n when 0 ; \"ok\"\n when 1 ; \"warning\"\n when 2 ; \"critical\"\n end\n end",
"def exit_status\n @status\n end",
"def current_status\n if done?\n failed? ? 'Error' : 'Completed'\n else\n 'Running'\n end\n ... | [
"0.76160234",
"0.7359066",
"0.7121581",
"0.6947373",
"0.6943834",
"0.68285805",
"0.6788427",
"0.6691783",
"0.668696",
"0.6682451",
"0.6664107",
"0.66612446",
"0.66575545",
"0.66575545",
"0.6626167",
"0.6607266",
"0.6552697",
"0.6551977",
"0.6550846",
"0.6550846",
"0.6550846",... | 0.67056316 | 7 |
Convert timestamp returned from server (as a string) to a Ruby datetime object. params : +stamp_string+ > String representation of the timestamp returned from the Arcturus server. returns : +utc_time+ > Ruby datetime object. | def process_stamp(stamp_string)
# Server gives us miliseconds, which we drop before converting.
stamp_val = stamp_string.to_i() / 1000
utc_time = Time.at(stamp_val).utc().to_datetime()
return utc_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_timestamp(time_string, time_zone)\n time_string.slice!(0)\n time_zone.chomp(\"]\")\n Time.strptime(time_string.concat(time_zone), \"%d/%b/%Y:%T%z\")\n end",
"def to_datetime(string)\n d = DateTime.parse(string)\n d.respond_to?(:in_time_zone) ? d.in_time_zone : d\n r... | [
"0.6146997",
"0.5978872",
"0.5611095",
"0.55131906",
"0.5490403",
"0.5482768",
"0.54533833",
"0.539756",
"0.53909314",
"0.5367294",
"0.53606087",
"0.5344925",
"0.53378844",
"0.5317793",
"0.53017586",
"0.52646625",
"0.52398473",
"0.51966727",
"0.51702845",
"0.5123699",
"0.5114... | 0.83113694 | 0 |
Get the start time of this choreography execution. returns : +utc_time+ > Ruby datetime object representation of choreo's start time. | def get_start_time()
return process_stamp(@start_time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def utc_start_time\n @time.utc.strftime(\"%Y-%m-%dT%H:%M:%S.000Z\")\n end",
"def start_time\n # API results are in milliseconds since the unix epoch\n epoch_msec = raw_result.fetch('time')\n epoch_sec = epoch_msec / 1000\n\n Time.at(epoch_sec).ctime\n en... | [
"0.72855383",
"0.72101134",
"0.71348083",
"0.69935304",
"0.6943778",
"0.69196063",
"0.69196063",
"0.6899058",
"0.6822301",
"0.6765929",
"0.67227787",
"0.6695264",
"0.6695264",
"0.66868436",
"0.6657903",
"0.66236454",
"0.66209334",
"0.65913373",
"0.6588392",
"0.6588392",
"0.65... | 0.70471233 | 3 |
Get the completion time of this choreography execution. returns : +utc_time+ > Ruby datetime object representation of choreo's completion time. | def get_completion_time()
return process_stamp(@end_time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time\n @time ||= incorporate_utc_offset(@utc, utc_offset)\n end",
"def completion_date_time\n return @completion_date_time\n end",
"def completion_date_time\n return @completion_date_time\n end",
"def completiontime\r\n\t\t\t`#{BITS::BITSADMIN} ... | [
"0.66420805",
"0.64632326",
"0.64632326",
"0.6341076",
"0.632313",
"0.61700076",
"0.6160909",
"0.6159015",
"0.6159015",
"0.6159015",
"0.6159015",
"0.6159015",
"0.6159015",
"0.6122842",
"0.59740067",
"0.5967476",
"0.5967476",
"0.5904274",
"0.5872739",
"0.5861539",
"0.5844806",... | 0.6838525 | 0 |
Get the execution id for the run associated with this result set. returns : +id+ > String representation of the execution ID number. | def get_id()
return @id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _execution_id\n attributes['id']\n end",
"def execution_id\n value = @execution_id.value\n return if value.instance_of?(Object)\n\n value\n end",
"def run_id\n job_group.execution_variables['run_id']\n end",
"def run_id()\n if @handle.ptr == nil\n r... | [
"0.7655519",
"0.75520486",
"0.7447516",
"0.7087437",
"0.62366015",
"0.6211082",
"0.6199892",
"0.6199826",
"0.6136218",
"0.613309",
"0.613309",
"0.613309",
"0.613309",
"0.6062316",
"0.5973386",
"0.5965091",
"0.5942381",
"0.59392005",
"0.5897675",
"0.5897675",
"0.58672273",
"... | 0.62757474 | 4 |
Get the value of a particular output. params : +key+ > String of the name of the ouput in whose value you are expressing interest. returns : +value+ > String of the value of the output you specified. | def get_result(key)
return @outputs[key]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getvalue(key)\n\n\t\tpath = \"/etc/libvirt/qemu/\" #Debian/ubuntu path for qemu's xml files\n\t\textension = \".xml\"\n\t\targuments = [key, path + resource[:name] + extension]\n\t\tline = grep arguments\n\t\n\t\treturn line.split('>')[1].split('<')[0]\t\n\n\tend",
"def getValue(key)\r\n \r\n ... | [
"0.6771661",
"0.65696067",
"0.6521084",
"0.64397824",
"0.64031255",
"0.63619435",
"0.6310173",
"0.6300118",
"0.6257983",
"0.6230891",
"0.6165605",
"0.6107799",
"0.6107012",
"0.6092",
"0.6088949",
"0.6088949",
"0.6046526",
"0.60273385",
"0.6010604",
"0.6008391",
"0.60072803",
... | 0.7850252 | 0 |
Get the names of the outputs in this result set. returns : +keys+ > Array of the names of the outputs in this result set. | def key_set()
return @outputs.keys()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names\n @index.keys\n end",
"def keys\n index.keys.collect {|keys| keys.to_s }\n end",
"def keys\n @inputs.keys\n end",
"def keys\n @values.keys\n end",
"def keys\n @values.keys\n end",
"def keys\n @values.keys\n end",
"def keys\n ... | [
"0.6825811",
"0.6659278",
"0.66237956",
"0.661232",
"0.661232",
"0.6607987",
"0.6607987",
"0.65901285",
"0.6576075",
"0.6550465",
"0.6550465",
"0.6513079",
"0.6504788",
"0.650026",
"0.6486203",
"0.6486203",
"0.6484901",
"0.6479135",
"0.64686525",
"0.64686525",
"0.64686525",
... | 0.76785266 | 0 |
Get all the outputs for this result set. returns : +outputs+ > Hash of the names and values of all outputs in this result set. | def get_outputs()
return @outputs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outputs\n data[:outputs]\n end",
"def outputs\n @outputs || []\n end",
"def outputs\n [Graph::OperationOutput.from_index(self.value_handle, 0)]\n end",
"def outputs\n inputs.map(&:output).compact\n end",
"def output\n @results\n end",
"def output\n @al... | [
"0.74861383",
"0.7368573",
"0.6981401",
"0.6914265",
"0.6902261",
"0.683043",
"0.6667094",
"0.6627017",
"0.6565993",
"0.65457314",
"0.65262944",
"0.6524716",
"0.6489012",
"0.644105",
"0.6438566",
"0.6429127",
"0.64227927",
"0.6361598",
"0.63564706",
"0.6329256",
"0.6271458",
... | 0.7785078 | 0 |
Return the last error associated with these results. returns +error_message+ > String of error message. | def get_last_error()
return @last_error
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_error\n @error.respond_to?(:message) ? @error.message : @error\n end",
"def last_error\n return @client.get_last_error\n end",
"def error\n @last_error && @last_error.error\n end",
"def last_err\n api(\"LastErr\")\n end",
"def error\n errors.full_messages.first\n... | [
"0.8154782",
"0.75354636",
"0.7217199",
"0.71869653",
"0.71350384",
"0.70190924",
"0.699638",
"0.6991631",
"0.6954777",
"0.6929684",
"0.6929684",
"0.69216406",
"0.68272626",
"0.67944765",
"0.67928183",
"0.6740756",
"0.6650295",
"0.6632814",
"0.6625214",
"0.6624006",
"0.658849... | 0.78423035 | 1 |
In All Strings Check if a short_string is a substring of ALL of the long_strings | def in_all_strings?(long_strings, short_string)
# sliding window
# check each long_string
long_strings.each do |s|
in_string = false
n = s.length - short_string.length
# check each substring of a long string
# if equal to short string
(0..n).each do |i|
# if we encounter the shortstring in the substring
# then we should move on to the next long string
if s.slice(i, short_string.length) == short_string
in_string = true
break
end
end
# if we didn't find a substring in this long string
# then we know that not all substrings are in the long string
if in_string == false
return false
end
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_all_strings?(long_strings, short_string)\n long_strings.all? do |long_string|\n long_string.include?(short_string)\n end\nend",
"def in_all_strings?(long_strings, short_string)\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all? { |long_string| sub_string?(long_string, substri... | [
"0.8532211",
"0.85141337",
"0.83607256",
"0.8327667",
"0.83249813",
"0.83185923",
"0.8296188",
"0.82955545",
"0.82942355",
"0.8293991",
"0.8283819",
"0.82801676",
"0.82747406",
"0.8255034",
"0.7854271",
"0.77119315",
"0.747314",
"0.72347224",
"0.7176637",
"0.69667244",
"0.694... | 0.86150664 | 0 |
Biodiversity Given an array of specimens, return the biodiversity index, which is defined by the following formula: number_of_species^2 times the smallest_population_size divided by the largest_population_size. In code, biodiversity = number_of_species2 smallest_population_size / largest_population_size | def find_minmax(populations)
min, max = nil, nil
populations.each do |s, p|
if min == nil or p < min
min = p
end
if max == nil or p > max
max = p
end
end
[min, max]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def biodiversity_index(specimens)\n population_size = Hash.new(0)\n specimens.each do |specimen|\n population_size[specimen] += 1\n end\n\n number_of_species = specimens.uniq.length\n smallest_population_size = population_size.values.min\n largest_population_size = population_size.values.max\n\n number_o... | [
"0.84250444",
"0.83462554",
"0.8268391",
"0.8252905",
"0.8160882",
"0.80297345",
"0.79999477",
"0.79974306",
"0.79965055",
"0.7850374",
"0.76026165",
"0.6755026",
"0.6755026",
"0.5790083",
"0.5426242",
"0.5341727",
"0.51899105",
"0.5073767",
"0.5060724",
"0.4984522",
"0.49665... | 0.0 | -1 |
Censor Write a function censor(sentence, curse_words) that censors the words given. Replace the vowels in the curse word with "". | def asterisked(word)
vowels = ["a", "e", "i", "o", "u"]
new_word = ""
word.each_char do |c|
if vowels.include?(c)
new_word << "*"
else
new_word << c
end
end
new_word
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def censor(sentence, curse_array)\n words = sentence.split(\" \")\n\n words.each.with_index do |word, w_index|\n if curse_array.include?(word.downcase) \n vowels = \"aeiou\"\n \n word.each_char.with_index do |letter, l_index|\n word[l_index] = \"*\" if v... | [
"0.81146324",
"0.78412163",
"0.7144027",
"0.6774451",
"0.67598844",
"0.6617898",
"0.65533406",
"0.6324771",
"0.6201902",
"0.5816114",
"0.56840247",
"0.5598387",
"0.5591348",
"0.5589922",
"0.5552527",
"0.5381631",
"0.5374659",
"0.5371387",
"0.53471017",
"0.5328699",
"0.5309279... | 0.4902085 | 38 |
For F's Sake Given a string, return the word that has the letter "f" closest to the end of it. If there's a tie, return the earlier word. Ignore punctuation. If there's no f, return an empty string. | def for_fs_sake(string)
words = string.split(" ")
the_word = ""
f_index = nil # index from end
words.each do |word|
#find an f
(1..word.length).each do |i|
if word[-i] == "f"
if the_word == "" or i < f_index
the_word = word
f_index = i
break
end
end
end
end
the_word
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def for_fs_sake(string)\n words = string.split\n min_f_distance = nil\n min_f_word = \"\"\n\n words.each do |word|\n current_f_distance = find_f_distance(word)\n if current_f_distance && (min_f_distance.nil? || current_f_distance < min_f_distance)\n min_f_distance = current_f_distance\n min_f_w... | [
"0.74975246",
"0.65524983",
"0.65432477",
"0.63952756",
"0.6358926",
"0.63057494",
"0.62776256",
"0.62187433",
"0.6171606",
"0.6146668",
"0.6143521",
"0.61392295",
"0.61161524",
"0.6042647",
"0.60168976",
"0.60046",
"0.59489864",
"0.59162354",
"0.5912015",
"0.59039",
"0.58811... | 0.80322593 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_bid_invoice
@bid_invoice = BidInvoice.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def bid_invoice_params
params.require(:bid_invoice).permit(:bid_id, :invoice_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
PROGRAMMER INSTRUCTIONS: IF EVENT_TYPE = PREGNANCY VISIT 1, PREGNANCY VISIT 2, OR FATHER, PRELOAD EVENT_TYPE, AND GO TO PV006. OTHERWISE, GO TO MULT_CHILD. | def is_pv1_or_pv2_or_father_or_informed_consent?(question)
event_type_code = event.try(:event_type_code).to_i
# If event is PV1, PV2, Father, or Informed Consent
valid_event_type_codes = [
Event.pregnancy_visit_1_code,
Event.pregnancy_visit_2_code,
Event.informed_consent_code,
Event.father_code
]
answer_for(question, valid_event_type_codes.include?(event_type_code))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postConditionalNextOPlanStage\n # find two random agents. They should be allowed to communicate\n # if they are not in the attack node\n agent1 = nil\n agent2 = nil\n @run.society.each_agent { |agent|\n if (agent.node.get_facet(\"attacker\") == nil)\n if (agent1 == nil) \n a... | [
"0.49794757",
"0.49425516",
"0.49037373",
"0.48983926",
"0.4876424",
"0.48570603",
"0.48014453",
"0.4789871",
"0.4785567",
"0.47737235",
"0.47303215",
"0.4677972",
"0.46655852",
"0.46179748",
"0.46083298",
"0.46011296",
"0.45640716",
"0.45358655",
"0.45250046",
"0.44938767",
... | 0.44069862 | 26 |
PROGRAMMER INSTRUCTIONS: IF CHILD_QNUM = 1 AND (R_FNAME)(R_MNAME)(R_LNAME) COLLECTED FOR PARENT/CAREGIVER DURING PREVIOUS INTERVIEW AND VALID RESPONSE PROVIDED, GO TO NAME_CONFIRM. IF CHILD_QNUM > 1 AND (R_FNAME)(R_MNAME)(R_LNAME) COLLECTED FOR PREVIOUS CHILD_QNUM, GO TO PROGRAMMER INSTRUCTIONS FOLLOWING PERSON_DOB. OTHERWISE, GO TO (R_FNAME) (R_MNAME) (R_LNAME). | def has_name_been_collected?(question)
ri = false
if person.full_name_exists?
ri = true
elsif person.only_middle_name_missing?
ri = true if middle_name_response_exists?
else
ri = true if first_name_response_exists? && middle_name_response_exists? && last_name_response_exists?
end
answer_for(question, ri)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_show_child_name?(question)\n ri = ((participant.person.try(:first_name) && participant.person.try(:last_name)) ||\n (child_first_name_response_exists? && child_last_name_response_exists?)) ? false : true\n answer_for(question, ri)\n end",
"def is_work_name_previously_collected_... | [
"0.54867274",
"0.5118274",
"0.50823694",
"0.5011451",
"0.5007296",
"0.49444285",
"0.49387127",
"0.4853222",
"0.47709718",
"0.4724555",
"0.47156155",
"0.47067344",
"0.4694046",
"0.46685538",
"0.46673915",
"0.46549562",
"0.46540022",
"0.4610477",
"0.46055758",
"0.45990363",
"0.... | 0.4786147 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.