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 |
|---|---|---|---|---|---|---|
Public: Fetch the next LessonBooking for the user. Returns a LessonBooking record or nil. | def next_lesson_booking
return @next_lesson_booking if @next_lesson_booking
next_lesson_booking = user.lesson_bookings.upcoming.order('lessons.start_at').first
@next_lesson_booking = LessonBookingDecorator.decorate(next_lesson_booking) if next_lesson_booking
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next\n if lesson_number < Lesson.all.last.lesson_number\n Lesson.all.detect {|lesson| lesson.lesson_number < lesson_number}\n else\n Lesson.find_by(lesson_number: lesson_number)\n end\n end",
"def next_booking\n bookings.order(start_date: :asc).first\n end",
"def next_lesson\n le... | [
"0.6386694",
"0.6191953",
"0.5745626",
"0.56032735",
"0.5512974",
"0.54154825",
"0.5184624",
"0.50079364",
"0.49310786",
"0.4908619",
"0.4887906",
"0.4880366",
"0.4835789",
"0.483113",
"0.4813792",
"0.47901157",
"0.47370833",
"0.47329015",
"0.47319037",
"0.47163123",
"0.47044... | 0.75258076 | 0 |
Public: The started_at date of the last (ended) visit. Returns a String. | def last_visit_started_at
last_visit = user.visits.ended.order(:started_at).last
last_visit ? I18n.l(last_visit.started_at.to_date) : "/"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def started_at_date\n if !@started_at_date_string\n @started_at_date_string = self.start_date_time.strftime(\"%A %-m/%d/%Y\")\n end\n @started_at_date_string\n end",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def started_at; end",
"def st... | [
"0.6754164",
"0.650741",
"0.650741",
"0.650741",
"0.650741",
"0.650741",
"0.62749004",
"0.62744343",
"0.62366194",
"0.6203803",
"0.619767",
"0.6155505",
"0.60887635",
"0.60788035",
"0.6058005",
"0.6058005",
"0.60141915",
"0.5998591",
"0.5998591",
"0.5998591",
"0.5998591",
"... | 0.8109684 | 0 |
Public: The created_at date of the last (failed) payments. Returns a String. | def last_failed_payment_created_at
last_failed_payment = payments.with_state(:declined).order(:created_at).last
last_failed_payment ? I18n.l(last_failed_payment.created_at.to_date) : ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_payment_on\n payment_histories.try(:last).try(:payment_date)\n end",
"def last_failed_payment_reason\n last_failed_payment = payments.with_state(:declined).order(:created_at).last\n\n last_failed_payment && last_failed_payment.comment.present? ? last_failed_payment.comment : \"\"\n... | [
"0.6557758",
"0.6523902",
"0.6270224",
"0.624913",
"0.62441266",
"0.6138802",
"0.61084026",
"0.6107206",
"0.6043634",
"0.6021852",
"0.5993182",
"0.5989684",
"0.59096205",
"0.5906392",
"0.5889433",
"0.5879776",
"0.58683556",
"0.58639234",
"0.58559376",
"0.5855814",
"0.582256",... | 0.8608816 | 0 |
Public: The created_at date of the last lesson bookings. Returns a String. | def last_lesson_booking_created_at
last_lesson_booking = lesson_bookings.order(:created_at).last
last_lesson_booking ? I18n.l(last_lesson_booking.created_at.to_date) : ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_time_drinking\n if breast_feedings.count > 0\n breast_feedings.last.created_at\n else\n ''\n end\n end",
"def last_meeting_date\n if !self.meetings.last\n return nil\n end\n\n self.meetings.last.created_at\n end",
"def created_at\n\t\tobject... | [
"0.66197604",
"0.6594907",
"0.6521631",
"0.6377627",
"0.6326965",
"0.6326965",
"0.6326965",
"0.6326965",
"0.6320591",
"0.63203454",
"0.6315097",
"0.630511",
"0.62913173",
"0.62886316",
"0.6287454",
"0.6271946",
"0.62558645",
"0.62554884",
"0.62554884",
"0.62510866",
"0.624781... | 0.8313305 | 0 |
Public: The reason date of the last (failed) payments. Returns a String. | def last_failed_payment_reason
last_failed_payment = payments.with_state(:declined).order(:created_at).last
last_failed_payment && last_failed_payment.comment.present? ? last_failed_payment.comment : ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_failed_payment_created_at\n last_failed_payment = payments.with_state(:declined).order(:created_at).last\n\n last_failed_payment ? I18n.l(last_failed_payment.created_at.to_date) : \"\"\n end",
"def last_payment_on\n payment_histories.try(:last).try(:payment_date)\n end",
"def pa... | [
"0.7840966",
"0.6284026",
"0.6280392",
"0.61249185",
"0.60614246",
"0.5993087",
"0.59025013",
"0.58183414",
"0.5802675",
"0.5786412",
"0.5750654",
"0.57451403",
"0.57451403",
"0.57026386",
"0.5696277",
"0.5692255",
"0.5662121",
"0.5649442",
"0.56039584",
"0.56039584",
"0.5601... | 0.7901477 | 0 |
Public: The reason date of the last (failed) payments. Returns a String. | def last_subscription_name
last_subscription = subscriptions.includes(:subscription_plan).order(:created_at).last
last_subscription ? last_subscription.subscription_plan.name : ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_failed_payment_reason\n last_failed_payment = payments.with_state(:declined).order(:created_at).last\n\n last_failed_payment && last_failed_payment.comment.present? ? last_failed_payment.comment : \"\"\n end",
"def last_failed_payment_created_at\n last_failed_payment = payments.with_state(:dec... | [
"0.7901477",
"0.7840966",
"0.6284026",
"0.6280392",
"0.61249185",
"0.60614246",
"0.5993087",
"0.59025013",
"0.58183414",
"0.5802675",
"0.5786412",
"0.5750654",
"0.57451403",
"0.57451403",
"0.57026386",
"0.5696277",
"0.5692255",
"0.5662121",
"0.5649442",
"0.56039584",
"0.56039... | 0.0 | -1 |
Public: A link tag to use when displaying autocomplete data for a User. Returns a String. | def autocomplete_link
h.link_to '#' do
h.content_tag :div, class: 'row' do
h.content_tag(:div, profile_image_thumbnail, class: 'col-sm-2').html_safe +
h.content_tag(
:div,
"#{full_name} #{h.tag(:br)} #{I18n.t('user.decorator.last_visit')} #{last_visit_started_at}".html_safe,
class: 'col-sm-10'
).html_safe
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name( user )\n link_to user[\"first_name\"][0..8], link( user[\"uid\"] ), :target => \"_blank\"\n end",
"def full_user_link(user)\n link_to edit_user_path(user) do\n html = content_tag :strong, \"#{user.prename} #{user.name}\"\n html << \" (#{user.username})\"\n end\n end",
"def auto_c... | [
"0.6989713",
"0.67756903",
"0.67241126",
"0.6620647",
"0.6604165",
"0.65266323",
"0.6314645",
"0.6311315",
"0.6298081",
"0.6192027",
"0.61601317",
"0.60989916",
"0.60989916",
"0.60989916",
"0.60984516",
"0.60846514",
"0.6026635",
"0.60239726",
"0.601209",
"0.5990403",
"0.5963... | 0.73224664 | 0 |
Public: Build a Hash of required data to use as an autocomplete JSON response. Returns a Hash. | def as_json_for_autocomplete
{id: id, value: full_name, link: autocomplete_link}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_json\n to_return = Hash.new()\n to_return[:primary_key] = @primary_key\n to_return[:name] = @name\n to_return[:identifier] = @identifier\n to_return[:cloudkit_identifier] = @user_record_name\n to_return[:cloudkit_last_modified_device] = @cloudkit_last_modified_device\n to_return[:h... | [
"0.6158485",
"0.6098028",
"0.6064257",
"0.60611516",
"0.59925056",
"0.59441066",
"0.58858365",
"0.5853889",
"0.5820442",
"0.57829046",
"0.5773953",
"0.5767955",
"0.5745928",
"0.573454",
"0.57243544",
"0.5720522",
"0.5711681",
"0.5675797",
"0.5660568",
"0.5659987",
"0.56390095... | 0.7310635 | 0 |
=begin Name: W3E2_change_text.rb Description: Replace word in text Author: Arvinder Kang Date: 20140725 Licensed under the MIT license =end | def replace_word_in_text(text, orignal_word, replaced_word)
regex = %r[\b#{orignal_word}\b]
text.gsub(regex, replaced_word)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_text old_text, new_text, slide_number = 0\n \n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if old_text == ''\n raise 'old text not specified'\n end\n \n if n... | [
"0.7012226",
"0.66911596",
"0.66065156",
"0.65307134",
"0.6519848",
"0.6512943",
"0.6510973",
"0.64993095",
"0.6399547",
"0.6375923",
"0.6318604",
"0.62790287",
"0.6238349",
"0.62202686",
"0.6206677",
"0.6204758",
"0.6203201",
"0.6181058",
"0.604006",
"0.60352135",
"0.6014867... | 0.66211927 | 2 |
HACK: VCR is not threadsafe, and so tests running under VCR fail | def use_threads?
!defined?(VCR)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_all_calls_to_r\n ensure_endpoint_matches_cassette\n configure_vcr\n always_use_vcr\n\n # enable_update_mode # uncomment for development, see instructions above\nend",
"def authenticated_client\n VCR.use_cassette('authenticated_client') do\n RedditKit::Client.new redditkit_username, redditkit_pas... | [
"0.6820894",
"0.62843037",
"0.62094283",
"0.60987824",
"0.6068488",
"0.5976265",
"0.58760244",
"0.5819305",
"0.58036643",
"0.579484",
"0.57890594",
"0.5773612",
"0.57633305",
"0.5755279",
"0.56898713",
"0.56831455",
"0.55621725",
"0.55406827",
"0.5539293",
"0.5485018",
"0.544... | 0.5723915 | 14 |
allow to connect twitter/linkedin | def has_connection_with(provider)
auth = self.authorizations.where(provider: provider).first
if auth.present?
auth.token.present?
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def third_party_connect\n if tw_user_id.nil? && fb_user_id.nil?\n errors.add(\"Either twitter or facebook connect required\") \n end\n end",
"def twitter\n handle_oauth\n end",
"def connected_to_twitter?\n twitter_token && twitter_secret\n end",
"def twitter_connect\n access_token = OA... | [
"0.73619723",
"0.727",
"0.71526325",
"0.7006313",
"0.7004292",
"0.68301743",
"0.673461",
"0.6669247",
"0.6642057",
"0.6601837",
"0.6599731",
"0.6588453",
"0.6587248",
"0.6523163",
"0.64814967",
"0.646561",
"0.6431424",
"0.6390304",
"0.632691",
"0.6322139",
"0.62799823",
"0.... | 0.57058275 | 76 |
Returns true if the current user is following the other user. | def following?(other_user)
following.include?(other_user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n ... | [
"0.8531212",
"0.8511795",
"0.8511795",
"0.8511795",
"0.84812903",
"0.84812903",
"0.84812903",
"0.84812903",
"0.84237736",
"0.84133893",
"0.83408505",
"0.83408505",
"0.83408505",
"0.83408505",
"0.83408505",
"0.83408505",
"0.83408505",
"0.83408505",
"0.83408505",
"0.83408505",
... | 0.8306674 | 88 |
returns cell name for a profile path assumes only one cell folder can exist in a profile config path | def profile_cell(p_path)
::Dir.chdir("#{p_path}/config/cells")
cell = ::Dir.glob('*').select { |f| ::File.directory? f }
cell.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile_complete_path(profile_base_path, profile_name)\n File.join(\"#{profile_base_path}\", \"#{profile_name}\")\n end",
"def pathToCell(state)\n\t\treturn File.dirname(__FILE__) + \"/../../Assets/\" + @resolution +\"/Common/Backgrounds/\"+ @size +\"/\"+ state +\".png\"\n\tend",
"def load_profile_... | [
"0.59325475",
"0.5830892",
"0.5756489",
"0.5478807",
"0.54514104",
"0.54421943",
"0.5386187",
"0.5382519",
"0.532699",
"0.5272843",
"0.5246202",
"0.52301306",
"0.52287966",
"0.5225982",
"0.52210766",
"0.52112544",
"0.5190877",
"0.5189448",
"0.5173911",
"0.51712036",
"0.515523... | 0.80234164 | 0 |
creats the method of emails (being able to read and write) | def initialize(emails) # accepts strings of unformatted emails (sting of multiple emails )
@emails = emails # set the instance varibale email to the value for emails passed in arguement
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email; end",
"def email; end",
"def email; end",
"def email; end",
"def mailer; end",
"def mail; end",
"def mail; get_data_in_file :mail end",
"def mail_box; end",
"def get_mail\n \n end",
"def email_list\n end",
"def inbound_email; end",
"def inbound_email; end",
"def ... | [
"0.6957006",
"0.6957006",
"0.6957006",
"0.6957006",
"0.69209254",
"0.68221116",
"0.6563123",
"0.6533884",
"0.6488976",
"0.6370616",
"0.63418776",
"0.63418776",
"0.62548894",
"0.61965847",
"0.61870784",
"0.6172511",
"0.6148518",
"0.6120292",
"0.60655403",
"0.59853876",
"0.5963... | 0.5736677 | 38 |
Checks if the image dimensions are below the height and width thresholds | def check_dimensions(image)
if image.height < $max_height and image.width < $max_width
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_bigger_than?(dimensions)\n image_file_width > dimensions[:width] && image_file_height > dimensions[:height]\n end",
"def acceptable_size?\n \n return true if width > 50 and\n width < 100 and\n height > 50 and\n height < 100\n \n end",
"def... | [
"0.7845231",
"0.76549834",
"0.7480967",
"0.72111934",
"0.7187928",
"0.7000452",
"0.6975818",
"0.69533813",
"0.6952864",
"0.6777492",
"0.6742192",
"0.66938835",
"0.6660266",
"0.6658957",
"0.65825576",
"0.657412",
"0.65513283",
"0.6538593",
"0.65375966",
"0.65287",
"0.6481412",... | 0.8341829 | 0 |
Returns an array with all the parents of this administrative region The first position in the array is the +country+ and up to 3 more positions can contain the ADM1, ADM2 and ADM3 divisions containing this one | def containers
return @containers unless @containers.nil?
container_codes = []
codes = code.split('|')
container_codes << (codes = codes[0..-2]).join('|') while codes.size > 1
# first is country code
@containers = [country]
# second, third can be parent administrative division if not nil
# NOTE container codes is like: ["ES|58|PO", "ES|58", "ES"] (country is last)
@containers += Division.find_all_by_code container_codes[0..-2], :order => :level if container_codes.size > 1
return @containers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_hierarchy\n [\n parentADM4,\n parentADM3,\n parentADM2,\n parentADM1,\n parentCountry\n ].reject(&:empty?)\n end",
"def get_parents\n parents=\"\"\n parent_id_aux= parent_id\n while parent_id_aux!=0\n access = Access.find(pa... | [
"0.7557499",
"0.60089445",
"0.60017395",
"0.58615977",
"0.58610994",
"0.58571583",
"0.58510023",
"0.57173574",
"0.571164",
"0.569916",
"0.56954193",
"0.56876826",
"0.5682969",
"0.5641863",
"0.56355315",
"0.55960464",
"0.55948466",
"0.5574315",
"0.55722547",
"0.55651206",
"0.5... | 0.5633889 | 15 |
Initialize an Enumerable predicate | def initialize(left, right)
super(left, Immutable.freeze_object(right))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_predicate; end",
"def predicate(&block)\n @predicate = block unless block.nil?\n @predicate\n end",
"def initialize(predicate, arguments, &block)\n @predicate = predicate\n @arguments = arguments\n @block = block\n @@arguments << self\n end",
"def predicate_mat... | [
"0.64506173",
"0.63024455",
"0.6227391",
"0.6006142",
"0.6006142",
"0.60035056",
"0.5837363",
"0.575503",
"0.5662409",
"0.55983937",
"0.5583084",
"0.55297065",
"0.5507405",
"0.54452443",
"0.54401994",
"0.54372895",
"0.5421072",
"0.54148835",
"0.53934747",
"0.5359088",
"0.5315... | 0.0 | -1 |
All possible win combinations on the board | def initialize
@cells = *(0..9) # Splat operator creates an array of ten items, zero to nine
@cells[0] = nil # Ignore the 0th element
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def win_combos \n row_wins = @board.map { |x| x - 1 }.each_slice(@n).to_a\n column_wins = @columns.flatten.map { |x| x - 1 }.each_slice(@n).to_a \n diagonal_wins = @diagonals.flatten.map { |x| x - 1 }.each_slice(@n).to_a \n win_combos = row_wins + column_wins + diagonal_wins\n end",
"def winning_co... | [
"0.8556192",
"0.8010347",
"0.7588234",
"0.7439547",
"0.7342756",
"0.7146505",
"0.71234894",
"0.7104183",
"0.69800985",
"0.69605523",
"0.6925258",
"0.69098955",
"0.68909234",
"0.68865013",
"0.68829054",
"0.68589413",
"0.6848862",
"0.6830772",
"0.6826475",
"0.6807598",
"0.67920... | 0.0 | -1 |
The path under which all groups will be created. defaults to DEFAULT_ROOT if not set | def zk_root
@@mutex.synchronize { @@zk_root ||= DEFAULT_ROOT }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups\n g = File.join(@root,'groups')\n FileUtils.mkdir_p g\n Dir.chdir(File.join(@root,'groups')) do\n Dir['*']\n end\n end",
"def root\n @group.root\n end",
"def home_path_for(sling)\n if ( @path == nil )\n props = sling.get_node_props(group_url)\n ... | [
"0.6698444",
"0.6505229",
"0.6279678",
"0.6256979",
"0.6225523",
"0.6030893",
"0.60270435",
"0.6005298",
"0.5961455",
"0.5955674",
"0.59550834",
"0.5939628",
"0.5878174",
"0.5871947",
"0.5858435",
"0.5855708",
"0.58478504",
"0.5836977",
"0.5834179",
"0.58325195",
"0.58303076"... | 0.0 | -1 |
Sets the default global zk root path. | def zk_root=(path)
@@mutex.synchronize { @@zk_root = path.dup.freeze }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zk_root\n @@mutex.synchronize { @@zk_root ||= DEFAULT_ROOT }\n end",
"def root=(path)\n self.config[:root] = path\n end",
"def set_root_path!\n raise 'APP_ROOT is not set' unless defined?(::APP_ROOT)\n raise 'APP_ROOT is not a directory' unless File.directory?(::APP_... | [
"0.7282331",
"0.7174491",
"0.7162716",
"0.7127605",
"0.7048987",
"0.69978434",
"0.673274",
"0.65967554",
"0.6581437",
"0.6571168",
"0.65544546",
"0.6509867",
"0.64730704",
"0.6349257",
"0.6322991",
"0.62802786",
"0.62683296",
"0.6268175",
"0.6253122",
"0.6234249",
"0.6231204"... | 0.7482332 | 0 |
stop receiving event notifications, tracking membership changes, etc. XXX: what about memberships? | def close
synchronize do
return unless @created
@created = false
@broadcast_callback.shutdown
@on_connected_sub.unsubscribe
@membership_ev_sub.unsubscribe
@known_members.clear
@membership_subscriptions.each(&:unsubscribe)
@orig_zk.delete(@path, :ignore => [:no_node, :not_empty])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_notify_stop\n\t\t\t\tprint_status(\"Stopping the monitoring of sessions to Slack\")\n\t\t\t\tself.framework.events.remove_session_subscriber(self)\n\t\t\tend",
"def unsubscribe; end",
"def unsubscribed; end",
"def unsubscribed\n end",
"def unsubscribed\n end",
"def unsubscribe()\n \n ... | [
"0.6692853",
"0.6613558",
"0.6566871",
"0.64997053",
"0.64997053",
"0.6457893",
"0.64251935",
"0.6388641",
"0.6356709",
"0.62878716",
"0.6274981",
"0.6249755",
"0.6235084",
"0.6224862",
"0.6217233",
"0.6186599",
"0.6083457",
"0.60500693",
"0.6048061",
"0.60477173",
"0.6040761... | 0.0 | -1 |
this is "are we set up" not "did we create the group" | def created?
synchronize { !!@created }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def may_create_groups?\n\t\t\tmay_administrate?\n\t\tend",
"def may_create_group_membership?(group)\n\t\t\t!is_group_member?(group)\n\t\tend",
"def create_group\n group new_resource.group do\n gid new_resource.gid\n system true\n end\n end",
"def createGroup\n ... | [
"0.73660076",
"0.71067274",
"0.70654213",
"0.6980578",
"0.69086504",
"0.6859827",
"0.6790684",
"0.6731988",
"0.66901624",
"0.6682981",
"0.6589772",
"0.65625286",
"0.6552791",
"0.6525182",
"0.6522255",
"0.65033966",
"0.65008307",
"0.64986396",
"0.6484728",
"0.64825493",
"0.648... | 0.0 | -1 |
does the group exist already? | def exists?
zk.exists?(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_group?(name)\n run(\"id -g #{name}\").success?\n end",
"def has_group?\n @group == ''\n end",
"def group_exists?(group)\n Sys::Admin.get_group(group)\n true\n rescue\n false\n end",
"def group_exists?(name)\n @project.groups.where(name: name).count > 0\n ... | [
"0.8146093",
"0.7906453",
"0.7889404",
"0.78522336",
"0.7733418",
"0.77300274",
"0.76311207",
"0.76045215",
"0.7585952",
"0.7533957",
"0.7460858",
"0.7411494",
"0.73376167",
"0.7329158",
"0.72860783",
"0.7271405",
"0.7262648",
"0.7212708",
"0.72061515",
"0.7193252",
"0.715380... | 0.0 | -1 |
creates this group, does not raise an exception if the group already exists. | def create(*args)
synchronize do
begin
create!(*args)
rescue Exceptions::GroupAlreadyExistsError
# ok, this is a little odd, if you call create! and it fails, semantically
# in this method we're supposed to catch the exception and return. The problem
# is that the @known_members and @last_stat won't have been set up. we want
# both of these methods available, so we need to set that state up here, but
# only if create! fails in this particular way
@created = true
broadcast_membership_change!
nil
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createGroup\n call :createGroup\n end",
"def create\n ::ActiveRecord::Base.transaction do\n if group.save!\n membership = add_creator_as_group_admin!\n @side_effects << membership\n end\n end\n rescue ActiveRecord::RecordInvalid => _exception\n raise ... | [
"0.78416824",
"0.7770734",
"0.747698",
"0.713764",
"0.6999957",
"0.6997828",
"0.699643",
"0.6984709",
"0.6974676",
"0.6942253",
"0.69299036",
"0.6927978",
"0.69126886",
"0.69097435",
"0.68980414",
"0.689634",
"0.6876305",
"0.6839078",
"0.6825176",
"0.6752429",
"0.6730975",
... | 0.75714505 | 2 |
returns the current list of member names, sorted. | def member_names(opts={})
watch = opts.fetch(:watch, true)
absolute = opts.fetch(:absolute, false)
zk.children(path, :watch => watch).sort.tap do |rval|
rval.map! { |n| File.join(path, n) } if absolute
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def member_names; end",
"def members_list\n all_lifters.map {|lifters| lifters.name}\n end",
"def lifters_names\n lifters.map {|memeber| member.name}\n end",
"def names\n @list.keys\n end",
"def get_names\n @names\n end",
"def list_all_members\n @users.each { |x| puts \"-#{x.first}\"... | [
"0.7414323",
"0.71434253",
"0.70475894",
"0.67837375",
"0.67770296",
"0.6775538",
"0.6751699",
"0.6750602",
"0.6735427",
"0.6728839",
"0.6625439",
"0.66166943",
"0.6599597",
"0.6577622",
"0.65242076",
"0.65007615",
"0.64710814",
"0.6462248",
"0.6461188",
"0.64165473",
"0.6407... | 0.6820558 | 3 |
Register a block to be called back when the group membership changes. Notifications will be delivered concurrently (i.e. using the client's threadpool), but serially. In other words, when notification is delivered to us that the group membership has changed, we queue up notifications for all callbacks before handling the next event. This way each callback will see the same sequence of updates every other callback sees in order. They just may receive the notifications at different times. | def on_membership_change(opts={}, &blk)
MembershipSubscription.new(self, opts, blk).tap do |ms|
# the watch is registered in create!
synchronize { @membership_subscriptions << ms }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify(&block)\n @notify_blocks << block\n end",
"def on_quorumchg(&block)\n\t\t@quorumchg_callback = block\n\tend",
"def on_notification(&block)\n @callback = block\n end",
"def update &block\n receive_update_callbacks << block\n end",
"def on_change (&blo... | [
"0.6310603",
"0.61090535",
"0.6014383",
"0.59945005",
"0.58753896",
"0.5872062",
"0.5835674",
"0.5764829",
"0.57550985",
"0.5575949",
"0.5573399",
"0.557335",
"0.5545694",
"0.5401096",
"0.5380993",
"0.5380993",
"0.53080994",
"0.52494705",
"0.5237624",
"0.5198349",
"0.51677585... | 0.62351894 | 1 |
called by the MembershipSubscription object to deregister itself | def unregister(subscription)
synchronize do
@membership_subscriptions.delete(subscription)
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsubscribe\n unregister\n end",
"def unregister\n @is_registered = false\n self\n end",
"def unsubscribe\n @subscription_reference.unsubscribe\n end",
"def unsubscribe()\n \n end",
"def unsubscribe()\n end",
"def unsubscribe\n raise Unsubscribed... | [
"0.78600717",
"0.7358757",
"0.7348387",
"0.73150694",
"0.7295642",
"0.7294852",
"0.72936845",
"0.70590556",
"0.7046891",
"0.7039846",
"0.69800323",
"0.69687355",
"0.6960774",
"0.68909234",
"0.68909234",
"0.6812204",
"0.67677593",
"0.67486304",
"0.6742707",
"0.6720687",
"0.671... | 0.719396 | 7 |
Creates a Member instance for this Group. This its own method to allow subclasses to override. By default, uses Member | def create_member(znode_path, member_klass)
logger.debug { "created member #{znode_path.inspect} returning object" }
member_klass.new(@orig_zk, self, znode_path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @member = Member.new\n # set the initial data for member\n @member.role = MemberRole.general_role\n @member.account = current_member.account\n end",
"def new\n @member = Member.new\n end",
"def new\n @member = Member.new\n end",
"def new\n @member = Member.new\n end",
"de... | [
"0.68772805",
"0.67340297",
"0.67340297",
"0.67340297",
"0.67340297",
"0.6704309",
"0.6697304",
"0.6647272",
"0.65055066",
"0.6503195",
"0.6470129",
"0.6411981",
"0.6355018",
"0.6230526",
"0.6213394",
"0.6195529",
"0.6119378",
"0.60993624",
"0.6091246",
"0.60875905",
"0.60863... | 0.6598476 | 8 |
NOTE: no checksum computation is happening here (neither on our side, nor on cloud provider's). we're just comparing the checksum we have stored with the checksum we asked the cloud provider to store. we really don't expect any drift, but we're here, and it's a cheap check to do, and it'd be weird if they differed, so why not? TODO: in a later work cycle, we'd like to spot check some cloud archives: that is, pull the zip down, recompute the checksum for the retrieved zip, and make sure it matches what we stored. | def compare_checksum_metadata(s3_object, part)
replicated_checksum = s3_object.metadata['checksum_md5']
if part.md5 == replicated_checksum
part.update(last_checksum_validation: Time.zone.now)
true
else
results.add_result(
Audit::Results::ZIP_PART_CHECKSUM_MISMATCH,
endpoint_name: part.zipped_moab_version.zip_endpoint.endpoint_name,
s3_key: part.s3_key,
md5: part.md5,
replicated_checksum: replicated_checksum,
bucket_name: bucket_name
)
part.update(status: 'replicated_checksum_mismatch', last_checksum_validation: Time.zone.now)
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checksums; end",
"def checksum?\n self.checksum == compute_checksum\n end",
"def validate_checksum(file_to_check)\n # desired = fetch_checksum\n desired = ::File.read(\"#{Chef::Config['file_cache_path']}/#{new_resource.tarball_name}.md5\").split.last\n actual = Digest::MD5.hexdigest(::File.rea... | [
"0.6671739",
"0.6618571",
"0.6567923",
"0.64767045",
"0.63276017",
"0.6307273",
"0.61881506",
"0.61841804",
"0.6163735",
"0.61513966",
"0.6149621",
"0.613348",
"0.6075252",
"0.6068021",
"0.6052988",
"0.6033567",
"0.6021525",
"0.6000422",
"0.5997144",
"0.5986868",
"0.5983563",... | 0.62571025 | 6 |
Use callbacks to share common setup or constraints between actions. | def set_user_envelope
@user_envelope = UserEnvelope.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 user_envelope_params
params.require(:user_envelope).permit(:amount, :user_id, :envelope_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 |
Initialize a new event | def initialize(id, payload = EMPTY_HASH)
@id = id
@payload = payload
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(event = nil)\n @event = event\n end",
"def new\n @event = Event.new\n end",
"def new\n\t\t@event = Event.new\n\tend",
"def new\n \t@event = Event.new\n end",
"def new\n \t@event = Event.new\n end",
"def new\n @event = Event.new\n end",
"def new\n @event = Eve... | [
"0.7983124",
"0.75966996",
"0.7513011",
"0.7499263",
"0.7499263",
"0.73490137",
"0.73490137",
"0.73490137",
"0.73490137",
"0.73490137",
"0.73490137",
"0.73490137",
"0.72704697",
"0.71212435",
"0.7052115",
"0.7052115",
"0.6920688",
"0.68721205",
"0.682892",
"0.6816831",
"0.678... | 0.0 | -1 |
Get data from the payload | def [](name)
@payload.fetch(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data\n @payload['data']\n end",
"def payload\n @payload.fetch('payload')\n end",
"def payload\n @payload\n end",
"def payload\n @payload[0] if @payload\n end",
"def payload; end",
"def payload; end",
"def payload; message[:payload]; end",
"def inbound_payload\n JSON.par... | [
"0.84632015",
"0.7791073",
"0.76611465",
"0.76417816",
"0.73941505",
"0.73941505",
"0.73749775",
"0.72726715",
"0.7169842",
"0.7059741",
"0.68629557",
"0.6828518",
"0.6796839",
"0.6795984",
"0.67902654",
"0.67902654",
"0.67902654",
"0.67830575",
"0.6752781",
"0.6727405",
"0.6... | 0.6141729 | 83 |
Coerce an event to a hash | def to_h
@payload
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_to_hash(event)\n corrective_change = defined?(event.corrective_change) ? event.corrective_change : nil\n {\n \"status\" => event.status,\n \"timestamp\" => Puppet::Util::Puppetdb.to_wire_time(event.time),\n \"name\" => event.name,\n \"property\" ... | [
"0.76966494",
"0.73574054",
"0.7255504",
"0.7200569",
"0.7103141",
"0.6892392",
"0.68509936",
"0.6734007",
"0.65294456",
"0.6414735",
"0.62595576",
"0.62595576",
"0.62595576",
"0.62595576",
"0.62595576",
"0.62595576",
"0.6258157",
"0.61768466",
"0.61469126",
"0.6072788",
"0.6... | 0.0 | -1 |
Get or set a payload | def payload(data = nil)
if data
self.class.new(id, @payload.merge(data))
else
@payload
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_payload\n @payload = Payload.find(params[:id])\n end",
"def set_payload\n self.payload = self.create_payload\n end",
"def payload=(payload)\n @message[:payload] = payload\n end",
"def payload\n @payload.fetch('payload')\n end",
"def payload\n self.update(:payload)\n ... | [
"0.7900347",
"0.77152735",
"0.7580084",
"0.74429536",
"0.7318002",
"0.7194006",
"0.71465",
"0.7142833",
"0.7108387",
"0.7017994",
"0.6928271",
"0.6928271",
"0.6881357",
"0.67984307",
"0.6512983",
"0.64218783",
"0.64114785",
"0.6306765",
"0.63055056",
"0.6299268",
"0.62965554"... | 0.66472226 | 14 |
START_SPIDEROAK_COMMAND = '"ls al" Cm' | def exit_unless_log_dir_exists
unless Dir.exist?(LOG_DIR)
STDERR.puts "FATAL ERROR: the log dir: #{LOG_DIR} does not exist"
exit(CODE_LOG_DIR_DOES_NOT_EXIST)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ls(path = \"\")\n\t\tcmd 'ls ' + path.to_s\n\tend",
"def cli_prefix; end",
"def shell_commands(cmd, args); end",
"def command_prefix\n :_run_\n end",
"def command_start=(_arg0); end",
"def command_start=(_arg0); end",
"def command_start=(_arg0); end",
"def la\n send_command \"la\... | [
"0.5985156",
"0.59287935",
"0.57723355",
"0.5751157",
"0.57431877",
"0.57431877",
"0.57431877",
"0.5693799",
"0.56779635",
"0.56494",
"0.5636815",
"0.5581982",
"0.557535",
"0.557535",
"0.557535",
"0.55680615",
"0.5511497",
"0.5505764",
"0.5477648",
"0.5477648",
"0.5472338",
... | 0.0 | -1 |
XXX Resque doesn't call any job hooks in Resqueremove_queue. We don't get a chance to clean up the locks def test_lock_is_removed_after_remove_queue queue = Resque.queue_from_class(Job) Resque.enqueue(Job, "hello") assert_equal 1, Resque.size(queue) Resque.remove_queue(queue) assert_equal nil, Resque.redis.get(Job.lock("hello")) assert_equal nil, Resque.redis.get(Job.run_lock("hello")) end | def test_autoexpire_lock
Resque.enqueue(AutoexpireLockJob, 123)
sleep 2
Resque.enqueue(AutoexpireLockJob, 123)
assert_equal 2, Resque.size(Resque.queue_from_class(AutoexpireLockJob))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_lock\n Sidekiq.redis { |redis| redis.del(@locking_key) }\n end",
"def pop_perform_unlocked(queue)\n item = pop(queue) or return\n\n job = Resque::Job.new(queue, item)\n if job.uniqueness.perform_locked?\n push(queue, item)\n nil\n else\n ... | [
"0.6579808",
"0.6508623",
"0.63440496",
"0.6228626",
"0.6218558",
"0.61884636",
"0.61690116",
"0.61492115",
"0.61212766",
"0.6113819",
"0.6087297",
"0.6058044",
"0.6003856",
"0.59961635",
"0.59778655",
"0.5948042",
"0.59185636",
"0.59151566",
"0.59145695",
"0.58729005",
"0.58... | 0.7119452 | 1 |
def initialize(color, board, pos) super end | def symbol
:R
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n # super(color, board, pos)\n end",
"def initialize(color, board, pos)\n @color = color\n @board = board\n @pos = pos\n end",
"def initialize(pos, color, board)\n @pos = pos\n @color = color\n @board = board\n end",
"def initialize(board, color, position)\n ... | [
"0.9616754",
"0.9278348",
"0.92298883",
"0.9038915",
"0.8969376",
"0.8934406",
"0.8779503",
"0.8533355",
"0.8438203",
"0.8431079",
"0.8284779",
"0.81973857",
"0.8081652",
"0.8033602",
"0.8000175",
"0.79724455",
"0.79569733",
"0.78739274",
"0.783375",
"0.7822151",
"0.77187574"... | 0.0 | -1 |
POST /simple_searches POST /simple_searches.json | def create
@simple_search = SimpleSearch.new(simple_search_params)
get_response(params)
respond_to do |format|
format.html { render :index}
format.json { render :index, status: 200 }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_saved_search(query)\n post(\"/saved_searches/create.json\", :query => query)\n end",
"def create\n @search = @website.searches.new params[:search]\n\n\t\t@search.url = @website.search_url(params[:search_terms]) if params[:search_terms]\n\n @search.terms = @search.description.split(' ') i... | [
"0.68483615",
"0.6513494",
"0.6481168",
"0.6434358",
"0.63115585",
"0.6195301",
"0.618424",
"0.61477685",
"0.6146718",
"0.61085916",
"0.61085916",
"0.61085916",
"0.61085916",
"0.61085916",
"0.61007416",
"0.6099708",
"0.6099708",
"0.6099708",
"0.6099708",
"0.6089726",
"0.60655... | 0.70580554 | 0 |
get response with params | def get_response(params)
@simple_search.set_up_client
@current_page = params[:page].nil? ? 1 : params[:page].to_i
response = @simple_search.get_search_result(@current_page)
result = JSON.parse(response.body)
@search_results = result['ResponseJobSearch']
@total_page = @search_results['TotalPages'].first.to_i if @search_results
unless @search_results
@notice = result['message']
Rails.logger.error result['message']
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_response\n parse_response(parse_JSON(get_request))\n end",
"def get\n url = prefix + \"get\" + id_param\n return response(url)\n end",
"def get(params)\n\n request_url = create_url(params)\n begin\n @json_response = HTTParty.get(URI.encode(request_url))\n rescue Socke... | [
"0.7078003",
"0.6801319",
"0.6792748",
"0.67712575",
"0.6757441",
"0.6576704",
"0.65341425",
"0.64972776",
"0.6453862",
"0.6432905",
"0.6425938",
"0.63999695",
"0.6370359",
"0.6369856",
"0.6362718",
"0.63315725",
"0.6324409",
"0.6319685",
"0.631917",
"0.631917",
"0.631917",
... | 0.6571337 | 6 |
Never trust parameters from the scary internet, only allow the white list through. | def simple_search_params
params.require(:simple_search).permit(:keywords, :location)
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 |
To display card in all the site | def container_card(title, &block)
content_tag(:div, class: "card card-accent-info") do
content_tag(:div, class: "card-header") do
title
end +
content_tag(:div, class: "card-block") do
capture(&block)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def card(multiverse_id)\n get '/Pages/Card/Details.aspx', :multiverseid => multiverse_id\n end",
"def show\n set_card\n end",
"def show\n @card_one = Card.find( params[:id] )\n setup_for_display \n end",
"def display (card)\n image_name = \"/images/cards/\" + card[0] + \"_\" + card[1]... | [
"0.7043578",
"0.7020904",
"0.69667774",
"0.69180405",
"0.6897999",
"0.67286724",
"0.6569184",
"0.65651107",
"0.65370524",
"0.64936405",
"0.64812714",
"0.64812714",
"0.64812714",
"0.64812714",
"0.64812714",
"0.647761",
"0.64486694",
"0.6437297",
"0.6409043",
"0.64002115",
"0.6... | 0.0 | -1 |
When changing a permission for an object/user, ensure an update is done, not a duplicate | def default_permissions_attributes_with_uniqueness=(attributes_collection)
if attributes_collection.is_a? Hash
keys = attributes_collection.keys
attributes_collection = if keys.include?('id') || keys.include?(:id)
Array(attributes_collection)
else
attributes_collection.sort_by { |i, _| i.to_i }.map { |_, attributes| attributes }
end
end
attributes_collection.each do |prop|
existing = case prop[:type]
when 'group'
search_by_type(:group)
when 'person'
search_by_type(:person)
end
next unless existing
selected = existing.find { |perm| perm.agent_name == prop[:name] }
prop['id'] = selected.id if selected
end
self.default_permissions_attributes_without_uniqueness=attributes_collection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update?\n @current_user.permission('Bid', :clerk)\n end",
"def update?\n raise CustomErrors::PermissionError unless record.id == user.id\n\n Regular.new(record)\n end",
"def update!(**args)\n @permission = args[:permission] if args.key?(:permission)\n end",
"def update!(**args)\... | [
"0.7261793",
"0.7028419",
"0.69049585",
"0.69049585",
"0.6892777",
"0.6860417",
"0.67717814",
"0.67717814",
"0.66692823",
"0.66553426",
"0.66496223",
"0.66239774",
"0.66227776",
"0.6607094",
"0.6585461",
"0.6582921",
"0.6556768",
"0.6555136",
"0.65540403",
"0.6551321",
"0.655... | 0.0 | -1 |
method accept arguments: 'on' 'off' | def turn_airplane_mode value
toggle_airplane_mode if value == "on"
set_network_connection(6) if value == "off"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def off?; !self.on?; end",
"def on!\n set(:on => true)\n end",
"def toggle!\n if status\n off!\n return false\n else\n on!\n return true\n end\n end",
"def switch_light_off\n puts \"*** switch_light_off\"\n true\nend",
"def turn_on!\n @turned_off = false\n end",
... | [
"0.7669205",
"0.7150208",
"0.7059845",
"0.6877677",
"0.68540514",
"0.67971677",
"0.67799836",
"0.67709583",
"0.66319036",
"0.66046983",
"0.6599481",
"0.6583407",
"0.65402204",
"0.65402204",
"0.65402204",
"0.65402204",
"0.65402204",
"0.64944535",
"0.6464879",
"0.6435497",
"0.6... | 0.0 | -1 |
GET /cita GET /cita.json | def index
if !logged_in?
redirect_to :root
end
@citas = Citum.paginate(page: params[:page], per_page: 4)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @cita = Cita.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cita }\n end\n end",
"def new\n @cita = Cita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cita }\n e... | [
"0.7567945",
"0.67825365",
"0.67753553",
"0.6734669",
"0.6719219",
"0.66423863",
"0.66388",
"0.66180027",
"0.6603365",
"0.6569685",
"0.65665406",
"0.6545015",
"0.6545015",
"0.652503",
"0.652294",
"0.6499668",
"0.6487363",
"0.64813524",
"0.6470469",
"0.6468279",
"0.64659846",
... | 0.0 | -1 |
GET /cita/1 GET /cita/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @cita = Cita.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cita }\n end\n end",
"def show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { rende... | [
"0.7578234",
"0.6941135",
"0.68357944",
"0.6824512",
"0.6820392",
"0.67853785",
"0.67222863",
"0.67208403",
"0.67197937",
"0.6685971",
"0.6673469",
"0.6673469",
"0.66468614",
"0.6633121",
"0.6614249",
"0.66098404",
"0.656555",
"0.65416807",
"0.6539877",
"0.6512245",
"0.651040... | 0.0 | -1 |
GET /cita/new GET /cita/new/:solicitud_id | def new
if !logged_in?
redirect_to :root
end
@citum = Citum.new
@citum.solicitud_id = params[:solicitud_id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n authorize! :create, Solicitud\n @solicitante=Solicitante.find(params[:solicitante_id])\n @beneficiario=Beneficiario.find(params[:beneficiario_id])\n @solicitud = Solicitud.create(solicitud_params)\n @solicitud.solicitante_id=@solicitante.id\n @solicitud.beneficiario_id=@beneficiario.... | [
"0.7219879",
"0.7198327",
"0.71176606",
"0.7102844",
"0.708847",
"0.6974129",
"0.6973238",
"0.69668525",
"0.6954973",
"0.6911856",
"0.6896036",
"0.685232",
"0.68405974",
"0.68390995",
"0.6825602",
"0.68249524",
"0.68071204",
"0.6756959",
"0.6748686",
"0.6698964",
"0.66779244"... | 0.74000543 | 0 |
POST /cita POST /cita.json | def create
@citum = Citum.new(citum_params)
respond_to do |format|
if @citum.save
format.html { redirect_to @citum, notice: 'Citum was successfully created.' }
format.json { render :show, status: :created, location: @citum }
else
format.html { render :new }
format.json { render json: @citum.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @objeto = Cita.new(cita_params)\n\n respond_to do |format|\n if @objeto.save\n format.html { redirect_to @objeto, notice: \"Cita was successfully created.\" }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new, st... | [
"0.69771844",
"0.6615691",
"0.65719885",
"0.65003556",
"0.63254255",
"0.6243329",
"0.62379473",
"0.6216676",
"0.6214872",
"0.6197567",
"0.6181442",
"0.61491925",
"0.6143637",
"0.61373454",
"0.61352503",
"0.61340094",
"0.6098459",
"0.6093548",
"0.6086694",
"0.60788876",
"0.605... | 0.0 | -1 |
PATCH/PUT /cita/1 PATCH/PUT /cita/1.json | def update
respond_to do |format|
if @citum.update(citum_params)
format.html { redirect_to @citum, notice: 'La cita se registro correctamente.' }
format.json { render :show, status: :ok, location: @citum }
else
format.html { render :edit }
format.json { render json: @citum.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @cita = Cita.find(params[:id])\n\n respond_to do |format|\n if @cita.update_attributes(params[:cita])\n format.html { redirect_to @cita, notice: 'Cita was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n ... | [
"0.6803536",
"0.67457813",
"0.6678",
"0.66087013",
"0.66004574",
"0.65840435",
"0.65509504",
"0.6516065",
"0.6489417",
"0.63909084",
"0.637092",
"0.63678294",
"0.6342354",
"0.6337003",
"0.6332188",
"0.6330897",
"0.6327193",
"0.6286214",
"0.6281864",
"0.6272107",
"0.62641",
... | 0.0 | -1 |
DELETE /cita/1 DELETE /cita/1.json | def destroy
@citum.destroy
respond_to do |format|
format.html { redirect_to cita_url, notice: 'Citum was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @chaine = Chaine.find(params[:id])\n @chaine.destroy\n\n respond_to do |format|\n f... | [
"0.7218741",
"0.7044935",
"0.6956412",
"0.69347024",
"0.6871098",
"0.68611133",
"0.6851461",
"0.684687",
"0.68314445",
"0.6829453",
"0.68269897",
"0.6803415",
"0.67826116",
"0.67699593",
"0.6767978",
"0.676198",
"0.67547435",
"0.6750717",
"0.6737312",
"0.6726887",
"0.67232627... | 0.6514321 | 99 |
Use callbacks to share common setup or constraints between actions. | def set_citum
@citum = Citum.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 list of trusted parameters through. | def citum_params
params.require(:citum).permit(:cod_cita, :cod_solicitud, :solicitud_id, :fecha, :estado, :usu_crea, :fec_crea, :usu_mod, :fec_mod)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
belongs_to :company, serializer: CompanySerializer | def avatar
if object.avatar.attached?
if Rails.env === 'production'
object.avatar.url
else
rails_blob_url(object.avatar)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create \n company = Company.new(company_params)\n if company.save \n render json: CompanySerializer.new(company)\n else\n render json: {error: \"Couldnt be saved\"}\n end\nend",
"def show\n render json: @company\n end",
"def byId\n @company = Company.find(company_params[:i... | [
"0.67775935",
"0.66880804",
"0.63934284",
"0.6269885",
"0.6238945",
"0.61742455",
"0.6099507",
"0.6019638",
"0.59797883",
"0.59630215",
"0.59630215",
"0.5942774",
"0.58821934",
"0.58658695",
"0.58554804",
"0.5821884",
"0.58215946",
"0.58215946",
"0.58215946",
"0.58215946",
"0... | 0.0 | -1 |
GET /user_mentions GET /user_mentions.json | def index
@user_mentions = UserMention.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mentions(params = {})\n get \"statuses/mentions\", params\n end",
"def mentions(options={})\n perform_get(\"statuses/mentions.#{Twitter.format}\", options)\n end",
"def mentions\n result_hash['mention']\n end",
"def get_users_mentions\n return !@user.id.eql?(\"uid-0\") ? Users.get_... | [
"0.81161124",
"0.74667037",
"0.71441054",
"0.7006973",
"0.6964976",
"0.6955854",
"0.68988675",
"0.68804044",
"0.68579626",
"0.68324476",
"0.6832297",
"0.6758563",
"0.67544",
"0.6746641",
"0.67185736",
"0.6678232",
"0.66194266",
"0.6471463",
"0.6449015",
"0.6443324",
"0.641803... | 0.7725492 | 1 |
GET /user_mentions/1 GET /user_mentions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mentions(params = {})\n get \"statuses/mentions\", params\n end",
"def index\n @user_mentions = UserMention.all\n end",
"def mentions(options={})\n perform_get(\"statuses/mentions.#{Twitter.format}\", options)\n end",
"def mentions\n result_hash['mention']\n end",
"def get_users... | [
"0.7847274",
"0.7725007",
"0.72135884",
"0.7148446",
"0.70704263",
"0.7057312",
"0.6905129",
"0.6877102",
"0.6868548",
"0.68063915",
"0.6764026",
"0.67364895",
"0.67102474",
"0.66884667",
"0.66444135",
"0.6626915",
"0.6612553",
"0.6594337",
"0.6523182",
"0.6456308",
"0.639932... | 0.0 | -1 |
POST /user_mentions POST /user_mentions.json | def create
@user_mention = UserMention.new(user_mention_params)
respond_to do |format|
if @user_mention.save
format.html { redirect_to @user_mention, notice: 'User mention was successfully created.' }
format.json { render :show, status: :created, location: @user_mention }
else
format.html { render :new }
format.json { render json: @user_mention.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_mention_params\n params.require(:user_mention).permit(:username, :mentions)\n end",
"def create\n params[:mentions].each do |men_params|\n men_params = men_params.permit(:ticker_id, :positive_count, :negative_count, :neutral_count)\n @mention = Mention.new(men_params)\n @mentio... | [
"0.7155845",
"0.6685916",
"0.6669351",
"0.66455996",
"0.6562456",
"0.64833754",
"0.64036536",
"0.6264055",
"0.6145872",
"0.60419923",
"0.60275835",
"0.60055083",
"0.5986491",
"0.5949337",
"0.5948062",
"0.59310865",
"0.5927416",
"0.590577",
"0.5881846",
"0.58753264",
"0.583481... | 0.69691265 | 1 |
PATCH/PUT /user_mentions/1 PATCH/PUT /user_mentions/1.json | def update
respond_to do |format|
if @user_mention.update(user_mention_params)
format.html { redirect_to @user_mention, notice: 'User mention was successfully updated.' }
format.json { render :show, status: :ok, location: @user_mention }
else
format.html { render :edit }
format.json { render json: @user_mention.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @mention.update(mention_params)\n format.html { redirect_to @mention, notice: 'Mention was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @menti... | [
"0.7163638",
"0.7011991",
"0.6568438",
"0.6389745",
"0.6338029",
"0.6157644",
"0.6075686",
"0.60506874",
"0.6029597",
"0.59946066",
"0.5981186",
"0.59653795",
"0.5935245",
"0.5902577",
"0.5902409",
"0.58854896",
"0.5880008",
"0.58776456",
"0.5866071",
"0.5862347",
"0.58063895... | 0.74361265 | 0 |
DELETE /user_mentions/1 DELETE /user_mentions/1.json | def destroy
@user_mention.destroy
respond_to do |format|
format.html { redirect_to user_mentions_url, notice: 'User mention was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mention.destroy\n respond_to do |format|\n format.html { redirect_to mentions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mentionslegale.destroy\n respond_to do |format|\n format.html { redirect_to mentionslegales_url, notice: 'Mentionslega... | [
"0.7758634",
"0.6727265",
"0.6668172",
"0.66265064",
"0.6575274",
"0.65250087",
"0.65176255",
"0.65038055",
"0.6440088",
"0.64058536",
"0.64053077",
"0.6364999",
"0.63640785",
"0.63589376",
"0.63540804",
"0.6325319",
"0.6322865",
"0.6321169",
"0.6312329",
"0.628699",
"0.62829... | 0.78832304 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_user_mention
@user_mention = UserMention.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 user_mention_params
params.require(:user_mention).permit(:username, :mentions)
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 |
Applies the default border to the interface or view. As part of an interface: Vedeu.interface :my_interface do border! ... some code end As part of a view: Vedeu.render do view :my_interface do border! ... some code end end | def border!
border do
# adds default border
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def border; end",
"def border_style ; view.borderStyle ; end",
"def border=(_arg0); end",
"def border(options={})\n set RGhost::Border.new(options)\n end",
"def bordered; self.border = true; self; end",
"def render_border(screen)\n border ? screen.box(abs_x, abs_y, abs_width, abs_height, border.s... | [
"0.7177785",
"0.6857058",
"0.67868125",
"0.6615835",
"0.661477",
"0.64513296",
"0.6356081",
"0.6316441",
"0.6306788",
"0.612652",
"0.61121875",
"0.6107853",
"0.6086228",
"0.6086228",
"0.6018151",
"0.5994528",
"0.59715927",
"0.59200513",
"0.5897118",
"0.58916223",
"0.58736074"... | 0.70830935 | 1 |
Make a HTTP GET request given the URL and headers. Yields a `Net::HTTPResponse`. | def with_http_response(url, &block)
uri = URI(url)
request = Net::HTTP::Get.new(uri)
request.initialize_http_header(request_headers)
request_options[:use_ssl] = true
environment_proxy = ignore_env_proxy ? nil : :ENV
Net::HTTP.start(
uri.host,
uri.port,
request_proxy&.host || environment_proxy,
request_proxy&.port,
request_proxy&.user,
request_proxy&.password,
request_options
) do |http|
http.request(request, &block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(url, headers: {}, params: {}, options: {}, &block)\n url = encode_query(url, params)\n\n request = Net::HTTP::Get.new(url, @default_headers.merge(headers))\n\n execute_streaming(request, options: options, &block)\n end",
"def get(url, headers = {})\n do_request Net::HTTP::Get, url, headers\n... | [
"0.7990028",
"0.7965364",
"0.79572535",
"0.7754934",
"0.7655026",
"0.7655026",
"0.76029766",
"0.7585122",
"0.7583876",
"0.7322134",
"0.7303531",
"0.7181803",
"0.71167177",
"0.71125674",
"0.70961624",
"0.7087334",
"0.7087117",
"0.7072624",
"0.7046525",
"0.69838154",
"0.6942032... | 0.0 | -1 |
Stream a Net::HTTPResponse by line, handling lines that cross chunks. | def stream_response_lines(response, &block)
last_line = ""
response.read_body do |chunk|
chunk_lines = (last_line + chunk).lines
# This could end with half a line, so save it for next time. If
# chunk_lines is empty, pop returns nil, so this also ensures last_line
# is always a string.
last_line = chunk_lines.pop || ""
chunk_lines.each(&block)
end
yield last_line unless last_line.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stream\n 10_000_000.times do |i|\n response.stream.write \"This is line#{i}\\n\"\n end\n ensure\n response.stream.close\n end",
"def parse_body(line)\n return :break if @length&.zero?\n\n if @transfer_encoding == \"chunked\"\n parse_body_chunked(line)\n else\n puts \"Http2:... | [
"0.694224",
"0.6476382",
"0.6196748",
"0.6146465",
"0.59741044",
"0.5929317",
"0.5881107",
"0.5848408",
"0.5833758",
"0.5775827",
"0.57642204",
"0.57616377",
"0.5681749",
"0.5664902",
"0.5636888",
"0.5634624",
"0.5626736",
"0.56219405",
"0.56120133",
"0.5607703",
"0.5599462",... | 0.81083393 | 0 |
TODO ADD Duplicate method (using clone) TODO ADD Compute accruals method TODO ADD Compute depreciation method GET /invoices GET /invoices.xml | def index
@search = Invoice.search(params[:search])
@invoices = @search.all.paginate(:page => params[:page], :order => 'created_at desc')
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @invoices }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoices(reload = false)\n self.cache(CostAgent::Invoice, :all, reload) do\n (self.api(\"invoices\")/\"invoice\").collect do |invoice|\n items = (invoice/\"invoice-item\").collect do |item|\n price = (item/\"price\").first.inner_text.to_f\n quantity = (item/\"quantity\").first.... | [
"0.7067046",
"0.66842467",
"0.6674184",
"0.65757966",
"0.6565875",
"0.6538859",
"0.64919215",
"0.6434327",
"0.64189816",
"0.63302606",
"0.6253393",
"0.62513876",
"0.62108064",
"0.6204325",
"0.61960334",
"0.6179211",
"0.6171445",
"0.6155306",
"0.6146891",
"0.6129027",
"0.61184... | 0.0 | -1 |
GET /invoices/1 GET /invoices/1.xml | def show
@invoice = Invoice.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @invoice }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n '/api/invoices'\n end",
"def show\n @invoice = Invoice.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @invoice.to_xml }\n end\n end",
"def get_invoices(modified_since = nil)\n request_params = modified_since ... | [
"0.744857",
"0.7276012",
"0.70030487",
"0.69955766",
"0.68879193",
"0.6835057",
"0.67528844",
"0.67003596",
"0.66996425",
"0.6694621",
"0.6647452",
"0.65595865",
"0.6540081",
"0.6517394",
"0.6505114",
"0.6486551",
"0.64825267",
"0.64725137",
"0.64684266",
"0.64675367",
"0.646... | 0.720512 | 6 |
GET /invoices/new GET /invoices/new.xml | def new
@users = User.find(:all)
@invoice = Invoice.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @invoice }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @invoice = Invoice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @invoice }\n end\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @invoice }\n end\n end",
"def new... | [
"0.77572095",
"0.7727668",
"0.7386839",
"0.7143585",
"0.71419907",
"0.7118709",
"0.7112754",
"0.7110927",
"0.71023536",
"0.7031224",
"0.69672626",
"0.69672626",
"0.69467944",
"0.6925111",
"0.68894213",
"0.68633705",
"0.6825958",
"0.6806801",
"0.68060416",
"0.6794918",
"0.6777... | 0.76288086 | 2 |
POST /invoices POST /invoices.xml | def create
@invoice = Invoice.new(params[:invoice])
respond_to do |format|
if @invoice.save
format.html { redirect_to(@invoice, :notice => 'Invoice was successfully created.') }
format.xml { render :xml => @invoice, :status => :created, :location => @invoice }
else
format.html { render :action => "new" }
format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_invoices(invoices)\n b = Builder::XmlMarkup.new\n request_xml = b.Invoices {\n invoices.each do | invoice |\n invoice.to_xml(b)\n end\n }\n\n response_xml = http_put(@client, \"#{@xero_url}/Invoices?SummarizeErrors=false\", request_xml, {})\n\n response = ... | [
"0.7404747",
"0.7038786",
"0.69371504",
"0.6926702",
"0.68648845",
"0.68648845",
"0.67967945",
"0.6717637",
"0.6695001",
"0.6657453",
"0.66458714",
"0.6639475",
"0.66067076",
"0.660422",
"0.65990335",
"0.65973634",
"0.65913975",
"0.65901405",
"0.65901405",
"0.65901405",
"0.65... | 0.6904467 | 4 |
PUT /invoices/1 PUT /invoices/1.xml | def update
@invoice = Invoice.find(params[:id])
respond_to do |format|
if @invoice.update_attributes(params[:invoice])
format.html { redirect_to(@invoice, :notice => 'Invoice was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n ... | [
"0.7412265",
"0.67717284",
"0.6751313",
"0.67184025",
"0.67184025",
"0.66387206",
"0.66312987",
"0.6609958",
"0.6535826",
"0.6507939",
"0.6507939",
"0.65032524",
"0.64928216",
"0.64242053",
"0.64198864",
"0.6383049",
"0.6366862",
"0.634026",
"0.6323545",
"0.63027",
"0.6258110... | 0.67013884 | 5 |
DELETE /invoices/1 DELETE /invoices/1.xml | def destroy
@invoice = Invoice.find(params[:id])
@invoice.destroy
respond_to do |format|
format.html { redirect_to(invoices_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @az_invoice = AzInvoice.find(params[:id])\n @az_invoice.destroy\n\n respond_to do |fo... | [
"0.7493625",
"0.730658",
"0.7081265",
"0.7024961",
"0.7024961",
"0.7024961",
"0.7024961",
"0.7015801",
"0.70132536",
"0.70009625",
"0.6966207",
"0.6944955",
"0.6915478",
"0.6886578",
"0.6840611",
"0.67662996",
"0.67568326",
"0.67554927",
"0.6727152",
"0.6714177",
"0.6684064",... | 0.7545571 | 3 |
Given a currency code and floating point amount, convert to the equivalent amount in USD (U. S. dollars). The result MUST be rounded to two fractional digits. | def to_dollars(currency_code, amount)
curr = RATES.fetch(currency_code)
total = amount * curr
return total.round(2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_usd(amt, currency)\n unless currency == \"USD\"\n path = @xml_parser.find_conversion_path(currency, \"USD\")\n amount = @xml_parser.get_rates_from_xml(path[0])\n #pp path # print the path array (for debug if you need it)\n\n #conversion = find_conversion_amt(currency, \"USD\")\n el... | [
"0.7335346",
"0.69973856",
"0.6952437",
"0.69468266",
"0.6937742",
"0.6919467",
"0.6775157",
"0.6775157",
"0.6773773",
"0.6651863",
"0.6608943",
"0.66041976",
"0.66000897",
"0.6595693",
"0.6565369",
"0.6563329",
"0.65474",
"0.65373415",
"0.6525132",
"0.65239227",
"0.65239227"... | 0.7101878 | 1 |
Given a currency code and floating point amount, convert to the amount in USD (U. S. dollars) to an equivalent amount in the currency. The result MUST be rounded to two fractional digits. | def from_dollars(currency_code, amount)
curr = RATES.fetch(currency_code)
total = amount / curr
return total.round(2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_usd(amt, currency)\n unless currency == \"USD\"\n path = @xml_parser.find_conversion_path(currency, \"USD\")\n amount = @xml_parser.get_rates_from_xml(path[0])\n #pp path # print the path array (for debug if you need it)\n\n #conversion = find_conversion_amt(currency, \"USD\")\n el... | [
"0.7327108",
"0.7168034",
"0.70556724",
"0.7055287",
"0.69181156",
"0.6886201",
"0.6850106",
"0.6746506",
"0.6746506",
"0.67234284",
"0.6708898",
"0.6705818",
"0.66818154",
"0.66773796",
"0.6666345",
"0.66526973",
"0.66339445",
"0.6610594",
"0.65911806",
"0.65911806",
"0.6591... | 0.7005417 | 4 |
Given an input string in CSV format, return an array of strings representing the fields as demarcated by commas. | def parse( line )
info = line.split(',')
return info
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_to_array(csv)\n csv.split(\",\").map(&:strip)\n end",
"def csv_to_array(csv)\n csv.split(\",\").map(&:strip)\n end",
"def parse_csv_line(text_line)\n\tcolumns = text_line.split(\",\")\n\tvalues = []\n\tcolumns.each { |x| values << x.strip}\n\treturn values\nend",
"def fetch_csv_array(... | [
"0.7547906",
"0.7547906",
"0.71665204",
"0.71349406",
"0.7117916",
"0.667818",
"0.6676753",
"0.65344954",
"0.645351",
"0.63635176",
"0.63568467",
"0.6260366",
"0.62378705",
"0.62157166",
"0.620512",
"0.61139065",
"0.60851693",
"0.60782325",
"0.60726374",
"0.60645354",
"0.6039... | 0.53500414 | 51 |
Initializes the internal member. | def initialize
@captured = ''
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n init\n end",
"def initialize\n end",
"def initialize\r\n init_public_members\r\n init_private_members\r\n end",
"def initialize\n \n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def init\n end",
... | [
"0.79214805",
"0.77991664",
"0.7695921",
"0.7693466",
"0.7648273",
"0.7648273",
"0.7645311",
"0.7645311",
"0.7645311",
"0.76198596",
"0.76101923",
"0.76085967",
"0.76085967",
"0.76085967",
"0.76085967",
"0.76085967",
"0.76085967",
"0.75955087",
"0.75955087",
"0.75955087",
"0.... | 0.0 | -1 |
find one parcel at a time, extracting all the details and saving to the database | def update_remaining(table_type_instance)
update_details table_type_instance.records_to_complete
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_residency\n a = residence_different ? res_address : address\n z = residence_different ? res_zip : zip\n a = a.gsub(\"STREET\",\"ST\");\n a = a.gsub(\"DRIVE\",\"DR\");\n a = a.gsub(\"AVENUE\",\"AVE\");\n a = a.gsub(\"ROAD\",\"RD\");\n a = a.gsub(\"LANE\",\"LN\");\n a = a.gsub(\" \"... | [
"0.5765707",
"0.57341415",
"0.5648117",
"0.56417125",
"0.5525904",
"0.55149996",
"0.5510445",
"0.5465362",
"0.5457187",
"0.54057544",
"0.5393725",
"0.5341765",
"0.5330238",
"0.5265699",
"0.5249468",
"0.52408624",
"0.52270466",
"0.5225614",
"0.52068114",
"0.5187545",
"0.516027... | 0.0 | -1 |
GET /map_areas/1 GET /map_areas/1.xml | def show
@map_area = MapArea.find(params[:id])
@start = @map_area
@zoom= 4
@houses = House.count(:conditions => ["map_area_id = ?",params[:id]])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @map_area }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_to do |format|\n format.html { redirect_to \"/\" }\n format.xml { render :xml => @maps }\n end\n end",
"def show\n find_map\n respond_to do |format|\n format.html do\n redirect_to edit_map_path(@map)\n end\n format.any(:json, :xml) do\n res... | [
"0.6638383",
"0.6583954",
"0.6574354",
"0.6499223",
"0.6463132",
"0.6424737",
"0.63149023",
"0.63149023",
"0.6306608",
"0.6302297",
"0.6273864",
"0.62539345",
"0.6190594",
"0.6081293",
"0.6009829",
"0.5988725",
"0.5984539",
"0.59742373",
"0.59638625",
"0.5960226",
"0.5940678"... | 0.64175755 | 7 |
GET /map_areas/new GET /map_areas/new.xml | def new
@map_area = MapArea.new
@start = GeoLoc.new(:lat=>40.010492, :lng=> -105.276843)
@zoom= 14
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @map_area }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @area = Area.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @area }\n end\n end",
"def new\n @area = Area.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @area }\n end\n en... | [
"0.73611414",
"0.73348",
"0.73348",
"0.7251168",
"0.7216695",
"0.7214031",
"0.71847403",
"0.68891627",
"0.68618304",
"0.6807173",
"0.68048877",
"0.68048877",
"0.67606837",
"0.6759648",
"0.6712049",
"0.6658706",
"0.6635083",
"0.6631533",
"0.66181993",
"0.6611113",
"0.66055965"... | 0.6814642 | 9 |
POST /map_areas POST /map_areas.xml | def create
@map_area = MapArea.new(params[:map_area])
@map_area.craigslist = params[:map_area][:craigslist] + ".craigslist.org"
respond_to do |format|
if @map_area.save
flash[:notice] = 'MapArea was successfully created.'
format.html { redirect_to(@map_area) }
format.xml { render :xml => @map_area, :status => :created, :location => @map_area }
else
format.html { render :action => "new" }
format.xml { render :xml => @map_area.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def areas\n @area = Area.new(geo_json: params.to_json)\n if @area.save\n json_response([id: @area.id], :created, :geo_json_recieved)\n else\n json_response(nil, :error, :db_error)\n end\n end",
"def create\n #params[:area] == {\"parent_id\"=>\"21\",\"name\"=>\"test4\"} parent id from h... | [
"0.630032",
"0.5881383",
"0.5874135",
"0.56986576",
"0.569001",
"0.5520591",
"0.5494831",
"0.5468766",
"0.54546654",
"0.54546654",
"0.54444027",
"0.5439435",
"0.54299223",
"0.54231703",
"0.5417023",
"0.5398709",
"0.5386855",
"0.5386339",
"0.53767633",
"0.53719157",
"0.5359135... | 0.5863109 | 3 |
PUT /map_areas/1 PUT /map_areas/1.xml | def update
@map_area = MapArea.find(params[:id])
respond_to do |format|
if @map_area.update_attributes(params[:map_area])
flash[:notice] = 'MapArea was successfully updated.'
format.html { redirect_to map_areas_path }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @map_area.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @area = Area.find(params[:id])\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n #format.html { redirect_to(@area, :notice => \"#{@area.to_s} was successfully updated.\") }\n format.html { redirect_to(locations_url, :notice => \"#{@area.to_s} was success... | [
"0.6302117",
"0.62718856",
"0.62718856",
"0.6104586",
"0.59913033",
"0.59913033",
"0.59913033",
"0.592846",
"0.5912385",
"0.58214444",
"0.57772475",
"0.57561314",
"0.56832033",
"0.5667586",
"0.5629137",
"0.560807",
"0.5606854",
"0.5596874",
"0.5579682",
"0.5573442",
"0.552748... | 0.678487 | 1 |
DELETE /map_areas/1 DELETE /map_areas/1.xml | def destroy
@map_area = MapArea.find(params[:id])
@map_area.destroy
respond_to do |format|
format.html { redirect_to(map_areas_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @area = Area.find(params[:id])\n if @area.children.size == 0 and @area.name != \"localhost\"\n @area.destroy\n flash[:notice] = \"Deleted #{@area.to_s}\" \n else\n flash[:notice] = \"#{@area.to_s} not deleted. It has children or is the localhost node.\" \n end\n\n re... | [
"0.6842845",
"0.676144",
"0.66951376",
"0.667555",
"0.667555",
"0.66695094",
"0.6521686",
"0.6472517",
"0.63823134",
"0.636301",
"0.634412",
"0.63297474",
"0.63184315",
"0.6290306",
"0.6289179",
"0.6283996",
"0.62604487",
"0.62523764",
"0.62523764",
"0.62523764",
"0.6249928",... | 0.732275 | 1 |
checks if you are the user of the shown profile so you can edit or delete a post | def simple_posts_edit_button(current_user, simple_post)
if(current_user.id == @user.id)
link_to svg('edit-2'), edit_user_simple_post_path(current_user, simple_post), class:"btn"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorized_to_edit?(post)\n post.user == current_user\n end",
"def authorized_to_edit?(post)\n post.user == current_user\n end",
"def show\n @can_edit = false\n if user_signed_in?\n @my_pre = Preference.find_by user_id: current_user.id\n @my_pro = Profile.find_by user_id: cu... | [
"0.76493454",
"0.76493454",
"0.7486724",
"0.7327775",
"0.7277283",
"0.71202385",
"0.71151525",
"0.7109181",
"0.7105091",
"0.70701927",
"0.7039814",
"0.70239156",
"0.6962316",
"0.6949056",
"0.694054",
"0.6926965",
"0.69245607",
"0.69079465",
"0.68767166",
"0.6876219",
"0.68644... | 0.0 | -1 |
checks if there is a previous or next post | def next_post_button(user, simple_post)
next_post = simple_post.next
if(!next_post.nil?)
link_to svg('chevron-right'), [user, next_post], remote: true, class: "btn float-right"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def previous?\n return @page > 1\n end",
"def has_previous?\n return self.current_page != 1 && self.total_pages > 1\n end",
"def following?(post)\n posts.include?(post)\n end",
"def prev?\n current_page > 1\n end",
"def previous_page?\n page > 1\n end",
"def previo... | [
"0.7072934",
"0.7013209",
"0.6995179",
"0.69793475",
"0.69030213",
"0.6846312",
"0.6818344",
"0.68179756",
"0.6753731",
"0.6715861",
"0.66672254",
"0.66120315",
"0.6588389",
"0.6557944",
"0.6547694",
"0.6540279",
"0.653683",
"0.64513445",
"0.6447845",
"0.64437944",
"0.6426398... | 0.57957554 | 72 |
GET /cat_memes GET /cat_memes.json | def index
@cat_memes = CatMeme.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def demo\n render json: Cat.all\n end",
"def set_cat_meme\n @cat_meme = CatMeme.find(params[:id])\n end",
"def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n ... | [
"0.6341813",
"0.63068706",
"0.6297045",
"0.6289176",
"0.62236726",
"0.6211266",
"0.62088007",
"0.61613494",
"0.6134093",
"0.6122648",
"0.6111902",
"0.6098143",
"0.6085125",
"0.6031143",
"0.6028749",
"0.60226214",
"0.60191625",
"0.6002245",
"0.600139",
"0.59945303",
"0.5994530... | 0.7017185 | 0 |
Sinatra Route is defined in the controller and the action supplied with a block get '/cat_memes' do end GET /cat_memes/1 GET /cat_memes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n @cats = JSON.parse(response.body)\n else\n @cats = []\n end\n end",
"def GET; end",
"de... | [
"0.5986739",
"0.56561184",
"0.56414455",
"0.5613579",
"0.55909806",
"0.55577266",
"0.5513877",
"0.55087453",
"0.55087453",
"0.5487165",
"0.5480563",
"0.54805446",
"0.54805446",
"0.54805446",
"0.54805446",
"0.54805446",
"0.54805446",
"0.54805446",
"0.54805446",
"0.54805446",
"... | 0.0 | -1 |
POST /cat_memes POST /cat_memes.json | def create
@cat_meme = CatMeme.new(cat_meme_params)
respond_to do |format|
if @cat_meme.save
format.html { redirect_to @cat_meme, notice: 'Cat meme was successfully created.' }
format.json { render :show, status: :created, location: @cat_meme }
else
format.html { render :new }
format.json { render json: @cat_meme.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cat_meme_params\n params.require(:cat_meme).permit(:title, :alt, :user_id, :image_url)\n end",
"def set_cat_meme\n @cat_meme = CatMeme.find(params[:id])\n end",
"def create\n @cat = Cat.new(params[:cat])\n\n respond_to do |format|\n if @cat.save\n _update_topics \n ... | [
"0.68278843",
"0.6391136",
"0.6224142",
"0.61588174",
"0.61244416",
"0.6096952",
"0.59690565",
"0.59684074",
"0.59531224",
"0.5941473",
"0.58527845",
"0.5841979",
"0.58079237",
"0.5806027",
"0.5806027",
"0.5753768",
"0.57319695",
"0.57292306",
"0.5724499",
"0.5722389",
"0.570... | 0.75442034 | 0 |
PATCH/PUT /cat_memes/1 PATCH/PUT /cat_memes/1.json | def update
respond_to do |format|
if @cat_meme.update(cat_meme_params)
format.html { redirect_to @cat_meme, notice: 'Cat meme was successfully updated.' }
format.json { render :show, status: :ok, location: @cat_meme }
else
format.html { render :edit }
format.json { render json: @cat_meme.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n json_update(category,category_params, Category)\n end",
"def update\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n if @cat.update_attributes(params[:cat])\n format.html { redirect_to @cat, notice: 'Cat was successfully updated.' }\n format.json { head :no_co... | [
"0.6611247",
"0.6484292",
"0.6353613",
"0.63124985",
"0.6250025",
"0.6217656",
"0.6183744",
"0.6145973",
"0.6096488",
"0.60946673",
"0.6064223",
"0.603451",
"0.5974329",
"0.594336",
"0.593043",
"0.5927625",
"0.591977",
"0.59154713",
"0.5911374",
"0.5908544",
"0.5906256",
"0... | 0.708257 | 0 |
DELETE /cat_memes/1 DELETE /cat_memes/1.json | def destroy
@cat_meme.destroy
respond_to do |format|
format.html { redirect_to cat_memes_url, notice: 'Cat meme was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @cat = Cat.find(params[:id])\n @cat.destroy\n\n respond_to do |format|\n format.html { redirect_to cats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cat = Cat.find(params[:id])\n @cat.destroy\n\n respond_to do |format|\n format.html { r... | [
"0.6810249",
"0.6810249",
"0.6687091",
"0.6654182",
"0.66509825",
"0.66462135",
"0.66416305",
"0.6630486",
"0.6611035",
"0.65908253",
"0.65806156",
"0.65689313",
"0.6562641",
"0.65624094",
"0.6538201",
"0.6537338",
"0.6527516",
"0.65242434",
"0.6494796",
"0.6485679",
"0.64786... | 0.7203558 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_cat_meme
@cat_meme = CatMeme.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 list of trusted parameters through. | def cat_meme_params
params.require(:cat_meme).permit(:title, :alt, :user_id, :image_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
def count_nucleotides(string) all_a = string.scan(/a/) all_c = string.scan(/c/) all_g = string.scan(/g/) all_t = string.scan(/t/) end SOLUTION: | def count_nucleotides dna
bases_count = {
'A' => 0,
'C' => 0,
'T' => 0,
'G' => 0,
}
#
dna.each_char do |x|
if bases_count.key? base
bases_count[ base ] += 1
else
puts "#{base} not a valid nucleotide"
end # if
end # DNA.each_char end
bases_count.each do |key, val|
puts "#{key} : #{val}"
end #bases_count.each end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_nucleotides(data)\n ['A', 'C', 'G', 'T'].map {|nucleotid| data.count(nucleotid)} * ' '\nend",
"def count_nucleotides string\n nucleotides = {\n 'A' => 0,\n 'C' => 0,\n 'G' => 0,\n 'T' => 0,\n 'Error' => 0\n }\n\n string.split(//).map do |item|\n if nucleotides[item.capitalize]\n ... | [
"0.7923182",
"0.78497607",
"0.74380815",
"0.7389448",
"0.7193786",
"0.7137014",
"0.6866946",
"0.676718",
"0.66921526",
"0.66782403",
"0.66643757",
"0.66558516",
"0.66247857",
"0.6608477",
"0.66012543",
"0.66011655",
"0.65842617",
"0.6567991",
"0.6539018",
"0.6537372",
"0.6502... | 0.6901184 | 6 |
This method counts how many times the iteration runs | def iteration_counter(array, target)
counter = 0
for el in array
counter += 1
if el == target
return counter
end
end
counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count\n @count ||= 0\n @count += 1\n end",
"def count\n count = 0\n each do |data|\n count += 1\n end\n count\n end",
"def count\n run.count\n end",
"def count\n each.count\n end",
"def incr_count\n @count ||= 0\n @count += 1\n end... | [
"0.7805668",
"0.7761765",
"0.7614494",
"0.75863355",
"0.7442151",
"0.73567104",
"0.7349548",
"0.7321257",
"0.73161894",
"0.7280452",
"0.7263807",
"0.72380286",
"0.7152548",
"0.7152548",
"0.7152548",
"0.71435",
"0.7134459",
"0.7116222",
"0.70841384",
"0.7065886",
"0.7036829",
... | 0.0 | -1 |
TODO: add logic for deleting old files | def initialize(cache_root, logger = nil)
@cache_root = cache_root
@logger = logger
@cached_files = {}
initialize_root
super()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obsolete_files; end",
"def existing_files; end",
"def cleanup_old_files\n # make a local copy of to_delete while simultaneously clearing the original (atomicity)\n # local_to_delete = $to_delete.slice!(0..-1).to_a\n local_to_delete = []\n $to_delete.delete_if { |v| local_to_delete << v; true }\n\n $fi... | [
"0.7394145",
"0.7293094",
"0.70943284",
"0.70835227",
"0.70358235",
"0.7006662",
"0.6929057",
"0.68905944",
"0.6821465",
"0.6811739",
"0.6793192",
"0.6759935",
"0.6744462",
"0.67403895",
"0.67267406",
"0.6674917",
"0.6662741",
"0.66419834",
"0.66363937",
"0.6617637",
"0.66076... | 0.0 | -1 |
Checks if the file is already cached and return true or false accordingly. | def cached?(file_id)
synchronize do
return @cached_files.include?(file_id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_exists?\n File.exist?(cached_file)\n end",
"def cached?\n cache_path.exist?\n end",
"def cached?\n cache_path.exist?\n end",
"def cache_exist?\n File.exist?(@cache_file)\n end",
"def cached_file?\n Settings.documents.page_cache && File.exists?(cache_file)\n ... | [
"0.8801499",
"0.8486208",
"0.8420005",
"0.83783525",
"0.81750053",
"0.80899715",
"0.79864174",
"0.7980999",
"0.787734",
"0.7779528",
"0.75850266",
"0.7554939",
"0.7519779",
"0.75125843",
"0.7465913",
"0.7453566",
"0.73810333",
"0.73737234",
"0.7337251",
"0.7320416",
"0.731099... | 0.786666 | 9 |
Caches a file identified by unique id. | def save_file(file_id, source)
synchronize do
unless cached?(file_id)
destination = File.join(@cache_root, Utils.fileid2name(file_id))
FileUtils.cp(source, destination)
if File.exist?(destination)
cached_file = CachedFile.new
cached_file.filename = File.basename(source)
cached_file.last_copy = DateTime::now
@cached_files[file_id] = cached_file
else
message = "Cache: Unable to copy file with id #{file_id}."
@logger.error(message) if @logger
raise message
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache(file_obj, data_result, url, username, password)\n data_result[:uuid] = UUID.generate\n key = generate_key url, username, password\n\n begin\n data_result[:data_tmp_path] = store_data_to_tmp file_obj, data_result[:uuid]\n data_result[:time_stored] = Time.now\n @@file_ca... | [
"0.6839888",
"0.6696811",
"0.6696811",
"0.6696811",
"0.6696811",
"0.6696811",
"0.6696811",
"0.6696811",
"0.6648968",
"0.65852475",
"0.6552254",
"0.64469004",
"0.6399794",
"0.6369085",
"0.62505096",
"0.6239655",
"0.622877",
"0.6200016",
"0.61732274",
"0.61520576",
"0.61241394"... | 0.70419055 | 0 |
Copies a saved file to a specified destination. | def copy_file(file_id, destination)
synchronize do
if cached?(file_id)
source = File.join(@cache_root, Utils.fileid2name(file_id))
FileUtils.cp(source, destination)
if File.exist?(destination)
@cached_files[file_id].last_copy = DateTime::now
else
message = "Cache: Unable to copy file '#{source}' to '#{destination}'."
@logger.error(message) if @logger
raise message
end
else
message = "Cache: File with id #{file_id} does not exist in cache."
@logger.error(message) if @logger
raise message
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_file(source, destination)\n FileUtils.cp(source, destination)\n destination\n end",
"def copy_file(source, destination)\n FileUtils.cp(source, destination)\n destination\n end",
"def copy_file(src, dst)\n File.open(src) do |fin|\n File.open(dst, 'w') do |fout|... | [
"0.80119956",
"0.80119956",
"0.78985274",
"0.7674267",
"0.7674267",
"0.756865",
"0.74799395",
"0.73099256",
"0.7305307",
"0.719895",
"0.7177519",
"0.7166594",
"0.7166594",
"0.7122975",
"0.7121902",
"0.71134603",
"0.70774436",
"0.7035559",
"0.7006027",
"0.69038504",
"0.6850593... | 0.6459683 | 50 |
Initialized the cache root directory. This includes creating the directory and clearing its contents. | def initialize_root
Utils.create_directory(@cache_root)
Utils.clear_directory(@cache_root)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_root\n dataroot.join('cache').tap { |p| p.mkpath unless p.exist? }\n end",
"def make_cache_dir\n ::FileUtils.mkdir_p(@cache_dir) unless ::File.directory?(@cache_dir)\n end",
"def initialize \n @dirpath = self.class.dirname\n\n if Dir.exist? @dirpath\n raise \"Dire... | [
"0.7641436",
"0.70265007",
"0.6926599",
"0.6821386",
"0.66308755",
"0.65888155",
"0.65797955",
"0.65637535",
"0.6555658",
"0.65249306",
"0.6467081",
"0.6467081",
"0.63289946",
"0.6278692",
"0.62424815",
"0.6214418",
"0.620009",
"0.6167654",
"0.6146246",
"0.6134458",
"0.612186... | 0.9031053 | 0 |
initialize is constructor for class | def initialize nama
@nama = nama
@blood = 100
@manna = 40
@status =""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize() end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; en... | [
"0.86529315",
"0.8460407",
"0.8460407",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83959866",
"0.83876824",
"0.83876824",
"0.83876824",
"0.83876824",
"0.83876824",
"0.83843565",
... | 0.0 | -1 |
this is preferable over extend self | def some_method
"some_method2"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extended(*) end",
"def +@\n self\n end",
"def +@\n self\n end",
"def +@\n return self\n end",
"def +@\n return self\n end",
"def main\n super\n return self\n end",
"def initialize\n super\n end",
"def initialize\n super\n ... | [
"0.7080642",
"0.6966245",
"0.6966245",
"0.6942812",
"0.6942812",
"0.6899978",
"0.6829348",
"0.6829348",
"0.6824577",
"0.67600024",
"0.6740772",
"0.6740772",
"0.6740772",
"0.67390305",
"0.67390305",
"0.67352813",
"0.67317253",
"0.65913737",
"0.65779775",
"0.65429133",
"0.65212... | 0.0 | -1 |
Start this saga. Must pass an UID of requested VDS | def start(vds_uid, message)
@vds_uid = vds_uid
@message = message
Log4r::Logger['ontology::cloud'].info "++ Starting saga #{id}: Query VDS #{vds_uid} state"
@ontology.replace [:vds, vds_uid, :actual_state, :STATE], :querying
query_all_nodes
timeout(60)
change_state(STATE_WAITING_FOR_REPLY)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n execute_prlctl('start', @uuid)\n end",
"def start\n data = Storm::Base::SODServer.remote_call '/Server/start',\n :uniq_id => @uniq_id\n data[:started]\n end",
"def vespa_destination_start\n @vespa_destination_pid... | [
"0.57657015",
"0.5763425",
"0.57155174",
"0.5675545",
"0.5608363",
"0.55396765",
"0.54715",
"0.53343344",
"0.53253204",
"0.53251916",
"0.53116006",
"0.53113264",
"0.5299489",
"0.5286301",
"0.5271641",
"0.525807",
"0.52528316",
"0.524095",
"0.52171576",
"0.52169186",
"0.517903... | 0.7328523 | 0 |
MatchData VariableList > true/false Process a variable declaration line Params: match MatchData for the variable declaration var_list VariableList to add this variable to type_table TypeTable containing all defined basic types Return: true on success Raises an exception on type error or variable redeclaration | def process_var(match, block, type_table)
ident = match[1]
type = match[2]
var_list = block.var_list
if var_list.has_ident?(ident)
raise "Redeclared variable '#{ident}'"
end
type = process_typestr(type, type_table)
if type.is_a?(ArrayType)
raise "Array declaration not currently supported"
end
var = Variable.new(type, ident)
block.add_variable(var)
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variable_declaration_list\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 21 )\n return_value = VariableDeclarationListReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = ... | [
"0.60415375",
"0.6033331",
"0.5840922",
"0.56377506",
"0.5565464",
"0.5500965",
"0.54801846",
"0.5405096",
"0.53738135",
"0.5341144",
"0.52759093",
"0.523931",
"0.52300054",
"0.5141959",
"0.5088056",
"0.50798535",
"0.50596875",
"0.50441957",
"0.50351644",
"0.49128085",
"0.490... | 0.7177698 | 0 |
Adds an instruction for setting the value of a variable Checks to ensure that the variable was previously defined and that it has a proper expression | def process_set(match, function, type_table)
name = match[1]
array_index = match[3]
value = match[4]
# Error checking:
unless function.is_a? Function
raise "Can only set variables inside functions"
end
var_list = function.var_list
unless var_list.include?(name)
raise "Undeclared variable '#{name}'"
end
var = function.var_list.get(name)
if array_index != nil and (not var.is_array?)
raise "Cannot use array index on non-array variable"
end
# Parse value and create instruction
ident_list = function.ident_list
value_expression = process_expression(value, ident_list, type_table)
var_type = var.type
if array_index
var_type = var.type.element_type
end
unless value_expression.type.castable?(var_type)
raise "Cannot convert expression type #{value_expression.type.to_s} " +
"to variable type #{var_type.to_s}"
end
instruction = SetVariableInstruction.new(var, value_expression, function)
# The variable is being used as an array, add array index to instruction
if array_index
index_expression = process_expression(array_index, ident_list,
type_table)
instruction.array_index = index_expression
unless index_expression.type.castable?(WORD_TYPE)
raise "Cannot convert array index #{index_expression.type.to_s} " +
"to word type"
end
end
function.add_instruction(instruction)
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_variable\n var_name=EvalBlock.lasgn(expression)\n self.variable=var_name.present? ? Variable.find_or_create_by(game: game, name: var_name) : nil\n end",
"def test_set_eval\n set = SetVariableEval.new(@int_var, @int_lit)\n set.eval\n assert_equal \"SET [Y+9], 10\\n\", MPPCompiler.last\n e... | [
"0.6846346",
"0.63382006",
"0.63153833",
"0.6298828",
"0.6273813",
"0.60009253",
"0.59948134",
"0.591338",
"0.5884114",
"0.5884114",
"0.5868029",
"0.5788665",
"0.5705764",
"0.5695379",
"0.5695379",
"0.56910557",
"0.5669107",
"0.56683683",
"0.566461",
"0.5661797",
"0.564711",
... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.