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 |
|---|---|---|---|---|---|---|
checks whether a flag is checked by the user | def buzz_flag_checked(flag,user)
BuzzFlag.select('id, expiry_date').where('buzz_id = ? and flag_id = ? and user_id = ? and (expiry_date >= ? or expiry_date is Null)',self.id, flag.id, user.id, Date.today).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flagged?(flag)\n self.flags.include? flag\n end",
"def user_has_flags?(user,flags)\n flags.each_char {|flag|\n return false if not user.flags.index(flag)\n }\n true\nend",
"def valid_read_only?(flag)\n [true, false].include?(flag)\n end",
"def can_flag?\n !sent? && !flagged?\n ... | [
"0.72560686",
"0.70887065",
"0.69995606",
"0.69157064",
"0.6817748",
"0.681139",
"0.6787479",
"0.6787479",
"0.6758689",
"0.6678703",
"0.6654228",
"0.6632745",
"0.65814024",
"0.6575237",
"0.6566427",
"0.6565554",
"0.6544489",
"0.6520449",
"0.65140116",
"0.64408046",
"0.643672"... | 0.0 | -1 |
getting the attachment url for the buzz | def getting_attachment_name
url = self.attachment.url
"#{File.basename(url, '.*').truncate(15, :omission => '...')}.#{File.extname(url)}" if url.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attachment_url\n return self.attachment.url unless self.attachment.blank?\n end",
"def file_url(attachment_name, style=nil); file_path(attachment_name, style); end",
"def attachment_path\n return unless attachment.attached?\n\n attachment.service_url\n end",
"def attachme... | [
"0.7501699",
"0.7375592",
"0.71492195",
"0.70759344",
"0.70470756",
"0.69504035",
"0.6934396",
"0.69061166",
"0.6861835",
"0.68394154",
"0.67798775",
"0.6765381",
"0.6765381",
"0.67563057",
"0.6745321",
"0.6715933",
"0.6701776",
"0.6688937",
"0.6648165",
"0.6640532",
"0.66007... | 0.0 | -1 |
getting the buzz name for the buzz | def getting_buzz_name(user)
user.buzz_names.select("id, name").where('buzz_id = ?', self.id).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bear_name(name)\n return name\n end",
"def name\n return @playing_girl ? @name_girl : @name_boy\n end",
"def name\n BadASS::BAD_DRAGON_SKUS[@sku]\n end",
"def name\n #IMPLEMENTING INSTANCE VARIABLES using @\n @this_dogs_name\n end",
"def name\n @this_dogs_name\n end",
... | [
"0.7163489",
"0.6873007",
"0.6560837",
"0.654659",
"0.6541183",
"0.65215605",
"0.65152067",
"0.65038455",
"0.6484925",
"0.6476835",
"0.6452287",
"0.63985145",
"0.63697004",
"0.63697004",
"0.63697004",
"0.63697004",
"0.63683176",
"0.63683176",
"0.6345498",
"0.63429487",
"0.633... | 0.7467584 | 0 |
getting buzz limted user names | def get_buzz_limited_member_names(buzz_members)
user_name = []
buzz_members.each{|member| user_name << member.user.full_name}
user_name.join(' , ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def usernames\n Message::Statement.display_usernames(raw_data.keys)\n end",
"def reply_users_names\n reply_users&.split(/[, ]+/)&.map do |reply_user_id|\n User.find(reply_user_id).real_name\n end&.join(', ')\n end",
"def complete_name_list\n #User.select(:name).map{|user_record| user_recor... | [
"0.75527066",
"0.72167397",
"0.7114538",
"0.7102604",
"0.7100973",
"0.7100973",
"0.7097716",
"0.7085067",
"0.70120084",
"0.6995239",
"0.69899595",
"0.69885314",
"0.695327",
"0.6902298",
"0.6897352",
"0.6861215",
"0.68421376",
"0.682391",
"0.681142",
"0.6806184",
"0.6799256",
... | 0.71718407 | 2 |
limiting the members for rezzs | def save_rezz_members buzz
buzz.buzz_members.each{|member| self.buzz_members.create({:channel_id => buzz.channel_id, :user_id => member.user_id})}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def only_members items\n only_ items, :member\nend",
"def members; end",
"def members; end",
"def members; end",
"def members; end",
"def members; end",
"def members; end",
"def members; end",
"def just_members\n members - [owner]\n end",
"def stand_by_members\n return [] if all_membe... | [
"0.63762474",
"0.62684715",
"0.62684715",
"0.62684715",
"0.62684715",
"0.62684715",
"0.62684715",
"0.62684715",
"0.6260017",
"0.6215065",
"0.6197302",
"0.6162799",
"0.60899395",
"0.5987116",
"0.5964457",
"0.5958124",
"0.5948905",
"0.5935047",
"0.59264946",
"0.59220797",
"0.59... | 0.54770404 | 57 |
def is_owners_priority_buzz(user_id) PriorityBuzz.owner_priority_buzz(self.id,user_id).count > 0 end | def is_user_insync?(user_id)
BuzzInsync.where("buzz_id = ? and user_id = ?",self.id,user_id).first.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_owner? user\n self.account_users.where(user: user, is_owner: true).count > 0\n end",
"def has_owner(user)\n return self.user.id==user.id\n end",
"def is_owner?(user)\n user.id == self.user_id\n end",
"def owned_by?(u)\n self.user == u\n end",
"def is_owned_by_user?(user)\n se... | [
"0.7364297",
"0.73522246",
"0.71482646",
"0.7135772",
"0.7103922",
"0.70905846",
"0.70802677",
"0.70489556",
"0.69397366",
"0.6925941",
"0.68781686",
"0.6813424",
"0.6797089",
"0.6781868",
"0.67772794",
"0.67749983",
"0.67675406",
"0.6743304",
"0.667168",
"0.66650575",
"0.664... | 0.0 | -1 |
def get_all_characters response = RestClient.get(" characters_array = JSON.parse(response.body)["results"] characters_array.each do |character| StarWarsCliApi::Character.new(character) end end | def get_all_characters(page=nil)
if page
response = RestClient.get(page)
else
response = RestClient.get("https://swapi.co/api/people")
end
characters_array = JSON.parse(response.body)["results"]
characters_array.each do |character|
StarWarsCliApi::Character.new(character)
end
# next_page = JSON.parse(response.body)["next"]
# if next_page
# get_all_characters(next_page)
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_list_characters\n response_string = RestClient.get('http://www.swapi.co/api/people/')\n response_hash = JSON.parse(response_string)\n\n character = response_hash[\"results\"].map {|char| char[\"name\"]}\nend",
"def search_for_chars\n results = []\n response = client.characters(:nameStartsWith ... | [
"0.79970825",
"0.79081917",
"0.7710236",
"0.764793",
"0.7507944",
"0.750055",
"0.7195348",
"0.7126229",
"0.70696735",
"0.70583075",
"0.7036509",
"0.6924967",
"0.69007957",
"0.6898658",
"0.68421644",
"0.68162596",
"0.6790286",
"0.67416817",
"0.6736535",
"0.6715574",
"0.6710496... | 0.8410466 | 0 |
Working, shows all recent checkins from all following | def habit_activity(habit_id)
HTTParty.get('https://www.lift.do/api/v2/habits/%d/activity' % habit_id, @options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_checkins(response)\n user = response.matches.first.first || response.user.name\n\n if redis.sismember('users', user)\n log.debug(\"#{user} looks like an Untappd user\")\n untappd_user = user\n else\n # look up the Untappd user for this chat user\n l... | [
"0.6232945",
"0.60642385",
"0.59909207",
"0.5962495",
"0.5901253",
"0.59005994",
"0.58340734",
"0.5816888",
"0.58114666",
"0.5811321",
"0.5771759",
"0.5771759",
"0.5771759",
"0.57636344",
"0.5745678",
"0.5724336",
"0.57086384",
"0.5706479",
"0.57022136",
"0.56990165",
"0.5692... | 0.0 | -1 |
NOT WORKING Changed from v1 to v3 and it checked me into weird habit (Warm Water & Lemon) | def checkin(habit_id, time=DateTime.now)
data = {body: {habit_id: habit_id, date: time.to_s}}
HTTParty.post('https://www.lift.do/api/v3/checkins', @options.merge(data))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def villian; end",
"def romeo_and_juliet; end",
"def silly_adjective; end",
"def leeway; end",
"def leeway; end",
"def anchored; end",
"def verdi; end",
"def buzzword; end",
"def buzzword; end",
"def king_richard_iii; end",
... | [
"0.6161322",
"0.61220133",
"0.6095568",
"0.59677494",
"0.5943028",
"0.5943028",
"0.59402555",
"0.59202725",
"0.5917457",
"0.5917457",
"0.58898723",
"0.58371323",
"0.5829512",
"0.58043605",
"0.57500285",
"0.5728095",
"0.57149905",
"0.5708953",
"0.5692833",
"0.56910735",
"0.568... | 0.0 | -1 |
NOT WORKING (page has changed format) | def checkin_data(habit_id)
response = HTTParty.get('https://www.lift.do/users/%s/%d' % [@profile_hash, habit_id])
doc = Nokogiri::HTML(response.body)
month_names = doc.search('//*[@id="profile-calendar"]/div/div/h3')
month_tables = doc.search('#profile-calendar table')
checkins = []
while (!month_names.empty?)
month_name = month_names.shift
month_table = month_tables.shift
month_table.search('div.checked').each do |day|
m_day = day.text
checkins.push(Date.parse(m_day + ' ' + month_name.content))
end
end
{
'habit-name' => doc.search('.profile-habit-name').first.content,
'checkins' => checkins.sort
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def page; end",
"def pages; end",
"def turn_page(old_url)\n split_old_url = old_url.split('&page=')... | [
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6267087",
"0.6235911",
"0.6130624",
"0.6112474",
"0.60150665",
"0.60147774",
"0.5981886",
"0.59766114",
"0.59570634",
"0.5923515",... | 0.0 | -1 |
default arguments will get the entire file | def get_range_in_file( file_name, line_a=1, line_b=-1 )
@data_source = File.open( file_name, "r" )
initial_load_range( line_a, line_b )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_read_opts=(_arg0); end",
"def get_file()\n puts(\"Please enter a file path: \")\n for arg in ARGV\n \tname = arg\n end\n print meta_data(name)\n name\nend",
"def file=(_arg0); end",
"def file=(_arg0); end",
"def file=(_arg0); end",
"def file(*args)\n if args.empty?\n return @fi... | [
"0.70335394",
"0.6910446",
"0.6791883",
"0.6791883",
"0.6791883",
"0.67397314",
"0.6688616",
"0.6623966",
"0.65420926",
"0.65000105",
"0.64442396",
"0.64100736",
"0.64090246",
"0.64090246",
"0.62961125",
"0.6226411",
"0.6206504",
"0.6206504",
"0.6206504",
"0.6206504",
"0.6206... | 0.0 | -1 |
default arguments will get the whole file | def initial_load_range( line_a=1, line_b=-1 )
@lines = []
line_number = 0
f = @data_source
f.each do |line|
line_number += 1
next unless line_number >= line_a
@lines << Line.new(line_number, line.chomp )
break if line_b != -1 && line_number >= line_b
end
f.close if f.is_a? File
@lines
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_read_opts=(_arg0); end",
"def get_file()\n puts(\"Please enter a file path: \")\n for arg in ARGV\n \tname = arg\n end\n print meta_data(name)\n name\nend",
"def file=(_arg0); end",
"def file=(_arg0); end",
"def file=(_arg0); end",
"def files=(_arg0); end",
"def file_read_opts; end",
"... | [
"0.7107387",
"0.7018891",
"0.6853999",
"0.6853999",
"0.6853999",
"0.6690448",
"0.6646771",
"0.66215926",
"0.6559367",
"0.6417385",
"0.6392918",
"0.6392918",
"0.6371434",
"0.6277533",
"0.62664074",
"0.6262908",
"0.6214164",
"0.6214164",
"0.6214164",
"0.6214164",
"0.6214164",
... | 0.0 | -1 |
Process the data in place to join lines ending in '\' Some lines may be appended to the ones before them. Their text will be set to nil. | def join_lines
output = []
n = 0
while n < @lines.length do
cur_line = n
longer_line = String.new;
if @lines[cur_line].text[-1] == '\\'
longer_line = @lines[cur_line].text.chop()
cur_line += 1
longer_line += @lines[cur_line].text
longer_line.chop!() if longer_line[-1] == '\\'
end
while @lines[cur_line].text[-1] == '\\'
cur_line += 1
longer_line += @lines[cur_line].text[0..-2]
end
# if there were joined lines
if n < cur_line
@lines[n].text = longer_line
# catch up
while n < cur_line
n += 1
@lines[n].text = nil
end
end
n += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_missing_newline(data)\n return data if data.end_with?(LINE_SEPARATOR)\n\n data << LINE_SEPARATOR\n end",
"def clean2\n content = text.split(\"\\n\")\n \n # First, find and mark songs\n in_song = false\n new_content = []\n content.each do |line|\n ... | [
"0.63218105",
"0.60625005",
"0.57142127",
"0.5708246",
"0.55971336",
"0.5570881",
"0.5559456",
"0.5520789",
"0.5492862",
"0.54659563",
"0.54580545",
"0.54541236",
"0.54434645",
"0.543528",
"0.53958005",
"0.53688633",
"0.53209794",
"0.53195345",
"0.53195345",
"0.5314026",
"0.5... | 0.6491404 | 0 |
BEGIN Email Related accessors | def appellant_email
hearing.appellant_recipient&.email_address
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email; @email; end",
"def inbound_email; end",
"def inbound_email; end",
"def email\n self[:emailAddress]\n end",
"def email; end",
"def email; end",
"def email; end",
"def email; end",
"def get_mail\n \n end",
"def mailboxer_email(object)\n self.email\n end",
"def email\n ... | [
"0.7311611",
"0.7236259",
"0.7236259",
"0.70782286",
"0.6992571",
"0.6992571",
"0.6992571",
"0.6992571",
"0.6959735",
"0.69240016",
"0.6861537",
"0.68499315",
"0.68445045",
"0.68043214",
"0.68043214",
"0.67776626",
"0.677019",
"0.67675537",
"0.6762441",
"0.6744333",
"0.668888... | 0.0 | -1 |
END Email related accessors After a certain point after this change gets merged, alias_with_host will never be nil so we can rid of this logic then | def formatted_alias_or_alias_with_host
alias_with_host.nil? ? VirtualHearing.formatted_alias(alias_name) : alias_with_host
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host_aliases\n @fragments.map(&:host_aliases).flatten.uniq + [name]\n end",
"def exchange_alias=(value)\n @exchange_alias = value\n end",
"def mailbox_aliases\n return @mailbox_aliases if @mailbox_aliases\n @mailbox_aliases = {}\n @default_mailbox_aliases.each d... | [
"0.6339075",
"0.6162226",
"0.6119055",
"0.61133975",
"0.60743576",
"0.60575587",
"0.6047779",
"0.5998335",
"0.5923425",
"0.5897429",
"0.5869697",
"0.5841089",
"0.5732481",
"0.57318133",
"0.56983596",
"0.56853515",
"0.56675583",
"0.56569767",
"0.5647202",
"0.564539",
"0.563857... | 0.6702133 | 0 |
Returns a random host and guest pin | def generate_conference_pins
self.guest_pin_long = "#{rand(1_000_000_000..9_999_999_999).to_s[0..9]}#"
self.host_pin_long = "#{rand(1_000_000..9_999_999).to_s[0..9]}#"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_mac_addr(provider)\n symbol = provider.to_sym\n case symbol\n when :virtualbox\n PROVIDER_MAC_PREFIXES[:virtualbox] + 3.times.map { '%02x' % rand(0..255) }.join\n when :libvirt\n PROVIDER_MAC_PREFIXES[:libvirt] + 3.times.map { '%02x' % rand(0..255) }.join\n when :vmware_fusion\n ... | [
"0.69550633",
"0.6610773",
"0.6576419",
"0.6576419",
"0.6576419",
"0.6384577",
"0.63426864",
"0.6247598",
"0.6235803",
"0.62247527",
"0.62247527",
"0.616741",
"0.60979444",
"0.60242975",
"0.5889751",
"0.58385026",
"0.5837403",
"0.5816317",
"0.5781644",
"0.5773647",
"0.5758505... | 0.67258584 | 1 |
Override the guest pin | def guest_pin
guest_pin_long || self[:guest_pin]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pin\n @pin = 1234\n end",
"def host_pin\n host_pin_long || self[:host_pin]\n end",
"def host_pin\n host_pin_long || self[:host_pin]\n end",
"def pin(*args)\n owner.pin(*args)\n end",
"def on(pin=@pin)\n super(pin)\n end",
"def pin\n password = $pin\n end",
"def... | [
"0.6648401",
"0.6444452",
"0.6444452",
"0.62319446",
"0.6213308",
"0.62020683",
"0.61970055",
"0.61128086",
"0.610788",
"0.6010711",
"0.5961117",
"0.5803999",
"0.57913864",
"0.57746583",
"0.57746583",
"0.5745951",
"0.5744335",
"0.57031345",
"0.5692389",
"0.56586725",
"0.56483... | 0.7587704 | 0 |
Override the host pin | def host_pin
host_pin_long || self[:host_pin]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pin\n @pin = 1234\n end",
"def on(pin=@pin)\n super(pin)\n end",
"def pin!\n update_attribute(:pinned, true)\n end",
"def ip\n super\n end",
"def pin(*args)\n owner.pin(*args)\n end",
"def pin!\n update_attribute(:pinned, true)\n end",
"def host=(new_host); e... | [
"0.67316514",
"0.65162057",
"0.6340123",
"0.62397045",
"0.6230415",
"0.6229824",
"0.61746866",
"0.6156466",
"0.6148787",
"0.59765357",
"0.5970469",
"0.5942297",
"0.59173113",
"0.59112924",
"0.5861036",
"0.5861036",
"0.5855505",
"0.5788389",
"0.5788389",
"0.5769143",
"0.575331... | 0.76240027 | 0 |
for guest_link and host_link: links generated January 2021 and later are stored in guest_hearing_link and host_hearing_link; links generated before January 2021 are assembled from variables as seen below. We are continuing to support both, even after all hearings scheduled pre 1/2021 are held, to ensure that there is an accurate historical record of the links that were used to hold the hearing. We will refactor our handling of pre and post1/2021 links with CASEFLOW1336. | def guest_link
return guest_hearing_link if guest_hearing_link.present?
"#{VirtualHearing.base_url}?join=1&media=&escalate=1&" \
"conference=#{formatted_alias_or_alias_with_host}&" \
"pin=#{guest_pin}&role=guest"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rebuild_and_save_links\n fail NoAliasWithHostPresentError if alias_with_host.blank?\n\n conference_id = alias_with_host[/BVA(\\d+)@/, 1]\n link_service = VirtualHearings::LinkService.new(conference_id)\n\n # confirm that we extracted the conference ID correctly,\n # and that the original link wa... | [
"0.68230057",
"0.57524157",
"0.57331365",
"0.5698852",
"0.5607377",
"0.5491498",
"0.5459556",
"0.54442924",
"0.54274756",
"0.5353429",
"0.5346814",
"0.53033304",
"0.5266671",
"0.52595234",
"0.52441376",
"0.5236868",
"0.5229796",
"0.5193972",
"0.5183167",
"0.5181487",
"0.51664... | 0.58326095 | 1 |
Determines if the hearing type has been switched to the original type NOTE: This can only happen from the hearing details page where the hearing coordinator can switch the type from virtual back to Video or Central. This essentailly cancels this virtual hearing. | def cancelled?
# the establishment has been cancelled by the user
request_cancelled?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_type_set?\n self.change_type\n end",
"def deLigne?() return @type == @@LIGNE end",
"def same_type_guard?\n @type_guard == true\n end",
"def is_hardfence?(); @type == GRT_HARDFENCE; end",
"def update_type(user)\n if (self.is_self_auditor?(user) && self.is_self_audit?)\n :se... | [
"0.6097701",
"0.5924922",
"0.5753666",
"0.5719369",
"0.56004953",
"0.55512124",
"0.5457831",
"0.5457831",
"0.541484",
"0.541185",
"0.5381636",
"0.53714806",
"0.53571236",
"0.53490996",
"0.53148156",
"0.53008866",
"0.52790713",
"0.527846",
"0.5260195",
"0.5255351",
"0.52553",
... | 0.0 | -1 |
Hearings are pending if the conference is not created and it is not cancelled | def pending?
status == :pending
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closed?\n # the conference has been created the virtual hearing was deleted\n conference_id.present? && conference_deleted?\n end",
"def conference_in_progress?(room)\n client = Twilio::REST::Client.new ACCOUNT_SID, AUTH_TOKEN\n\n client.account.conferences.list({\n status: \"in-progress\",... | [
"0.618166",
"0.6076625",
"0.60551685",
"0.5997591",
"0.5924441",
"0.59139097",
"0.5873665",
"0.5856943",
"0.57776356",
"0.56675315",
"0.5649362",
"0.56486857",
"0.5641624",
"0.56072426",
"0.5583525",
"0.5521519",
"0.5520492",
"0.5516189",
"0.54997736",
"0.5497753",
"0.5496447... | 0.52243036 | 62 |
Determines if the hearing conference has been created | def active?
# the conference has been created the virtual hearing is active
conference_id.present? || (guest_hearing_link.present? && host_hearing_link.present?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closed?\n # the conference has been created the virtual hearing was deleted\n conference_id.present? && conference_deleted?\n end",
"def meetup_auto_create_account?\n self.meetup_auto_create_account\n end",
"def create?\n event == 'create'\n end",
"def on_create_called?\n... | [
"0.744377",
"0.6746672",
"0.65278167",
"0.64847547",
"0.6391124",
"0.6368004",
"0.62895054",
"0.6287913",
"0.6282235",
"0.62214786",
"0.61817634",
"0.61222357",
"0.60650444",
"0.6035884",
"0.6032376",
"0.6013387",
"0.6013387",
"0.60106546",
"0.60094994",
"0.5989623",
"0.59718... | 0.76282614 | 0 |
Determines if the conference was deleted NOTE: Even though the conference is deleted for every virtual hearing, this status helps us distinguish between hearings that had their types switched back to original type and cancelled and postponed hearings which require us to delete the conference but not set `request_cancelled`. | def closed?
# the conference has been created the virtual hearing was deleted
conference_id.present? && conference_deleted?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_deleted?(participant)\n return false if participant.nil?\n return receipt_for(participant).first.deleted\n end",
"def deleted?\n status == :deleted\n end",
"def delete_conference(virtual_hearing)\n response = client.delete_conference(conference_id: virtual_hearing.conference_id)\n\... | [
"0.66026765",
"0.6398089",
"0.63222456",
"0.6306968",
"0.62646055",
"0.6222733",
"0.61604553",
"0.613505",
"0.6109301",
"0.60784096",
"0.60784096",
"0.60746825",
"0.6068564",
"0.6065888",
"0.6065888",
"0.6047485",
"0.60069734",
"0.60016507",
"0.59892166",
"0.59892166",
"0.598... | 0.6831049 | 0 |
Determines the status of the Virtual Hearing based on the establishment | def status
return :cancelled if cancelled?
return :closed if closed?
return :active if active?
# If the establishment is not active, closed, or cancelled it is pending
:pending
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_on_vehicle\r\r\n front_x = $game_map.round_x_with_direction(@x, @direction)\r\r\n front_y = $game_map.round_y_with_direction(@y, @direction)\r\r\n @vehicle_type = :boat if $game_map.boat.pos_rect?(front_x, front_y, interaction_rect)\r\r\n @vehicle_type = :ship if $game_map.ship.pos_rect?(... | [
"0.62155426",
"0.6049171",
"0.59387726",
"0.58352077",
"0.5802558",
"0.56621695",
"0.56493163",
"0.56132525",
"0.553734",
"0.5434833",
"0.5428422",
"0.53965116",
"0.5394102",
"0.53508437",
"0.5344858",
"0.53388447",
"0.53366137",
"0.53198504",
"0.5317147",
"0.53139675",
"0.52... | 0.54783267 | 9 |
Hearings can be established only if the conference has been created and emails sent | def can_be_established?
active? && all_emails_sent?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active?\n # the conference has been created the virtual hearing is active\n conference_id.present? || (guest_hearing_link.present? && host_hearing_link.present?)\n end",
"def meeting_accepted(meeting)\n setup_email\n @recipients = meeting.host.email\n @subject += \"Cita aceptada\"\n @body ... | [
"0.7010778",
"0.6377015",
"0.609618",
"0.59492475",
"0.5855504",
"0.58374333",
"0.57900155",
"0.57459074",
"0.5721918",
"0.5687393",
"0.563947",
"0.56137633",
"0.559459",
"0.5584839",
"0.55799675",
"0.55796343",
"0.55481315",
"0.5526166",
"0.5495868",
"0.5483832",
"0.5475784"... | 0.6457394 | 1 |
Sets the virtual hearing status to cancelled | def cancel!
update(request_cancelled: true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancelled!\n @cancelled = true\n end",
"def cancel!\n state_guard { modify_call 'Status' => 'cancelled' }\n end",
"def cancel\n self.update_status :cancelled\n end",
"def cancelled?; end",
"def cancel!; end",
"def cancel\n @error = :cancelled\n end",
"def cance... | [
"0.68059635",
"0.6698275",
"0.66848767",
"0.66044414",
"0.6432417",
"0.6431587",
"0.6418582",
"0.6418582",
"0.6415717",
"0.63138425",
"0.62964475",
"0.62821627",
"0.62765956",
"0.62765956",
"0.62765956",
"0.62741435",
"0.62741435",
"0.6256216",
"0.6256216",
"0.6256216",
"0.62... | 0.59994125 | 43 |
rebuild and save the virtual hearing links using the original pins; to be used if the format of the links has changed | def rebuild_and_save_links
fail NoAliasWithHostPresentError if alias_with_host.blank?
conference_id = alias_with_host[/BVA(\d+)@/, 1]
link_service = VirtualHearings::LinkService.new(conference_id)
# confirm that we extracted the conference ID correctly,
# and that the original link was generated with the link service
if link_service.alias_with_host != alias_with_host ||
link_service.host_pin != host_pin_long ||
link_service.guest_pin != guest_pin_long
fail LinkMismatchError
end
update!(host_hearing_link: link_service.host_link, guest_hearing_link: link_service.guest_link)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_hardlinks\n counter = 0\n @hardlinks.each do |file, target|\n counter += 1 \n\n # in case of recursive redirects, which shouldn't happen, but alas\n recursion = 0\n while @hardlinks[target] && recursion < 3\n recursion += 1\n target = @hardlinks[... | [
"0.5392191",
"0.5302628",
"0.52852947",
"0.52798116",
"0.52614474",
"0.5223507",
"0.5191005",
"0.51862663",
"0.516568",
"0.5158677",
"0.51584035",
"0.5155588",
"0.5150016",
"0.5150016",
"0.51145667",
"0.51120526",
"0.5098754",
"0.50970954",
"0.5068497",
"0.50452524",
"0.50383... | 0.67006445 | 0 |
GET /publishers/1 GET /publishers/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publishers\n get_publishers_from_url('/publishers')\n end",
"def publishers(location = @location)\n raise ArgumentError, \"No location specified\" unless location\n\n url = build_url(location, 'publishers')\n\n JSON.parse(rest_get(url)).map{ |element| element['name'] }\n ... | [
"0.7344729",
"0.70221287",
"0.6967046",
"0.67222667",
"0.67222667",
"0.66588825",
"0.6556266",
"0.64498484",
"0.6358653",
"0.63559747",
"0.6206997",
"0.6199853",
"0.6198845",
"0.61826456",
"0.61599267",
"0.61426324",
"0.6138005",
"0.6098605",
"0.60707784",
"0.60675895",
"0.60... | 0.0 | -1 |
POST /publishers POST /publishers.json | def create
# disabled for now
# @publisher = Publisher.new(publisher_params)
# respond_to do |format|
# if @publisher.save
# format.html { redirect_to @publisher, notice: 'Publisher was successfully created.' }
# format.json { render :show, status: :created, location: @publisher }
# else
# format.html { render :new }
# format.json { render json: @publisher.errors, status: :unprocessable_entity }
# end
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publishers\n get_publishers_from_url('/publishers')\n end",
"def publishers(location = @location)\n raise ArgumentError, \"No location specified\" unless location\n\n url = build_url(location, 'publishers')\n\n JSON.parse(rest_get(url)).map{ |element| element['name'] }\n ... | [
"0.6474215",
"0.6445448",
"0.636836",
"0.63470775",
"0.63298005",
"0.60759574",
"0.59439266",
"0.5912301",
"0.57539654",
"0.57456464",
"0.5637651",
"0.5619581",
"0.55755424",
"0.55648065",
"0.5564621",
"0.55557436",
"0.55469054",
"0.55165076",
"0.5489888",
"0.5459094",
"0.542... | 0.58337903 | 8 |
PATCH/PUT /publishers/1 PATCH/PUT /publishers/1.json | def update
@categories = Category.pluck(:name,:id)
@publisher.skip_reconfirmation!
if params[:default_logo]
params[:logo] = nil
end
respond_to do |format|
if @publisher.update_without_password(publisher_params)
format.html { redirect_to @publisher, notice: 'Publisher was successfully updated.' }
format.json { render :show, status: :ok, location: @publisher }
else
format.html { render :edit }
format.json { render json: @publisher.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @publisher = Publisher.find(params[:id])\n\n respond_to do |format|\n if @publisher.update_attributes(params[:publisher])\n format.html { redirect_to @publisher, :notice => 'Publisher was successfully updated.' }\n format.json { head :no_content }\n else\n format.h... | [
"0.61841756",
"0.61762595",
"0.61633074",
"0.61456585",
"0.6135309",
"0.61344546",
"0.61222243",
"0.6107791",
"0.6025436",
"0.5896632",
"0.5896632",
"0.5896632",
"0.5891527",
"0.5873326",
"0.5835332",
"0.58070266",
"0.57991904",
"0.57821727",
"0.57821727",
"0.5773705",
"0.575... | 0.0 | -1 |
DELETE /publishers/1 DELETE /publishers/1.json | def destroy
# disabled for now
# @publisher.destroy
# respond_to do |format|
# format.html { redirect_to publishers_url, notice: 'Publisher was successfully destroyed.' }
# format.json { head :no_content }
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @publisher = Publisher.find(params[:id])\n @publisher.destroy\n\n respond_to do |format|\n format.html { redirect_to publishers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @publisher = Publisher.find(params[:id])\n @publisher.destroy\n\n res... | [
"0.752619",
"0.752619",
"0.752619",
"0.73233724",
"0.7257622",
"0.7238183",
"0.710225",
"0.69793224",
"0.69419235",
"0.69419235",
"0.6928661",
"0.6864735",
"0.6859178",
"0.68200094",
"0.68200094",
"0.68025416",
"0.6769383",
"0.67457914",
"0.67420477",
"0.6717668",
"0.6682058"... | 0.7052496 | 7 |
Use callbacks to share common setup or constraints between actions. | def set_publisher
# something is causing the application to turn :delete /signout requests to :get requests
# here's minor patch to fix it when that happens
if params[:id] == "sign_out"
flash[:error] = "There was a connection error while signing out. Please try again."
redirect_to root_path and return
end
@publisher = Publisher.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 publisher_params
params.require(:publisher).permit(:email, :name,
:domain, :password, :verified,
:blog_name, :category_id, :logo,
:free_demographics, :questions_active)
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 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
smallest_key = 0
current_value = 0
current_key = ""
name_hash.collect do |key, value|
if value < current_value || current_value == 0
current_value = value
current_key = key
end
end
if current_key == ""
return nil
else
current_key
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.882206",
"0.87785",
"0.87776536",
"0.8746582",
"0.8690028",
"0.86559135",
"0.86532515",
"0.8617044",
"0.8588429",
"0.8572508",
"0.85678524",
"0.85517466",
"0.85302997",
"0.85302997",
"0.8519287",
"0.8494114",
"0.8475786",
"0.8475786",
"0.8466334",
"0.8449688",
"0.8449442",... | 0.0 | -1 |
Given an environment and a command array, produce a new environment and command array. this mechanism lets us shove things in, provide defaults, and so on | def filter_command(envs, cmd)
new_env = {}
merged_path = ENV["PATH"].split(/:/)
new_cmd = cmd
envs.each do |env|
case env
when /=/
k,v = env.split(/\s*=\s*/, 2)
expand_parm(k,v,cmd) {|c, ae, p| new_env.update(ae); new_cmd = c; merged_path << p; }
else
expand(env,cmd) {|c, ae, p| new_env.update(ae); new_cmd = c; merged_path << p; }
end
end
ENV["PATH"] = merged_path.uniq.compact.join(":")
[new_cmd.flatten.compact, new_env]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_env_wrapper(command, environment)\r\n if environment\r\n env_string = environment.map { |k, v| \"$env:#{k}='#{v}'\" }.join('; ')\r\n \"& { #{env_string}; #{command} }\"\r\n else\r\n command\r\n end\r\nend",
"def construct_environment(envs)\n envs.each do |key, value|\n if value\n ... | [
"0.6682348",
"0.6119103",
"0.6020778",
"0.59231",
"0.56885535",
"0.55839604",
"0.5544265",
"0.5502776",
"0.55020946",
"0.54806113",
"0.5460223",
"0.5450832",
"0.54126006",
"0.54035896",
"0.53223485",
"0.52491313",
"0.52409315",
"0.5219129",
"0.5195148",
"0.5174931",
"0.513305... | 0.6251569 | 1 |
Given the set of env strings, set various environment variables. Note that these can be set directly on the command line, too. but typically you'd create a filter in the above function that expands to the desired environment | def construct_environment(envs)
envs.each do |key, value|
if value
value = value.to_s
value = nil if value.length == 0
end
ENV[key.to_s] = value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_env_variables(env_vars = [])\n env_vars.each do |_v|\n key, value = _v.split(\"=\")\n\n ENV[key] = value\n end\n end",
"def set_env_variables(container_names = '*', block: false, timeout: 60, polling: 5, **env)\n env_strings = env.map { |k, v| v ? \"#{k}=#{v}\" : \"#{k}-\" }\... | [
"0.79698515",
"0.6843395",
"0.68306535",
"0.682145",
"0.67813945",
"0.6765523",
"0.664615",
"0.6625289",
"0.6605878",
"0.656962",
"0.65440977",
"0.6518798",
"0.65081346",
"0.6479111",
"0.6475819",
"0.64663184",
"0.6444869",
"0.64189106",
"0.64182085",
"0.641308",
"0.64111805"... | 0.6409043 | 21 |
This is the options of the program, see OptionParser | def program_options
[
# The values of the array are,
# [long_option, short_option and parameter, description, code to execute]
['--to', '-t TO', "Send email to recipent",
lambda { |value| options.to = value }
],
['--message', '-m MESSAGE', "Include the message.",
lambda { |value| options.message = value }
],
['--subject', '-s SUBJECT', "Include the subject.",
lambda { |value| options.subject = value }
],
['--verbose', '-v', "Log to standard output.",
lambda { |value| options.verbose = true }
],
['--version', '-V', "Display the program version.",
lambda { |value|
puts "#{program_name}, version #{PROGRAM_VERSION}"
exit
}
]
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def program_options\n [\n # The values of the array are,\n # [long_option, short_option and parameter, description, code to execute]\n ['--google', '-g', \"Format for Google blogger.\",\n lambda { |value| options.google = true }\n ],\n ['--jayway', '-j', \"Format for Jayway blog.\",\n lambda { |v... | [
"0.7995416",
"0.78072274",
"0.7707425",
"0.76896536",
"0.7605422",
"0.7574655",
"0.750012",
"0.74080044",
"0.73792815",
"0.7377898",
"0.73614323",
"0.732538",
"0.729533",
"0.72771305",
"0.7258441",
"0.7252047",
"0.7252047",
"0.72488445",
"0.71998274",
"0.7193044",
"0.7184772"... | 0.78244734 | 1 |
Saves a user's identity in their custom fields. Params: +public+:: Serialized public identity +private+:: Serialized private identity +label+:: Private identity label +overwrite+:: Force overwrite of public and private identities Returns status code 200 on success or 409 if user already has an identity and public identities mismatch. | def update_keys
public_identity = params.require(:public)
private_identity = params[:private]
private_id_label = params[:label]
# Check if encryption is already enabled (but not changing passphrase).
old_identity = current_user.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD]
if params[:overwrite].blank? && old_identity && old_identity != public_identity
return render_json_error(I18n.t('encrypt.enabled_already'), status: 409)
end
current_user.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD] = public_identity
if private_identity.present?
if private_id_label.present?
data = JSON.parse(current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD]) rescue {}
data[private_id_label.downcase] = private_identity
current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD] = JSON.dump(data)
else
current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD] = private_identity
end
end
current_user.save_custom_fields
render json: success_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n # TODO validar atributos?\n response = Http.post(\"/organizations/api/identities/#{self.identity.uuid}/accounts/\", create_body)\n raise \"unexpected response: #{response.code} - #{response.body}\" unless response.code == 201\n attributes_hash = MultiJson.decode(response.body)\n ... | [
"0.5879495",
"0.5562793",
"0.5507102",
"0.54902977",
"0.5404748",
"0.53885025",
"0.5367655",
"0.52539855",
"0.51638776",
"0.5124784",
"0.51172554",
"0.5076176",
"0.5051577",
"0.50498164",
"0.50443053",
"0.50396734",
"0.50006974",
"0.499121",
"0.49671277",
"0.49648055",
"0.496... | 0.63163334 | 0 |
Delete a user's identity from the private identity. Params: +label+:: Private identity label Returns status code 200 after label is deleted. | def delete_key
private_id_label = params.require(:label)
data = JSON.parse(current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD]) rescue {}
if data.delete(private_id_label)
current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD] = JSON.dump(data)
current_user.save_custom_fields
end
render json: success_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_label!(repo, label, options = {})\n boolean_from_response :delete, \"#{Repository.path repo}/labels/#{label}\", options\n end",
"def remove_label(label)\n @api.do_request(\"DELETE\", label.get_base_api_path() + \"/messages/\" + get('id'))\n if @label_ids_set.has_key?(label.id... | [
"0.6868516",
"0.6617155",
"0.6617155",
"0.63307744",
"0.62861073",
"0.6283864",
"0.6130395",
"0.61273026",
"0.60674906",
"0.59023494",
"0.5875444",
"0.58609504",
"0.58165115",
"0.5798453",
"0.57804745",
"0.5751681",
"0.57336336",
"0.5701598",
"0.56758934",
"0.5652961",
"0.562... | 0.6496554 | 3 |
Gets public identities of a set of users. Params: +usernames+:: Array of usernames Returns status code 200 and a hash of usernames and their public identities. | def show_user
usernames = params.require(:usernames)
identities = Hash[User.where(username: usernames).map { |u| [u.username, u.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD]] }]
render json: identities
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile(usernames)\n get(\"/1/users/show.json\", :users => [usernames].flatten).users\n end",
"def show_user\n usernames = params.require(:usernames)\n\n keys = Hash[User.where(username: usernames).map { |u| [u.username, u.custom_fields['encrypt_public_key']] }]\n\n render json: ... | [
"0.6707377",
"0.60679686",
"0.59529704",
"0.59411293",
"0.5868382",
"0.5765018",
"0.56895864",
"0.5648605",
"0.5529795",
"0.5529399",
"0.55143064",
"0.54694766",
"0.544982",
"0.5419449",
"0.5397319",
"0.53531545",
"0.53196645",
"0.5319197",
"0.53131306",
"0.5301627",
"0.52972... | 0.6703211 | 1 |
Resets encryption keys for a user. Params: +user_id+:: ID of user to be reset +everything+:: Whether user should be univited all keys removed Returns status code 200 after user is reset. | def reset_user
user_id = params.require(:user_id)
user = User.find_by(id: user_id)
raise Discourse::NotFound if user.blank?
guardian.ensure_can_edit!(user)
if params[:everything] == 'true'
TopicAllowedUser
.joins(topic: :_custom_fields)
.where(topic_custom_fields: { name: DiscourseEncrypt::TITLE_CUSTOM_FIELD })
.where(topic_allowed_users: { user_id: user.id })
.delete_all
PluginStoreRow
.where(plugin_name: 'discourse-encrypt')
.where("key LIKE 'key_%_' || ?", user.id)
.delete_all
end
# Delete encryption keys.
user.custom_fields.delete(DiscourseEncrypt::PUBLIC_CUSTOM_FIELD)
user.custom_fields.delete(DiscourseEncrypt::PRIVATE_CUSTOM_FIELD)
user.save_custom_fields
render json: success_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_user\n user_id = params.require(:user_id)\n\n user = User.find_by(id: user_id)\n raise Discourse::NotFound if user.blank?\n\n if params[:everything] == 'true'\n TopicAllowedUser\n .joins(topic: :_custom_fields)\n .where(topic_custom_fields: { nam... | [
"0.73714375",
"0.56958705",
"0.53963137",
"0.53963137",
"0.5280119",
"0.52788967",
"0.5278653",
"0.52623546",
"0.52046466",
"0.5142758",
"0.5117884",
"0.50680953",
"0.4994835",
"0.49862838",
"0.49479502",
"0.49245828",
"0.49092135",
"0.48937768",
"0.48879483",
"0.48817176",
"... | 0.72523326 | 1 |
Updates an encrypted post, used immediately after creating one to update signature. Params: +post_id+:: ID of post to be updated +encrypted_raw+:: Encrypted raw with signature included Returns status code 200 after post is updated. | def update_post
post_id = params.require(:post_id)
encrypted_raw = params.require(:encrypted_raw)
post = Post.find_by(id: post_id)
guardian.ensure_can_edit!(post)
if post.updated_at < 5.seconds.ago
return render_json_error(I18n.t('too_late_to_edit'), status: 409)
end
post.update!(raw: encrypted_raw)
render json: success_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n return request_aes_key if decrypt_sym!(:post).nil?\n pp = post_params\n pp[:tags] = pp[:tags].split(/,\\s*/) if pp[:tags].is_a? String\n\n respond_to do |format|\n if @post.update(pp)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.... | [
"0.5699983",
"0.567479",
"0.56425524",
"0.5421158",
"0.537014",
"0.5362465",
"0.53209114",
"0.53205645",
"0.52808577",
"0.52497",
"0.52413726",
"0.5231352",
"0.52106684",
"0.5152795",
"0.51346177",
"0.5134559",
"0.51343685",
"0.5125249",
"0.51110625",
"0.50839156",
"0.5074692... | 0.76361924 | 0 |
Returns the id of the entry or its url if not id is present, as some formats don't support it | def id
@entry_id || @url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n @entry_id ||= @url\n end",
"def id\n @id || @url\n end",
"def url_id\n id\n end",
"def id\n ref = JSONModel::parse_reference(self.uri)\n\n if ref\n ref[:id]\n else\n nil\n end\n end",
"def entry_global_id(entry=@entry)\... | [
"0.7983267",
"0.7161089",
"0.69326895",
"0.6739302",
"0.6737244",
"0.67200047",
"0.6604739",
"0.65557164",
"0.65311474",
"0.6498708",
"0.6478208",
"0.6398779",
"0.6369139",
"0.6358144",
"0.6355827",
"0.6195194",
"0.61810464",
"0.6163052",
"0.61183256",
"0.61169285",
"0.608580... | 0.8290022 | 0 |
Writter for published. By default, we keep the "oldest" publish time found. | def published=(val)
parsed = parse_datetime(val)
@published = parsed if !@published || parsed < @published
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish\n if self.draft\n self.published_at = nil\n else\n self.published_at ||= DateTime.now\n end\n end",
"def publish_now\n self.publish_at = Time.now.utc\n self.save!\n end",
"def published_post\n if self.published && self.published_at.nil?\n self.published_at = Time.... | [
"0.7648807",
"0.72954357",
"0.7218927",
"0.7174793",
"0.70462954",
"0.6992209",
"0.69819987",
"0.696967",
"0.69628674",
"0.6892109",
"0.6891091",
"0.687692",
"0.68585116",
"0.684239",
"0.6839865",
"0.68328017",
"0.67935336",
"0.67461336",
"0.6675807",
"0.6675807",
"0.6675402"... | 0.669122 | 19 |
Writter for udapted. By default, we keep the most recenet update time found. | def updated=(val)
parsed = parse_datetime(val)
@updated = parsed if !@updated || parsed > @updated
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uptouch(uid, time)\n ref = ref_for uid, true\n if time > ref.updated_at\n Rcpref.record_timestamps=false\n ref.updated_at = time \n ref.save\n Rcpref.record_timestamps=true\n else\n false\n end\n end",
"def stamp\n @options[:last_received_time] = Time.now\n sel... | [
"0.57197547",
"0.56665033",
"0.5612255",
"0.5577939",
"0.55503494",
"0.5457901",
"0.5457901",
"0.54573333",
"0.54479015",
"0.5445881",
"0.54344726",
"0.5423537",
"0.5353642",
"0.5349424",
"0.5335069",
"0.53316325",
"0.5325373",
"0.5317406",
"0.53048426",
"0.5297152",
"0.52937... | 0.0 | -1 |
To delete an account Intuit requires we provide Id and SyncToken fields | def valid_for_deletion?
return false if id.nil? || sync_token.nil?
id.value.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete!\n resource = RESOURCE % { account_id: account.id, id: id }\n response = Request.new(account.client, :delete, resource).perform\n from_response(response.body[:data])\n end",
"def delete_account\n @connection.request({\n :method => 'DELETE'\n }) \... | [
"0.6627556",
"0.6596065",
"0.657452",
"0.6552221",
"0.6200793",
"0.60903734",
"0.60141116",
"0.5949836",
"0.59059274",
"0.59028435",
"0.58804786",
"0.58432853",
"0.5828941",
"0.5828465",
"0.5818916",
"0.57717425",
"0.57436705",
"0.5723006",
"0.57161117",
"0.5710659",
"0.57009... | 0.0 | -1 |
GET /members/1 GET /members/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_members\n @user = User.find_by(user_params)\n @members = @user.members\n \n if not @members.nil?\n render json: @members\n else \n render json: \"\"\n end\n end",
"def members\n raw_response = get_request('users/members')\n ... | [
"0.80228907",
"0.7432116",
"0.73426265",
"0.73426265",
"0.73426265",
"0.73199797",
"0.7296418",
"0.72179145",
"0.72172683",
"0.714581",
"0.714581",
"0.714581",
"0.714581",
"0.714581",
"0.714581",
"0.714581",
"0.714581",
"0.714581",
"0.71455556",
"0.7133603",
"0.7093254",
"0... | 0.0 | -1 |
POST /members POST /members.json | def create
@member = Member.new(create_params)
respond_to do |format|
if @member.save
session[:member_id] = @member.id
format.html { redirect_to @member }
format.json { render action: 'show', status: :created, location: @member }
else
format.html { render action: 'new' }
format.json { render json: @member.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_member_to_list(user, list, member_id, options={})\n post(\"/#{user}/#{list}/members.json\", options.merge(:id => member_id))\n end",
"def create_member(data)\n headers = @client.make_request(:post, @client.concat_user_path(\"#{CONFERENCE_PATH}/#{id}/members\"), data)[1]\n id = Client.ge... | [
"0.6734318",
"0.6707801",
"0.6686722",
"0.66615456",
"0.66511947",
"0.6612481",
"0.6595865",
"0.6571146",
"0.6571146",
"0.6571146",
"0.6569636",
"0.65571123",
"0.65534073",
"0.6552213",
"0.6539384",
"0.6535769",
"0.6534659",
"0.6526704",
"0.6526704",
"0.6526704",
"0.6526704",... | 0.62419695 | 36 |
PATCH/PUT /members/1 PATCH/PUT /members/1.json | def update
respond_to do |format|
if @member.update(update_params)
format.html { redirect_to @member }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @member.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # byebug \n respond_to do |format|\n if self.current_member && self.current_member.id == params[:id].to_i\n if @member.update(member_params)\n format.json { render :show, status: :ok, location: @member }\n else\n return api_error(status: :unprocessable_entity... | [
"0.6825534",
"0.66732514",
"0.65920675",
"0.6553189",
"0.65405244",
"0.6517594",
"0.6517594",
"0.6517594",
"0.6517594",
"0.6517594",
"0.65155286",
"0.6492895",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.64920187",
"0.6... | 0.66082865 | 2 |
DELETE /members/1 DELETE /members/1.json | def destroy
session[:member_id] = nil
@member.destroy
respond_to do |format|
format.html { redirect_to members_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n \n respond_to do |format|\n format.html { redirect_to members_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to me... | [
"0.76811135",
"0.7641645",
"0.7641645",
"0.7611159",
"0.7611159",
"0.7567891",
"0.7567891",
"0.7557493",
"0.7545504",
"0.7545504",
"0.7545504",
"0.7545504",
"0.7545504",
"0.7545504",
"0.7545504",
"0.73531353",
"0.7306475",
"0.7306475",
"0.7306475",
"0.7306475",
"0.7306475",
... | 0.7197343 | 35 |
Use callbacks to share common setup or constraints between actions. | def set_member
@member = Member.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.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
TODO: Use the Luhn algorithm to validate the NPI (by prefixing 80840) | def valid?(num)
odd = false
num.to_s.gsub(/\D/,'').reverse.split('').map(&:to_i).collect { |d|
d *= 2 if odd = !odd
d > 9 ? d - 9 : d
}.inject(:+) % 10 == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_luhn(s)\n s.gsub!(/[^0-9]/, \"\")\n ss = s.reverse.split(//)\n\n alternate = false\n total = 0\n ss.each do |c|\n if alternate\n i = c.to_i*2\n total += (i > 9) ? (i % 10 + 1) : i\n else\n total += c.to_i\n end\n alternate = !alternate\n end\n\n ... | [
"0.76584285",
"0.75819033",
"0.7544115",
"0.74610126",
"0.7371557",
"0.7227616",
"0.7047708",
"0.6991559",
"0.6989278",
"0.6961214",
"0.6852578",
"0.68048114",
"0.6748718",
"0.6748431",
"0.67206544",
"0.667534",
"0.6668248",
"0.6659971",
"0.66580415",
"0.6631618",
"0.6567391"... | 0.0 | -1 |
after_action :create_artist? only: [:create, :update] | def index
@albums = @user.albums
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @artist = Artist.new(artist_params)\n\n respond_to do |format|\n if @artist.save\n format.html { redirect_to admin_artist_path(@artist), notice: 'Artist was successfully created.' }\n else\n format.html { render action: 'new' }\n end\n end\n end",
"def create\n... | [
"0.6960191",
"0.68869317",
"0.6710649",
"0.66878855",
"0.668635",
"0.6666839",
"0.6666839",
"0.66552234",
"0.66470325",
"0.6643622",
"0.6637893",
"0.66101515",
"0.65627867",
"0.65252787",
"0.65252787",
"0.64862007",
"0.64492625",
"0.64487624",
"0.6439292",
"0.6376267",
"0.637... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_album
@album = Album.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.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def album_params
params.require(:album).permit(:name, :artist_name_field)
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.71217275",
"0.7052942",
"0.6947555",
"0.6903013",
"0.6735074",
"0.67167085",
"0.6687677",
"0.66765445",
"0.66602796",
"0.65548825",
"0.6524274",
"0.6455697",
"0.6451343",
"0.645123",
"0.64465624",
"0.6433475",
"0.64118403",
"0.64118403",
"0.6390524",
"0.6378871",
"0.637887... | 0.0 | -1 |
Gets reference to the tempalte file | def loadTemplate
@template = File.read(@templateFile)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_template_file\n @config['template']\n end",
"def temp_value #:nodoc:\n if tempfile?\n if original_filename\n %(#{@temp_name}/#{filename};#{original_filename})\n else\n %(#{@temp_name}/#{filename})\n end\n end\n end",
"def temp_path\n ... | [
"0.6991975",
"0.69503677",
"0.6886656",
"0.6869584",
"0.68025964",
"0.67662656",
"0.67626697",
"0.6759216",
"0.6695752",
"0.6656927",
"0.6520019",
"0.6519072",
"0.6512814",
"0.6489338",
"0.6464953",
"0.6449791",
"0.6419762",
"0.6410309",
"0.640817",
"0.6338045",
"0.6313819",
... | 0.5901811 | 85 |
Replaces specific variables in template file | def replaceVariables
@template = @template.gsub! "###namespace###", @namespace
@template = @template.gsub! "###model-name###", @modelName
@template = @template.gsub! "###baseApi###", (@baseApi.nil? ? "" : " : #{@baseApi}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replaceVariables\n\t\t@template = @template.gsub! \"###namespace###\", @namespace\n\t\t@template = @template.gsub! \"###model-name###\", @modelName\n\t\t@template = @template.gsub! \"###properties###\", @properties\n\tend",
"def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t ... | [
"0.8088574",
"0.7314142",
"0.71300095",
"0.6865499",
"0.68319935",
"0.6389633",
"0.63729984",
"0.63608205",
"0.62852305",
"0.626708",
"0.619774",
"0.619774",
"0.6160063",
"0.6072173",
"0.6032847",
"0.60066015",
"0.60066015",
"0.60066015",
"0.60066015",
"0.60066015",
"0.600660... | 0.7839094 | 1 |
def update end def destroy end | def listing_params
params.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update \n end",
"def update\r\n end",
"def update;end",
"def update\r\n\r\n end",
"def update \n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n ... | [
"0.75881505",
"0.75830644",
"0.7517725",
"0.7511638",
"0.75072753",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
"0.7487825",
... | 0.0 | -1 |
throws exceptions for negative responses after a refresh request | def check_refresh_response(response)
case response.code.to_i
when 200
return
when OauthWrap::WebApp::UNAUTHORIZED_STATUS_CODE
if wrap_response?(response)
raise OauthWrap::Unauthorized
else
raise OauthWrap::RequestFailed.new(response)
end
else
raise OauthWrap::RequestFailed.new(response)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_if_near_expiration; end",
"def refresh\n respond_to do |format|\n @endpoint.last_refresh_request_at = Time.now\n\n if @endpoint.save\n RefreshEndpointWorker.perform_async RefreshSubmission.new(@endpoint.id)\n\n format.html { redirect_to root_url, notice: 'Endpoint refreshin... | [
"0.62535083",
"0.622108",
"0.61134964",
"0.6105754",
"0.6089958",
"0.6089958",
"0.60889333",
"0.60833645",
"0.6027096",
"0.5919887",
"0.59133846",
"0.58858603",
"0.5877693",
"0.587032",
"0.58448976",
"0.5831839",
"0.58101875",
"0.58067256",
"0.5798165",
"0.57900995",
"0.57844... | 0.7370869 | 0 |
GET /entrants/1 GET /entrants/1.json | def show
@entrant = Entrant.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @entrant }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tenants = keystone.tenants\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tenants }\n end\n end",
"def index\n @entrants = Entrant.all\n end",
"def show\n @lent = Lent.find(params[:id])\n\n respond_to do |format|\n form... | [
"0.7002972",
"0.6761511",
"0.6711722",
"0.6618852",
"0.6567906",
"0.6487214",
"0.646711",
"0.64271617",
"0.64255106",
"0.6425264",
"0.64175916",
"0.6416643",
"0.6410826",
"0.6402416",
"0.6368883",
"0.6359172",
"0.63552094",
"0.63306653",
"0.63047826",
"0.62975407",
"0.6292192... | 0.66533583 | 3 |
GET /entrants/new GET /entrants/new.json | def new
@entrant = Entrant.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @entrant }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @entity = Entity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end",
"def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n... | [
"0.747026",
"0.7382323",
"0.7298897",
"0.725569",
"0.7240697",
"0.7235054",
"0.723259",
"0.7227676",
"0.72272253",
"0.71887165",
"0.7167621",
"0.7147151",
"0.7086993",
"0.70835274",
"0.70633477",
"0.7062462",
"0.70407486",
"0.7033796",
"0.70286965",
"0.70269793",
"0.70154655"... | 0.7304922 | 3 |
POST /entrants POST /entrants.json | def create
@entrant = Entrant.new(params[:entrant])
respond_to do |format|
if @entrant.save
Pusher['chatroom'].trigger('welcome', {
:new_member_msg => "Welcome to the chatroom!"
})
format.html { redirect_to @entrant, notice: 'Entrant was successfully created.' }
format.json { render json: @entrant, status: :created, location: @entrant }
else
format.html { render action: "new" }
format.json { render json: @entrant.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @tent = Tent.new(tent_params)\n\n respond_to do |format|\n if @tent.save\n format.html { redirect_to admin_tent_path(@tent), notice: 'Tent was successfully created.' }\n format.json { render :show, status: :created, location: @tent }\n else\n format.html { render :... | [
"0.66398567",
"0.6397998",
"0.63739306",
"0.6237274",
"0.6232115",
"0.61941034",
"0.61104864",
"0.60820115",
"0.6056505",
"0.6012292",
"0.6009554",
"0.6001154",
"0.5957061",
"0.59519655",
"0.59466887",
"0.5944537",
"0.594337",
"0.5935249",
"0.5917858",
"0.5887883",
"0.5884107... | 0.5670929 | 54 |
PUT /entrants/1 PUT /entrants/1.json | def update
@entrant = Entrant.find(params[:id])
respond_to do |format|
if @entrant.update_attributes(params[:entrant])
format.html { redirect_to @entrant, notice: 'Entrant was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @entrant.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants... | [
"0.68182236",
"0.6596296",
"0.6200425",
"0.6170685",
"0.61518323",
"0.60291386",
"0.6012163",
"0.5985583",
"0.59719235",
"0.59712976",
"0.5966346",
"0.5960542",
"0.59488153",
"0.5917326",
"0.59060395",
"0.58978283",
"0.5895179",
"0.58924913",
"0.58818495",
"0.5875656",
"0.586... | 0.61447936 | 5 |
DELETE /entrants/1 DELETE /entrants/1.json | def destroy
@entrant = Entrant.find(params[:id])
@entrant.destroy
respond_to do |format|
format.html { redirect_to entrants_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:... | [
"0.7298221",
"0.717743",
"0.7063036",
"0.69764274",
"0.69566697",
"0.68377703",
"0.6829198",
"0.6811223",
"0.6789937",
"0.6788871",
"0.6781442",
"0.67542285",
"0.6749928",
"0.6749642",
"0.6733372",
"0.67270124",
"0.67264056",
"0.67128223",
"0.67066425",
"0.6704456",
"0.669214... | 0.67872506 | 10 |
GET /level2s GET /level2s.json | def index
@level2s = Level2.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_level2\n @level2 = Level2.find(params[:id])\n end",
"def get_levels\n if params[:levels_by_nf] == 'true'\n @foundation = Foundation.find_by(name: params[:name])\n if @foundation\n render json: {levels: @foundation.levels.pluck(:name)}, status: 200\n else\n render j... | [
"0.6265029",
"0.60809934",
"0.6002785",
"0.5677105",
"0.5644152",
"0.5525872",
"0.5510575",
"0.54337996",
"0.5340523",
"0.5296375",
"0.5284204",
"0.52191705",
"0.5198943",
"0.516373",
"0.51533717",
"0.51399106",
"0.5127288",
"0.51102525",
"0.5089938",
"0.5089938",
"0.5058577"... | 0.7097432 | 0 |
GET /level2s/1 GET /level2s/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @level2s = Level2.all\n end",
"def set_level2\n @level2 = Level2.find(params[:id])\n end",
"def create\n @level2 = Level2.new(level2_params)\n\n respond_to do |format|\n if @level2.save\n format.html { redirect_to @level2, notice: 'Level2 was successfully created.' }\n... | [
"0.7216145",
"0.6761445",
"0.62426656",
"0.6135883",
"0.59773225",
"0.59625447",
"0.5938572",
"0.57487905",
"0.5575051",
"0.5572889",
"0.55478257",
"0.5523244",
"0.55229336",
"0.5441607",
"0.5398762",
"0.5393672",
"0.5345239",
"0.534006",
"0.5304932",
"0.5294798",
"0.5286955"... | 0.0 | -1 |
POST /level2s POST /level2s.json | def create
@level2 = Level2.new(level2_params)
respond_to do |format|
if @level2.save
format.html { redirect_to @level2, notice: 'Level2 was successfully created.' }
format.json { render :show, status: :created, location: @level2 }
else
format.html { render :new }
format.json { render json: @level2.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level2_params\n params.require(:level2).permit(:name, :level1_id)\n end",
"def set_level2\n @level2 = Level2.find(params[:id])\n end",
"def index\n @level2s = Level2.all\n end",
"def update\n respond_to do |format|\n if @level2.update(level2_params)\n format.html { redi... | [
"0.64647025",
"0.57380086",
"0.5635318",
"0.56023484",
"0.55169004",
"0.55073464",
"0.55073464",
"0.54760844",
"0.5425838",
"0.54206836",
"0.5359434",
"0.5345013",
"0.5284195",
"0.51821554",
"0.5150324",
"0.5133972",
"0.51234645",
"0.5092318",
"0.50731796",
"0.5070191",
"0.50... | 0.7168359 | 0 |
PATCH/PUT /level2s/1 PATCH/PUT /level2s/1.json | def update
respond_to do |format|
if @level2.update(level2_params)
format.html { redirect_to @level2, notice: 'Level2 was successfully updated.' }
format.json { render :show, status: :ok, location: @level2 }
else
format.html { render :edit }
format.json { render json: @level2.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @level = Level.find(params[:id])\n\n respond_to do |format|\n if @level.update_attributes(params[:level])\n format.html { redirect_to @level, notice: 'Level was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.61386544",
"0.6137431",
"0.61099154",
"0.6081029",
"0.60067236",
"0.5938345",
"0.5897329",
"0.5889011",
"0.5886666",
"0.584407",
"0.5840352",
"0.57014716",
"0.5669532",
"0.5641464",
"0.5640329",
"0.5638657",
"0.5629852",
"0.56296897",
"0.56280077",
"0.56264293",
"0.5623792... | 0.7041001 | 0 |
DELETE /level2s/1 DELETE /level2s/1.json | def destroy
@level2.destroy
respond_to do |format|
format.html { redirect_to level2s_url, notice: 'Level2 was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @level.destroy\n respond_to do |format|\n format.html { redirect_to levels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @level = Level.find(params[:id])\n @level.destroy\n\n respond_to do |format|\n format.html { redirect_to levels_url }\n ... | [
"0.6828369",
"0.67323095",
"0.6711666",
"0.6526392",
"0.6386106",
"0.63462335",
"0.63358235",
"0.6330126",
"0.63216144",
"0.62929434",
"0.6270872",
"0.6266355",
"0.6265937",
"0.6261469",
"0.6249689",
"0.62285924",
"0.62007093",
"0.61937",
"0.61903596",
"0.6150769",
"0.6150769... | 0.74834967 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_level2
@level2 = Level2.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.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def level2_params
params.require(:level2).permit(:name, :level1_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
rps("Paper") rps("Paper") rps("Rock") rps("Scissors") | def remix pairs
alcohols = pairs.map{ |pair| pair[0] }
mixers = pairs.map{ |pair| pair[1] }
mixed_pairs = alcohols.zip mixers.shuffle
while mixed_pairs.any? { |pair| pairs.include? pair }
mixed_pairs = alcohols.zip mixers.shuffle
end
mixed_pairs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rps(choice)\n choice = choice.capitalize\n rps = [\"Rock\", \"Paper\", \"Scissors\"]\n computer_choice = rps[rand(3)]\n return \"You: #{choice}, Computer: #{computer_choice}, Draw\" if choice == computer_choice\n return \"You: #{choice}, Computer: #{computer_choice}, Win\" if choice == \"Rock\" && compute... | [
"0.752567",
"0.73394626",
"0.7290011",
"0.6969378",
"0.69662684",
"0.69514316",
"0.68819034",
"0.68549645",
"0.68136364",
"0.6765043",
"0.67479104",
"0.67402685",
"0.67402685",
"0.67402685",
"0.67402685",
"0.67402685",
"0.67402685",
"0.67402685",
"0.67402685",
"0.67402685",
"... | 0.0 | -1 |
Implementation de la construction de la tache | def build(project_name, auto_install, proxy_option)
# On verifie la presence de rcov
Utils.verify_gem_presence("rcov", auto_install, proxy_option)
# On lance la generation
puts " Building rcov code coverage report..."
if Dir.glob("test/**/*_test.rb").length > 0
pattern = "test/**/*_test.rb"
else
pattern = "spec/**/*_spec.rb"
end
rcov_ignored_gems = []
gem_list = Utils.run_command("gem list")
gem_list.split("\n").each{|gem|rcov_ignored_gems << gem.split(' ')[0]}
rcov_command = nil
if rcov_ignored_gems.length == 0
rcov_command = "rcov --rails #{pattern}"
else
rcov_command = "rcov --rails --exclude #{rcov_ignored_gems.join(',')} #{pattern}"
end
rcov_pass = Utils.run_command(rcov_command)
if rcov_pass.index("Finished in").nil?
raise " Execution of rcov failed with command '#{rcov_command}'.\n BUILD FAILED."
end
# On recupere le rapport genere
Dir.mkdir "#{Continuous4r::WORK_DIR}/rcov"
FileUtils.mv("coverage", "#{Continuous4r::WORK_DIR}/rcov/")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct\n end",
"def constructor; end",
"def initialize() end",
"def initialize\n \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; end",
... | [
"0.6724964",
"0.6620649",
"0.65315235",
"0.6447821",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6370174",
"0.6315361",
"0.62026525",
"0.62026525",
"0.62026525",
"0.62026525",
"0.62026525... | 0.0 | -1 |
Methode qui permet d'extraire le pourcentage de qualite extrait d'un builder | def quality_percentage
require 'hpricot'
doc = Hpricot(File.read("#{Continuous4r::WORK_DIR}/rcov/coverage/index.html"))
(doc/'tt[@class^="coverage_code"]')[0].inner_text.split(/%/)[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def builder; end",
"def builder; end",
"def builder; end",
"def definition_builder; end",
"def definition_builder; end",
"def build_minimal_viable_product\n @builder.produce_part_a\n end",
"def builder_attribute?\n attribute_name && builder\n end",
"def make_builder_settings(e... | [
"0.64452",
"0.64452",
"0.64452",
"0.5960818",
"0.5960818",
"0.5942603",
"0.5875415",
"0.587481",
"0.57903016",
"0.578274",
"0.578274",
"0.56864065",
"0.56518734",
"0.5611731",
"0.56007636",
"0.5583071",
"0.54827356",
"0.54827356",
"0.54617727",
"0.5451444",
"0.5447369",
"0.... | 0.0 | -1 |
Nom de l'indicateur de qualite | def quality_indicator_name
"tests coverage"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def masculine_name; end",
"def insured_name\n if @eob_type != 'Patient'\n id, qual = @eob.member_id_and_qualifier\n ['NM1', 'IL', '1', @eob.subscriber_last_name, @eob.subscriber_first_name,\n @eob.subscriber_middle_initial, '', @eob.subscriber_suffix, qual,id].trim_segment.join(@element_seper... | [
"0.66588026",
"0.65999806",
"0.65496105",
"0.6427481",
"0.6420599",
"0.6420599",
"0.6409174",
"0.6378639",
"0.63555723",
"0.63312656",
"0.63079447",
"0.6307633",
"0.62885207",
"0.6282286",
"0.6266189",
"0.6258037",
"0.62569773",
"0.62556726",
"0.62358856",
"0.6232383",
"0.619... | 0.0 | -1 |
Convert from a time span in hour or decimal format to a float. | def time2float time_string
if time_string =~ /:/
hours, minutes = time_string.split(':')
hours.to_f + (minutes.to_f / 60.0)
else
time_string.to_f
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_to_float(input)\n return input.respond_to?(:to_time) ? input.to_time.to_f : input.to_f\n end",
"def lap_time_to_float(time)\n time = time.split( /:|\\./ )\n time[1].to_f + ( time[0].to_i * 60 ) + \"0.#{time[2]}\".to_f\n end",
"def t2f(time) \n time.strftime('%H.%M').to_f\n end",
... | [
"0.72675467",
"0.6866254",
"0.662409",
"0.63408417",
"0.6304696",
"0.6287406",
"0.62016016",
"0.5794665",
"0.57732517",
"0.57732517",
"0.57732517",
"0.5763802",
"0.5763676",
"0.5679536",
"0.5653339",
"0.55738616",
"0.55266273",
"0.5446587",
"0.544445",
"0.54151964",
"0.540957... | 0.6913892 | 1 |
Returns true if the own class is equal to the other class and if the other object contains the same condition, the same then part and the same else part. | def ==(other)
super && @condition == other.condition && @then_part == other.then_part && @else_part == other.else_part
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def look_same_as?(other)\n return nil unless other.kind_of?(self.class)\n (name == other.name) and (definition == other.definition)\n end",
"def ==(other)\n self.class == other.class\n end",
"def == other\n self.class == other.class and\n @parent == other.parent... | [
"0.6809678",
"0.66712976",
"0.665886",
"0.6646227",
"0.66147304",
"0.6569873",
"0.6565071",
"0.65454847",
"0.65346956",
"0.6517674",
"0.65072304",
"0.64920443",
"0.6488266",
"0.6476647",
"0.6427063",
"0.6424963",
"0.641292",
"0.641292",
"0.64054424",
"0.6405009",
"0.6398745",... | 0.74562305 | 0 |
Returns a pretty print string of the conditional. | def to_s
"if " + @condition.to_s + " then\n" + indent(@then_part.to_s) + (else_part.skip? ? "" : ("\nelse\n" + indent(@else_part.to_s))) + "\nend"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n indent = Indentation.get\n str = \"#{indent}if (#{@condition}) {\\n\"\n Indentation.indent { str << \"#{@if_block}\\n\" }\n str << \"#{indent}}\\n\"\n str << \"#{@elsifs}\\n\" unless @elsifs.empty?\n unless @else_block.empty?\n Indentation.indent do\n str <<... | [
"0.72872114",
"0.6810567",
"0.66294044",
"0.64838606",
"0.63308424",
"0.6284218",
"0.6207747",
"0.6136998",
"0.59287655",
"0.5928064",
"0.590061",
"0.5864185",
"0.5728805",
"0.57274556",
"0.5724362",
"0.567904",
"0.5658959",
"0.56576943",
"0.56169605",
"0.55759054",
"0.553884... | 0.7985569 | 0 |
Executes the conditional in a given context. | def interpret(context)
if @condition.interpret(context) then
@then_part.interpret(context)
else
@else_part.interpret(context)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_conditional(context, if_or_unless)\n if if_or_unless.is_a?(Proc)\n context.instance_exec(&if_or_unless)\n else\n context.method(if_or_unless).call\n end\n end",
"def call(binding_, *context)\n return unless if_condition.call(binding_, *context)\n return if u... | [
"0.7826399",
"0.67348766",
"0.66912615",
"0.66912615",
"0.64310396",
"0.63620925",
"0.62675804",
"0.622805",
"0.6219693",
"0.61581326",
"0.61181015",
"0.61181015",
"0.60865724",
"0.60708475",
"0.60634124",
"0.6059252",
"0.60578185",
"0.6010971",
"0.5997432",
"0.5937129",
"0.5... | 0.7430599 | 1 |
Compiles the conditional to C code. | def compile_to_c
"if (" + @condition.compile_to_c + ") {\n" +
indent_c(@then_part.compile_to_c) +
"\n} else {\n" +
indent_c(@else_part.compile_to_c) +
"\n}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_to_ruby\n \"if \" + indent_c(@condition.compile_to_ruby) + \"\\n\" +\n indent_ruby(@then_part.compile_to_ruby) +\n \"\\nelse\\n\" +\n indent_c(@else_part.compile_to_ruby) +\n \"\\nend\"\n end",
"def compileif\n\n end",
"def compile_if(scope, cond, if_arm, else_a... | [
"0.7555976",
"0.728607",
"0.6805954",
"0.67053425",
"0.6656353",
"0.660647",
"0.660647",
"0.63877314",
"0.63456035",
"0.63244176",
"0.6260958",
"0.6260573",
"0.62496245",
"0.62474096",
"0.61761266",
"0.6147983",
"0.6128498",
"0.612275",
"0.61050475",
"0.61041117",
"0.6076521"... | 0.8435859 | 0 |
Compiles the conditional to Ruby code. | def compile_to_ruby
"if " + indent_c(@condition.compile_to_ruby) + "\n" +
indent_ruby(@then_part.compile_to_ruby) +
"\nelse\n" +
indent_c(@else_part.compile_to_ruby) +
"\nend"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_to_c\n \"if (\" + @condition.compile_to_c + \") {\\n\" +\n indent_c(@then_part.compile_to_c) +\n \"\\n} else {\\n\" +\n indent_c(@else_part.compile_to_c) +\n \"\\n}\"\n end",
"def compileif\n\n end",
"def codegen_conditional_functions\n code = []\n ... | [
"0.835174",
"0.708532",
"0.6990865",
"0.6899235",
"0.6870006",
"0.68548995",
"0.6725953",
"0.6714175",
"0.67072785",
"0.6662125",
"0.6662125",
"0.6633201",
"0.6599799",
"0.6545617",
"0.64916766",
"0.6465039",
"0.64499617",
"0.6322219",
"0.62907535",
"0.62644756",
"0.62335366"... | 0.869628 | 0 |
Collects the names of all variables in the conditional, the then part and the else_part. | def collect_variables
(@condition.collect_variables + @then_part.collect_variables +
@else_part.collect_variables).uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def var_names\n @var_names ||= eval \"local_variables\", get_binding\n end",
"def variables()\n all_vars = children.each_with_object([]) do |a_child, subResult|\n case a_child\n when Placeholder\n subResult << a_child.name\n when Section\n subResult.concat(a_child.... | [
"0.5856736",
"0.5514253",
"0.546313",
"0.54315567",
"0.53886485",
"0.5286206",
"0.5284878",
"0.52780485",
"0.5274396",
"0.52525765",
"0.52424365",
"0.5238392",
"0.5231829",
"0.5229918",
"0.51611716",
"0.5139717",
"0.51325643",
"0.5131325",
"0.50148517",
"0.50148517",
"0.49903... | 0.7352648 | 0 |
Find the user that owns the access token | def current_resource_owner
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticated_user_with_token\n ApiKey.find_user_with_token(decoded_token)\n end",
"def current_user_ws\n return User.find_by_authentication_token(params[:access_token])\n end",
"def current_user\r\n api_key = ApiKey.active.where(access_token: token).first\r\n if api_key\r\n retu... | [
"0.71800554",
"0.717608",
"0.70570946",
"0.7043153",
"0.6980842",
"0.69353694",
"0.6866426",
"0.68589824",
"0.6851308",
"0.6822145",
"0.6817038",
"0.6806014",
"0.6794738",
"0.67199945",
"0.66894114",
"0.66769886",
"0.66769886",
"0.66769886",
"0.66769886",
"0.66709507",
"0.664... | 0.6700082 | 14 |
MySQL wants a string as the lock key. | def quoted_lock_str
connection.quote(lock_str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redis_lock_key(*args)\n ['lock', self.class.name, identifier(*args)].compact.join(':')\n end",
"def lock_type\n @lock_type ||= :mysql\n end",
"def lock_key(*arguments)\n nil\n end",
"def lock_id\n Integer('0x' + Digest::MD5.hexdigest(name)) % (1 << 63)\n end",
"def lock_... | [
"0.7498956",
"0.6607128",
"0.6588161",
"0.6377665",
"0.62444276",
"0.6189412",
"0.6147662",
"0.61024725",
"0.6095563",
"0.6049504",
"0.6049504",
"0.6038756",
"0.6030655",
"0.59872067",
"0.59777445",
"0.5970899",
"0.5942479",
"0.5914022",
"0.5887232",
"0.5883355",
"0.5883355",... | 0.6920036 | 1 |
before_filter :assign_user, only: [ :new ] | def index
@chats = Chat.all.order("created_at DESC")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_user\n \n end",
"def set_new_user\n @new_user = NewUser.find(params[:id])\n end",
"def new\n @permitted_user = PermittedUser.new\n end",
"def new_user\n \trender action: 'new_user'\n end",
"def newUser\n end",
"def new?\n @user\n end",
"def new\n # empty check\n ... | [
"0.711421",
"0.70973486",
"0.7030273",
"0.69341666",
"0.6933356",
"0.6926989",
"0.68960184",
"0.6895395",
"0.688412",
"0.6864545",
"0.6835878",
"0.68152016",
"0.6759932",
"0.67572236",
"0.67247885",
"0.670651",
"0.6702436",
"0.6688243",
"0.66841763",
"0.667388",
"0.6658433",
... | 0.0 | -1 |
I worked on this challenge with: Jack. =begin Use loop that will go through each number going down to 1 ... number.times. Set a counter variable equal to zero. product = product (Initial number counter) =end Your Solution Below | def factorial(number)
# Your code goes here
product = number
if number == 0
product = 1
end
while number > 1
product = product * (number - 1)
number = number - 1
end
product
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factorial(number) \n if number == 0\n return 1\n end\n \n product = 1\n \n for number in (1..number)\n product = product * number\n \t\n end\n \n return product\n end",
"def fn(num)\n array = []\n product = 1\n until num == 0\n array << num\n\tnum -= 1\n end\n array.each do |num|\n\tpr... | [
"0.76661885",
"0.76533616",
"0.7533804",
"0.75309646",
"0.7477704",
"0.74575883",
"0.74413466",
"0.7406331",
"0.7379314",
"0.73649585",
"0.7309933",
"0.73076993",
"0.72813016",
"0.72768295",
"0.72627527",
"0.7262259",
"0.72622555",
"0.72602147",
"0.72590256",
"0.7246021",
"0.... | 0.733598 | 10 |
Returns the location of the local copy cache, if the strategy should use a local cache + copy instead of a new checkout/export every time. Returns +nil+ unless :copy_cache has been set. If :copy_cache is +true+, a default cache location will be returned. | def copy_cache
@copy_cache ||= configuration[:copy_cache] == true ?
File.join(Dir.tmpdir, configuration[:application]) :
configuration[:copy_cache]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cached_location\n dlt = (download_type) ? download_type : 'default'\n Drupid.cache_path + self.class.to_s.split(/::/).last + extended_name + dlt + name\n end",
"def copy_strategy\n @copy_strategy ||= configuration.fetch(:copy_strategy, :checkout)\n end",
"def copy_strategy\... | [
"0.58885175",
"0.58252484",
"0.5825052",
"0.5693597",
"0.5644441",
"0.5624791",
"0.5486106",
"0.5418643",
"0.5416309",
"0.5396287",
"0.5393869",
"0.5300897",
"0.5289763",
"0.5266506",
"0.5253991",
"0.5219664",
"0.515956",
"0.5158906",
"0.5141751",
"0.5141751",
"0.5137827",
... | 0.6629044 | 0 |
def remove_dir(dir, excludes) Find.find(dir) do |path| if dir.eql?path next else if File.directory?path if excludes.include?path Find.prune else logger.debug(path) FileUtils.rm_rf(path) Find.prune end else logger.debug(path) FileUtils.rm_rf(path) Find.prune end end end end | def build_target_path
File.join(destination, configuration[:build_target_path])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rm_r(dir)\n Dir.entries(dir).each do |entrada|\n if (File.directory?(\"#{dir}/#{entrada}\") and (entrada != \".\" and entrada != \"..\") )\n rm_r(\"#{dir}/#{entrada}\")\n Dir.delete(\"#{dir}/#{entrada}\")\n else\n File.delete(\"#{dir}/#{entrada}\") if (entrada != \".\" and entrada != \"..... | [
"0.75156385",
"0.7506152",
"0.718266",
"0.7151676",
"0.70957947",
"0.7067031",
"0.69733727",
"0.6861599",
"0.6847634",
"0.6697601",
"0.6615825",
"0.66151613",
"0.66142416",
"0.6561384",
"0.65607715",
"0.65486246",
"0.65345657",
"0.64747477",
"0.6461324",
"0.64092314",
"0.6372... | 0.0 | -1 |
Specify patterns to exclude from the copy. This is only valid when using a local cache. | def copy_exclude
@copy_exclude ||= Array(configuration.fetch(:copy_exclude, []))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exclude(pattern)\n excludes << pattern\n end",
"def exclude(pattern)\n excludes << pattern\n end",
"def exclude(pattern)\n exclusions << pattern\n exclusions.dup\n end",
"def exclude(pattern)\n exclusions << pattern\n exclusions.dup\n end",
"def exclude(*pa... | [
"0.76474077",
"0.76438755",
"0.7582189",
"0.7582189",
"0.7481426",
"0.7399069",
"0.7279217",
"0.7068264",
"0.70643586",
"0.6956012",
"0.69228995",
"0.6815718",
"0.6813149",
"0.68043876",
"0.6803636",
"0.67794394",
"0.677723",
"0.6743827",
"0.6726387",
"0.66034335",
"0.650228"... | 0.728991 | 6 |
Returns the basename of the release_path, which will be used to name the local copy and archive file. | def destination
#configuration[:release_path]
@destination ||= File.join(tmpdir, File.basename(configuration[:release_path]))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def basename\n File.basename(path)\n end",
"def basename\n File.basename(@path, '.*')\n end",
"def basename\n @basename ||= File.basename(path)\n end",
"def basename\n File.basename( fullpath, ext )\n end",
"def basename( path )\r\n File.basename( path )\r\n ... | [
"0.75596374",
"0.75040686",
"0.7500764",
"0.73535275",
"0.72361225",
"0.7174899",
"0.71568906",
"0.7146268",
"0.7127468",
"0.7069236",
"0.70661056",
"0.70661056",
"0.70661056",
"0.70513296",
"0.7028749",
"0.7011097",
"0.6997063",
"0.6992538",
"0.6983787",
"0.6980069",
"0.6965... | 0.0 | -1 |
Returns the value of the :copy_strategy variable, defaulting to :checkout if it has not been set. | def copy_strategy
@copy_strategy ||= configuration.fetch(:copy_strategy, :checkout)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def command\n logger.debug(\"#{copy_strategy}\")\n @command ||= case copy_strategy\n when :checkout\n source.checkout(revision, destination)\n when :export\n source.export(revision, destination)\n end\n end",
"def command\n... | [
"0.670518",
"0.65516925",
"0.5925143",
"0.5614146",
"0.52500516",
"0.51216036",
"0.5082016",
"0.5005396",
"0.49482286",
"0.48891735",
"0.48598874",
"0.48598164",
"0.4852102",
"0.48513877",
"0.4837682",
"0.48231483",
"0.47942728",
"0.47694364",
"0.47641146",
"0.475574",
"0.470... | 0.88226765 | 0 |
Should return the command(s) necessary to obtain the source code locally. | def command
logger.debug("#{copy_strategy}")
@command ||= case copy_strategy
when :checkout
source.checkout(revision, destination)
when :export
source.export(revision, destination)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commands\n @commands ||= source.checkout(revision, configuration[:deploy_release])\n end",
"def source_files; end",
"def get_source\n raise 'check this!'\n # _reflector = new ReflectionClass($this);\n # $file = _reflector.filename;\n # if (!file_exists($file)) ... | [
"0.65104884",
"0.6423224",
"0.6319297",
"0.6316915",
"0.6313672",
"0.6215248",
"0.6148721",
"0.60539186",
"0.6025394",
"0.5995973",
"0.5966581",
"0.5966581",
"0.59422445",
"0.59422445",
"0.59422445",
"0.59422445",
"0.5935302",
"0.5879834",
"0.5869902",
"0.58444655",
"0.583535... | 0.0 | -1 |
Returns the name of the file that the source code will be compressed to. | def filename
@filename ||= File.join(tmpdir, "#{File.basename(destination)}.#{compression_extension}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_filename(script)\n (Zlib::Inflate.inflate(script[2]) != '' ? \"#{fix_name(script[1])}.rb\" : 'EMPTY')\nend",
"def filename\n @filename ||= File.join(tmpdir, \"#{File.basename(destination)}.#{compression.extension}\")\n end",
"def archive_file_name\n raise \"Not implemente... | [
"0.720456",
"0.7134051",
"0.7094275",
"0.66779584",
"0.66396004",
"0.6561407",
"0.6546313",
"0.6525534",
"0.65116245",
"0.6477118",
"0.6460425",
"0.6460425",
"0.6445424",
"0.6423296",
"0.6412045",
"0.63954306",
"0.6389002",
"0.6388837",
"0.6380847",
"0.6346271",
"0.63332826",... | 0.7166173 | 1 |
The directory to which the copy should be checked out | def tmpdir
@tmpdir ||= configuration[:copy_dir] || Dir.tmpdir
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_clone_directory()\n\n if @to\n folder_exists = File.directory?( @to )\n FileUtils.mkdir_p( @to ) unless folder_exists\n return @to\n end\n\n if @verse.has_key?( Indices::GIT_CLONE_BASE_PATH )\n folder_exists = File.directory?( @verse[ Indices::GIT_CLONE_BASE_PATH ... | [
"0.72450954",
"0.7082457",
"0.68894595",
"0.68397737",
"0.67253846",
"0.67096287",
"0.66936755",
"0.6686203",
"0.6683455",
"0.66818917",
"0.66516143",
"0.6622161",
"0.6622161",
"0.66079134",
"0.6602673",
"0.6602548",
"0.6577989",
"0.6557617",
"0.65484196",
"0.6547805",
"0.649... | 0.0 | -1 |
The directory on the remote server to which the archive should be copied | def remote_dir
@remote_dir ||= configuration[:copy_remote_dir] || "/tmp"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_path_to_remote_dir\n (remote_dir[0] == ?/ ? remote_dir : \"$(pwd)/#{remote_dir}\").chomp('/')\n end",
"def get_remote_dir\n return @resource[:remote_dir]\n end",
"def tar_directory #:nodoc:\n rp = Pathname.new(remote_directory)\n rp.dirname.to_s\n end",
"def remote_bac... | [
"0.75828135",
"0.7579635",
"0.7502372",
"0.74358314",
"0.7282003",
"0.72414196",
"0.71930015",
"0.6912278",
"0.6836271",
"0.6806961",
"0.6773808",
"0.6636376",
"0.66150945",
"0.6613089",
"0.6608715",
"0.65970933",
"0.6585402",
"0.6578669",
"0.6446069",
"0.640418",
"0.6403554"... | 0.829721 | 1 |
The location on the remote server where the file should be temporarily stored. | def remote_filename
@remote_filename ||= File.join(remote_dir, File.basename(filename))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remote_tmp_path\n '/tmp'\n end",
"def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end",
"def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end",
"def download_location\n self.remote_location... | [
"0.76054543",
"0.71793115",
"0.7179138",
"0.7085174",
"0.7012074",
"0.6967381",
"0.6730941",
"0.66946197",
"0.6661659",
"0.6639473",
"0.6534031",
"0.6531253",
"0.6518388",
"0.6465627",
"0.6404473",
"0.6388255",
"0.63818514",
"0.6381377",
"0.63804924",
"0.6367608",
"0.6358335"... | 0.6581957 | 11 |
The compression method to use, defaults to :gzip. | def compression
configuration[:copy_compression] || :gzip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compression_method; end",
"def default_compression; end",
"def compression\n instance.options[:compression]\n end",
"def compression\n instance.options[:compression]\n end",
"def compression\n unless defined?(@compression)\n @compression = :bzip2\n reset_computed_va... | [
"0.8291712",
"0.8142131",
"0.8061136",
"0.8061136",
"0.7900254",
"0.77657944",
"0.7696077",
"0.7650976",
"0.7555027",
"0.7533599",
"0.7533599",
"0.7470146",
"0.74171627",
"0.7359441",
"0.735098",
"0.71692514",
"0.71501756",
"0.7149595",
"0.71231985",
"0.7053468",
"0.7023913",... | 0.8238282 | 1 |
Returns the file extension used for the compression method in question. | def compression_extension
case compression
when :gzip, :gz then "tar.gz"
when :bzip2, :bz2 then "tar.bz2"
when :zip then "zip"
else raise ArgumentError, "invalid compression type #{compression.inspect}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_extension\n FILE_EXTENSION\n end",
"def file_extension\n filename.split(\".\").last\n end",
"def file_extension\n self.class.file_extension\n end",
"def extension\n split_extension(filename)[1] if filename\n end",
"def file_extension\n self::FIL... | [
"0.80557215",
"0.80176324",
"0.7985735",
"0.79395354",
"0.791444",
"0.786451",
"0.78269476",
"0.78009236",
"0.7788866",
"0.7788866",
"0.7788866",
"0.7777666",
"0.76466846",
"0.7635763",
"0.7621672",
"0.7606027",
"0.75549245",
"0.7528434",
"0.751233",
"0.7493818",
"0.74742216"... | 0.79457366 | 3 |
Returns the command necessary to compress the given directory into the given file. The command is returned as an array, where the first element is the utility to be used to perform the compression. | def compress(directory, file)
case compression
when :gzip, :gz then ["tar", "czf", file, directory]
when :bzip2, :bz2 then ["tar", "cjf", file, directory]
when :zip then ["zip", "-qr", file, directory]
else raise ArgumentError, "invalid compression type #{compression.inspect}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compress(directory, file)\n compression.compress_command + [file, directory]\n end",
"def compress_directory dir\n if File.directory? dir\n puts \"# - Compressing directory: #{dir}\"\n dir_compressed_name = dir.sub(\".\",'').sub(\"/\",'').gsub(\"/\", '_')[0..-2]\n system(\"tar\"... | [
"0.67195225",
"0.6354455",
"0.5692953",
"0.55897874",
"0.5522513",
"0.54472375",
"0.5399682",
"0.5360636",
"0.5344867",
"0.5337145",
"0.52717507",
"0.52685636",
"0.5229555",
"0.5201102",
"0.5185721",
"0.5118542",
"0.51078176",
"0.5092815",
"0.50768125",
"0.503376",
"0.5016028... | 0.6680714 | 1 |
Returns the command necessary to decompress the given file, relative to the current working directory. It must also preserve the directory structure in the file. The command is returned as an array, where the first element is the utility to be used to perform the decompression. | def decompress(file)
case compression
when :gzip, :gz then ["tar", "xzf", file]
when :bzip2, :bz2 then ["tar", "xjf", file]
when :zip then ["unzip", "-q", file]
else raise ArgumentError, "invalid compression type #{compression.inspect}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decompress(file)\n compression.decompress_command + [file]\n end",
"def unzip_gnu(file)\r\n puts `unzip -o #{file}`\r\nend",
"def absolute_command(cmd, path: nil)\n was_array = cmd.is_a?(Array)\n cmd = if was_array\n cmd.dup\n else\n Shellwords.split(cmd)\n... | [
"0.6376652",
"0.54872245",
"0.5267973",
"0.5244182",
"0.5117621",
"0.5051877",
"0.50313604",
"0.50189584",
"0.5010522",
"0.4984258",
"0.49649933",
"0.49600044",
"0.49502954",
"0.4945601",
"0.49406534",
"0.49281293",
"0.49166155",
"0.491116",
"0.49095017",
"0.488604",
"0.48779... | 0.6332522 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.