query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
returns team with highest average goals allowed | def worst_defense
@teams.max_by { |team| team.average_goals_allowed }.team_name
end | [
"def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end",
"def most_goals_scored(team_id)\n team_id = team_id.to_i\n goals_per_game = @game_teams.map do |game|\n if game.team_id == team_id\n game.goals\n end\n end\n goals_per_game.compact.ma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns team with highest average away goals | def highest_scoring_visitor
@teams.max_by { |team| team.average_away_goals }.team_name
end | [
"def most_goals_scored(team_id)\n (away_goals_scored(team_id) + home_goals_scored(team_id)).max\n end",
"def highest_scoring_home_team\n home_goals = Hash.new(0.00)\n #get sum of away_goals per home team (hash output)\n unique_home_teams_array_helper.each do |team_id|\n self.games.each_value do ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns team with highest average home goals | def highest_scoring_home_team
@teams.max_by { |team| team.average_home_goals }.team_name
end | [
"def highest_scoring_home_team\n home_goals = Hash.new(0.00)\n #get sum of away_goals per home team (hash output)\n unique_home_teams_array_helper.each do |team_id|\n self.games.each_value do |game|\n home_goals[team_id] += (game.home_goals) if game.home_team_id == team_id\n end\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns team with lowest average home goals | def lowest_scoring_home_team
@teams.min_by { |team| team.average_home_goals }.team_name
end | [
"def lowest_scoring_home_team\n foo = {}\n\n teams.each do |team|\n team_id = team['team_id']\n team_name = team['teamName']\n\n foo[team_name] = average_goals_home(team_id)\n end\n\n foo.max_by { |_k, v| -v }[0]\n end",
"def lowest_total_score\n total_game_scores = games.map { |gam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns team with highest win percentage | def winningest_team
@teams.max_by { |team| team.total_win_percentage }.team_name
end | [
"def winning_team_game\n self.team_games.sort_by { |team_game| team_game.total_score }.last\n end",
"def highest_scoring_visitor\n @teams.max_by { |team| team.average_away_goals }.team_name\n end",
"def highest_scoring_home_team\n @teams.max_by { |team| team.average_home_goals }.team_name\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the season with the highest win percentage for a team | def best_season(team_id)
team_id = team_id.to_i
team = @teams.select { |each_team| each_team.team_id == team_id }.first
team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s
end | [
"def worst_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s\n end",
"def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the season with the lowest win percentage for a team | def worst_season(team_id)
team_id = team_id.to_i
team = @teams.select { |each_team| each_team.team_id == team_id }.first
team.season_win_percentages.min_by { |season, percentage| percentage }.first.to_s
end | [
"def best_season(team_id)\n team_id = team_id.to_i\n team = @teams.select { |each_team| each_team.team_id == team_id }.first\n team.season_win_percentages.max_by { |season, percentage| percentage }.first.to_s\n end",
"def lowest_scoring_home_team\n @teams.min_by { |team| team.average_home_goals }.tea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns average win percentage of all games for a team | def average_win_percentage(team_id)
team_id = team_id.to_i
team = @teams.select { |each_team| each_team.team_id == team_id }.first
team.total_win_percentage.round(2)
end | [
"def average_win_percentage(team_id)\n (total_games_won(team_id) / total_games_played(team_id)).round(2)\n end",
"def average_win_percentage(team_id)\n all_percents = []\n win_percent_per_season(team_id).each {|season, win_percentage| all_percents << win_percentage}\n all_percents.sum / all_percents.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the highest number of goals a particular team has scored in a game | def most_goals_scored(team_id)
team_id = team_id.to_i
goals_per_game = @game_teams.map do |game|
if game.team_id == team_id
game.goals
end
end
goals_per_game.compact.max
end | [
"def most_goals_scored(team_id)\n (away_goals_scored(team_id) + home_goals_scored(team_id)).max\n end",
"def most_goals_scored(team_id)\n most_goals_scored_counter = 0\n int_team_id = team_id.to_i\n self.game_teams.each do |game_team_obj|\n if game_team_obj.team_id == int_team_id\n if gam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the lowest number of goals a particular team has scored in a game | def fewest_goals_scored(team_id)
team_id = team_id.to_i
goals_per_game = @game_teams.map do |game|
if game.team_id == team_id
game.goals
end
end
goals_per_game.compact.min
end | [
"def fewest_goals_scored(team_id)\n (away_goals_scored(team_id) + home_goals_scored(team_id)).min\n end",
"def fewest_goals_scored(team_id)\n get_all_games_from_team(team_id).min_by do |game|\n game.goals\n end.goals\n end",
"def lowest_total_score\n total_game_scores = games.map { |game| gam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the biggest difference between team goals and opponent goals for a loss for the given team | def worst_loss(team_id)
@games.map do |game|
if game.away_team_id.to_s == team_id
game.home_goals - game.away_goals
elsif game.home_team_id.to_s == team_id
game.away_goals - game.home_goals
end
end.compact.max
end | [
"def worst_loss(team_id)\n\n #select games team lost and delete rest\n games = games_for_team_helper(team_id).select! do |game|\n if (game.away_team_id == team_id) && (game.away_goals < game.home_goals)\n true\n elsif (game.home_team_id == team_id) && (game.home_goals < game.away_goals)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /fault_books GET /fault_books.json | def index
@fault_books = FaultBook.where(:truck_fleet_id => current_user.truck_fleet.id)
@fault_books = FaultBook.belongs_to_truck_fleet(current_user.truck_fleet, @fault_books) if current_user.admin?
respond_to do |format|
format.html # index.html.erb
format.json { render json: @fault_books }
... | [
"def index\n if params[:book_id]\n @book_suggestions = find_book.book_suggestions\n render json: @book_suggestions\n else\n @book_suggestions = BookSuggestion.all\n render json: @book_suggestions\n end\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleap... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /fault_books POST /fault_books.json | def create
@fault_book = FaultBook.new(params[:fault_book])
@fault_book.truck_fleet_id = @fault_book.fleet.truck_fleet_id
respond_to do |format|
if @fault_book.save
s = Serviceable.find_by_fleet_id(params['fault_book']['fleet_id'])
s.next_service_date = @fault_book.fault_date
... | [
"def create\n @fault = Fault.new(fault_params)\n\n respond_to do |format|\n if @fault.save\n format.html { redirect_to faults_url, notice: 'Fault was successfully created.' }\n format.json { render :index, status: :created, location: @fault }\n else\n format.html { render :new }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /fault_books/1 PUT /fault_books/1.json | def update
@fault_book = FaultBook.find(params[:id])
respond_to do |format|
if @fault_book.update_attributes(params[:fault_book])
format.html { redirect_to @fault_book, notice: 'Fault book was successfully updated.' }
format.json { head :no_content }
else
format.html { rende... | [
"def update\n @api_book = Api::Book.find(params[:id])\n\n if @api_book.update(api_book_params)\n head :no_content\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
number: Accepts 3 parameters name, twilio, and area code. twilio determines if Twilio will be used to generate a real phone number. Name is used when setting the friendly name of a Twilio phone number. Area code is used when search for local Twilio numbers. End result a phone number. | def number(twilio=false, name=nil, area_code=nil)
if twilio
# Check if twilio configuration exists. If not throw and errors because twilio was passed as true.
if !@config[:configuration][:twilio].blank? and (!@config[:configuration][:twilio][:account_id].blank? and !@config[:configuration][:twili... | [
"def set_twilio_number(area_code, forward_to, name, inboundno)\n return false if area_code.blank? || forward_to.blank? || name.blank? || inboundno.blank?\n job_status = JobStatus.create(:name => \"Campaign.set_twilio_number\")\n \n begin\n # CALL URLS ############################################ \n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return 1st 3 words of content and ellipsis | def preview
self.content.split(' ')[0...5].join(' ') + '...'
end | [
"def first_n_words( n , text )\n words = text.split[0...n]\n words.join(' ') + if words.size == n then '...' else '' end\n end",
"def snippet(text, wordcount, omission)\n text.split[0..(wordcount-1)].join(\" \") + (text.split.size > wordcount ? \" \" + omission : \"\")\n end",
"def content_title\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This blocks anyone posting a link from paypal in chat | def no_paypal_content
errors.add_to_base("Please, no thirdparty websites.") if content =~ /paypal/i
end | [
"def garantir_link\n if link.present?\n link_params = link\n _link = link_params.split('/').reject { |l| l.blank? || l == 'http:' }\n _link[0].sub!(/s.|[^.]*.|\\s./, '') if _link[0].split('.').length == 3\n if ['herokuapp.com', 'codepen.io'].include? _link[0]\n link_params.gsub!('/' + ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
assembles one string argument into cmd | def test_assembles_one_string_argument_into_cmd
Crd::Flex::Command.new 'mxmlc' do |s|
s.output = 'Main.swf'
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-output=Main.swf' ), 'Could not find argument in to_cmd' )
end
end | [
"def build_command(cmd)\n cmd\n end",
"def build_command(command, *args)\n \"#{command} #{escape_arguments(args)}\".strip\n end",
"def cmdarg; end",
"def cmd(*args)\n\n cmd_args = []\n \n for arg in args\n \n case arg\n \n when Array\n cmd_literals = arg.shift.split(/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
assembles two string arguments into cmd | def test_assembles_two_string_arguments_into_cmd
Crd::Flex::Command.new 'mxmlc' do |s|
s.output = 'Main.swf'
s.static_link_runtime_shared_libraries = true
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-output=Main.swf' ), 'Could not find argume... | [
"def run2(*args)\n args.map!(&:to_s)\n command = args.join(' ')\n if include_meta_character?(command)\n run(command)\n else\n run(*args)\n end\n end",
"def pipe_to(command1, command2) \n command1 + ' | ' + command2 \n end",
"def test_assembles_two_array_arguments... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
assembles one array argument into cmd | def test_assembles_one_array_argument_into_cmd
Crd::Flex::Command.new 'mxmlc' do |s|
s.source_path << 'src'
s.source_path << 'lib/src'
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-source-path+=src,lib/src' ), 'Could not find argument in to_cm... | [
"def parse_cmd(array)\n array.collect do |e|\n if e.chars.to_a.include? ' '\n '\"' + e + '\"'\n else\n e\n end\n end.join(' ')\nend",
"def test_assembles_two_array_arguments_into_cmd\n Crd::Flex::Command.new 'mxmlc' do |s|\n s.source_path << 'src'\n s.source_path << 'lib/src'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
assembles two array arguments into cmd | def test_assembles_two_array_arguments_into_cmd
Crd::Flex::Command.new 'mxmlc' do |s|
s.source_path << 'src'
s.source_path << 'lib/src'
s.library_path << 'lib/bin'
cmd = s.to_cmd.split( /\s+/ )
assert_equal( 'mxmlc', cmd.shift )
assert( cmd.include?( '-source-path+=src,lib/src' )... | [
"def test_assembles_one_array_argument_into_cmd\n Crd::Flex::Command.new 'mxmlc' do |s|\n s.source_path << 'src'\n s.source_path << 'lib/src'\n cmd = s.to_cmd.split( /\\s+/ )\n assert_equal( 'mxmlc', cmd.shift )\n assert( cmd.include?( '-source-path+=src,lib/src' ), 'Could not find argum... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
found returns true for commands found in path | def test_found_returns_true_for_commands_found_in_path
Crd::Flex::Command.new 'mxmlc' do |s|
assert_equal( true, s.found? )
end
end | [
"def command?(path)\n !!(%r{\\A/(v(.*)/|)man\\/(.*)\\z} =~ path)\n end",
"def command_in_path?(command)\n found = ENV['PATH'].split(File::PATH_SEPARATOR).map do |p|\n File.exist?(File.join(p, command))\n end\n found.include?(true)\n end",
"def command_in_path?(command)\n found = ENV['PAT... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
found returns false for commands not found in path | def test_found_returns_false_for_commands_not_found_in_path
Crd::Flex::Command.new 'madeupcommandname' do |s|
assert_equal( false, s.found? )
end
end | [
"def command_exists?\n File.exists? self.command_file\n end",
"def command_exists?(command)\n line(\"which\", \"{command}\").pass(command: command) != \"\"\n end",
"def test_found_returns_true_for_commands_found_in_path\n Crd::Flex::Command.new 'mxmlc' do |s|\n assert_equal( true, s.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /latstraps1s GET /latstraps1s.json | def index
@latstraps1s = Latstraps1.all
end | [
"def index\n @latstraps2s = Latstraps2.all\n end",
"def index\n @latstraps4s = Latstraps4.all\n end",
"def index\n @latstrapshome1s = Latstrapshome1.all\n end",
"def create\n @latstraps1 = Latstraps1.new(latstraps1_params)\n\n respond_to do |format|\n if @latstraps1.save\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /latstraps1s POST /latstraps1s.json | def create
@latstraps1 = Latstraps1.new(latstraps1_params)
respond_to do |format|
if @latstraps1.save
format.html { redirect_to @latstraps1, notice: 'Latstraps1 was successfully created.' }
format.json { render :show, status: :created, location: @latstraps1 }
else
format.htm... | [
"def create\n @latstraps2 = Latstraps2.new(latstraps2_params)\n\n respond_to do |format|\n if @latstraps2.save\n format.html { redirect_to @latstraps2, notice: 'Latstraps2 was successfully created.' }\n format.json { render :show, status: :created, location: @latstraps2 }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /latstraps1s/1 PATCH/PUT /latstraps1s/1.json | def update
respond_to do |format|
if @latstraps1.update(latstraps1_params)
format.html { redirect_to "/latstraps1s"}
format.json { render :show, status: :ok, location: @latstraps1 }
else
format.html { render :edit }
format.json { render json: @latstraps1.errors, status: :... | [
"def update\n respond_to do |format|\n if @latstrapshome1.update(latstrapshome1_params)\n format.html { redirect_to \"/latstrapshome1s\"}\n format.json { render :show, status: :ok, location: @latstrapshome1 }\n else\n format.html { render :edit }\n format.json { render json:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /latstraps1s/1 DELETE /latstraps1s/1.json | def destroy
@latstraps1.destroy
respond_to do |format|
format.html { redirect_to latstraps1s_url, notice: 'Latstraps1 was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @latstrapshome1.destroy\n respond_to do |format|\n format.html { redirect_to latstrapshome1s_url, notice: 'Latstrapshome1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @latstraps2.destroy\n respond_to do |format|\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns unique array in which records are sorted by occurrence within array (Descending) | def sort_by_occurrence(records)
count = Hash.new(0)
records.each {|element| count[element] += 1}
records = records.uniq.sort {|x,y| count[y] <=> count[x]}
return records
end | [
"def consolidate_by_frequency(array)\n array.group_by{|x| x}.values.sort_by{|group| group.count}.reverse.flatten(1).uniq\nend",
"def remove_approve_duplicates(array)\n return array.flatten.uniq.sort\n end",
"def sort_by_frequency(arr)\n arr.sort_by {|e| [-arr.count(e), e]}\nend",
"def remove_reject_dup... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns unique hash in which records are sorted by "record" => "occurrence" (Descending) | def sort_by_occurrence_h(input)
output = input.each_with_object(Hash.new(0)){ |tag, counts| counts[tag] += 1 }
output = Hash[output.sort_by{ |tags, counts| counts}.reverse]
return output
end | [
"def sort_by_occurrence(records)\n count = Hash.new(0)\n records.each {|element| count[element] += 1}\n records = records.uniq.sort {|x,y| count[y] <=> count[x]}\n return records\n end",
"def unique_visit\n parsed_result.each do |result|\n visit_hash[result.first] = result.last.uniq.count\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register this class for the given +id+. Example: class MyPlugin < PluginHost::BaseClass register_for :my_id ... end See PluginHost.register. | def register_for id
@plugin_id = id
plugin_host.register self, id
end | [
"def register_for(id); end",
"def register plugin, id\n plugin_hash[validate_id(id)] = plugin\n end",
"def register(plugin, id); end",
"def register(id, klass)\n ETL.logger.debug(\"Registering job class with manager: #{id} => #{klass}\")\n if @job_classes.has_key?(id)\n ETL.logger.war... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The PluginHost for this Plugin class. | def plugin_host host = nil
if host.is_a? PluginHost
const_set :PLUGIN_HOST, host
end
self::PLUGIN_HOST
end | [
"def instance\n unless @plugin_instance\n @plugin_instance = FreeBASE::Plugin.new(@configuration.core, self)\n end\n @plugin_instance\n end",
"def plugin_host(host = T.unsafe(nil)); end",
"def plugin\n # $stderr.puts \"#{self.class.name} #{id || 'new'} plugin\"\n @plugin ||=\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculates the zone outdoor airflow requirement and divides by the zone area. | def outdoor_airflow_rate_per_area()
tot_oa_flow_rate_per_area = 0.0
# Find total area of the zone
sum_floor_area = 0.0
self.spaces.sort.each do |space|
sum_floor_area += space.floorArea
end
# Get the OA flow rate
tot_oa_flow_rate = outdoor_airflow_rate
# Calculate the per-a... | [
"def area_wrt_ground ()\n \n end",
"def fare\n total = 0\n zone_price = (@journey[:start].zone - @journey[:end].zone).abs\n total = @@MIN_FARE + zone_price\n end",
"def calculate_fare(start_zone=nil, end_zone=nil)\n start_zone ||= 1\n end_zone ||= 1\n fare = ZONE_FARES[start_zone - 1]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function for testing a preprocessor | def test_preprocessor(preprocessor,input,expected)
# Prepare the output and the input streams
puts "Preparing the input and ouput streams..."
output = StringIO.new("")
# Process the input and exepected arguments.
if !input.respond_to?(:each_line) or input.is_a?(String) then
# input is actual... | [
"def preprocessors; end",
"def test_preprocessor_exception(preprocessor,string,exception)\n input = StringIO.new(string)\n output = StringIO.new(\"\")\n begin\n $ppr.preprocess(input,output)\n puts \"*Error*: preprocessed without exception.\"\n return false\n rescue Exception => e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function for testing a preprocessor on +string+ which should raise an +exception+ string. | def test_preprocessor_exception(preprocessor,string,exception)
input = StringIO.new(string)
output = StringIO.new("")
begin
$ppr.preprocess(input,output)
puts "*Error*: preprocessed without exception."
return false
rescue Exception => e
if e.to_s.include?(exception.to_s) ... | [
"def exception(string)\n #This is a stub, used for indexing\n end",
"def mk_exc(_message)\n assert false\nrescue => err\n err\nend",
"def check_and_raise_error(exception, message)\n fail exception unless exception.message.include?(message)\n end",
"def exception(string = nil)\n return self ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write a statement that allows a member to be updated by their name and age. This should take in the attributes of name, age and id. | def update()
sql = "UPDATE members SET (name, age) = ($1, $2) WHERE id = $3"
values = [@name, @age, @id]
SqlRunner.run(sql, values)
end | [
"def update()\n sql = \"UPDATE merchants\n SET (name) = ($1)\n WHERE id = $2\"\n values = [@name, @id]\n SqlRunner.run( sql, values )\n end",
"def update\n expose Member.update(@oauth_token, params[:membername], params)\n end",
"def update_member(params)\n connection.call_method('lists.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /layers POST /layers.json | def create
@layer = Layer.new(layer_params)
respond_to do |format|
if @layer.save
format.html { redirect_to @layer, notice: 'Layer was successfully created.' }
format.json { render :show, status: :created, location: @layer }
else
format.html { render :new }
format.js... | [
"def create\n @layer = @map.layers.build(params[:layer])\n\n respond_to do |format|\n if @layer.save\n format.html { redirect_to([@layer.map, @layer], :notice => 'Layer was successfully created.') }\n format.json { render :json => @layer, :status => :created, :location => [@layer.map, @laye... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /layers/1 PATCH/PUT /layers/1.json | def update
respond_to do |format|
if @layer.update(layer_params)
format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }
format.json { render :show, status: :ok, location: @layer }
else
format.html { render :edit }
format.json { render json: @layer.e... | [
"def update\n @layer = @map.layers.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n format.html { redirect_to([@layer.map, @layer], :notice => 'Layer was successfully updated.') }\n format.json { head :ok }\n else\n format.html { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /itineraries/new GET /itineraries/new.xml | def new
@travel = Travel.find(params[:travel_id])
@itinerary = Itinerary.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @itinerary }
end
end | [
"def new\n @itinerary = Itinerary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @itinerary }\n end\n end",
"def new\n @liner = Liner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @liner }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /itineraries POST /itineraries.xml | def create
@travel = Travel.find(params[:travel_id])
@itinerary = @travel.itineraries.new(itinerary_param)
respond_to do |format|
if @itinerary.save
format.html { redirect_to(admin_travel_itineraries_url(@travel), :notice => 'Itinerary was successfully created.') }
format.xml { rende... | [
"def create\n itinerary = current_user.itineraries.create!(itinerary_params)\n itinerary_id = current_user.itineraries.last\n \n events = params[:events]\n events.each do |event|\n itinerary_id = current_user.itineraries.last[:id]\n EventsItinerary.create(itinerary_id: itinerary_id, event_i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is where we pull the route out of the submitted slack command eg /tram 96 or tram route 96 will pull out '96' defaults to Route 109 (Montague St) | def determine_requested_route(slack_query)
submitted_text = slack_query.to_s
return STOP_INFO[:'96'] if submitted_text.include? '96'
STOP_INFO[:'109']
rescue NoMethodError
STOP_INFO[:'109']
end | [
"def get_route\n self.route\n end",
"def format_route route\n route.first.split('')\n end",
"def route\n @route\n end",
"def get_route\n data = {\n visits: visits,\n fleet: fleet\n }\n\n data[:options] = options if options\n result = Util.send_request(\"POST\", \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
calls 'choose_hero' to display all the cards to the user, and assigns their choice to 'card' TTY prompt for the yes/no menu if 'yes', creates a new row in the card table for that specific user_id, assigning them that card_id asks if user wants to select another card, if they do it calls on itself to offer the choices a... | def choose_and_add_card_to_user_deck
prompt = TTY::Prompt.new
card = choose_hero
response = prompt.select('Do you want to add this card to your collection?', %w(Yes No))
if response == "Yes"
added_card = UserCard.create(user_id: self.id, card_id: card.id)
puts "#{added_card.card.name.upcase}... | [
"def choose_hero\n prompt = TTY::Prompt.new\n names = Card.all.map {|cards| cards[\"name\"]}\n selected_name = prompt.select('Choose a character', names, filter: true, cycle: true, help: \"(Start typing to filter results)\",help_color: :green, active_color: :yellow, per_page: 20)\n hero = Card.find_by(name: sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get 5 random cards from the cards table, add them to the user's collection | def open_pack
cards = Card.all.sample(5)
cards.each { |card| UserCard.create(user_id: self.id, card_id: card.id)}
names = cards.map { |card| card.name }
puts "#{names.join(", ").upcase} ...were added to your collection!"
sleep(3)
end | [
"def generate_cards(user)\n rand(1..3).times do\n c = CreditCard.new\n c.number = Faker::Business.credit_card_number\n c.expiration_month = rand(1..12)\n c.expiration_year = rand(2016..2020)\n c.csv_code = rand(100..999)\n c.default_billing = true\n c.user_id = user.id\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
iterates over all the cards for that user, passes resulting array of names to TTY prompt to display choices. choice from the list of names is stored in selected_card_name the card object for that choice is stored in selected_card the UserCard object from that specific user's collection is stored in choice choice is des... | def delete_card
prompt = TTY::Prompt.new
your_cards = self.cards
card_names = your_cards.map { |card| card["name"] }
selected_card_name = prompt.select('Choose a character to delete', card_names, filter: true, cycle: true, help: "(Start typing to filter results)", help_color: :green, active_color: :yel... | [
"def list_hand_cards(card_array) \n user_choice = \"\"\n while user_choice != \"⬅️ BACK ⬅️\" && user_choice != \"🗑 DELETE READING 🗑\" do\n user_choice = prompt.select(\"🔮 #{self.user.name}, Select a card to see more details.\") do |menu|\n card_emoji_string = \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
finds the users cards, removes any duplicates and subtracts that number from total cards (160) Displays message showing how many cards user still needs to complete colletion. | def cards_left_to_collect
card_ids = UserCard.select {|card| card["user_id"] == self.id}
remaining = Card.all.count - card_ids.map { |card| card["card_id"] }.uniq.count
if remaining == 0
puts "====================================================================="
puts "Congratulations, you have ... | [
"def removeCards\n\t\t@userChoice.each do |card1|\n\t\t\t@table.each do |card2|\n\t\t\t\tif card1.path == card2.path\n\t\t\t\t\t@table.delete(card2)\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\tend\n\tend",
"def full_dance_card\n\t\tif @card.length > 5\n\t\t\tputs \"Your dance card is full! You have to dance with #{@card... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unit + balance text | def units_balance
return "#{@unit} balance" if @unit.present?
'Balance'
end | [
"def output_balance\n '£' + '%.2f' % @balance\n end",
"def print_balance\n \"Your balance is now: £#{self.balance}\"\n end",
"def display_balance\n \"Your balance is $#{@balance}.\"\n end",
"def prt_balance\n b = self.balance\n return \"#{'-' if b.cents<0}#{b.currency.symbol}#{b.abs... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /purchase_templates/1 GET /purchase_templates/1.json | def show
@purchase_template = PurchaseTemplate.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @purchase_template }
end
end | [
"def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end",
"def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end",
"def details\n response = get \"/templates/#{template_id}.json\", {}\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /purchase_templates/new GET /purchase_templates/new.json | def new
@purchase_template = PurchaseTemplate.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @purchase_template }
end
end | [
"def new\n @ticket_template = @current_account.ticket_templates.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket_template }\n end\n end",
"def new\n @template = Template.new\n\n respond_to do |format|\n format.html # new.html.erb... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /purchase_templates POST /purchase_templates.json | def create
@purchase_template = PurchaseTemplate.new(params[:purchase_template])
respond_to do |format|
if @purchase_template.save
format.html { redirect_to @purchase_template, notice: 'Purchase template was successfully created.' }
format.json { render json: @purchase_template, status: :... | [
"def create(options)\n API::request(:post, 'subscription_agreement_templates', options)\n end",
"def add_report_template(args = {}) \n post(\"/reports.json/template\", args)\nend",
"def create(values)\n @client.call(method: :post, path: 'templates', body_values: values)\n end",
"def cr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /purchase_templates/1 PUT /purchase_templates/1.json | def update
@purchase_template = PurchaseTemplate.find(params[:id])
respond_to do |format|
if @purchase_template.update_attributes(params[:purchase_template])
format.html { redirect_to @purchase_template, notice: 'Purchase template was successfully updated.' }
format.json { head :no_conten... | [
"def update_report_template(args = {}) \n put(\"/reports.json/template/#{args[:templateId]}\", args)\nend",
"def create\n @purchase_template = PurchaseTemplate.new(params[:purchase_template])\n\n respond_to do |format|\n if @purchase_template.save\n format.html { redirect_to @purchase_template, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /purchase_templates/1 DELETE /purchase_templates/1.json | def destroy
@purchase_template = PurchaseTemplate.find(params[:id])
@purchase_template.destroy
respond_to do |format|
format.html { redirect_to purchase_templates_url }
format.json { head :no_content }
end
end | [
"def delete\n response = CreateSend.delete \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n @invoice_template = InvoiceTemplate.find(params[:id])\n @invoice_template.destroy\n\n respond_to do |format|\n format.html { redirect_to invoice_templates_url }\n format.json { head ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /serie_detalles POST /serie_detalles.json | def create
@serie_detalle = SerieDetalle.new(serie_detalle_params)
respond_to do |format|
if @serie_detalle.save
format.html { redirect_to @serie_detalle, notice: 'Serie detalle was successfully created.' }
format.json { render :show, status: :created, location: @serie_detalle }
els... | [
"def create\n @detalle = Detalle.new(params[:detalle])\n\n respond_to do |format|\n if @detalle.save\n format.html { redirect_to @detalle, notice: 'Detalle was successfully created.' }\n format.json { render json: @detalle, status: :created, location: @detalle }\n else\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /serie_detalles/1 PATCH/PUT /serie_detalles/1.json | def update
respond_to do |format|
if @serie_detalle.update(serie_detalle_params)
format.html { redirect_to @serie_detalle, notice: 'Serie detalle was successfully updated.' }
format.json { render :show, status: :ok, location: @serie_detalle }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n if @registro_cliente_servicio_detalle.update(registro_cliente_servicio_detalle_params)\n format.html { redirect_to @registro_cliente_servicio_detalle, notice: 'Cliente servicio detalle was successfully updated.' }\n format.json { render :show, status: :ok... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /serie_detalles/1 DELETE /serie_detalles/1.json | def destroy
@serie_detalle.destroy
respond_to do |format|
format.html { redirect_to serie_detalles_url, notice: 'Serie detalle was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @detalle = Detalle.find(params[:id])\n @detalle.destroy\n\n respond_to do |format|\n format.html { redirect_to detalles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @venta_detalle = VentaDetalle.find(params[:id])\n @venta_detalle.destroy\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /task_stats/1 GET /task_stats/1.json | def show
@task_stat = TaskStat.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @task_stat }
end
end | [
"def stats\n get 'stats', format: 'json'\n end",
"def stats\n # find project\n @project = Project.find(params[:id])\n # check user is manager of project\n if (!@superuser_is_superadmin && !(superuser_is_part_of_project? @project))\n flash[:warning] = \"You can't see stats for this p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /task_stats/new GET /task_stats/new.json | def new
@task_stat = TaskStat.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @task_stat }
end
end | [
"def create\n @task_stat = TaskStat.new(params[:task_stat])\n\n respond_to do |format|\n if @task_stat.save\n format.html { redirect_to @task_stat, notice: 'Task stat was successfully created.' }\n format.json { render json: @task_stat, status: :created, location: @task_stat }\n else\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /task_stats POST /task_stats.json | def create
@task_stat = TaskStat.new(params[:task_stat])
respond_to do |format|
if @task_stat.save
format.html { redirect_to @task_stat, notice: 'Task stat was successfully created.' }
format.json { render json: @task_stat, status: :created, location: @task_stat }
else
forma... | [
"def statistics_task_by_status_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatisticsApi.statistics_task_by_status ...'\n end\n # resource path\n local_var_path = '/statistics/task_by_status'\n\n # query parameters\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /task_stats/1 PUT /task_stats/1.json | def update
@task_stat = TaskStat.find(params[:id])
respond_to do |format|
if @task_stat.update_attributes(params[:task_stat])
format.html { redirect_to @task_stat, notice: 'Task stat was successfully updated.' }
format.json { head :no_content }
else
format.html { render acti... | [
"def update\n if @task.update(task_param)\n render json: get_task_hash(@task)\n else\n render json: @task.errors.full_messages\n end\n end",
"def update\n @task_metric = TaskMetric.find(params[:id])\n\n respond_to do |format|\n if @task_metric.update_attributes(params[:task_metric])... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /task_stats/1 DELETE /task_stats/1.json | def destroy
@task_stat = TaskStat.find(params[:id])
@task_stat.destroy
respond_to do |format|
format.html { redirect_to task_stats_url }
format.json { head :no_content }
end
end | [
"def destroy\n @task_metric = TaskMetric.find(params[:id])\n @task_metric.destroy\n\n respond_to do |format|\n format.html { redirect_to task_metrics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @system_task_statu = SystemTaskStatu.find(params[:id])\n @system_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
initialize the 'verse with empty hash to add planets to | def initialize(verse)
@the_verse = verse
@planets = {}
end | [
"def initialize(h = {})\n @vector = Hash.new(0)\n @vector = @vector.merge!(h)\n end",
"def initialize(market_hash)\n @id = market_hash[:id]\n @name = market_hash[:name]\n @address = market_hash[:address]\n @city = market_hash[:city]\n @county = market_hash[:county]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to add new planets to the hash, adding name as key | def new_planet(planet)
@planets[planet.name] = planet
end | [
"def add_planets(planet_hash)\n planet_hash.each do |planet, planet_info|\n @planets[planet] = planet_info\n end\n end",
"def add_one_planet(planet, planet_info)\n @planets[planet] = planet_info\n end",
"def add new_planet\n @planets << new_planet\n end",
"def add_planet (planet)\n @pla... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register one or more Interceptors which will be called before SMS is sent. | def register_interceptors(*interceptors)
interceptors.flatten.compact.each { |interceptor| register_interceptor(interceptor) }
end | [
"def register_interceptors(*interceptors); end",
"def register_interceptors(*interceptors)\n interceptors.flatten.compact.each { |interceptor| register_interceptor(interceptor) }\n end",
"def unregister_interceptors(*interceptors); end",
"def register_interceptor(interceptor)\r\n delivery_i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register an Observer which will be notified when SMS is delivered. Either a class, string or symbol can be passed in as the Observer. If a string or symbol is passed in it will be camelized and constantized. | def register_observer(observer)
delivery_observer = case observer
when String, Symbol
observer.to_s.camelize.constantize
else
observer
end
Sms.register_observer(delivery_observer)
end | [
"def register_observer(observer)\n delivery_observer = (observer.is_a?(String) ? observer.constantize : observer)\n Mail.register_observer(delivery_observer)\n end",
"def register_observer(observer)\n Mail.register_observer(observer_class_for(observer))\n end",
"def register_obser... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register an Interceptor which will be called before SMS is sent. Either a class, string or symbol can be passed in as the Interceptor. If a string or symbol is passed in it will be camelized and constantized. | def register_interceptor(interceptor)
delivery_interceptor = case interceptor
when String, Symbol
interceptor.to_s.camelize.constantize
else
interceptor
end
Sms.register_interceptor(delivery_interceptor)
end | [
"def register_interceptor(interceptor)\n delivery_interceptor = (interceptor.is_a?(String) ? interceptor.constantize : interceptor)\n Mail.register_interceptor(delivery_interceptor)\n end",
"def register_interceptor(interceptor)\n Mail.register_interceptor(observer_class_for(interceptor)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the name of current carrier. If this is an anonymous carrier, this method will return +anonymous+ instead. | def carrier_name
@carrier_name ||= anonymous? ? "anonymous" : name.underscore
end | [
"def carrier_name\r\n self.class.carrier_name\r\n end",
"def carrier_name\n carrier.name unless carrier.blank?\n end",
"def carrier_code\n @raw_data[:CarrierCode]\n end",
"def get_carrier\n return self.sendcmd(\"modem.get_carrier\")\n end",
"def carrier=(carrier)\n @carrie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wraps an SMS delivery inside of ActiveSupport::Notifications instrumentation. This method is actually called by the Sms object itself through a callback when you call :deliver on the Sms, calling +deliver_sms+ directly and passing a Sms will do nothing except tell the logger you sent the SMS. | def deliver_sms(sms) #:nodoc:
ActiveSupport::Notifications.instrument("deliver.sms_carrier") do |payload|
set_payload_for_sms(payload, sms)
yield # Let Sms do the delivery actions
end
end | [
"def deliver\n #inform_interceptors\n if delivery_handler\n delivery_handler.deliver_sms(self) { do_delivery }\n else\n do_delivery\n end\n inform_observers\n self\n end",
"def deliver(sms)\n new.deliver!(sms)\n end",
"def deliver_sms(options={})\n#puts... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the name of the carrier object. | def carrier_name
self.class.carrier_name
end | [
"def carrier_name\n carrier.name unless carrier.blank?\n end",
"def carrier_name\r\n @carrier_name ||= anonymous? ? \"anonymous\" : name.underscore\r\n end",
"def getName()\n return @obj_name\n end",
"def carrier_named(str)\n format(str, @carrier)\n end",
"def object_name\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The main method that creates the message and renders the SMS templates. There are two ways to call this method, with a block, or without a block. It accepts a headers hash. This hash allows you to specify the most used headers in an SMS message, these are: +:to+ Who the message is destined for, can be a string of addre... | def sms(options = {})
return @_message if @_sms_was_called && options.blank?
m = @_message
# Call all the procs (if any)
default_values = {}
self.class.default.each do |k,v|
default_values[k] = v.is_a?(Proc) ? instance_eval(&v) : v
end
# Handle defaults
... | [
"def generate_message(&block)\n require 'net/smtp'\n require 'smtp_tls'\n require 'mail'\n mail = Mail.new(&block)\n mail.delivery_method(*smtp_settings)\n mail\n end",
"def makemsg\n # if this is a nagios template, use the ENV vars to build the template\n # else just use ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /weapons/1 GET /weapons/1.json | def show
@weapon = Weapon.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @weapon }
end
end | [
"def index\n @weapons = Weapon.all\n\n render json: @weapons\n end",
"def show\n @weapons_type = WeaponsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weapons_type }\n end\n end",
"def show\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /weapons/new GET /weapons/new.json | def new
@weapon = Weapon.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @weapon }
end
end | [
"def new\n @weapons_type = WeaponsType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weapons_type }\n end\n end",
"def new\n @weapon_kind = WeaponKind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /weapons POST /weapons.json | def create
@weapon = Weapon.new(params[:weapon])
respond_to do |format|
if @weapon.save
format.html { redirect_to @weapon, notice: 'Weapon was successfully created.' }
format.json { render json: @weapon, status: :created, location: @weapon }
else
format.html { render action:... | [
"def create\n @weapon = Weapon.new(weapon_params)\n\n if @weapon.save\n render json: @weapon, status: :created, location: @weapon\n else\n render json: @weapon.errors, status: :unprocessable_entity\n end\n end",
"def create\n @weapon = Weapon.new(weapon_params)\n\n respond_to do |form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /weapons/1 PUT /weapons/1.json | def update
@weapon = Weapon.find(params[:id])
respond_to do |format|
if @weapon.update_attributes(params[:weapon])
format.html { redirect_to @weapon, notice: 'Weapon was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
... | [
"def update\n @weapon = Weapon.find(params[:id])\n\n if @weapon.update(weapon_params)\n head :no_content\n else\n render json: @weapon.errors, status: :unprocessable_entity\n end\n end",
"def update\n @weapon_type = WeaponType.find(params[:id])\n\n if @weapon_type.update(weapon_type_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /weapons/1 DELETE /weapons/1.json | def destroy
@weapon = Weapon.find(params[:id])
@weapon.destroy
respond_to do |format|
format.html { redirect_to weapons_url }
format.json { head :no_content }
end
end | [
"def destroy\n @weapons_type = WeaponsType.find(params[:id])\n @weapons_type.destroy\n\n respond_to do |format|\n format.html { redirect_to weapons_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @weapon = Weapon.find(params[:id])\n @weapon.destroy\n\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Opens google analytics for given date range | def analytics_day(start_date=nil, end_date=nil)
start_date = start_date ? Date.parse("#{start_date}/2010") : Date.today
start_date = start_date.strftime("%Y%m%d")
end_date ||= start_date
"https://www.google.com/analytics/reporting/?reset=1&id=14680769&pdr=#{start_date}-#{end_date}"
end | [
"def campaigns_daily_report show_id, date_range, format\n \n params = {\n :show_id => show_id,\n :date_range => date_range,\n :format => format\n }\n \n response = connection.do_get(construct_url(\"analytics\", \"request_campaigns_daily_r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds an array of FileName Objects (array of files), and prints to console how many files scanned iterates through each item in the cwd, determines if it's a file if it's a file push it to the an array of FileName objects and print every time it scans another 100 items or it's a directory, cd into dir and recursively ... | def buildArray(localObjCache, increase)
localDirContents=[] #Array of all items in the cwd
localDirContents=Dir[Dir.pwd+"/*"] #Builds the array of items in cwd
localDirContents.each do |item|
if File.file?(item)
fileObj = FileName.new(item)
localObjCache.push(fileObj)
n = increase.call #printing e... | [
"def run_through_directory\n@file_array = []\n Dir.foreach('text_files') do |item|\n next if item == '.' or item == '..'\n @file_array << item\n end\nend",
"def process_files( aDir )\n\tunless FileTest.directory?(aDir)\n\t\tputs \"Error. Invalid input for report directory: #{aDir}.\"\n\t\texit\n\tend # un... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compares each fileObj's md5sum against all But first, if it's empty write to push it to a blanks array However, if equal create a hash of the files and | def findDups(objArray, dupsHashArray, emptyFileArray)
objArray.each_with_index do |obj, idx1|
if obj.is_empty?
emptyFileArray.push(obj.fileName)
next
end
objArray.each_with_index do |obj2, idx2|
next if idx1 >= idx2
if obj.md5 === obj2.md5
foundDupHash= {:filePath => obj.fileName, :... | [
"def md5_duplicates\n CfsFile.where(md5_sum: md5_sum).where('id != ?', id).to_a\n end",
"def digest_md5(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::MD5.hexdigest(File.read(file)) : nil\n }\n end",
"def calculate_md5\n @files.each do |f|\n @md5[f] = Di... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Print all blanks to a file | def printEmpty(emptyFileArray)
puts "Writing blanks to: /tmp/blanks.txt"
File.open("/tmp/blanks.txt", "w") do |f|
emptyFileArray.each { |element| f.puts(element)}
end
end | [
"def write_empty\r\n write_line('')\r\n end",
"def blank_line\n output \"\"\n end",
"def write_white_space\r\n #@file.write String.new.rjust(@indentation)\r\n @file.write(' ' * @indentation)\r\n end",
"def print_blanks_array\n @blanks_array.join(' ')\n end",
"def out... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write all dups to a file | def printDups(dupsHashArray)
puts "Writing duplicates to: /tmp/duplicates.txt"
File.open("/tmp/duplicates.txt","w") do |f|
dupsHashArray.each { |element| f.puts(element[:filePath] + " : " + element[:duplicatePath]) }
end
end | [
"def remove_duplicate_entries\n File.open(\"#{output_directory_path}unique_ucf_lists.txt\", \"w+\") { |file|\n file.puts File.readlines(single_bad_ucf_file).uniq\n }\n end",
"def reopen_logs\n to_reopen = []\n append_flags = File::WRONLY | File::APPEND\n\n ObjectSpace.each_object(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the string representation of the angle (default unit: radians). | def to_s(unit = :radians)
case unit
when :degrees, :deg then "#{@degrees}°"
when :radians, :rad then "#@radians rad"
else
raise InvalidArgumentsError, "Unit should be :degrees, :deg, :radians ord :rad."
end
end | [
"def format_angle(value, unit)\n value + case unit\n when :degree then '\\degree'\n when :gon then '\\unit{gon}'\n when :radian then '\\unit{radian}'\n end\n end",
"def format_angle(value, unit)\n if unit == :degree\n value + '°'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Normalize the angle (in degrees) and converts it in radians. | def convert_and_normalize_degrees(angle)
@degrees = normalize_angle(angle, 360)
@radians = deg_to_rad(@degrees)
end | [
"def convert_and_normalize_radians(angle)\n @radians = normalize_angle(angle, (2 * Math::PI))\n @degrees = rad_to_deg(@radians)\n end",
"def norm_angle(angle)\n while angle < 0; angle += Const::PI2; end\n while angle > Const::PI2; angle -= Const::PI2; end\n return angle\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Normalize the angle (in radians) and converts it in degrees. | def convert_and_normalize_radians(angle)
@radians = normalize_angle(angle, (2 * Math::PI))
@degrees = rad_to_deg(@radians)
end | [
"def convert_and_normalize_degrees(angle)\n @degrees = normalize_angle(angle, 360)\n @radians = deg_to_rad(@degrees)\n end",
"def normalize_angle(angle)\n if angle > Math::PI\n angle - 2 * Math::PI\n elsif angle < -Math::PI\n angle + 2 * Math::PI\n else\n angle\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Instantiates a new Science::Angle with the unit "radians". | def radians
Science::Angle.new(self, :radians)
end | [
"def angle_unit=(unit)\n unless unit == :deg || unit == :rad\n raise ArgumentError, \"Unknown angle unit '#{unit}'\"\n end\n\n @angle_unit = unit\n end",
"def rotate(radians)\n sin = Math.sin radians\n cos = Math.cos radians\n Vector.new cos * @x - sin * @y, sin * @x + cos ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return symbol name for supported digest algorithms and string name for custom ones. | def digest_algorithm
@digester.symbol || @digester.digest_name
end | [
"def signature_digest_algorithm\n @sign_digester.symbol || @sign_digester.digest_name\n end",
"def name\n # See function: c_digest_name(...) in ext/sha3/_digest.c\n end",
"def name\n name_ptr = FFI::MemoryPointer.new(:pointer)\n result = @handle.interface[:md_name].call(@handle.contain... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allows to change algorithm for node digesting (default is SHA1). You may pass either a one of +:sha1+, +:sha256+ or +:gostr3411+ symbols or +Hash+ with keys +:id+ with a string, which will denote algorithm in XML Reference tag and +:digester+ with instance of class with interface compatible with +OpenSSL::Digest+ class... | def digest_algorithm=(algorithm)
@digester = Kiji::Digester.new(algorithm)
end | [
"def digest_instance algorithm\n case algorithm.to_s.strip.downcase\n when /\\Asha-?1\\z/\n Digest::SHA1.new\n when /\\Asha-?256\\z/\n Digest::SHA256.new\n when /\\Asha-?512\\z/\n Digest::SHA512.new\n when /\\Asha-?384\\z/\n Digest::SHA384.new\n when /\\Amd-?5\\z/\n Digest... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return symbol name for supported digest algorithms and string name for custom ones. | def signature_digest_algorithm
@sign_digester.symbol || @sign_digester.digest_name
end | [
"def digest_algorithm\n @digester.symbol || @digester.digest_name\n end",
"def name\n # See function: c_digest_name(...) in ext/sha3/_digest.c\n end",
"def name\n name_ptr = FFI::MemoryPointer.new(:pointer)\n result = @handle.interface[:md_name].call(@handle.container, name_ptr)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Allows to change digesting algorithm for signature creation. Same as +digest_algorithm=+ | def signature_digest_algorithm=(algorithm)
@sign_digester = Kiji::Digester.new(algorithm)
end | [
"def signature_digest_algorithm\n @sign_digester.symbol || @sign_digester.digest_name\n end",
"def digest_algorithm=(algorithm)\n @digester = Kiji::Digester.new(algorithm)\n end",
"def digest_instance algorithm\n case algorithm.to_s.strip.downcase\n when /\\Asha-?1\\z/\n Digest::SHA1.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Receives certificate for signing and tries to guess a digest algorithm for signature creation. Will change +signature_digest_algorithm+ and +signature_algorithm_id+ for known certificate types and reset to defaults for others. | def cert=(certificate)
@cert = certificate
# Try to guess a digest algorithm for signature creation
case @cert.signature_algorithm
when 'GOST R 34.11-94 with GOST R 34.10-2001'
self.signature_digest_algorithm = :gostr3411
self.signature_algorithm_id = 'http://www.w3.org/2001/04/x... | [
"def signature_digest_algorithm=(algorithm)\n @sign_digester = Kiji::Digester.new(algorithm)\n end",
"def signature_digest_algorithm\n @sign_digester.symbol || @sign_digester.digest_name\n end",
"def digest\n case @signature_method\n when \"HMAC-SHA256\" then OpenSSL::Digest.new(\"sha2... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Digests some +target_node+, which integrity you wish to track. Any changes in digested node will invalidate signed message. All digest should be calculated before signing. Available options: [+:id+] Id for the node, if you don't want to use automatically calculated one [+:inclusive_namespaces+] Array of namespace prefi... | def digest!(target_node, options = {})
wsu_ns = namespace_prefix(target_node, WSU_NAMESPACE)
current_id = target_node["#{wsu_ns}:Id"] if wsu_ns
id = options[:id] || current_id || "_#{Digest::SHA1.hexdigest(target_node.to_s)}"
# if id.to_s.size > 0
# wsu_ns ||= namespace_prefix(target_nod... | [
"def digest(*args)\n options = args.extract_options!\n ::Klarna::API.digest(*[(self.store_id unless options[:store_id] == false), args, self.store_secret].compact.flatten)\n end",
"def generate_digest(element, algorithm)\n element = document.at_xpath(element, namespaces) if element... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sign document with provided certificate, private key and other options This should be very last action before calling +to_xml+, all the required nodes should be digested with +digest!+ before signing. Available options: [+:security_token+] Serializes certificate in DER format, encodes it with Base64 and inserts it with... | def sign!(options = {})
binary_security_token_node if options[:security_token]
x509_data_node if options[:issuer_serial]
if options[:inclusive_namespaces]
c14n_method_node = signed_info_node.at_xpath('ds:CanonicalizationMethod', ds: 'http://www.w3.org/2000/09/xmldsig#')
inclusive_name... | [
"def canonicalized_signed_info\n\n parametros = ActiveSupport::OrderedHash.new\n parametros[\"xmlns\"] = \"http://www.w3.org/2000/09/xmldsig#\"\n parametros[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n parametros[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n \n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Searches in namespaces, defined on +target_node+ or its ancestors, for the +namespace+ with given URI and returns its prefix. If there is no such namespace and +desired_prefix+ is specified, adds such a namespace to +target_node+ with +desired_prefix+ | def namespace_prefix(target_node, namespace, desired_prefix = nil)
ns = target_node.namespaces.key(namespace)
if ns
ns.match(/(?:xmlns:)?(.*)/) && Regexp.last_match(1)
elsif desired_prefix
target_node.add_namespace_definition(desired_prefix, namespace)
desired_prefix
end
... | [
"def namespace_prefix(target_node, namespace, desired_prefix = nil)\n ns = target_node.namespaces.key(namespace)\n if ns\n ns.match(/(?:xmlns:)?(.*)/) && $1\n elsif desired_prefix\n target_node.add_namespace_definition(desired_prefix, namespace)\n desired_prefix\n end\n end",
"def get_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TODO: Given an array of integers, find the two subsequences that are disjoint and contiguous such that the difference of their sums is maximized. | def disjoint_attempt(arr)
part = [0]
maxPrev = [0]
maxLeft = []
minPrev = [0]
minLeft = []
max = 0
# main idea: subsequence sum is partial sum at end minus partial
# sum at start. Max score is thus either
# maxLeft[i] + maxPrev[i] - 2 * part[i] or
# - minLeft[i] - minPrev[i] + 2 * part[i]
# for ... | [
"def largest_continuous_subsum(arr)\n sub_sets = []\n arr.each_with_index do |el1, i|\n arr.each_with_index do |el2, j|\n sub_sets << arr[i..j] if j >= i\n end\n end\n large_sum = sub_sets[0].reduce(:+)\n sub_sets.each do |set|\n sum = set.reduce(:+)\n large_sum = sum if large_sum < sum\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
time to parse some lisp input: string with newlines and tabs output: parens around function blocks iterate through characters in the string there are several states the parser can be in the token counting state, where line tokens are counted up and tabs are counted the tab counting state, where tabs are being read to d... | def parse_lisp(str)
# TODO: handle the tab tree and resulting token structure
depth_stack = [] # can have (, ", and [
current_token = nil
state_stack = []
state = "token counting"
tab_count = 0
str.each_char do |char|
current_token << char
if state == "tab counting" && char != "\t"
# do stuff wi... | [
"def cooktime\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n value = nil\n cooktime_start_index = @input.index\n lineorstop10 = nil\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the number of atoms in a sequence. If type is given, return the number of specific atoms in a sequence. | def total_atoms(type=nil)
if !type.nil?
type = type.to_sym
if /^(?:C|H|O|N|S){1}$/ !~ type.to_s
raise ArgumentError, "type must be C/H/O/N/S/nil(all)"
end
end
num_atom = {:C => 0,
:H => 0,
:O => 0,
:N => 0,
... | [
"def count_with_type(type)\n with_type(type).length\n end",
"def amount(type)\n return list(type).length\n end",
"def countAtoms(seq)\n\t\t\t\to = 0\n\t\t\t\tn = 0\n\t\t\t\tc = 0\n\t\t\t\th = 0\n\t\t\t\ts = 0\n\t\t\t\tp = 0\n\t\t\t\tse = 0\n\t\t\t\tseq.each_char do |aa|\n\t\t\t\t\to = o + MS... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the number of nitrogens. | def num_nitro
@num_nitro ||= total_atoms :N
end | [
"def number_of_occurrences\n return @number_of_occurrences\n end",
"def number_of_concept_genres(login=nil)\n count_by_frbr(login, :has_as_its_genre, :how_many_concepts?) \n end",
"def n_itens\n n = 0\n self.produtos_quantidades.each { |c| n += c.qtd }\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the number of oxygens. | def num_oxygen
@num_oxygen ||= total_atoms :O
end | [
"def length\n number_of_otus\n end",
"def num_genotypes()\n @genotypes.size\n end",
"def number_of_occurrences\n return @number_of_occurrences\n end",
"def nb_opinions() opinion_ids.size end",
"def shape_count\r\n \r\n return @shapes.size\r\n\r\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the number of sulphurs. | def num_sulphur
@num_sulphur ||= total_atoms :S
end | [
"def num_snps()\n @snps.size\n end",
"def spicy_count\n self.spicies.size\n end",
"def number_llamas\n count\n end",
"def no_of_hops\n @hops\n end",
"def noOfStones()\r\n no = 0\r\n @field.each{\r\n |i|\r\n if i == @turn\r\n no += 1\r\n end\r\n\r\n }\r\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate molecular weight of an AA sequence. _Protein Mw is calculated by the addition of average isotopic masses of amino acids in the protein and the average isotopic mass of one water molecule._ | def molecular_weight
@mw ||= begin
mass = WATER_MASS
each_aa do |aa|
mass += AVERAGE_MASS[aa.to_sym]
end
(mass * 10).floor().to_f / 10
end
end | [
"def get_prot_mass(prot_seq)\r\n weights = {\"A\" =>71.03711,\"C\" => 103.00919,\"D\" => 115.02694,\"E\" => 129.04259,\"F\" => 147.06841,\r\n \"G\" => 57.02146,\"H\" => 137.05891,\"I\" => 113.08406,\"K\" => 128.09496,\"L\" => 113.08406,\r\n \"M\" => 131.04049,\"N\" => 114.04293,\"P\" =>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Claculate theoretical pI for an AA sequence with bisect algorithm. pK value by Bjelqist, et al. is used to calculate pI. | def theoretical_pI
charges = []
residue_count().each do |residue|
charges << charge_proc(residue[:positive],
residue[:pK],
residue[:num])
end
round(solve_pI(charges), 2)
end | [
"def p(i, j, k)\n state = pick_state(i)\n n = neighbours(i, k)\n if n.include?(j) then\n this_move_value = 0.0\n other_possible_moves_summed_value = 0.0\n state.transaction do\n this_move_value = state[:trails][[i, j]]\n other_pos... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return estimated half_life of an AA sequence. _The halflife is a prediction of the time it takes for half of the amount of protein in a cell to disappear after its synthesis in the cell. ProtParam relies on the "Nend rule", which relates the halflife of a protein to the identity of its Nterminal residue; the prediction... | def half_life(species=nil)
n_end = @seq[0].chr.to_sym
if species
HALFLIFE[species][n_end]
else
{
:ecoli => HALFLIFE[:ecoli][n_end],
:mammalian => HALFLIFE[:mammalian][n_end],
:yeast => HALFLIFE[:yeast][n_end]
}
end
end | [
"def calculate(person, end_date = Synthea::Config.end_date)\n # Disability-Adjusted Life Year = DALY = YLL + YLD\n # Years of Life Lost = YLL = (1) * (standard life expectancy at age of death in years)\n # Years Lost due to Disability = YLD = (disability weight) * (average duration of case)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate instability index of an AA sequence. _The instability index provides an estimate of the stability of your protein in a test tube. Statistical analysis of 12 unstable and 32 stable proteins has revealed [7] that there are certain dipeptides, the occurence of which is significantly different in the unstable pro... | def instability_index
@instability_index ||=
begin
instability_sum = 0.0
i = 0
while @seq[i+1] != nil
aa, next_aa = [@seq[i].chr.to_sym, @seq[i+1].chr.to_sym]
if DIWV.key?(aa) && DIWV[aa].key?(next_aa)
instability_sum += DIWV[aa][next_aa]... | [
"def aliphatic_index\n aa_map = aa_comp_map\n @aliphatic_index ||= round(aa_map[:A] +\n 2.9 * aa_map[:V] +\n (3.9 * (aa_map[:I] + aa_map[:L])), 2)\n end",
"def get_AIBC(i)\n @@tam = @medidas.length\n if i >= @@ta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return wheter the sequence is stable or not as String (stable/unstable). _Protein whose instability index is smaller than 40 is predicted as stable, a value above 40 predicts that the protein may be unstable._ | def stability
(instability_index <= 40) ? "stable" : "unstable"
end | [
"def stable?\n (instability_index <= 40) ? true : false\n end",
"def complete?\n return nil unless ivsat_table\n line = ivsat_table.split(\"\\n\").find{|l| l.include? 'INFO: Sequence completeness:' }\n line && !line.include?('partial')\n end",
"def stable\n self[:draft] == false && self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.