query stringlengths 7 6.41k | document stringlengths 12 28.8k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 5 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Delete a movie and redirect to the movies page. | def destroy
@movie = Movie.find params[:id]
@movie.destroy
flash[:notice] = "Deleted '#{@movie.title}'."
redirect_to movies_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n redirect_to root_path\n end",
"def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :ok }\n end\n end",
"def d... | [
"0.8053855",
"0.8044876",
"0.801782",
"0.8010855",
"0.8010855",
"0.8010855",
"0.8010855",
"0.8010855",
"0.8010855",
"0.8010855",
"0.79602176",
"0.79566145",
"0.79566145",
"0.79566145",
"0.7895408",
"0.7895408",
"0.7895408",
"0.7895408",
"0.77677155",
"0.77301943",
"0.76772344... | 0.8188732 | 1 |
Check if SSH connection is closed +connection+:: SSH connection to check | def closed?(connection)
return true if connection.closed?
begin
# Hack to check connection isn't dead
connection.exec!('true') unless connection.busy?
rescue Net::SSH::Exception, SystemCallError => e
return true
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close\n Timeout.timeout(3) { @connector.close }\n true\n rescue\n warn \"ssh connection could not be closed gracefully\"\n Metriks.meter('worker.vm.ssh.could_not_close').mark\n false\n ensure\n buffer.stop\n @buffer = nil\n end... | [
"0.72463757",
"0.71900713",
"0.7141059",
"0.70817316",
"0.70251876",
"0.7020031",
"0.66902846",
"0.6634494",
"0.6586284",
"0.6509211",
"0.6489014",
"0.6468289",
"0.64608103",
"0.63966924",
"0.63942343",
"0.6351752",
"0.6337756",
"0.63358283",
"0.631936",
"0.62726146",
"0.6252... | 0.83323675 | 0 |
Check if SSH connection is busy +connection+:: SSH connection to check | def busy?(connection)
connection.busy?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connected?\n start_ssh {|ssh| } # do nothing\n rescue *CONNECTION_EXCEPTIONS => ex\n @connection_error = ex\n return false\n else\n return true\n end",
"def closed?(connection)\n return true if connection.closed?\n begin \n # Hack to check connection isn't dead\n connec... | [
"0.7125103",
"0.7113677",
"0.6865184",
"0.67932945",
"0.67154586",
"0.66424054",
"0.66414",
"0.6624428",
"0.6595834",
"0.658586",
"0.65762615",
"0.65313566",
"0.6405135",
"0.63832116",
"0.6379563",
"0.6370428",
"0.6370428",
"0.63554823",
"0.63304424",
"0.63084054",
"0.6288727... | 0.7712347 | 0 |
Get new SSH connection | def get_new
logger.debug "Establishing connection for #{creep.user}@#{creep.host} passwd:#{creep.password}"
ssh = Net::SSH.start(creep.host, creep.user, {:password => creep.password, :verbose => (ENV['SSH_DEBUG'] && ENV['SSH_DEBUG'].to_sym) || :fatal })
ssh.send_global_request("keepalive@openssh.com"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssh_connection\n @ssh_connection ||= Net::SSH.start(@host, config[:user], config[:ssh_options] || {})\n end",
"def connection\n #N Without this check, we would get a new connection even though we already have a new one\n if @connection == nil\n #N Without this, we don't get feedb... | [
"0.7704465",
"0.753015",
"0.7499289",
"0.7486356",
"0.7360706",
"0.7253392",
"0.7141851",
"0.7062906",
"0.7006936",
"0.68804973",
"0.68083835",
"0.6803162",
"0.668882",
"0.6650494",
"0.66315615",
"0.66134554",
"0.65821123",
"0.6515367",
"0.6503821",
"0.64943033",
"0.64000446"... | 0.7589419 | 1 |
Kill SSH connection +connection+:: SSH connection | def kill_connection(connection)
connection.shutdown!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disconnect!\n @logger.info(\"Terminating SSH connection to server name=#{@name}\")\n @ssh.close\n @ssh = nil\n end",
"def disconnect_ssh_tunnel\n @logger.debug('closing SSH tunnel..')\n\n @ssh.shutdown! unless @ssh.nil?\n @ssh = nil\n end",
"def disconnect\n @ssh.close if @ssh\n ... | [
"0.78902334",
"0.74020976",
"0.7323594",
"0.7260872",
"0.6967944",
"0.68434197",
"0.68269557",
"0.67401654",
"0.6717816",
"0.66854787",
"0.65052295",
"0.6493948",
"0.6479168",
"0.64440835",
"0.64433104",
"0.64343905",
"0.6426265",
"0.6341712",
"0.63246053",
"0.6255591",
"0.62... | 0.74455947 | 1 |
Return name of the key in the response body hash where fetched resources are, like bookings or rentals | def resources_key
decoded_body.keys.delete_if { |key|
SPECIAL_JSONAPI_FIELDS.include?(key)
}.pop
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_names\n JSON.parse(@body).fetch('Resources', {}).keys\n end",
"def response_key\n self.class.response_key\n end",
"def name\n response[\"name\"]\n end",
"def key_name\n data[:key_name]\n end",
"def entity_key\n resource_name.underscore.to_sym\n end",... | [
"0.6497969",
"0.6203025",
"0.5927049",
"0.58522993",
"0.5756338",
"0.573681",
"0.5632388",
"0.5599015",
"0.55635786",
"0.5557683",
"0.553708",
"0.5508156",
"0.5482203",
"0.5472907",
"0.54635125",
"0.5448371",
"0.5434228",
"0.5426645",
"0.54165304",
"0.5405529",
"0.54032314",
... | 0.6574003 | 0 |
Return an array of Resources from the response body | def resources
@resources ||= process_data(decoded_body[resources_key])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resources\n @resources ||= @response[@resource_field].to_a\n end",
"def resources\n body && [*body]\n end",
"def elements\n begin\n if %w(tags posts).include?(@resource.to_s)\n return parsed_response[@resource.to_s][singular_r_name] || []\n el... | [
"0.7762595",
"0.73285437",
"0.69553196",
"0.6887481",
"0.6771974",
"0.66755265",
"0.661304",
"0.661304",
"0.661304",
"0.642064",
"0.6392817",
"0.6371199",
"0.634188",
"0.6317118",
"0.6308756",
"0.62940305",
"0.6287624",
"0.62645566",
"0.6253435",
"0.625116",
"0.6240897",
"0... | 0.73566824 | 1 |
Returns a Hash of meta information taken from the response body | def meta
@meta ||= decoded_body[:meta]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meta\n json_body.fetch('meta', {})\n end",
"def metadata\n {\n line: \"#{method.upcase} #{uri}\",\n headers: headers,\n body: body,\n }.compact\n end",
"def meta\n @meta ||= begin\n arr = @header_str.split(/\\r?\\n/)\n arr.shift\n ... | [
"0.8209115",
"0.703759",
"0.6809584",
"0.6728309",
"0.6629828",
"0.6614577",
"0.6594861",
"0.6567625",
"0.6565107",
"0.6482766",
"0.64749366",
"0.64748484",
"0.6464112",
"0.64502573",
"0.6447846",
"0.64390594",
"0.6412634",
"0.6396967",
"0.6360413",
"0.63546664",
"0.63276446"... | 0.7857405 | 1 |
PROBLEM: Given a string, write a method change_me which returns the same string but with all the words in it that are palindromes uppercased. input: string output: string (not the same object) rules: Explicit requirements: every palindrome in the string must be converted to uppercase. (Reminder: a palindrome is a word ... | def change_me(string)
result = []
words = string.split
iterator = 0
loop do
break if iterator == words.size
word = words[iterator]
if word.reverse == word
result << word.upcase
else
result << word
end
iterator += 1
end
result.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rearranger(str)\nstr = str.split(' ')\nfinal = str.reverse.join(' ')\nfinal = final.downcase\nend",
"def weirdcase(string)\n #gets array of strings, creates empty results array\n arr = string.split (' ')\n result = []\n\n #iterates over array of strings..\n arr.each do |i|\n #..breaking apart each st... | [
"0.71505433",
"0.7049792",
"0.6892113",
"0.68268406",
"0.6826752",
"0.68225676",
"0.6807951",
"0.6806652",
"0.6799156",
"0.67507946",
"0.67364055",
"0.6729693",
"0.6688976",
"0.66532886",
"0.66393644",
"0.6638953",
"0.66371673",
"0.66154104",
"0.6612245",
"0.6607148",
"0.6605... | 0.7823821 | 0 |
PUT /telefons/1 PUT /telefons/1.xml | def update
@telefon = Telefon.find(params[:id])
@telefon.update_attributes(params[:telefon])
respond_with(@telefon)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @tipo_telefone = TipoTelefone.find(params[:id])\n\n respond_to do |format|\n if @tipo_telefone.update_attributes(params[:tipo_telefone])\n flash[:notice] = 'TipoTelefone was successfully updated.'\n format.html { redirect_to(@tipo_telefone) }\n format.xml { head :ok }\... | [
"0.66841274",
"0.65371025",
"0.6384179",
"0.6306385",
"0.6227374",
"0.6210042",
"0.61810344",
"0.58926636",
"0.5862392",
"0.5760047",
"0.56905603",
"0.5678629",
"0.5643345",
"0.5629788",
"0.5595618",
"0.558561",
"0.55845004",
"0.5583074",
"0.5550877",
"0.5541985",
"0.55403036... | 0.6554062 | 1 |
GET /client_profiles GET /client_profiles.json | def index
@client_profiles = ClientProfile.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @client_profiles = ClientProfile.all\n\n authorize ClientProfile\n end",
"def profiles \n personid = params[:id]\n @response = JSON.parse(current_user.access_token.token.get('/api/v0/aspects/profiles?ids=['+params[:id]+']'))\n respond_to do |format|\n format.html\n ... | [
"0.7066529",
"0.7010263",
"0.6964071",
"0.6911514",
"0.6817861",
"0.6725345",
"0.6717022",
"0.6716054",
"0.6711716",
"0.6673309",
"0.66695815",
"0.6627569",
"0.6627569",
"0.6571033",
"0.6540882",
"0.6501271",
"0.6496163",
"0.6483836",
"0.6454368",
"0.64317626",
"0.6431076",
... | 0.7600032 | 0 |
POST /client_profiles POST /client_profiles.json | def create
@client_profile = ClientProfile.new(client_profile_params)
respond_to do |format|
if @client_profile.save
format.json { render :show, status: :created, location: @client_profile }
else
format.json { render json: @client_profile.errors, status: :unprocessable_e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @client_profile = current_client.build_client_profile(client_profile_params)\n\n authorize @client_profile\n\n respond_to do |format|\n if @client_profile.save\n format.html { redirect_to @client_profile, notice: 'Client profile was successfully created.' }\n format.json { ... | [
"0.7382159",
"0.6989375",
"0.6530571",
"0.63997746",
"0.6383759",
"0.6372186",
"0.63159794",
"0.6270599",
"0.622642",
"0.620696",
"0.6149313",
"0.60813195",
"0.6047061",
"0.6032439",
"0.6006447",
"0.6002127",
"0.59745467",
"0.5973002",
"0.596753",
"0.5955531",
"0.59200394",
... | 0.75950766 | 0 |
PATCH/PUT /client_profiles/1 PATCH/PUT /client_profiles/1.json | def update
respond_to do |format|
if @client_profile.update(client_profile_params)
format.json { render :show, status: :ok, location: @client_profile }
else
format.json { render json: @client_profile.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n authorize @client_profile\n respond_to do |format|\n if @client_profile.update(client_profile_params)\n format.html { redirect_to @client_profile, notice: 'Client profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @client_profile }\n ... | [
"0.72260207",
"0.6723318",
"0.657502",
"0.64624083",
"0.64601666",
"0.64480466",
"0.64459664",
"0.63586",
"0.6346588",
"0.6324564",
"0.6291774",
"0.62917554",
"0.6271877",
"0.6262125",
"0.6254571",
"0.6247829",
"0.6238143",
"0.62135655",
"0.6201705",
"0.6189819",
"0.6189684",... | 0.739365 | 0 |
DELETE /client_profiles/1 DELETE /client_profiles/1.json | def destroy
@client_profile.destroy
respond_to do |format|
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n authorize @client_profile\n \n @client_profile.destroy\n respond_to do |format|\n format.html { redirect_to client_profiles_url, notice: 'Client profile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @profile.destroy\n ... | [
"0.7570437",
"0.6955545",
"0.6902419",
"0.68988854",
"0.6881676",
"0.6881446",
"0.6881446",
"0.68612945",
"0.68560594",
"0.68560594",
"0.68560594",
"0.68541515",
"0.6840027",
"0.6840027",
"0.68260026",
"0.68188083",
"0.68188083",
"0.68188083",
"0.68188083",
"0.68188083",
"0.6... | 0.7805865 | 0 |
Given a DDI metadata file, parse it and return study information Returns a Nesstar::Study object | def parse ddi_file
@logger.info 'Parsing DDI file ' + ddi_file
catalog = DDI::Catalog.new
study = DDI::Study.new
study_info_hash = Hash.new
#TODO This will not work on windows since it depends on the unix tool file need to use a different way. Possibly use rchardet instead
begin
en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_ddi_metadata\n dataset = Dataset.find(dataset_id)\n ddi_parser = DDI::Parser.new\n all_variables = Variable.all(:conditions=> {:dataset_id => dataset_id})\n all_variable_ids = all_variables.collect{|var| var.id}\n parsed_variable_ids = []\n new_variables = []\n study = d... | [
"0.6062818",
"0.5943793",
"0.53857136",
"0.5285459",
"0.52500516",
"0.5240419",
"0.5210561",
"0.5209262",
"0.5196281",
"0.5161175",
"0.5157264",
"0.51322967",
"0.51322967",
"0.51322967",
"0.51322967",
"0.51322967",
"0.51322967",
"0.51322967",
"0.50869656",
"0.50776047",
"0.50... | 0.73066497 | 0 |
GET /theloaisaches or /theloaisaches.json | def index
@theloaisaches = Theloaisach.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end",
"def index\n @teaches = Teach.all\n\t\trespond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@tea... | [
"0.6470635",
"0.6407504",
"0.6238453",
"0.613327",
"0.60264987",
"0.59744483",
"0.589963",
"0.5894425",
"0.5887093",
"0.5886826",
"0.5879474",
"0.58148515",
"0.5810373",
"0.57945275",
"0.5775904",
"0.5772876",
"0.57721025",
"0.57721025",
"0.574822",
"0.5747134",
"0.5746791",
... | 0.649614 | 0 |
POST /theloaisaches or /theloaisaches.json | def create
@theloaisach = Theloaisach.new(theloaisach_params)
respond_to do |format|
if @theloaisach.save
format.html { redirect_to @theloaisach, notice: "Theloaisach was successfully created." }
format.json { render :show, status: :created, location: @theloaisach }
else
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @the_loai_sach = TheLoaiSach.new(the_loai_sach_params)\n\n respond_to do |format|\n if @the_loai_sach.save\n format.html { redirect_to @the_loai_sach, notice: \"The loai sach was successfully created.\" }\n format.json { render :show, status: :created, location: @the_loai_sach... | [
"0.62331986",
"0.608334",
"0.6050477",
"0.60193133",
"0.5928199",
"0.59031975",
"0.58509755",
"0.58329386",
"0.58242935",
"0.580276",
"0.57687545",
"0.5760426",
"0.57530797",
"0.5752694",
"0.5751293",
"0.5714319",
"0.57073456",
"0.56998605",
"0.5693231",
"0.56797504",
"0.5661... | 0.6510152 | 0 |
PATCH/PUT /theloaisaches/1 or /theloaisaches/1.json | def update
respond_to do |format|
if @theloaisach.update(theloaisach_params)
format.html { redirect_to @theloaisach, notice: "Theloaisach was successfully updated." }
format.json { render :show, status: :ok, location: @theloaisach }
else
format.html { render :edit, status: :unpro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @kela.update(kela_params)\n format.html { redirect_to @kela, notice: 'Kela was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kela.errors, stat... | [
"0.6350506",
"0.62601316",
"0.6170705",
"0.61663663",
"0.61515725",
"0.6132433",
"0.6128296",
"0.6124237",
"0.61210877",
"0.61175823",
"0.6057317",
"0.60144114",
"0.5969454",
"0.59593225",
"0.5950163",
"0.59428006",
"0.59189516",
"0.5917302",
"0.5913498",
"0.59021586",
"0.589... | 0.6319693 | 1 |
DELETE /theloaisaches/1 or /theloaisaches/1.json | def destroy
@theloaisach.destroy
respond_to do |format|
format.html { redirect_to theloaisaches_url, notice: "Theloaisach was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @thema.destroy\n respond_to do |format|\n format.html { redirect_to themata_url }\n format.json { head :no_content }\n end\n end",
"def delete!( opts =... | [
"0.70291334",
"0.69779515",
"0.69654626",
"0.6963724",
"0.6958891",
"0.6955817",
"0.6955817",
"0.6901878",
"0.6884223",
"0.6882267",
"0.6878711",
"0.6865196",
"0.68605876",
"0.685439",
"0.6836049",
"0.68346196",
"0.68263817",
"0.68033034",
"0.6800072",
"0.6792529",
"0.6792154... | 0.71921873 | 0 |
Returns a single project segment | def segment(project_id, key_id, language_iso, segment_number, req_params = {})
params = { query: [project_id, key_id, language_iso, segment_number], req: req_params }
data = endpoint(name: 'Segments', params: params).do_get
resource 'Segment', data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project\n self.projects.first unless projects.empty?\n end",
"def segment\n return asset_on_segment_history.segment rescue nil\n end",
"def project\n self.format.try(:project)\n end",
"def project_number\n segments = @audience.split \"/\"\n idx = segments.index \"projects\"\... | [
"0.62779295",
"0.6224353",
"0.6086003",
"0.60174924",
"0.60174924",
"0.59211",
"0.58989817",
"0.5890216",
"0.5889555",
"0.5869268",
"0.585898",
"0.5847536",
"0.5816321",
"0.5809094",
"0.5784023",
"0.57799643",
"0.57666916",
"0.57666916",
"0.57666916",
"0.57666916",
"0.5766691... | 0.6414373 | 0 |
set and return user rate: example > set_rate(4) if value user_rate is zero, user_rate sets random between from 1 to 5 | def rate(user_rate = nil)
@user_rate = user_rate.nil? ? @user_rate : (user_rate.to_i.zero? ? rand(1..5) : user_rate if (0..5).cover?(user_rate.to_i))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate=(value)\n @rate = value\n end",
"def rate(rate)\n @rated_times += 1\n @average_rating = (@average_rating + rate) / @rated_times\n end",
"def rate(stars, user, dirichlet_method=false)\n\n if can_rate? user\n rates.... | [
"0.767989",
"0.7085148",
"0.70643735",
"0.704562",
"0.6980152",
"0.6906819",
"0.67577386",
"0.6691674",
"0.6688505",
"0.66768706",
"0.6667784",
"0.66606396",
"0.6628255",
"0.6628255",
"0.6628255",
"0.6628255",
"0.66172",
"0.6570844",
"0.6539932",
"0.6525699",
"0.64806056",
... | 0.8673743 | 0 |
add user in Usergroup | def add_user(newuser)
@group_users.push(newuser)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_user_to_group(user, group)\n\t\t\tend",
"def add_user(user)\n UserGroup.create(user_id: user.id, group_id: id)\n end",
"def add_user(user)\n group_members.create(group: self, user: user, accepted: DateTime.now)\n end",
"def addUserToGroup\n @user_to_add = User.find(params[:user_to_ad... | [
"0.866995",
"0.80869144",
"0.8024208",
"0.80109406",
"0.79968184",
"0.7844103",
"0.7824062",
"0.7791386",
"0.778691",
"0.77759737",
"0.7724631",
"0.7705011",
"0.7694962",
"0.7667048",
"0.7646646",
"0.7646646",
"0.7628266",
"0.75875455",
"0.7560802",
"0.75232434",
"0.75015485"... | 0.8232307 | 1 |
delete user from Usergroup with user_id | def delete_user(deluser_id)
@group_users.delete_if { |item| item.user_id == deluser_id }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_member\n @group = Group.find(params[:id])\n @user = User.find_by_id(params[:user_id])\n\n if @group.users.include?(@user)\n @group.users.delete(@user)\n @group.save\n flash[:notice] = \"Miembro borrado exitosamente.\"\n end\n\n redirect_to group_path(@group)\n end",
"def... | [
"0.81837416",
"0.81311756",
"0.80089074",
"0.8001407",
"0.7976349",
"0.7850211",
"0.77733505",
"0.76814353",
"0.7675185",
"0.76748925",
"0.7647359",
"0.756417",
"0.74978167",
"0.7465452",
"0.7449766",
"0.7444721",
"0.74442255",
"0.7436912",
"0.74138004",
"0.7408918",
"0.74005... | 0.83215886 | 0 |
retur user with max rate | def best_user
@group_users.max_by(&:rate)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def worst_user\n @group_users.min_by(&:get_rate)\n end",
"def rate(user_rate = nil)\n @user_rate = user_rate.nil? ? @user_rate : (user_rate.to_i.zero? ? rand(1..5) : user_rate if (0..5).cover?(user_rate.to_i))\n end",
"def rate_limit\n return nil unless @client\n\n t = Time.now\n l... | [
"0.69234794",
"0.65097123",
"0.6312583",
"0.6200378",
"0.6195007",
"0.61941636",
"0.59912187",
"0.58899343",
"0.58846974",
"0.5860604",
"0.5834517",
"0.5830606",
"0.58122903",
"0.5795221",
"0.57940906",
"0.5776754",
"0.5765384",
"0.57529",
"0.5733467",
"0.5733467",
"0.5714975... | 0.724183 | 0 |
retur user with min rate | def worst_user
@group_users.min_by(&:get_rate)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate(user_rate = nil)\n @user_rate = user_rate.nil? ? @user_rate : (user_rate.to_i.zero? ? rand(1..5) : user_rate if (0..5).cover?(user_rate.to_i))\n end",
"def best_user\n @group_users.max_by(&:rate)\n end",
"def rate \n @user = User.find_from_param(params[:id])\n if @user.rateable_by?(cu... | [
"0.68062645",
"0.6316115",
"0.6305841",
"0.60808563",
"0.60808563",
"0.6027617",
"0.5965653",
"0.5944634",
"0.5943455",
"0.5893678",
"0.5888269",
"0.5888269",
"0.5873097",
"0.5870971",
"0.58697945",
"0.58389455",
"0.58305746",
"0.5807044",
"0.5806139",
"0.58017963",
"0.578064... | 0.66465753 | 1 |
An alias for RUBY_PLATFORM === Return name(String):: RUBY_PLATFORM | def name
RUBY_PLATFORM
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ruby_platform_osname\n return unless Object.const_defined? :RUBY_PLATFORM\n\n case RUBY_PLATFORM\n when /darwin/ # macOS\n :macos\n when /linux/\n :linux\n when /mingw/\n :windows\n when /openbsd/\n :openbsd\n end\n end",... | [
"0.8385413",
"0.80764323",
"0.79234445",
"0.79072535",
"0.7794235",
"0.76909053",
"0.7668009",
"0.76161766",
"0.7599129",
"0.75935096",
"0.7548656",
"0.7500768",
"0.74804527",
"0.7411195",
"0.73644245",
"0.7327517",
"0.72889",
"0.72582203",
"0.7254949",
"0.72412205",
"0.72383... | 0.8984987 | 0 |
Are we in an EC2 cloud? === Return true:: If machine is located in an EC2 cloud false:: Otherwise | def ec2?
resolve_cloud_type if @ec2.nil?
@ec2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ec2?\n @ec2 ||= EC2.instance_id.include?('i-')\n end",
"def on_ec2?\n ec2 != nil\n end",
"def on_ec2?\n ec2 != nil\n end",
"def on_rightscale_ec2_platform?\n return false if (ec2 == nil || ec2[:userdata].match(/RS_/) == nil) # only ec2 supported\n true\nend",
"def on_ec2?\n ec2 != ni... | [
"0.7770823",
"0.77519435",
"0.77519435",
"0.7539143",
"0.7538713",
"0.7261664",
"0.72427356",
"0.72195977",
"0.6968421",
"0.6890333",
"0.6847384",
"0.68048495",
"0.6792794",
"0.6792794",
"0.67596835",
"0.6728041",
"0.65887463",
"0.6585326",
"0.6583575",
"0.651594",
"0.6450099... | 0.7923933 | 0 |
Are we in a Rackspace cloud? === Return true:: If machine is located in an EC2 cloud false:: Otherwise | def rackspace?
resolve_cloud_type if @rackspace.nil?
@rackspace
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_rackspace?\n rackspace != nil\n end",
"def on_rackspace?\n rackspace != nil\n end",
"def has_rackspace_kernel?\n kernel[:release].split('-').last.eql?(\"rscloud\")\nend",
"def on_rackspace?\n rackspace != nil\nend",
"def rackspace?(node)\n node.key?('rackspace')\n end",
"def ... | [
"0.73676956",
"0.73676956",
"0.71825504",
"0.71666217",
"0.70988107",
"0.7036013",
"0.70162314",
"0.69914424",
"0.6989146",
"0.6876613",
"0.6876613",
"0.68709594",
"0.6845766",
"0.68402237",
"0.6818065",
"0.67730516",
"0.6763897",
"0.67538035",
"0.6740978",
"0.6740978",
"0.66... | 0.742828 | 0 |
Controller object === Return c(Controller):: Platformspecific controller object | def controller
platform_service(:controller)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def controller\n @controller ||= ApplicationController.new\n end",
"def controller\n @controller ||= controller_name.constantize\n end",
"def controller\n @controller ||= MainController.new\n end",
"def controller client\n client.env[CONTROLLER_NAME]\n end",
"def control... | [
"0.7643023",
"0.75106966",
"0.72431034",
"0.7160315",
"0.7066273",
"0.6995412",
"0.69361246",
"0.69347775",
"0.68931943",
"0.6866875",
"0.67717665",
"0.67452484",
"0.67452484",
"0.6734607",
"0.6731051",
"0.6721731",
"0.67209756",
"0.6696914",
"0.6696914",
"0.6620909",
"0.6620... | 0.78103113 | 0 |
Filesystem config object === Return fs(Filesystem):: Platformspecific filesystem config object | def filesystem
platform_service(:filesystem)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filesystem_data\n self['filesystem2'] || self['filesystem']\n end",
"def get_filesystem\n @@current_fake ? @@current_fake[:filesystem] : ''\n end",
"def filesystem_impl=(impl)\n @filesystem_impl = impl\n end",
"def filesystem_file(host)\n case host['platform']\n when %r{... | [
"0.6952392",
"0.69179416",
"0.65042853",
"0.6335989",
"0.632909",
"0.63050026",
"0.62324154",
"0.60316855",
"0.5980779",
"0.5933646",
"0.5915341",
"0.58948094",
"0.5754041",
"0.57516235",
"0.5748909",
"0.5716312",
"0.56952953",
"0.5685673",
"0.56470746",
"0.56381303",
"0.5623... | 0.75143844 | 0 |
SSH information object === Return platform specific ssh object | def ssh
platform_service(:ssh)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssh_info\n # Run a custom action called \"read_ssh_info\" which does what it says\n # and puts the resulting SSH info into the `:machine_ssh_info` key in\n # the environment.\n #\n # Ssh info has following format..\n #\n #{\n # :host => \"1.2.3.4\",\n ... | [
"0.7775004",
"0.7382572",
"0.7382572",
"0.7382572",
"0.7382572",
"0.73283446",
"0.70838785",
"0.692864",
"0.6861395",
"0.68420076",
"0.6628104",
"0.6443306",
"0.6394162",
"0.6394162",
"0.6394162",
"0.63198215",
"0.62954736",
"0.6245317",
"0.62439144",
"0.6239657",
"0.6238132"... | 0.738389 | 1 |
Linux platformspecific platform object === Return instance of Platform::Linux:: If ruby interpreter is running on Linux nil:: Otherwise | def linux
raise PlatformError.new("Only available under Linux") unless linux?
require_linux
return Linux.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linux?\n kind_of? Unix::Platform rescue false\n end",
"def linux?\n /linux/.match(RUBY_PLATFORM)\n end",
"def isLinux()\n RUBY_PLATFORM.include? \"linux\"\nend",
"def linux?\n RUBY_PLATFORM =~ /linux/\n end",
"def linux?\n RUBY_PLATFORM.match(/linux/)\n end",
"def l... | [
"0.81641793",
"0.81434256",
"0.81431",
"0.8081668",
"0.8068725",
"0.8013422",
"0.7965977",
"0.7919813",
"0.7897795",
"0.7783285",
"0.77361685",
"0.7702981",
"0.76829845",
"0.76795894",
"0.76517737",
"0.7591393",
"0.7581479",
"0.75757873",
"0.755613",
"0.74806726",
"0.74346614... | 0.8190539 | 0 |
Determines which cloud we're on by the cheap but simple expedient of reading the RightScale cloud file. | def resolve_cloud_type
cloud_type = File.read(File.join(self.filesystem.right_scale_state_dir, 'cloud')) rescue nil
@ec2 = false
@rackspace = false
@eucalyptus = false
case cloud_type
when 'ec2' then ec2 = true
when 'rackspace' then @rackspace = true
when 'eucalyptu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cloud?(node)\n node.key?('cloud')\n end",
"def cloud?(node = __getnode)\n # cloud is always present, but nil if not on a cloud\n !node[\"cloud\"].nil?\n end",
"def in_cloud?(file)\n File.dirname(file).start_with?(Kinksync.configuration.cloud_path)\n end",
"def get_c... | [
"0.6666226",
"0.64531565",
"0.61970085",
"0.60109115",
"0.59555256",
"0.59150255",
"0.5889657",
"0.568545",
"0.5662921",
"0.5646818",
"0.5626254",
"0.5564425",
"0.5551584",
"0.5496858",
"0.54917866",
"0.5428814",
"0.540402",
"0.5390353",
"0.5338402",
"0.5304133",
"0.5275231",... | 0.724408 | 0 |
in case we need one, e.g. "Rechnung000001082011.pdf" Note: this is | def human_pdf_filename
"Rechnung-#{self.short_number}.pdf"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filename(url)\n parts = url.split('/')\n dirname = parts[-2]\n filename = parts[-1].split('.')[0] + \"_ocr.pdf\"\n '990s/' + dirname + '/' + filename\nend",
"def filename2seq(name)\n m = name.sub(\"_\",\"\").match(/([0-9]{12}).jpg/)\n return nil unless m\n return m[1].to_i\nend",
"def number\n ... | [
"0.6600497",
"0.6376852",
"0.634441",
"0.6344274",
"0.63266385",
"0.630589",
"0.62819576",
"0.62586564",
"0.61954087",
"0.6180131",
"0.6180131",
"0.617402",
"0.616587",
"0.61601573",
"0.6150146",
"0.6129026",
"0.6111114",
"0.6099381",
"0.60984665",
"0.60891366",
"0.6083737",
... | 0.68372995 | 0 |
Returns the first ten responses that would be scheduled for the given protocol. | def execute
@responses = []
@end_date = end_date
@end_date = TimeTools.increase_by_duration(start_date, protocol.duration) if @end_date.blank?
schedule_responses
# Return at most ten responses
@responses.sort_by! { |response| response[:open_from] }
@responses[0...MAX_PREVIEW_RESPONSE_COUNT]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_ten\n Rails.cache.fetch('top_ten_resp', expires_in: 1.minutes) do\n conn = Faraday.new(url: @base_url) do |faraday|\n faraday.adapter(Faraday.default_adapter)\n end\n\n resp = conn.get do |req|\n req.url '/v1/cryptocurrency/listings/latest'\n req.headers['X-CMC_PRO_AP... | [
"0.6036598",
"0.54201394",
"0.52545935",
"0.5220028",
"0.5153872",
"0.51267284",
"0.5106063",
"0.50040185",
"0.4976269",
"0.49652484",
"0.48677963",
"0.48536602",
"0.48529062",
"0.4844984",
"0.48421723",
"0.48193493",
"0.48128352",
"0.4751414",
"0.47443113",
"0.474421",
"0.47... | 0.5730701 | 1 |
8kyu I implemented a function which convert the given boolean value into its string representation. | def boolean_to_string(b)
return b.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boolean_to_string(b)\n if true\n \"true\"\n else\n \"false\"\n end\nend",
"def boolean_to_string(b)\n if b \n \"true\"\n else\n \"false\"\n end\nend",
"def bool_to_string(value)\n return 'yes' if value == true\n return 'no' if value == false\n value # if it doesn't match anythin... | [
"0.8680349",
"0.86385286",
"0.833737",
"0.79908687",
"0.7712514",
"0.7603247",
"0.7601336",
"0.7394316",
"0.73607004",
"0.73607004",
"0.7343037",
"0.73152786",
"0.72638005",
"0.7253689",
"0.7247133",
"0.7186867",
"0.71535224",
"0.7152073",
"0.7102689",
"0.7102689",
"0.707875"... | 0.8851261 | 0 |
POST /vehicle_armies POST /vehicle_armies.json | def create
@vehicle_army = VehicleArmy.new(vehicle_army_params)
respond_to do |format|
if @vehicle_army.save
format.html { redirect_to @vehicle_army, notice: (t 'vehicle_armies.title')+(t 'actions.created')}
format.json { render action: 'show', status: :created, location: @vehicle_army }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @vehicle = Vehicle.new(vehicle_params)\n if @vehicle.save\n render json: { status: 'Vehicle created successfully', vehicle: @vehicle }, status: :created\n else\n render json: { errors: @vehicle.errors.full_messages }, status: :bad_request\n end\n end",
"def create_vehicles veh... | [
"0.6746426",
"0.6452859",
"0.63560665",
"0.63560665",
"0.63560665",
"0.61956847",
"0.61088204",
"0.6034517",
"0.59630686",
"0.588549",
"0.5882796",
"0.5863898",
"0.5844551",
"0.5834354",
"0.5832875",
"0.58074296",
"0.58066344",
"0.5794564",
"0.5791548",
"0.5738122",
"0.573647... | 0.67126286 | 1 |
Behaves the same as File.dirname from the standard library, except when passed a second argument, n. In this case, dirname is called n times, essentially finding the file's nth parent. | def dirname file_name, n=1
n.times { file_name = _old_dirname(file_name) }
return file_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dirname() Path::Name.new(File.dirname(path)) end",
"def dirname\n File.dirname(filename)\n end",
"def dirname\n File.dirname(filename)\n end",
"def dirname( fn )\n ::File.dirname(fn).sub(%r/\\A[^\\/]+\\/?/o, '')\n end",
"def dirname(path)\n File.dirname(path)\n end",... | [
"0.64315546",
"0.61156213",
"0.6018476",
"0.5877481",
"0.5759991",
"0.5744559",
"0.56592196",
"0.5630027",
"0.5505143",
"0.54382086",
"0.5327235",
"0.53073025",
"0.5301667",
"0.52668536",
"0.5137502",
"0.5033914",
"0.5006094",
"0.49970862",
"0.49744707",
"0.4973133",
"0.49430... | 0.8302876 | 0 |
Returns the number of tokens in this text. | def length
@tokens.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_tokens()\n @counts = Hash.new(0)\n @tokens.each do |token|\n @counts[token] += 1\n end\n @counts\n end",
"def number_of_tokens\r\n return MONOPOLY_GAME[:tokens].count\r\nend",
"def word_number\n text.split.size\n end",
"def count_tokens(type)\n token_tuples(type).count\nend"... | [
"0.7242187",
"0.7057865",
"0.7049498",
"0.68790025",
"0.67769444",
"0.67601776",
"0.66924983",
"0.6657637",
"0.6655045",
"0.6621071",
"0.65733254",
"0.64848965",
"0.6478677",
"0.6475932",
"0.6357292",
"0.63485956",
"0.6332705",
"0.6331455",
"0.63176686",
"0.6304615",
"0.62973... | 0.77787447 | 0 |
appends a single token to the end of this text. | def <<(new_token)
@tokens << new_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_token(token)\n process_unknown\n @tokens << token\n @position += token.length\n end",
"def text_token text, kind\n @out << text\n end",
"def add_extra_token(tok)\n @extra_tokens.push(tok)\n end",
"def append_space\n return if @sb_last_was_whitespace\n\n ... | [
"0.70394105",
"0.6579808",
"0.6335208",
"0.62273157",
"0.61286646",
"0.58965105",
"0.58485353",
"0.5825494",
"0.5797446",
"0.5741546",
"0.5733852",
"0.57329094",
"0.57317764",
"0.56843024",
"0.567202",
"0.5655837",
"0.5632459",
"0.55840707",
"0.5575739",
"0.5505166",
"0.54601... | 0.6827971 | 1 |
Try to find a single xero record by its xero id | def find_record(xero_id)
raise_must_override
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_one(id)\n response = request(:get, \"/#{resource_name}/#{id}\")\n #puts response\n construct_record_from_singular(response)\n end",
"def find(id); end",
"def find(id); end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
... | [
"0.64689296",
"0.63627136",
"0.63627136",
"0.6335353",
"0.6335353",
"0.63308114",
"0.6325294",
"0.6324489",
"0.63060206",
"0.62488365",
"0.62438637",
"0.62347865",
"0.618941",
"0.61826444",
"0.61771",
"0.6171773",
"0.6126213",
"0.61185825",
"0.6091522",
"0.6081643",
"0.606306... | 0.7981715 | 0 |
OPTIONAL Update the local status code of the model to match what is in xero. This is needed to avoid status changes that will later cause failure when trying to sync. Example CreditNote: 1. Local status: submitted 2. Remote status: authorized This will be flagged for remote save, but will be updated with the local stat... | def sync_local_model_status(model, record)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_status(status)\n self.status = status\n self.save! validate: false\n end",
"def set_status\n self.status = Status.find_by(code: \"OPEN\")\n end",
"def update_status status\n @job.set({\n custom_status: status,\n pinged_at: Time.now\n })\n end",
"def set_status... | [
"0.69049907",
"0.66083694",
"0.6511697",
"0.65002716",
"0.64992464",
"0.6466261",
"0.64374685",
"0.6377628",
"0.6367667",
"0.6328119",
"0.6312454",
"0.6278468",
"0.6278209",
"0.62533057",
"0.6251229",
"0.62227833",
"0.6190832",
"0.6148658",
"0.6144465",
"0.6144465",
"0.614016... | 0.6694855 | 1 |
Responsible for finding the local model for this record It is up to the subclass to determine lookup logic or to create a new model if none is found. If nil is returned, the task won't attempt to process the record | def find_model(record)
raise_must_override
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_model(parent_model, name)\n Roby::Distributed::DRobyModel.anon_model_factory(parent_model, name)\n end",
"def find_record\n self.class.model_klass.find(params[:id])\n end",
"def find_existing_record\n @record = record_class.find(@locator)\n end",
"def find_... | [
"0.603749",
"0.5995005",
"0.59848475",
"0.59848475",
"0.5949274",
"0.5848526",
"0.58224106",
"0.58140403",
"0.576883",
"0.5757326",
"0.57531077",
"0.57494634",
"0.5748348",
"0.574255",
"0.5742007",
"0.5713181",
"0.5692753",
"0.56859833",
"0.567968",
"0.56624115",
"0.56624115"... | 0.61807853 | 0 |
PATCH/PUT /milkings/1 PATCH/PUT /milkings/1.json | def update
if @milking.update(milking_params)
render :show, status: :ok, location: v1_milking_url(@milking)
else
render json: @milking.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @milk.update(milk_params)\n format.html { redirect_to @milk, notice: 'Milk was successfully updated.' }\n format.json { render :show, status: :ok, location: @milk }\n else\n format.html { render :edit }\n format.json { render json: @... | [
"0.67619854",
"0.6147035",
"0.60891205",
"0.59965664",
"0.59591866",
"0.59155726",
"0.59019977",
"0.5878373",
"0.58765477",
"0.5820535",
"0.58196926",
"0.5813598",
"0.5774922",
"0.5770615",
"0.57634515",
"0.57591856",
"0.5758659",
"0.5740703",
"0.572757",
"0.5716799",
"0.5698... | 0.68252116 | 0 |
DELETE /milkings/1 DELETE /milkings/1.json | def destroy
@milking.destroy
render json: {status: "Record Deleted"}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @milk.destroy\n respond_to do |format|\n format.html { redirect_to milks_url, notice: 'Milk was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted... | [
"0.70463747",
"0.68726206",
"0.6729877",
"0.66869706",
"0.66628975",
"0.6645407",
"0.6580957",
"0.65752226",
"0.654971",
"0.6524203",
"0.6483389",
"0.64619124",
"0.64493763",
"0.64493763",
"0.6436136",
"0.6409707",
"0.6403845",
"0.63967836",
"0.6393506",
"0.6393405",
"0.63851... | 0.69651735 | 1 |
Determines irregular verbs from the expression Params: infinitive, the given verb preterite, denote events that took place in the past past_participle, form of a verb, ending in 'ed' &blk, block of code that may be run | def irregular(infinitive, preterite = nil, past_participle = nil, &blk)
if block_given?
# create new Verb object with infinitive and &blk
irregular = ::Verbs::Verb.new infinitive, &blk
else
unless preterite && past_participle
raise ArgumentError,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regular_preterite_for(verb)\n infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s\n\n if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_WITHOUT_C_PATTERN}$/) &&\n !conjugations.single_terminal_consonants.include?(verb.to_sym)\n return regular_pret... | [
"0.67030674",
"0.6077263",
"0.6065101",
"0.58036715",
"0.5788162",
"0.5759099",
"0.5536372",
"0.5522279",
"0.5517326",
"0.5503346",
"0.5483458",
"0.5430552",
"0.5430552",
"0.5430552",
"0.5430552",
"0.5430552",
"0.5410265",
"0.5384527",
"0.53753406",
"0.5351846",
"0.52921104",... | 0.6417911 | 1 |
Using options given, determine the conjugation and the subject Return the subject, if there is one, and the proper conjugation Params: infinitive, the given verb options, the list of parameters to alter the conjugation | def conjugate(infinitive, options = {})
infinitive = infinitive.dup if infinitive.is_a?(String)
# set all options according to parameter, or the default
tense = options[:tense] || :present # present, past, future
person = options[:person] || :third # first, second, third
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject(options)\n case [options[:person], options[:plurality]]\n when %i[first singular]\n 'I'\n when %i[first plural]\n 'we'\n when %i[second singular], %i[second plural]\n 'you'\n when %i[third singular]\n 'he'\n when %i[third plural]\n 'they'... | [
"0.6529123",
"0.65073097",
"0.6045123",
"0.57486117",
"0.5731374",
"0.54960376",
"0.54800636",
"0.54773915",
"0.5404189",
"0.53992635",
"0.5382994",
"0.5366697",
"0.5338393",
"0.5319206",
"0.522267",
"0.5191354",
"0.5173851",
"0.5173851",
"0.5173851",
"0.5173851",
"0.5173851"... | 0.66836923 | 0 |
Resolves conflictions between options of the conjugation Params: element, infinitive, the given verb tense, an option given by the user person, an option given by the user plurality, an option given by the user mood, an option given by the user | def resolve(element, infinitive, tense, person, plurality, mood)
case element
when String
element
when :infinitive
infinitive
when :present, :past, :present_participle, :past_participle
inflect infinitive, element, person, plurality, mood
when Symbol
inflect... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_improper_constructions(infinitive, tense, person, mood, diathesis)\n if (mood == :imperative) && !((person == :second) && (tense == :present))\n raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'\n end\n if (infinitive.to_sym == :be... | [
"0.59932154",
"0.5867925",
"0.5781977",
"0.5624133",
"0.55947804",
"0.5487107",
"0.5361296",
"0.5334847",
"0.53338236",
"0.52916795",
"0.52914923",
"0.5227277",
"0.51904595",
"0.5175002",
"0.51408833",
"0.5113212",
"0.50876766",
"0.5042484",
"0.5030979",
"0.501756",
"0.499533... | 0.63962233 | 0 |
Apply thir person rules to the verb for the conjugation Params: verb, apply proper third person rules to this | def present_third_person_singular_form_for(verb)
infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
case infinitive
when /[a-z&&#{CONSONANT_PATTERN}]y$/i
"#{infinitive[0..-2]}ies"
when /(ss|sh|t?ch|zz|x|#{CONSONANT_PATTERN}o)$/i
"#{infinitive}es"
when /[^s]s$... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regular_preterite_for(verb)\n infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s\n\n if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_WITHOUT_C_PATTERN}$/) &&\n !conjugations.single_terminal_consonants.include?(verb.to_sym)\n return regular_pret... | [
"0.6468106",
"0.57955927",
"0.5775022",
"0.5724713",
"0.5706209",
"0.5638677",
"0.5608252",
"0.5470209",
"0.5470209",
"0.5470209",
"0.5470209",
"0.5470209",
"0.53566796",
"0.53566796",
"0.52387756",
"0.5218787",
"0.52186495",
"0.5214793",
"0.5181069",
"0.51657146",
"0.5156089... | 0.65749305 | 0 |
Apply the regular past tense to a given verb for the conjugation Params: verb, apply regular past tense rules to this | def regular_preterite_for(verb)
infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_WITHOUT_C_PATTERN}$/) &&
!conjugations.single_terminal_consonants.include?(verb.to_sym)
return regular_preterite_with... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def past(infinitive, person, plurality, mood)\n if (verb = conjugations.irregulars[infinitive])\n conjugate_irregular(verb, tense: :past, person: person, plurality: plurality, mood: mood)\n else\n regular_preterite_for infinitive\n end\n end",
"def get_regular(verb)\n case ve... | [
"0.6472331",
"0.6230442",
"0.59399843",
"0.59242153",
"0.5890981",
"0.58609486",
"0.5734238",
"0.5704534",
"0.5698733",
"0.5698526",
"0.5698526",
"0.5698526",
"0.5698526",
"0.5698526",
"0.565137",
"0.56355035",
"0.56106085",
"0.551773",
"0.5517429",
"0.5471704",
"0.54675835",... | 0.6910308 | 0 |
Apply proper rules to consonant endings Params: verb, apply double consonant to this | def regular_preterite_with_doubled_terminal_consonant_for(verb)
regular_preterite_for verb.to_s.concat(verb.to_s[-1, 1]).to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def present_participle_with_doubled_terminal_consonant_for(verb)\n if /c$/ =~ verb.to_s\n present_participle verb.to_sym\n else\n present_participle verb.to_s.concat(verb.to_s[-1, 1]).to_sym\n end\n end",
"def regular_preterite_for(verb)\n infinitive = verb.is_a?(Verb) ? verb... | [
"0.65740854",
"0.64425373",
"0.64022726",
"0.62513596",
"0.614279",
"0.60967696",
"0.6093948",
"0.59111714",
"0.5892954",
"0.5832512",
"0.5821658",
"0.5784825",
"0.5760285",
"0.5752394",
"0.5713888",
"0.57036954",
"0.5686028",
"0.5668624",
"0.56383115",
"0.5635191",
"0.563257... | 0.6933846 | 0 |
Apply proper rules to consonant endings Params: verb, apply double consonant to this | def present_participle_with_doubled_terminal_consonant_for(verb)
if /c$/ =~ verb.to_s
present_participle verb.to_sym
else
present_participle verb.to_s.concat(verb.to_s[-1, 1]).to_sym
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regular_preterite_with_doubled_terminal_consonant_for(verb)\n regular_preterite_for verb.to_s.concat(verb.to_s[-1, 1]).to_sym\n end",
"def regular_preterite_for(verb)\n infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s\n\n if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTE... | [
"0.6933846",
"0.64425373",
"0.64022726",
"0.62513596",
"0.614279",
"0.60967696",
"0.6093948",
"0.59111714",
"0.5892954",
"0.5832512",
"0.5821658",
"0.5784825",
"0.5760285",
"0.5752394",
"0.5713888",
"0.57036954",
"0.5686028",
"0.5668624",
"0.56383115",
"0.5635191",
"0.5632572... | 0.65740854 | 1 |
Confirm an imperative mood contains the present tense and second person Params: tense, an option given by the user person, how the conjugation refers to the subject mood, an option given by the user diathesis, an option given by the user | def check_for_improper_constructions(infinitive, tense, person, mood, diathesis)
if (mood == :imperative) && !((person == :second) && (tense == :present))
raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'
end
if (infinitive.to_sym == :be) && (dia... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mood\n #it \"has a method 'mood' that returns 'happy' when the user is more happy than nauseous\" do\n if self.happiness && self.nausea\n if self.happiness > self.nausea\n \"happy\"\n #it \"has a method 'mood' that returns 'sad' when the user is more nauseous than happy\" do\n elsif sel... | [
"0.66450334",
"0.6400529",
"0.62736136",
"0.62602985",
"0.6254086",
"0.62043893",
"0.6188759",
"0.61202973",
"0.6102706",
"0.6100484",
"0.60802263",
"0.6074935",
"0.60642534",
"0.6056229",
"0.60277253",
"0.59890866",
"0.59468627",
"0.5888301",
"0.5876436",
"0.5869608",
"0.585... | 0.65158516 | 1 |
Send a file to the given email address | def send_email_by_passing_file(sendto, attachmnent_filename, path='./public')
Pony.mail({
:to => sendto,
:from => 'Magic Team',
:subject => 'Your web scrapper successfully finished',
:body => 'Thanks for using web scrapper service offered by MAGiC',
:attachments => {attachmnent_filenam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_email(url, email)\n file = open(url).read\n filename = get_name(url)\n\t\tPony.mail(:to => email,\n :from => 'Send To Kindle',\n\t\t :subject => 'Convert',\n\t\t :attachments => {filename => file},\n\t\t :via => :smtp, \n :via_options => @email_config\n ) \n\tend",
"def send_em... | [
"0.75949174",
"0.7006693",
"0.6991517",
"0.6812473",
"0.67422605",
"0.6665113",
"0.6662956",
"0.6589446",
"0.6575592",
"0.6488019",
"0.637528",
"0.63480085",
"0.6231508",
"0.62107563",
"0.619263",
"0.6165146",
"0.61543673",
"0.61523694",
"0.6135452",
"0.6134288",
"0.61196935"... | 0.7974564 | 0 |
Send a jsonobject to the given email address | def send_email_by_passing_jsonobject(sendto, json_object, filename)
Pony.mail({
:to => sendto,
:from => 'Magic Team',
:subject => 'Your web scrapper successfully finished',
:body => 'Thanks for using web scrapper service offered by MAGiC',
:attachments => {filename => "json_object"},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(email_name, email_to, data = {})\n payload = {\n :email_name => email_name,\n :email_to => email_to,\n :email_data => data\n }\n return api_request(\"send\", payload)\n end",
"def sendmail(object)\n email\n end",
"... | [
"0.672504",
"0.6705468",
"0.65184516",
"0.63990325",
"0.6251436",
"0.62277734",
"0.6200909",
"0.6138903",
"0.6072342",
"0.6067826",
"0.60566854",
"0.60341907",
"0.59921646",
"0.5970218",
"0.5907847",
"0.58910036",
"0.589",
"0.58713377",
"0.5851138",
"0.58451957",
"0.58270913"... | 0.7889941 | 0 |
Generate IIIF Presentation 2.0 manifest | def manifest
seed = { 'label' => title }
manifest = IIIF::Presentation::Manifest.new(seed)
manifest['@id'] = uri(image_server, "#{id}/manifest")
manifest.attribution = 'University of Pennsylvania Libraries'
manifest.viewing_hint = viewing_hint
manifest.viewing_direction = viewing_direction
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manifest\n anno = IIIF::Presentation::Annotation.new('on' => path)\n anno.resource = create_resource\n canvas.images << anno\n canvas.other_content = [annotations]\n manifest = IIIF::Presentation::Manifest.new(\n '@id' => path,\n 'label' => \"Histonets - Collection Template #{id}\"\n ... | [
"0.68924505",
"0.6339366",
"0.63171244",
"0.61669075",
"0.6130286",
"0.613018",
"0.6116419",
"0.5985955",
"0.59582496",
"0.58460945",
"0.5833622",
"0.5813625",
"0.57900375",
"0.57154995",
"0.5670805",
"0.56653976",
"0.56653976",
"0.5660883",
"0.56424326",
"0.56255674",
"0.560... | 0.6982323 | 0 |
Returns canvas with one annotated image. The canvas and image size are the same. | def canvas(index:, width:, height:, profile:, label: nil, filepath:, additional_downloads: nil)
canvas = IIIF::Presentation::Canvas.new
canvas['@id'] = uri(image_server, "#{id}/canvas/p#{index}")
canvas.label = label || "p. #{index}"
canvas.height = height
canvas.width = width
annotation = II... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_canvas(w, h, bkg_col)\n @draw = Magick::Draw.new\n @draw.pointsize = @@pointsize # TODO Use height\n @draw.pointsize = @options[:font_size] if @options.has_key?(:font_size)\n @canvas = Magick::Image.new(w , h) { self.background_color = bkg_col }\n\n # Make room for label and last value\n ... | [
"0.5890029",
"0.58261883",
"0.5790082",
"0.5738972",
"0.57041544",
"0.55744606",
"0.55509293",
"0.5486989",
"0.5475784",
"0.54657716",
"0.54566514",
"0.54434323",
"0.54019684",
"0.5386677",
"0.535922",
"0.52910435",
"0.51799273",
"0.5154018",
"0.5146952",
"0.5146834",
"0.5140... | 0.6389344 | 0 |
Returns range with sub ranges for each table of contents entry. For each table of contents entry will point to the entire canvas. Note: If at some point coordinates are provided for each table of contents entry we can point directly to the coordinates given. | def range(index:, label:, table_of_contents:)
subranges = table_of_contents.map.with_index do |entry, subrange_index|
IIIF::Presentation::Range.new(
'@id' => uri(image_server, "#{id}/range/r#{index}-#{subrange_index + 1}"),
'label' => entry[:text],
'canvases' => [uri(image_server, "#{i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subgrid(cords)\n subgrid = []\n x_pos = cords[0] - cords[0] % 3\n (x_pos..x_pos + 2).each do |row_num|\n y_pos = cords[1] - cords[1] % 3\n subgrid += @grid[row_num][y_pos, 3]\n end\n subgrid\n end",
"def getIndexRange()\n rangeTime = { :min => nil, :max => nil} ;\n rangeX ... | [
"0.59189934",
"0.5628868",
"0.55733085",
"0.5564517",
"0.54756737",
"0.54711795",
"0.5434841",
"0.541947",
"0.5410844",
"0.5381737",
"0.5369286",
"0.5367695",
"0.5333022",
"0.53319293",
"0.52209187",
"0.51913506",
"0.51913506",
"0.51832837",
"0.5172692",
"0.51633716",
"0.5162... | 0.66865855 | 0 |
Set API response data Author: Aman Date: 03/05/2018 Reviewed By: | def set_api_response_data
meta = {
page_payload: {
}
}
data = {
meta: meta,
result_set: 'admin_user_list',
admin_user_list: @curr_page_data,
can_invite_new_user: @can_invite_new_user.to_i
}
@api_response_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_api_response_data\n users_list = []\n @users.each do |u|\n ukd = @user_kyc_details[u.id]\n ukd_present = ukd.present?\n users_list << {\n user_id: u.id,\n case_id: ukd_present ? @user_kyc_details[u.id].id : 0,\n email: u.email,... | [
"0.6194693",
"0.6076281",
"0.590754",
"0.59030014",
"0.5798301",
"0.57328176",
"0.5616093",
"0.5567093",
"0.54666394",
"0.5437539",
"0.5358093",
"0.53480023",
"0.53397286",
"0.53344935",
"0.5303863",
"0.5264913",
"0.52462995",
"0.52160853",
"0.52081645",
"0.5206502",
"0.51895... | 0.62009466 | 0 |
POST /questionnairedetails POST /questionnairedetails.json | def create
@questionnairedetail = Questionnairedetail.new(questionnairedetail_params)
respond_to do |format|
if @questionnairedetail.save
format.html { redirect_to @questionnairedetail, notice: 'Questionnairedetail was successfully created.' }
format.json { render :show, status: :created,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @questionnaire = Questionnaire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def create\n @questionnaire = @participant.build_questionnaire(params[:questionnaire])\n @questionnaire.step = 1\n \n r... | [
"0.7216791",
"0.6832053",
"0.6813558",
"0.675791",
"0.6712738",
"0.66761154",
"0.6660387",
"0.66497654",
"0.6632976",
"0.6620636",
"0.6606846",
"0.65971565",
"0.65459937",
"0.6528876",
"0.6524684",
"0.6524684",
"0.6503811",
"0.64895904",
"0.64724636",
"0.64200264",
"0.6409102... | 0.7683533 | 0 |
PATCH/PUT /questionnairedetails/1 PATCH/PUT /questionnairedetails/1.json | def update
respond_to do |format|
if @questionnairedetail.update(questionnairedetail_params)
format.html { redirect_to @questionnairedetail, notice: 'Questionnairedetail was successfully updated.' }
format.json { render :show, status: :ok, location: @questionnairedetail }
else
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully updated.' }\n format.json { head :no_content }\n e... | [
"0.7308285",
"0.7213015",
"0.7071084",
"0.7018416",
"0.69889027",
"0.6822846",
"0.6793808",
"0.67804736",
"0.6752946",
"0.6743366",
"0.67090183",
"0.66666895",
"0.66576016",
"0.6638422",
"0.66212744",
"0.66160965",
"0.66143805",
"0.66142154",
"0.65997505",
"0.6597809",
"0.657... | 0.7357181 | 0 |
DELETE /questionnairedetails/1 DELETE /questionnairedetails/1.json | def destroy
@questionnairedetail.destroy
respond_to do |format|
format.html { redirect_to questionnairedetails_url, notice: 'Questionnairedetail was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n f... | [
"0.7912191",
"0.7899743",
"0.7899743",
"0.7664643",
"0.7662665",
"0.7552165",
"0.7463885",
"0.7459275",
"0.7426304",
"0.7374384",
"0.72807974",
"0.7231025",
"0.7203824",
"0.7194857",
"0.7178297",
"0.71466076",
"0.7134271",
"0.7126231",
"0.71232283",
"0.7109177",
"0.7096015",
... | 0.7925967 | 0 |
Little piggy return `:legacy` if columns include legacy timestamp. If not return true if include normal... | def timestamps?
if (model_column_names & %w[created_on updated_on]).any?
:legacy
else
(model_column_names & %w[created_at updated_at]).any?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legacy_sql?\n val = @gapi.configuration.query.use_legacy_sql\n return true if val.nil?\n val\n end",
"def legacy?\n false\n end",
"def timestamp?\n type == \"TIMESTAMP\"\n end",
"def must_convert?\n big_query_conversion_column.prese... | [
"0.64281315",
"0.63737583",
"0.6359907",
"0.6264884",
"0.61880654",
"0.6122293",
"0.6117424",
"0.6066156",
"0.6033362",
"0.6009418",
"0.57517433",
"0.57485795",
"0.57454",
"0.5692984",
"0.5685877",
"0.5685877",
"0.5685877",
"0.5665288",
"0.5634653",
"0.55782837",
"0.5557073",... | 0.7235441 | 0 |
only admins or team leads can swap duties | def swap?
sid = record.duty_day.season_id
user.has_role?(:admin) or user.has_role?(:leader, user.roster_spots.find_by(season_id: sid, team_id: record.duty_day.team_id)) or user.has_role?(:staff, user.roster_spots.find_by(season_id: sid))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pass_on_double_kill_assignment(assassin_id, deceased_id)\n assassin_id = assassin_id.to_i\n deceased_id = deceased_id.to_i\n assassin_assignment = Player.find(assassin_id).assignments.where(:active => true).last\n deceased_assignment = Player.find(deceased_id).assignments.where(:active => true).las... | [
"0.5938554",
"0.5792789",
"0.5743663",
"0.5689024",
"0.56889033",
"0.56475407",
"0.5573941",
"0.55691195",
"0.55393565",
"0.5538354",
"0.5515899",
"0.55106276",
"0.5466506",
"0.5458252",
"0.539861",
"0.53938746",
"0.53305703",
"0.5319151",
"0.531423",
"0.530832",
"0.5306062",... | 0.7076485 | 0 |
Call_HT_Event:: Call the specified Common Event | def call_ht_event(event_id, mode)
case mode
when 0
$game_temp.common_event_id = SynHT::Call_event_hunger[event_id]
when 1
$game_temp.common_event_id = SynHT::Call_event_thirst[event_id]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_common_event(id)\n if $imported[\"TH_SceneInterpreter\"] == true\n @interpreter.setup($data_common_events[id].list)\n @phone_command.activate\n else\n dispose_phone_background\n @phone_command.dispose\n $game_temp.reserve_common_event(id)\n SceneManager.return\n ... | [
"0.65438694",
"0.65334266",
"0.6190544",
"0.61736244",
"0.6131936",
"0.6086461",
"0.60568136",
"0.5956838",
"0.5893094",
"0.585501",
"0.5850222",
"0.5801438",
"0.57707983",
"0.57518286",
"0.57309884",
"0.56581235",
"0.5645046",
"0.5623829",
"0.5601605",
"0.55773646",
"0.55717... | 0.6648459 | 0 |
ssh_login attempts to log in as host_admin on all hosts from current user | def ssh_login
deploy_test_on_hosts_as self.host_admin, self.hosts, "/home/#{self.host_admin}\n", "should be able to connect via ssh" do
'pwd'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssh_login_as_root\n deploy_test_on_hosts_as 'root', self.hosts, '/root', \"Should be able to connect as root via ssh\" do\n 'pwd'\n end\n end",
"def ssh_login(do_tail, ssh_hostname, ssh_username, ssh_password)\n if ssh_hostname == '' or ssh_username == '' or ssh_password == ''\n puts ... | [
"0.69868636",
"0.6118218",
"0.60860646",
"0.59994775",
"0.5974996",
"0.59332573",
"0.5883073",
"0.58120173",
"0.58066857",
"0.577147",
"0.5739237",
"0.5737033",
"0.5695896",
"0.5680103",
"0.5666923",
"0.5657754",
"0.56322855",
"0.5620444",
"0.5586391",
"0.55781394",
"0.555690... | 0.7970251 | 0 |
ssh_login_as_root attempts to log in as root on all hosts from current user | def ssh_login_as_root
deploy_test_on_hosts_as 'root', self.hosts, '/root', "Should be able to connect as root via ssh" do
'pwd'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_root(host)\n if host['user'] != 'root'\n copy_ssh_to_root(host, @options)\n enable_root_login(host, @options)\n host['user'] = 'root'\n host.close\n end\n end",
"def enable_root(host)\n host['ssh'] = {:password => host['instance'].id}\n @logger.notify... | [
"0.76720446",
"0.69390243",
"0.69206846",
"0.68384326",
"0.6656752",
"0.6541249",
"0.6207311",
"0.5973428",
"0.58412856",
"0.58041894",
"0.57782066",
"0.57202286",
"0.57118976",
"0.57045114",
"0.5697089",
"0.5685545",
"0.56372404",
"0.56215596",
"0.55808175",
"0.55271655",
"0... | 0.8573499 | 0 |
Make sure we end up with a flat array of probe_sets | def probe_sets=(probe_sets)
@probe_sets = Array(probe_sets).flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probe_sets\n @probe_sets ||= Array.new\n end",
"def reset\n probe_sets.each(&:reset)\n end",
"def set_up_test(input_plates)\n input_plates.each do |plate|\n sample = plate.parts.first.sample\n plate.add_samples(Array.new(plate.get_empty.length, sample))\n end\n end",
"def... | [
"0.75054365",
"0.58259267",
"0.57316756",
"0.5596252",
"0.5537638",
"0.54014885",
"0.53901535",
"0.53901535",
"0.53901535",
"0.53779405",
"0.53712785",
"0.5337241",
"0.52932304",
"0.5266021",
"0.5200192",
"0.5173299",
"0.5155054",
"0.512626",
"0.5119021",
"0.50681007",
"0.506... | 0.7023269 | 1 |
Grab some probe_sets or an array | def probe_sets
@probe_sets ||= Array.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probe_sets=(probe_sets)\n @probe_sets = Array(probe_sets).flatten\n end",
"def search_handsets(proc)\n rez = @handsets.values.select do |hand| \n x = proc.call(hand) \n end\n return rez if rez != nil\n return Array::new\n end",
"def probe_set\n attrs = {}\n ... | [
"0.673225",
"0.5703736",
"0.55009794",
"0.5247279",
"0.5132042",
"0.51177025",
"0.51177025",
"0.51152086",
"0.51013553",
"0.50957507",
"0.5056",
"0.5043404",
"0.50407255",
"0.49609417",
"0.49414137",
"0.49347275",
"0.49272776",
"0.49272048",
"0.49239904",
"0.4921173",
"0.4915... | 0.7685559 | 0 |
Hash representation of all the probe_sets. This gives is an intermediate format that we can parse from other systems or code that needs reporting data for formatting, or whatever. | def to_hash
# Drop the probes into the report
probe_sets.inject({}) { |report, set|
report[set.name.to_s] = set.probes.inject({}) { |memo, (_, probe)|
# round the values to 2 decimal places
memo[probe.name] = (probe.value.to_f * 100).round().to_f/100
memo
}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probe_sets\n @probe_sets ||= Array.new\n end",
"def hash\n @__set.to_a.hash\n end",
"def to_hash\n {:hashes => @hashes}\n end",
"def probe_sets=(probe_sets)\n @probe_sets = Array(probe_sets).flatten\n end",
"def hashes\n return @hashes\n end... | [
"0.6722785",
"0.64648277",
"0.6322738",
"0.6222438",
"0.61927485",
"0.6073966",
"0.6037135",
"0.6010736",
"0.60016704",
"0.5999653",
"0.5960808",
"0.5914729",
"0.58373827",
"0.58327526",
"0.57916284",
"0.5787507",
"0.57529336",
"0.5749161",
"0.57395744",
"0.5723585",
"0.57222... | 0.7712999 | 0 |
Reset all the counters in each probe. | def reset
probe_sets.each(&:reset)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_checks\n @counter = 0\n end",
"def reset_stats; reset!; end",
"def reset\n @count = 0\n end",
"def reset!\n default_tags.clear\n adapters.clear\n groups.each_key { |group| singleton_class.send(:remove_method, group) if group && respond_to?(group) }\n @groups = ni... | [
"0.68230873",
"0.65737253",
"0.65549266",
"0.6529333",
"0.6486084",
"0.6453623",
"0.6449965",
"0.6429226",
"0.64178956",
"0.63817275",
"0.6360621",
"0.63248456",
"0.6299693",
"0.6275549",
"0.6275549",
"0.62741816",
"0.62735903",
"0.62514997",
"0.6224748",
"0.620902",
"0.62010... | 0.8291183 | 0 |
The remodel method takes an Xml object as parameter. Output is expected to be the same. Modify the node in place. is preferred. An "information" hash is also passed in. | def remodel( node, info={} )
level = info[:count] || 1
node.attributes['level'] = level
node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rexml!\n @@parser = USE_REXML\n end",
"def node_to_model(node)\n\t\tlog(\"node_to_model #{node.class}\")\n\t\tinstance = @factory.instantiate_transformed(node)\n\t\tmetaclass = instance.class\n\t\tmetaclass.ecore.eAllAttributes.each do |attr|\n\t\t\tpopulate_attr(node,attr,instance)\n\t\tend\n\t\... | [
"0.5833564",
"0.56044257",
"0.5586835",
"0.5562701",
"0.5546754",
"0.554131",
"0.55039716",
"0.5457295",
"0.5360595",
"0.52798563",
"0.5271179",
"0.5258607",
"0.5215591",
"0.52146006",
"0.52047265",
"0.5188132",
"0.51628274",
"0.5159342",
"0.5098895",
"0.5082334",
"0.5082334"... | 0.6260259 | 0 |
Generate the HTML report for the Scan | def html_report
begin
require 'ruport'
rescue LoadError
abort("Couldn't load ruport, suggest that gem install ruport should help")
end
unless @options.report_file
html_report_file_name = 'Kismet-Wireless-Report-' + Time.now.to_s + '.html'
end
unless @options.report_file =~ /h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_scan_report\n freshclam_stderr = IO.read($config[\"freshclam_stderr\"])\n freshclam_stdout = @freshclam_stdout\n template = IO.read(\"views/clamav.html.erb\")\n output = ERB.new(template).result(binding)\n File.open(\"clamav.html\", \"w\") {|file| file.write(output)}\nend",
"def output_report\n... | [
"0.74271506",
"0.7393127",
"0.7189573",
"0.7033436",
"0.7022559",
"0.7022559",
"0.7022559",
"0.7022559",
"0.7022559",
"0.69930935",
"0.6981009",
"0.696098",
"0.6942693",
"0.6930092",
"0.6929381",
"0.6885061",
"0.6865236",
"0.67651916",
"0.6759264",
"0.6730457",
"0.6719262",
... | 0.7743368 | 0 |
Sets up the HTML report header. CSS and Javascript for the Google Maps Option | def html_report_header
@report << '
<html>
<head>
<title> Kismet Wireless Report</title>
<style>
body {
font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
color: #4f6b72;
background: #E6EAE9;
}
#report-header {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header()\n if @api_key\n \"<script src=\\\"http://maps.google.com/maps?file=api&v=2&key=#{@api_key}\\\" type=\\\"text/javascript\\\"></script>\"\n else\n \"<!-- Google Map Header requires a valid api. Please add the api key to the relevant code calls. -->\"\n end\n end",... | [
"0.643799",
"0.61146224",
"0.60882235",
"0.60864824",
"0.59782887",
"0.5968217",
"0.59363127",
"0.5921589",
"0.5841794",
"0.58338255",
"0.57765985",
"0.57697207",
"0.57680744",
"0.57494533",
"0.5705583",
"0.56978935",
"0.5579585",
"0.55414575",
"0.553895",
"0.5527923",
"0.551... | 0.78838706 | 0 |
creates the report section for Infrastructure Networks | def html_report_inf
@report << '<div id="title">Infrastructure Networks</div><br /><br />'
@log.debug("Starting reporting Infrastructure networks there were " + @infrastructure_networks.length.to_s + " networks to list")
@infrastructure_networks.each do |ssid,bssid|
tab = Ruport::Data::Table(%w[bssid ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def network_report\n get_resource_list('network', 'v2.0/networks', 'networks')\n @network_csv_array = []\n @network_print_array = []\n @resource_id_list.each do |networkid|\n network = rest_get(\"#{@resource_url}/v2.0/networks/#{networkid}\", @token_id)\n network_array = JSON.parse(network)['... | [
"0.70572907",
"0.6266153",
"0.5928026",
"0.58000946",
"0.57995605",
"0.55592734",
"0.55405647",
"0.5443282",
"0.5390088",
"0.53755814",
"0.5340762",
"0.53404087",
"0.5275468",
"0.5241324",
"0.52379274",
"0.5229627",
"0.52271503",
"0.52072716",
"0.52032423",
"0.51805854",
"0.5... | 0.7079021 | 0 |
Sets up the HTML report for AdHoc Networks | def html_report_adhoc
@log.debug("Starting to report ad-hoc networks, there were " + @adhoc_networks.length.to_s + "to report")
@report << '<div id="title">Adhoc Networks</div><br /><br />'
@adhoc_networks.each do |ssid,bssid|
tab = Ruport::Data::Table(%w[bssid channel cipher cloaked? manufacturer fir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_report_inf\n @report << '<div id=\"title\">Infrastructure Networks</div><br /><br />'\n @log.debug(\"Starting reporting Infrastructure networks there were \" + @infrastructure_networks.length.to_s + \" networks to list\")\n @infrastructure_networks.each do |ssid,bssid|\n tab = Ruport::Data::... | [
"0.7459221",
"0.7118371",
"0.67816055",
"0.66127026",
"0.65719134",
"0.6269927",
"0.61325306",
"0.59784055",
"0.59327596",
"0.590996",
"0.58450633",
"0.58182484",
"0.5807827",
"0.5747814",
"0.57115436",
"0.5679135",
"0.5674424",
"0.56657",
"0.565188",
"0.565188",
"0.565188",
... | 0.7710169 | 0 |
Sets up the report for Probe Networks | def html_report_probe
@log.debug("Starting to report probe networks, there were " + @probe_networks.length.to_s + " to report")
@report << '<div id="title">Probe Networks</div><br /><br />'
@probe_tab = Ruport::Data::Table(%w[bssid manufacturer])
@probe_networks.each do |probe,info|
if @options.gp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_report_inf\n @report << '<div id=\"title\">Infrastructure Networks</div><br /><br />'\n @log.debug(\"Starting reporting Infrastructure networks there were \" + @infrastructure_networks.length.to_s + \" networks to list\")\n @infrastructure_networks.each do |ssid,bssid|\n tab = Ruport::Data::... | [
"0.6425803",
"0.6419864",
"0.5954142",
"0.5897921",
"0.581064",
"0.5745984",
"0.56856745",
"0.56772435",
"0.5655869",
"0.5655869",
"0.5655869",
"0.5655869",
"0.5655869",
"0.5594677",
"0.5581363",
"0.55392957",
"0.5489171",
"0.5442158",
"0.5414202",
"0.54055125",
"0.53828084",... | 0.7133374 | 0 |
GET /time_gliders/1 GET /time_gliders/1.xml | def show
@time_glider = TimeGlider.find(params[:id])
respond_to do |format|
format.html # show.html.erb
# we do not want to use this
# format.json { render :json => @time_glider }
# because we want to change the json output of a few fields
format.json # show.json.erb
format... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @time_glider = TimeGlider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @time_glider }\n end\n end",
"def stats\n @stats = time_data Gig.all\n\n respond_to do |format|\n format.html # stats.html.erb\n format.json { render ... | [
"0.64867616",
"0.5644373",
"0.55338675",
"0.5528827",
"0.5517569",
"0.5443626",
"0.5425797",
"0.5420775",
"0.53689706",
"0.53624874",
"0.5358312",
"0.5348056",
"0.5347751",
"0.53411824",
"0.5337852",
"0.53374267",
"0.5333507",
"0.53092635",
"0.5306529",
"0.5298561",
"0.528250... | 0.59750324 | 1 |
GET /time_gliders/new GET /time_gliders/new.xml | def new
@time_glider = TimeGlider.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @time_glider }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @time_glider = TimeGlider.new(params[:time_glider])\n\n respond_to do |format|\n if @time_glider.save\n format.html { redirect_to(@time_glider, :notice => 'Time glider was successfully created.') }\n format.xml { render :xml => @time_glider, :status => :created, :location => ... | [
"0.6850216",
"0.67855483",
"0.6704627",
"0.6657454",
"0.66228974",
"0.6522187",
"0.6490332",
"0.64871544",
"0.64809793",
"0.64335716",
"0.64267844",
"0.6410622",
"0.6407993",
"0.6407993",
"0.6391954",
"0.63864774",
"0.63755167",
"0.6365471",
"0.6358798",
"0.63340455",
"0.6331... | 0.76628387 | 0 |
POST /time_gliders POST /time_gliders.xml | def create
@time_glider = TimeGlider.new(params[:time_glider])
respond_to do |format|
if @time_glider.save
format.html { redirect_to(@time_glider, :notice => 'Time glider was successfully created.') }
format.xml { render :xml => @time_glider, :status => :created, :location => @time_glide... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @time_glider = TimeGlider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @time_glider }\n end\n end",
"def update\n @time_glider = TimeGlider.find(params[:id])\n\n respond_to do |format|\n if @time_glider.update_attributes(param... | [
"0.5996065",
"0.5393736",
"0.5320517",
"0.51162815",
"0.51122725",
"0.5108098",
"0.50843936",
"0.50840205",
"0.5058225",
"0.4985661",
"0.4940659",
"0.49380693",
"0.49276495",
"0.49202567",
"0.48934117",
"0.48835707",
"0.4879454",
"0.48536125",
"0.48367503",
"0.4827365",
"0.48... | 0.6775461 | 0 |
PUT /time_gliders/1 PUT /time_gliders/1.xml | def update
@time_glider = TimeGlider.find(params[:id])
respond_to do |format|
if @time_glider.update_attributes(params[:time_glider])
format.html { redirect_to(@time_glider, :notice => 'Time glider was successfully updated.') }
format.xml { head :ok }
else
format.html { ren... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @time_glider = TimeGlider.new(params[:time_glider])\n\n respond_to do |format|\n if @time_glider.save\n format.html { redirect_to(@time_glider, :notice => 'Time glider was successfully created.') }\n format.xml { render :xml => @time_glider, :status => :created, :location => ... | [
"0.6031941",
"0.5655149",
"0.5546752",
"0.553929",
"0.55168533",
"0.5471335",
"0.54589915",
"0.5418488",
"0.54001623",
"0.5378956",
"0.5320338",
"0.5287878",
"0.52556497",
"0.52540624",
"0.524614",
"0.5237099",
"0.5237099",
"0.5237099",
"0.5223671",
"0.52046907",
"0.5201099",... | 0.6973037 | 0 |
DELETE /time_gliders/1 DELETE /time_gliders/1.xml | def destroy
@time_glider = TimeGlider.find(params[:id])
@time_glider.destroy
respond_to do |format|
format.html { redirect_to(time_gliders_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @daily_grr = DailyGrr.find(params[:id])\n @daily_grr.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_daily_grrs_url) }\n format.xml { head :ok }\n end\n end... | [
"0.6471717",
"0.6219426",
"0.6209912",
"0.6202102",
"0.6158696",
"0.6150239",
"0.6057133",
"0.6049501",
"0.60351384",
"0.6016927",
"0.6010317",
"0.59923416",
"0.5958226",
"0.5954747",
"0.59516615",
"0.5942058",
"0.5929864",
"0.59114844",
"0.590835",
"0.59064096",
"0.58981824"... | 0.6922482 | 0 |
Use email as a search term to set the delegate_user | def find_email
val = @email
return if val.nil?
val = LdapQuery::Scanner.search(val).as_user_attributes[:email]
if val.nil?
errors.add :base, 'Email address not found'
return false
end
@email = val
xdelegate = User.find_by_email(val.to_s)
if xdelegate.nil?
errors... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_email(email = nil, email_selector = nil, ldap_lookup = nil)\n self.email = email || []\n if email_selector\n # Get the primary email address from the address list\n self.primary_email = email_selector.email(self.email)\n # Get the username from the primary... | [
"0.69874704",
"0.66270804",
"0.66270804",
"0.618256",
"0.6155082",
"0.6143417",
"0.6138992",
"0.61259073",
"0.6120344",
"0.6106986",
"0.6105193",
"0.6094031",
"0.6037938",
"0.601037",
"0.6009788",
"0.5985284",
"0.5985284",
"0.59808785",
"0.5973629",
"0.594316",
"0.594316",
... | 0.6881379 | 1 |
Overrides auth_handler= so if the authentication changes, the session cookie is cleared. | def auth_handler=(handler)
@session_cookie = nil
return super(handler)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_logout\n reset_session\n end",
"def handle_unverified_request\n super # call the default behaviour which resets the session\n cookies.delete(:remember_token)\n redirect_to :login\n end",
"def unobtrusively_authenticate_user!\n if cookies[:user_uid]\n set_user_session_from_c... | [
"0.66596895",
"0.6402066",
"0.63947856",
"0.63805807",
"0.6358268",
"0.63407105",
"0.6339492",
"0.6312544",
"0.63111037",
"0.63054043",
"0.6297264",
"0.6264113",
"0.6238354",
"0.621536",
"0.6194207",
"0.6162307",
"0.61618036",
"0.61444145",
"0.61423296",
"0.61218655",
"0.6108... | 0.86241615 | 0 |
Overrides make_request to handle 302 redirects with a session cookie. | def make_request(method, url, body = '', retries = 4)
response = super(method, url, body)
if response.status_code == 302 and retries > 0
@session_cookie = response.headers['set-cookie']
return self.make_request(method, url, body,
retries - 1)
else
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to(url)\n unless already_built_response?\n @res[\"location\"] = url\n @res.status = 302\n @already_built_response = true\n else\n fail\n end\n session.store_session(res)\n end",
"def redirect_to(url)\n self.res.status = 302\n #how would I know about location\n ... | [
"0.6412441",
"0.6408488",
"0.63788223",
"0.63478845",
"0.63209844",
"0.63020784",
"0.61808676",
"0.61748534",
"0.6166617",
"0.6151097",
"0.61457163",
"0.6100367",
"0.6086163",
"0.60827416",
"0.60687",
"0.6057229",
"0.6051553",
"0.6028398",
"0.6012906",
"0.5994556",
"0.5976894... | 0.74002177 | 0 |
Custom prepare_headers to include the session cookie if it exists | def prepare_headers
if @session_cookie
@headers['cookie'] = @session_cookie
end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_to_headers\n unless @session.nil?\n response.headers['sid'] = @session.id\n response.headers['utoken'] = @session.utoken\n end\n end",
"def set_headers! session = nil\n response.headers['sid'] = session.id\n response.headers['utoken'] = session.utoken\n end",
"def request_heade... | [
"0.71643215",
"0.7054277",
"0.6570502",
"0.6477382",
"0.64709556",
"0.6415803",
"0.6275893",
"0.62065095",
"0.6184406",
"0.6075642",
"0.5982159",
"0.58962125",
"0.5852985",
"0.5823074",
"0.5819162",
"0.5806698",
"0.5806698",
"0.5801525",
"0.57906514",
"0.57838815",
"0.5775405... | 0.8758742 | 0 |
Method that test the dark roast class | def test_dark_roast
beverage = DarkRoast.new
beverage = Milk.new(beverage)
beverage = Mocha.new(beverage)
beverage = Mocha.new(beverage)
beverage = Whip.new(beverage)
assert_equal("Dark Roast Coffee, Milk, Mocha, Mocha, Whip",
beverage.description)
assert_equal(1.59, beverag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dark_roast\n beverage = DarkRoast.new\n beverage = Milk.new(beverage)\n beverage = Mocha.new(beverage)\n beverage = Mocha.new(beverage)\n beverage = Whip.new(beverage)\n assert_equal(\"Dark Roast Coffee, Milk, Mocha, Mocha, Whip\", \n beverage.... | [
"0.6940778",
"0.69158936",
"0.6380528",
"0.63674176",
"0.628433",
"0.6283115",
"0.62816167",
"0.62688184",
"0.6238262",
"0.6223462",
"0.62120193",
"0.6193525",
"0.61556214",
"0.61370224",
"0.61171836",
"0.6112152",
"0.61099803",
"0.607291",
"0.60441893",
"0.5992969",
"0.59918... | 0.69537795 | 0 |
Method that test the house blend class | def test_house_blend
beverage = HouseBlend.new
beverage = Soy.new(beverage)
beverage = Mocha.new(beverage)
beverage = Whip.new(beverage)
assert_equal("House Blend Coffee, Soy, Mocha, Whip",
beverage.description)
assert_equal(1.34, beverage.cost)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_house_blend\n beverage = HouseBlend.new\n beverage = Soy.new(beverage)\n beverage = Mocha.new(beverage)\n beverage = Whip.new(beverage)\n assert_equal(\"House Blend Coffee, Soy, Mocha, Whip\", \n beverage.description)\n assert_equal(1.34, bever... | [
"0.7500098",
"0.74448866",
"0.62738144",
"0.62115896",
"0.6183764",
"0.6183764",
"0.6019236",
"0.59566027",
"0.591663",
"0.59158957",
"0.58785987",
"0.5853097",
"0.58238006",
"0.57870084",
"0.5742406",
"0.5681121",
"0.56789",
"0.56710964",
"0.5643395",
"0.5639998",
"0.5627904... | 0.7451167 | 1 |
Problem Write a method that takes an Array of integers as input, multiplies all the numbers together, divides the result by the number of entries in the Array, and then prints the result rounded to 3 decimal places. Assume the array is nonempty. Examples / Test Cases show_multiplicative_average([3, 5]) The result is 7.... | def show_multiplicative_average(array)
multiplied = array.reduce(:*)
average = multiplied / array.size.to_f
average.round(3)
#sprintf('%.3f', average )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_multiplicative_average(array)\n puts \"The result is #{format(\"%.3f\", array.reduce(:*)/array.size.to_f)}\"\nend",
"def show_multiplicative_average(array)\n result = (array.reduce(:*)) / array.size.to_f\n puts \"The result is #{format('%.3f' , result)}\"\nend",
"def show_multiplicative_average(arr... | [
"0.87578464",
"0.87400395",
"0.87395257",
"0.8719481",
"0.86959255",
"0.8692669",
"0.8691379",
"0.8682652",
"0.8658637",
"0.86493474",
"0.86429405",
"0.8636765",
"0.86268735",
"0.86236095",
"0.86151755",
"0.8614212",
"0.85903275",
"0.8578553",
"0.85757315",
"0.85649025",
"0.8... | 0.88321674 | 0 |
Returner enrollment type for en seksjon s | def getEnrollmentType(s)
# //The enrollment type. One of 'StudentEnrollment', 'TeacherEnrollment',
# //'TaEnrollment', 'DesignerEnrollment', 'ObserverEnrollment'.
# "type": "StudentEnrollment",
type = ""
case s["type"]
when "StudentEnrollment"
type = "student"
when "TeacherEnrollment"
type = "teac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enrollment_class\n (params[:enrollment].blank? || params[:enrollment][:type].blank? ? 'Enrollment' : params[:enrollment][:type]).constantize\n end",
"def enrollment_code_for(subject)\n Enrollment.find(:first, :conditions => {\n :user_id => self.id, :school_id => subject.school.id\n }).enrollme... | [
"0.7187711",
"0.63840365",
"0.6271871",
"0.6170893",
"0.6142005",
"0.6110634",
"0.6069084",
"0.5920033",
"0.5822918",
"0.5783087",
"0.5783087",
"0.5761107",
"0.5754447",
"0.5754272",
"0.57431734",
"0.5708474",
"0.5702752",
"0.5690099",
"0.5678745",
"0.5657737",
"0.5630255",
... | 0.7800354 | 1 |
Returner en liste av enrollments i seksjon sid. | def getEnrollmentsInSection(sid)
uri = sprintf("/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999", sid)
enrollments = $canvas.get(uri)
return enrollments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n set_enrolment\n if @enrolment\n @student_ids = @enrolment.student_ids\n else\n @student_ids = StudentId.all\n @notice = \"Displaying All Ids\"\n end\n end",
"def lasids\n render json: Student.all.pluck(:local_id) # not just active students\n end",
"def lasids\n re... | [
"0.64046454",
"0.6375124",
"0.6124821",
"0.5792812",
"0.570467",
"0.5677944",
"0.566025",
"0.5618372",
"0.5605166",
"0.55899096",
"0.5575739",
"0.55582684",
"0.55582684",
"0.5548243",
"0.55336076",
"0.55238193",
"0.55145574",
"0.55104864",
"0.55036575",
"0.5492298",
"0.547550... | 0.66680396 | 1 |
Create all screenshots for the Scrollytelling. | def create_all!
if title_card_path.exist?
Dir
.glob(story.screenshots.join("*page*.png"))
.sort_by { |path| path.scan(/\d+/).first.to_i }
.each do |path|
path.slice! File.extname(path) # drop the extension
@paths[:pages] << absolute(path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_screenshot\n Logbook.step('Taking a screenshot of a result page')\n @browser.save_screenshot(\"screenshots/screenshot - #{Time.now.strftime('%Y-%m-%d %H-%M-%S')}.png\")\n end",
"def screenshots(num_thumbnail_imgs)\n puts \"transcoded_movie thumbnail generation\"\n\t puts \"number of thumbna... | [
"0.66667306",
"0.6413551",
"0.6410283",
"0.64075047",
"0.6378417",
"0.6340471",
"0.63272524",
"0.62717605",
"0.62142974",
"0.619407",
"0.6190998",
"0.61683434",
"0.6149247",
"0.6093941",
"0.6066227",
"0.6037011",
"0.6013504",
"0.60011125",
"0.5875355",
"0.58747476",
"0.587082... | 0.6589683 | 1 |
Constructor > Get the listing details to be submitted in the given site | def initialize(listingDetails, site_url,login_details)
@site_details = listingDetails
@login_details = login_details
@site_url = site_url
@browser = Watir::Browser.new :chrome
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(name = \"\", url = \"\")\n @name = name\n @url = url\n @details = details\n scrape_details\n end",
"def fetch_listing\n districts = district_name_and_permalink_hash \n district_permalink = districts.fetch(district.name) { \n raise \"Whoa, cannot fetch listing,-- #{district.... | [
"0.6319154",
"0.6185045",
"0.61180764",
"0.60874146",
"0.60528314",
"0.6025864",
"0.59889686",
"0.5944641",
"0.5940689",
"0.5903633",
"0.58727425",
"0.5871586",
"0.5868298",
"0.5848401",
"0.5848401",
"0.5848401",
"0.5848401",
"0.57953566",
"0.5791074",
"0.57460856",
"0.574608... | 0.64471674 | 0 |
Delivers this payload to CrashLog Captures any exceptions and logs them. | def deliver!
deliver
rescue Exception => e
error('Failed to deliver notification to CrashLog collector')
log_exception(e)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processCrash; raise \"Abstract Exception: AbstractBeezwaxCrashProcessor.processCrash must be extended\"; end",
"def call(env)\n super\n rescue\n logger.error do\n \"#{$!.class.name} - #{$!.message} (#{$!.backtrace.first})\"\n end\n raise\n end",
"def rescuer\n... | [
"0.60967845",
"0.53365004",
"0.52355564",
"0.5174961",
"0.5152744",
"0.51387566",
"0.5121802",
"0.511532",
"0.51037663",
"0.5096618",
"0.5059202",
"0.5047573",
"0.5032194",
"0.50313455",
"0.49913314",
"0.4985346",
"0.49847648",
"0.49829665",
"0.49736038",
"0.49377817",
"0.493... | 0.607135 | 1 |
Takes a Community model and Plan entity. Returns a Hash in a form that MarketplaceRouter expects | def community_hash(community, plan)
Maybe(community).map { |c|
{
ident: c.ident,
domain: c.domain,
deleted: c.deleted?,
use_domain: c.use_domain?,
closed: Maybe(plan)[:closed].or_else(false),
hold: Maybe(plan)[:hold].or_else(false),
}
}.or_else(nil)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plan_params plan\n {\n name: plan.name,\n plan_id: plan.id,\n status: plan.status,\n chargebee_data: {\n price: plan.price,\n period: plan.period,\n period_unit: plan.period_unit,\n trial_period: plan.trial_period,\n trial_period_unit: plan.trial_period... | [
"0.6311829",
"0.5731611",
"0.5377128",
"0.5279702",
"0.5257567",
"0.52156913",
"0.5193629",
"0.51771855",
"0.5172494",
"0.5156871",
"0.5121325",
"0.5119473",
"0.511445",
"0.5104381",
"0.5090695",
"0.50836575",
"0.506335",
"0.50598586",
"0.50523263",
"0.5048519",
"0.5013052",
... | 0.64264363 | 0 |
GET /private_album_images GET /private_album_images.json | def index
@private_album_images = PrivateAlbumImage.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])}\n end\n end",
"def index\n @pictures = @album.pictures #JRD111115\n\n respond_to do |format|\n format.html #index.html.erb\n ... | [
"0.7502345",
"0.7087396",
"0.7041099",
"0.69735765",
"0.69724345",
"0.69284165",
"0.69117075",
"0.68325365",
"0.68223506",
"0.67660177",
"0.6761047",
"0.67549884",
"0.6751878",
"0.6743444",
"0.6694305",
"0.6693801",
"0.66898006",
"0.66894794",
"0.6686694",
"0.6685078",
"0.667... | 0.7814888 | 0 |
POST /private_album_images POST /private_album_images.json | def create
@private_album_image = PrivateAlbumImage.new(private_album_image_params)
respond_to do |format|
if @private_album_image.save
format.html { redirect_to @private_album_image, notice: 'Private album image was successfully created.' }
format.json { render action: 'show', status: :c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @album = Album.new(params[:album])\n \n respond_to do |format|\n images = [params[:images]].flatten\n @album.images << Image.find(images) unless images[0].nil?\n \n if @album.save\n format.html { redirect_to(albums_path, :notice => 'Album was successfully created.')... | [
"0.70358884",
"0.6958725",
"0.68498844",
"0.68260425",
"0.6766401",
"0.6743341",
"0.661099",
"0.6588316",
"0.6468611",
"0.6462717",
"0.6452367",
"0.64280766",
"0.64179707",
"0.64128506",
"0.6407221",
"0.64051026",
"0.639881",
"0.63375807",
"0.6289237",
"0.62540025",
"0.623817... | 0.70301104 | 1 |
PATCH/PUT /private_album_images/1 PATCH/PUT /private_album_images/1.json | def update
respond_to do |format|
if @private_album_image.update(private_album_image_params)
format.html { redirect_to @private_album_image, notice: 'Private album image was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @album = Album.find(params[:id])\n \n respond_to do |format|\n if @album.update_attributes(params[:album])\n @album.images.clear\n @album.images << Image.find([params[:images]].flatten)\n @album.save!\n format.html { redirect_to(albums_path, :notice => 'Album ... | [
"0.73571384",
"0.7031816",
"0.69092375",
"0.6908788",
"0.687213",
"0.6820628",
"0.6749838",
"0.6691485",
"0.6640333",
"0.66399324",
"0.6630723",
"0.662082",
"0.66140354",
"0.6613091",
"0.6589555",
"0.6547795",
"0.65395373",
"0.6498759",
"0.6474465",
"0.6465543",
"0.6448792",
... | 0.72819173 | 1 |
DELETE /private_album_images/1 DELETE /private_album_images/1.json | def destroy
@private_album_image.destroy
respond_to do |format|
format.html { redirect_to private_album_images_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n \t@album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @private_album.destroy\n respond_to do |form... | [
"0.75851434",
"0.7518786",
"0.7511975",
"0.75039047",
"0.7412196",
"0.7358814",
"0.7337884",
"0.7320177",
"0.73031056",
"0.7298864",
"0.7291708",
"0.72791886",
"0.7259161",
"0.7238636",
"0.7218582",
"0.7206611",
"0.7185427",
"0.71839875",
"0.7149847",
"0.7126101",
"0.7126075"... | 0.8040722 | 0 |
Internal: Determine what clock to use for the machine we are one. We want the highest resolution clock possible, which should be nanosecond resolution. Get the resolution of each clock id and then return the higest resolution id from the list Returns the clock id to use on this ruby | def determine_clock_id
ids_and_resolutions = potential_clock_ids.map { |clock_id|
[clock_id, Process.clock_getres(clock_id)]
}
# Sort them by the resolution - we want the smallest one first
ids_and_resolutions.sort_by! { |pair| pair[1] }
return ids_and_resolutions.first[0]
en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clock24_to_clock_sec(clock)\n check_pre((clock.clock24?))\n ClockSec[(clock.hour*HOUR_IN_SEC) + (clock.min*MIN_IN_SEC) + clock.sec]\nend",
"def parent_clock\n buffer = \"\\0\" * SIZEOF_LONG_LONG\n FMOD.invoke(:ChannelGroup_GetDSPClock, self, nil, buffer)\n buffer.unpack1('Q')\n end",
... | [
"0.5930892",
"0.5863771",
"0.58601826",
"0.5806299",
"0.5741912",
"0.57043856",
"0.5542434",
"0.5510987",
"0.5494828",
"0.54886955",
"0.5431437",
"0.5416595",
"0.5387152",
"0.5268263",
"0.5256649",
"0.5221533",
"0.52164114",
"0.51807314",
"0.5171924",
"0.5111444",
"0.509691",... | 0.8332264 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.