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 |
|---|---|---|---|---|---|---|
PATCH/PUT /air_moistures/1 PATCH/PUT /air_moistures/1.json | def update
respond_to do |format|
if @air_moisture.update(air_moisture_params)
format.html { redirect_to @air_moisture, notice: 'Air moisture was successfully updated.' }
format.json { render :show, status: :ok, location: @air_moisture }
else
format.html { render :edit }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @mile.update(mile_params)\n format.html { redirect_to @mile, notice: 'Mile was succes... | [
"0.6274479",
"0.62224776",
"0.6215002",
"0.61873496",
"0.6130231",
"0.61201",
"0.6114338",
"0.60977507",
"0.6090425",
"0.6045212",
"0.60351163",
"0.60275054",
"0.5998368",
"0.59876174",
"0.598102",
"0.5971419",
"0.596839",
"0.59681946",
"0.59681946",
"0.59334207",
"0.5931079"... | 0.67266005 | 0 |
DELETE /air_moistures/1 DELETE /air_moistures/1.json | def destroy
@air_moisture.destroy
respond_to do |format|
format.html { redirect_to air_moistures_url, notice: 'Air moisture was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @soil_moisture.destroy\n respond_to do |format|\n format.html { redirect_to soil_moistures_url, notice: 'Soil moisture was successfully ... | [
"0.7003927",
"0.70035815",
"0.69732076",
"0.695011",
"0.6943842",
"0.6917684",
"0.6902483",
"0.6899357",
"0.6897867",
"0.68952644",
"0.68856806",
"0.68581945",
"0.6854098",
"0.6851745",
"0.6819654",
"0.68140924",
"0.68092847",
"0.6798806",
"0.679734",
"0.678996",
"0.6787179",... | 0.72552097 | 0 |
show stops for line | def show_stops(lines, line1)
lines.each do |line|
if line[:lines] == line1
puts line[:stops]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLineStops (l)\n @lines[l][:stops]\nend",
"def get_line_stops(lines, origin_line)\n lines[origin_line.to_sym]\nend",
"def draw_line\n print H_SEP * columns\n end",
"def list_stops(line)\n puts line\n return \"all the stops on a line\"\nend",
"def draw_alt_line\n @dim.times do |i|\n if... | [
"0.6607579",
"0.6488185",
"0.6245445",
"0.6132525",
"0.6111507",
"0.6092206",
"0.6056067",
"0.5993023",
"0.5974445",
"0.59705985",
"0.5965411",
"0.59442824",
"0.5943782",
"0.59269977",
"0.5841553",
"0.58251005",
"0.57955676",
"0.57708865",
"0.5755447",
"0.57397103",
"0.569606... | 0.6886917 | 0 |
Search through provided list of trips and filter optionally by service_id and route_id | def search_trips(trips, opts = {})
service_id = opts[:service_id]
route_id = opts[:route_id]
service_id ||= 'S1'
valid_trips = trips.select { |trip|
trip[:service_id].eql? service_id
}
trips_with_route = valid_trips.select{ |trip|
if !route_id.nil? ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def trips_by_route_id(route_id)\n get \"/gtfs/trips/routeid/#{route_id}\"\n end",
"def trips\n Trip.all.filter do |trip|\n trip.listing == self\n en... | [
"0.6388643",
"0.6388643",
"0.60504746",
"0.59264445",
"0.58997303",
"0.5855909",
"0.58192116",
"0.5799047",
"0.57825017",
"0.57342863",
"0.57100093",
"0.56728137",
"0.567088",
"0.5621909",
"0.5620392",
"0.5618179",
"0.56052136",
"0.5541512",
"0.5539852",
"0.5518571",
"0.55021... | 0.8140789 | 0 |
Analyze the structure of the HTML document and score content blocks for likelihood of containing useful content | def analyze
opt = DEFAULTS.clone
opt.merge!(@options)
@sections = []
factor = continuous = 1.0
body = ''
score = 0
# The content is split into blocks of divs
list = @raw_content.split(/<\/?(?:div)[^>]*>/)
list.each do |block|
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate_content(content)\n contents = Hash.new\n for i in 0...content.size\n contents[\"#{i}\"] = 0.0\n\n # chceking if div does not contain whole document\n contents[\"#{i}\"] += -20 if content[i].to_s.lines.count > @@lines*0.95\n\n # rating contents for tags they contain\n content... | [
"0.71152675",
"0.61536187",
"0.6008303",
"0.5928885",
"0.5910866",
"0.58664024",
"0.5846169",
"0.5725032",
"0.57192284",
"0.55903924",
"0.5530526",
"0.5488424",
"0.5479663",
"0.547885",
"0.54749924",
"0.53934646",
"0.5374359",
"0.5365443",
"0.5345734",
"0.5332543",
"0.5323156... | 0.7070175 | 1 |
Checks if the given block has only tags without text. | def has_only_tags?(block)
block.gsub(/<[^>]*>/im, '').strip.length == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_paragraph_tag?(text)\n text !~ /^\\<p/\n end",
"def no_paragraph_tag?(text)\n text !~ /^\\<p/\n end",
"def element_is_text?\n !self[:is_tag]\n end",
"def should_spit_text?\n @tags_chain.size > 0 && \n #(not @text.empty?) &&\n [\"body\", \"p\", \"br\", \... | [
"0.6701398",
"0.6701398",
"0.66280824",
"0.63980025",
"0.62248796",
"0.6039487",
"0.5998476",
"0.58188146",
"0.5800965",
"0.5753922",
"0.5720263",
"0.57176304",
"0.5709449",
"0.5692271",
"0.56789213",
"0.565085",
"0.5638347",
"0.5638347",
"0.56019056",
"0.55812377",
"0.557687... | 0.86452794 | 0 |
Eliminates link heavy blocks and blocks that are lists of links and then returns block stripped of tags | def clean_block(block)
# Return empty block if it is a list of links
return "" if is_link_list?(block)
# Return empty block if it is a very link heavy block
count = 0
no_links = block.gsub(/<a\s[^>]*>.*?<\/a\s*>/im){count+=1;''}.gsub(/<form\s[^>]*>.*?<\/form\s*>/im, '')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_links(html); end",
"def strip_links(html); end",
"def strip_links(html); end",
"def remove_links(block)\n inline_block = block.gsub(LINK_PATTERN) do |s|\n url = URL_PATTERN.match(s)[2]\n extension = File.extname(url)\n /\\.js|\\.css/.match(extension) && !URI.... | [
"0.6566711",
"0.6566711",
"0.6566711",
"0.6559199",
"0.6457174",
"0.63547766",
"0.62854224",
"0.6244661",
"0.6109296",
"0.6030028",
"0.6029686",
"0.59956944",
"0.59488803",
"0.59488803",
"0.59488803",
"0.5935917",
"0.58676153",
"0.5801457",
"0.57909024",
"0.5735019",
"0.57316... | 0.78719556 | 0 |
Determines whether a block is link list or not | def is_link_list?(st)
if st =~ /<(?:ul|dl|ol)(.+?)<\/(?:ul|dl|ol)>/im
listpart = $1
outside = st.gsub(/<(?:ul|dl)(.+?)<\/(?:ul|dl)>/imn, '').gsub(/<.+?>/mn, '').gsub(/\s+/, ' ')
list = listpart.split(/<li[^>]*>/)
list.shift
rate = evaluate_list(list)
o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_link?\n [1,2].include?(link_type)\n end",
"def is_linktype?(); @type == GRT_LINKTYPE; end",
"def link?\n !link.nil? && !link.empty?\n end",
"def link?\n !link.nil? && !link.empty?\n end",
"def linked?\n return BlizzABS::Alignments::LINKED_GROUPS.include?(@group)\n ... | [
"0.6915274",
"0.66692495",
"0.6214611",
"0.6214611",
"0.6208301",
"0.6073194",
"0.60092074",
"0.59285074",
"0.5898732",
"0.58811426",
"0.5844004",
"0.58385414",
"0.583644",
"0.58260036",
"0.581676",
"0.58014876",
"0.5760968",
"0.5760968",
"0.5759168",
"0.5751555",
"0.57247365... | 0.6971343 | 0 |
We might have to remove certain characters, but for now we just CGI.escape it and remove any periods | def clean_name(name)
CGI.escape(name).gsub('.', '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize(name)\n #name.gsub(\".\", \"_\").gsub(/<.+>/, \"\")\n name.gsub(\".\", \"_\").gsub(\"$\", \"_\")\nend",
"def cgi_escape(input); end",
"def safe(str)\n CGI.unescape(str)\n end",
"def sanitize_as_filename\n self.gsub(/^.*(\\\\|\\/)/, '').transliterate.downcase.gsub(/[^a-z0-9\\. ]/, ' ... | [
"0.7022107",
"0.666911",
"0.6618527",
"0.65766394",
"0.64787436",
"0.642227",
"0.6407414",
"0.63973",
"0.6377207",
"0.63030505",
"0.629229",
"0.6253363",
"0.62434715",
"0.6239274",
"0.6201699",
"0.61980134",
"0.6189996",
"0.615272",
"0.61382097",
"0.613641",
"0.611482",
"0.... | 0.74023795 | 0 |
createsa minimal openurl to make a new request to umlaut | def create_openurl(request, wh)
metadata = request.referent.metadata
co = OpenURL::ContextObject.new
cor = co.referent
cor.set_format(wh['record_type'])
cor.add_identifier("info:oclcnum/#{wh['oclcnum']}")
cor.set_metadata('aulast', metadata['aulast'] ) if metadata['aulast']
cor.set_meta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def openurl(url)\n runcmd 'openurl', url\n end",
"def open_url\n opts = [config.oui_full_url]\n opts << { 'User-Agent' => config.user_agent } if config.user_agent\n open(*opts).read\n rescue OpenURI::HTTPError\n ''\n end",
"def autoname_url(url)\n request('POST', @uri.request_uri, ... | [
"0.6623941",
"0.65541255",
"0.6551269",
"0.64429736",
"0.6367715",
"0.6367715",
"0.63302237",
"0.6289301",
"0.6288969",
"0.62307286",
"0.6196741",
"0.6196741",
"0.6196741",
"0.6196741",
"0.6196741",
"0.6196741",
"0.6196741",
"0.617224",
"0.6110351",
"0.6063315",
"0.60149294",... | 0.6584969 | 1 |
We just link to worldcat using the oclc number provided FIXME this might need special partial if we incorporate a cover image | def create_worldcat_widely_held(request, xml)
# try to prevent circular links
top_holding_info = get_widely_held_info(xml)
return nil if circular_link?(request, top_holding_info)
# http://www.worldcat.org/links/
most = top_holding_info['most']
title = top_holding_info['title']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_rdf_catlink(b,ty)\n ul = \"http://catalog.library.cornell.edu/catalog/#{id}\"\n # if no elect access data, 'description' field.\n b.dc(:description,ul)\n end",
"def category\n path = @path_remote.split('/')\n return path[3] # Could require changes depending on the structure of the m... | [
"0.58421445",
"0.57172924",
"0.54939795",
"0.54489636",
"0.5408253",
"0.5284518",
"0.52164835",
"0.5123847",
"0.50671166",
"0.50663817",
"0.50655955",
"0.5063098",
"0.50439924",
"0.5029098",
"0.4994209",
"0.49723473",
"0.4956977",
"0.4947813",
"0.49284944",
"0.49106896",
"0.4... | 0.66617954 | 0 |
Create a new csv differ, this differ can then be used to create a split and a unified view. The raw csv strings are decoded and the csv header is extracted. If the table has more than 100 rows, a simplified version of the table will be rendered this will limit the performance hit of a very long table. | def initialize(generated, expected)
@generated = CSV.parse((generated || '').lstrip, nil_value: '')
@expected = CSV.parse((expected || '').lstrip, nil_value: '')
@gen_headers, *@generated = @generated
@gen_headers ||= []
@exp_headers, *@expected = @expected
@exp_headers ||= []
@simplified_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_build_table(builder, headers, is_generated_output)\n builder.table(class: 'split-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(span: headers.length)\n end\n builder.thead do\n if is_generated_output\n icon_cls =... | [
"0.6365711",
"0.617779",
"0.5809265",
"0.5763582",
"0.5737592",
"0.57320434",
"0.5729515",
"0.567915",
"0.5666242",
"0.5646566",
"0.56349075",
"0.5598919",
"0.55255604",
"0.52926606",
"0.5253105",
"0.52371824",
"0.52362704",
"0.52265257",
"0.5223451",
"0.52117753",
"0.5191535... | 0.63552666 | 1 |
Render a unified table view based on the data passed when creating the CsvDiffer instance. | def unified
builder = Builder::XmlMarkup.new
builder.table(class: 'unified-diff diff csv-diff') do
builder.colgroup do
builder.col(class: 'line-nr')
builder.col(class: 'line-nr')
builder.col(span: @combined_headers.length)
end
builder.thead do
builder.tr do
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_build_table(builder, headers, is_generated_output)\n builder.table(class: 'split-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(span: headers.length)\n end\n builder.thead do\n if is_generated_output\n icon_cls =... | [
"0.6573815",
"0.6189673",
"0.5929262",
"0.58629036",
"0.5862575",
"0.5783196",
"0.5720341",
"0.56802416",
"0.56705254",
"0.56525594",
"0.5648546",
"0.56348133",
"0.56308836",
"0.562267",
"0.56099725",
"0.55963296",
"0.5580589",
"0.55315",
"0.5478361",
"0.54780394",
"0.5438503... | 0.7310779 | 0 |
Render a split table view based on the data passed when creating the CsvDiffer instance. The split view renders two tables, that individually have a horizontal scrollbar. | def split
builder = Builder::XmlMarkup.new
builder.div do
split_build_table(builder, @gen_headers, true)
split_build_table(builder, @exp_headers, false)
end.html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_build_table(builder, headers, is_generated_output)\n builder.table(class: 'split-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(span: headers.length)\n end\n builder.thead do\n if is_generated_output\n icon_cls =... | [
"0.7004308",
"0.6201249",
"0.56568396",
"0.56285596",
"0.55700326",
"0.5349006",
"0.5320473",
"0.5285839",
"0.52177036",
"0.5211179",
"0.5185852",
"0.5173145",
"0.5152573",
"0.51514953",
"0.5122979",
"0.51103246",
"0.5064794",
"0.50607324",
"0.5060666",
"0.50437343",
"0.50365... | 0.65478545 | 1 |
Build one of the two tables of the split table view (see function 'split') | def split_build_table(builder, headers, is_generated_output)
builder.table(class: 'split-diff diff csv-diff') do
builder.colgroup do
builder.col(class: 'line-nr')
builder.col(span: headers.length)
end
builder.thead do
if is_generated_output
icon_cls = 'mdi-file-ac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split\n builder = Builder::XmlMarkup.new\n\n builder.div do\n split_build_table(builder, @gen_headers, true)\n split_build_table(builder, @exp_headers, false)\n end.html_safe\n end",
"def slice(table)\n head, body, array_h, array_b = 4.times.map { [] }\n index = ... | [
"0.7009416",
"0.56848836",
"0.56125796",
"0.555878",
"0.54818606",
"0.5472032",
"0.5456454",
"0.5423256",
"0.5380515",
"0.53663176",
"0.53643316",
"0.534272",
"0.534272",
"0.534272",
"0.534272",
"0.53099674",
"0.52941924",
"0.527488",
"0.5260239",
"0.5258009",
"0.52463865",
... | 0.6669901 | 1 |
Build a simplified version of the unified table body This simplified view combines all rows in a column into 1 row with newlines. The columns are still separate, but the diff is less accurate. | def unified_simple_body(builder)
gen_cols = @generated.transpose.map { |col| col.join("\n") }
builder.tr do
builder.td(class: 'line-nr') do
builder << (1..@generated.length).to_a.join("\n")
end
builder.td(class: 'line-nr')
builder << Array.new(@combined_headers.length) { |i| @ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unified\n builder = Builder::XmlMarkup.new\n builder.table(class: 'unified-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(class: 'line-nr')\n builder.col(span: @combined_headers.length)\n end\n builder.thead do\n buil... | [
"0.7234448",
"0.6947831",
"0.69122547",
"0.6492349",
"0.64286786",
"0.62928003",
"0.62743044",
"0.61191356",
"0.6065495",
"0.6048436",
"0.60426545",
"0.60366195",
"0.6035253",
"0.599704",
"0.5990995",
"0.5968515",
"0.5957089",
"0.5931741",
"0.5895767",
"0.588607",
"0.5869061"... | 0.7181176 | 1 |
Build a simplified version of the split table body This simplified view combines all rows in a column into 1 row with newlines. The columns are still separate, but the diff is less accurate. | def split_simple_body(builder, data, cls)
gen_cols = data.transpose.map { |col| col.join("\n") }
builder.tr do
builder.td(class: 'line-nr') do
builder << (1..data.length).to_a.join("\n")
end
gen_cols.each do |col|
builder.td(class: cls) do
builder << CGI.escape_html(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_build_table(builder, headers, is_generated_output)\n builder.table(class: 'split-diff diff csv-diff') do\n builder.colgroup do\n builder.col(class: 'line-nr')\n builder.col(span: headers.length)\n end\n builder.thead do\n if is_generated_output\n icon_cls =... | [
"0.703649",
"0.66588366",
"0.6583324",
"0.65022963",
"0.64263666",
"0.6323259",
"0.6167681",
"0.60666615",
"0.59544784",
"0.58305293",
"0.5770722",
"0.5667127",
"0.5666934",
"0.5651298",
"0.55769366",
"0.55761003",
"0.5564571",
"0.5550563",
"0.55431837",
"0.54857373",
"0.5461... | 0.6910786 | 1 |
Wrap the row elements (cells) in html td tags. Determine what class to use based on the row chunk action. This way the row will be correctly formatted (eg. green background). | def new_row(chunk)
new_class = {
'-' => '',
'+' => 'ins',
'=' => 'unchanged',
'!' => 'ins'
}[chunk.action]
[new_class.empty?, chunk.new_element.map { |el| %(<td class="#{new_class}">#{el}</td>) }]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_row_helper(cells, opts={})\n if cells[0] == :divider\n # this is not very nice..\n \"<tr><td colspan='#{cells[1]}' class='divider'><div></div></td></tr>\".html_safe\n else\n # Tried making this with content_tag but couldn't get the html_safe to work right... :S\n \"<tr>#{cells.c... | [
"0.73626834",
"0.6815915",
"0.6682152",
"0.66611123",
"0.6319589",
"0.6253161",
"0.61102957",
"0.6108904",
"0.6099915",
"0.60796154",
"0.60580844",
"0.60535693",
"0.6032365",
"0.5991391",
"0.5962249",
"0.5950943",
"0.5949478",
"0.58862174",
"0.58611566",
"0.5829479",
"0.57268... | 0.75109816 | 0 |
Compare the table headers of the generated and expected table. The combined headers is the minimal set of headers that include the generated and expected headers (including duplicates). The indices arrays can be used to map the original input headers to the correct headers in the combined header list. | def diff_header_indices(generated, expected)
counter = 0
gen_indices = []
exp_indices = []
gen_headers = []
exp_headers = []
combined_headers = []
Diff::LCS.sdiff(generated, expected) do |chunk|
case chunk.action
when '-'
gen_indices << counter
counter += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_header_names(key, models_columns, header)\n normalized_header = []\n\n got_error = false\n header.each_with_index do |h, i|\n logger.debug \"verify header: #{h}\"\n if h == \"id\"\n error(cur_sheet_name, 1, \"Header column #{h} not allowed, update not supported yet\")\n next\n end\... | [
"0.63184196",
"0.6097423",
"0.58528733",
"0.5850958",
"0.5802083",
"0.5683103",
"0.56407815",
"0.5597162",
"0.5579819",
"0.55273336",
"0.552548",
"0.55186576",
"0.55001485",
"0.5480812",
"0.54472744",
"0.5439384",
"0.54330105",
"0.54320794",
"0.5423372",
"0.5401045",
"0.53941... | 0.741105 | 0 |
register a timeout listener that will be called in given seconds (aprox). Returns a listener object that can be used with clear_timeout to remove the listener | def set_timeout(seconds, block)
listener = { seconds: seconds, block: block, time: @time, target: @time + seconds }
@timeout_listeners.push listener
listener
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timer(timeout,options={},&callback)\n bot.timer.add_timer(:timestamp=>Time.now+timeout.to_i, :requestor=>options[:requestor]||name,&callback)\n end",
"def _add_timeout_arg(a_func, timeout)\n proc do |request, **kwargs|\n kwargs[:timeout] = timeout\n a_func.call(request, **kwargs)\n ... | [
"0.6580678",
"0.6283373",
"0.6205954",
"0.615535",
"0.6121049",
"0.6081951",
"0.60530937",
"0.5976984",
"0.59044105",
"0.5765276",
"0.57223237",
"0.5713267",
"0.56706756",
"0.5661123",
"0.5660976",
"0.5628078",
"0.56160533",
"0.5572752",
"0.55707353",
"0.5554352",
"0.5530285"... | 0.707152 | 0 |
Returns an array with two values, the first being a hash of edges with a number containing their class assignment, the second valud is a boolean which states whether or not the graph is a comparability graph Complexity in time O(d|E|) where d is the maximum degree of a vertex Complexity in space O(|V|+|E|) | def gamma_decomposition
k = 0; comparability=true; classification={}
edges.map {|edge| [edge.source,edge.target]}.each do |e|
if classification[e].nil?
k += 1
classification[e] = k; classification[e.reverse] = -k
comparability &&= plexus_comparability_explore(e, k, clas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gamma_decomposition\r\n k = 0; comparability=true; classification={}\r\n edges.map {|edge| [edge.source,edge.target]}.each do |e|\r\n if classification[e].nil?\r\n k += 1\r\n classification[e] = k; classification[e.reverse] = -k\r\n comparability &&= gratr_comparabil... | [
"0.65403706",
"0.61264944",
"0.5824513",
"0.5689655",
"0.5675924",
"0.56293416",
"0.55407304",
"0.5478084",
"0.54539037",
"0.54467845",
"0.5397665",
"0.5392294",
"0.5370198",
"0.5340261",
"0.5313673",
"0.5300132",
"0.52891475",
"0.52799016",
"0.5260608",
"0.52445084",
"0.5239... | 0.6402958 | 1 |
Returns one of the possible transitive orientations of the UndirectedGraph as a Digraph | def transitive_orientation(digraph_class=Digraph)
raise NotImplementError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transitive_orientation(digraph_class=Digraph)\r\n raise NotImplementError\r\n end",
"def to_rgl_oriented\n RGL::ImplicitGraph.new do |g|\n g.vertex_iterator do |block|\n self.each_segment do |segment|\n [:+, :-].each do |orient|\n block.call([segment, orie... | [
"0.6486657",
"0.6296205",
"0.62370664",
"0.5971184",
"0.57780004",
"0.560419",
"0.5532907",
"0.54530483",
"0.5427812",
"0.5420133",
"0.5372397",
"0.5330243",
"0.53203136",
"0.53184295",
"0.52453",
"0.5230286",
"0.52212965",
"0.51883",
"0.51729876",
"0.51539457",
"0.5146304",
... | 0.64383256 | 1 |
searches books.google.com for books by isbn. returns either a hash, or if given an object providing a from_hash(hash) method will fill it with the data. the object members must be named like the keys in the hash. | def search_by_isbn(isbn, object = nil)
return nil if (isbn = isbn.gsub(/-/,"")).nil?
@client = HTTPClient.new
@book_hash = std_entry
@isbn = isbn
ol_hash = search_open_library
isbndb_hash = search_isbndb
gb_hash = search_google_books
@book_hash.each {|k,v|
@book_hash[k] = ol_has... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book_by_isbn(isbn)\n\t\t\tresponse = request('/book/isbn', :isbn => isbn)\n\t\t\tHashie::Mash.new(response['book'])\t\t\t\t\n\t\tend",
"def search_url\n \"http://books.google.com/books/feeds/volumes?q=ISBN#{ isbn }\"\n end",
"def get_book( book_id )\n response = if book_id.to_s.length >= 10\n ... | [
"0.6751553",
"0.6086912",
"0.60364693",
"0.5924739",
"0.59067893",
"0.57909685",
"0.561289",
"0.55804366",
"0.55078435",
"0.5490632",
"0.5490632",
"0.5488336",
"0.5474147",
"0.54411167",
"0.5440768",
"0.54307944",
"0.54307944",
"0.5427307",
"0.5415426",
"0.5379322",
"0.537349... | 0.7637749 | 0 |
Creates a new AESPipe object with the given _options_. If a _block_ is given, it will be passed the newly created AESPipe object. _options_ may contain the following keys: :mode:: The mode of the cipher, either :encrypt or :decrypt. Defaults to :encrypt. :block_size:: The blocksize to use with the cipher. Defaults to 4... | def initialize(options={},&block)
@mode = options.fetch(:mode,:encrypt).to_sym
@block_size = options.fetch(:block_size,DEFAULT_BLOCK_SIZE).to_i
@key_size = options.fetch(:key_size,DEFAULT_KEY_SIZE).to_i
@iv = options.fetch(:iv,DEFAULT_IV).to_s
@hash = options.fetch(:h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cipher\n aes = OpenSSL::Cipher::Cipher.new(\"aes-#{@key_size}-cbc\")\n\n case @mode\n when :encrypt\n aes.encrypt\n when :decrypt\n aes.decrypt\n else\n raise(InvalidMode,\"invalid mode #{@mode}\")\n end\n\n aes.key = @key\n aes.iv = @iv\n\n yie... | [
"0.6165562",
"0.5306818",
"0.52144134",
"0.51730794",
"0.51517487",
"0.51302695",
"0.5126202",
"0.49991134",
"0.4973685",
"0.49599954",
"0.49546283",
"0.49170345",
"0.49100235",
"0.49000397",
"0.4895201",
"0.4837976",
"0.483294",
"0.4815814",
"0.47978482",
"0.47694778",
"0.47... | 0.64230424 | 0 |
Returns a new AES cipher object. If a _block_ is given it will be passed the newly created cipher. | def cipher
aes = OpenSSL::Cipher::Cipher.new("aes-#{@key_size}-cbc")
case @mode
when :encrypt
aes.encrypt
when :decrypt
aes.decrypt
else
raise(InvalidMode,"invalid mode #{@mode}")
end
aes.key = @key
aes.iv = @iv
yield aes if block_given?
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cipher\r\n aes = OpenSSL::Cipher::AES.new(128, :CBC)\r\n aes.encrypt\r\n aes.key = key\r\n aes.iv = iv\r\n return aes\r\n end",
"def encrypt_with(name, &block)\n @encryptor = get_class_from_scope(Encryptor, name).new(&block)\n end",
"def get_cipher\n Ope... | [
"0.68026704",
"0.6411067",
"0.6362697",
"0.6215968",
"0.6100016",
"0.60487854",
"0.5936557",
"0.5882147",
"0.583795",
"0.5776261",
"0.5725184",
"0.57234573",
"0.56403446",
"0.56391084",
"0.5605318",
"0.5602889",
"0.5559221",
"0.5432213",
"0.53685135",
"0.53601974",
"0.5337855... | 0.7284387 | 0 |
Processes an input stream of the given _file_ and the specified _block_. If _file_ is not given +STDIN+ will be used instead. The specified _block_ will be passed each block of data from the stream. Once the _block_ has returned the input stream will be closed. | def process_input(file=nil)
input = if file
File.new(file.to_s)
else
STDIN
end
loop do
text = input.read(@block_size)
break unless text
yield text
end
input.close
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_stream(&block); end",
"def read_file(block=0)\n Rula.log(Logger::DEBUG,\"Reading file #{filename} block #{block}\",self)\n return nil if(block >= @file_size)\n return nil if(block < 0)\n file_handle = File.open(@filename,'rb')\n file_handle.pos = block\n @previous_bloc... | [
"0.64599484",
"0.62070936",
"0.60026777",
"0.5932396",
"0.5922345",
"0.5884504",
"0.5769879",
"0.57655627",
"0.57385254",
"0.5722197",
"0.56439584",
"0.55800575",
"0.5545476",
"0.54967123",
"0.54726946",
"0.5436581",
"0.540953",
"0.5375816",
"0.5365595",
"0.5356251",
"0.53208... | 0.73888326 | 0 |
Select instances by role, with optional name constraints. Select the "master" app instance: select_instances(app_master: true) Select the "master" db instance on a solo or multiinstance env: select_instances(solo: true, db_master: true) Select app, app_master, or utils (only if they are named resque or redis): select_i... | def select_instances(options)
instances_by_role(options.keys).select do |inst|
# get the value of the string/symbol key that matches without losing nil/false values
val = options.fetch(inst.role.to_sym) { options.fetch(inst.role.to_s, false) }
case val
when true, false t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instances_by_role(*roles)\n roles = roles.flatten.map(&:to_s)\n instances.select { |inst| roles.include?(inst.role.to_s) }\n end",
"def get_instances_by_role(group, role)\n get_instances(group).select do |instance|\n if not instance.tags['role'].nil? and instance.ready?\n in... | [
"0.6815968",
"0.6587964",
"0.62072724",
"0.60657895",
"0.5951953",
"0.5241145",
"0.5208313",
"0.51693743",
"0.5148964",
"0.514775",
"0.5121972",
"0.50967026",
"0.50681746",
"0.5068069",
"0.5065728",
"0.5056514",
"0.5054837",
"0.50277025",
"0.5013069",
"0.49788684",
"0.4978006... | 0.69315934 | 0 |
Simple version of select_instances that only selects roles, not names instances_by_role(:app_master, :app) same instances_by_role(%w[app_master app]) same select_instances(app_master: true, app: true) same | def instances_by_role(*roles)
roles = roles.flatten.map(&:to_s)
instances.select { |inst| roles.include?(inst.role.to_s) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_instances(options)\n instances_by_role(options.keys).select do |inst|\n # get the value of the string/symbol key that matches without losing nil/false values\n val = options.fetch(inst.role.to_sym) { options.fetch(inst.role.to_s, false) }\n\n case val\n when tr... | [
"0.7207731",
"0.6452275",
"0.60056883",
"0.5485831",
"0.54808927",
"0.54168063",
"0.51426065",
"0.50724375",
"0.5028341",
"0.50074726",
"0.5005638",
"0.5005568",
"0.49344948",
"0.4933732",
"0.49306875",
"0.49236944",
"0.48968926",
"0.48968926",
"0.48505467",
"0.48051736",
"0.... | 0.66395384 | 1 |
Throws a POST request at the API to /add_instances and adds one instance to this environment. Usage example: api = EY::CloudClient.new(token: 'your token here') env = api.environment_by_name('your_env_name') env.add_instance(role: "app") env.add_instance(role: "util", name: "foo") Note that the role for an instance MUS... | def add_instance(opts)
unless %w[app util].include?(opts[:role].to_s)
# Fail immediately because we don't have valid arguments.
raise InvalidInstanceRole, "Instance role must be one of: app, util"
end
# Sanitize the name to remove whitespace if there is any
if opts[:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_instance(instance)\n register_response = client.register_instances_with_load_balancer(load_balancer_name: name,\n instances: [{instance_id: instance.ec2_instance_id}])\n remaining_instance_count = register_response.instances.si... | [
"0.5855038",
"0.56592315",
"0.5599796",
"0.5410954",
"0.54064155",
"0.5356072",
"0.5354687",
"0.5354005",
"0.5349306",
"0.5331099",
"0.5286285",
"0.5285621",
"0.5262432",
"0.525653",
"0.5237013",
"0.5153389",
"0.51446885",
"0.5136719",
"0.50980014",
"0.50849426",
"0.5069928",... | 0.74952036 | 0 |
Sends a request to the API to remove the instance specified by its "provisioned_id" (Amazon ID). Usage example: api = EY::CloudClient.new(token: 'token') env = api.environment_by_name('my_app_production') bad_instance = env.instance_by_id(12345) instance ID should be saved upon creation env.remove_instance(bad_instance... | def remove_instance(instance)
unless instance
raise ArgumentError, "A argument of type Instance was expected. Got #{instance.inspect}"
end
# Check to make sure that we have a valid instance role here first.
unless %w[app util].include?(instance.role)
raise InvalidIns... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_instance(instance)\n deregister_response = client.deregister_instances_from_load_balancer(load_balancer_name: name,\n instances: [{instance_id: instance.ec2_instance_id}])\n remaining_instance_count = deregister_response... | [
"0.6574653",
"0.65076655",
"0.64812964",
"0.6419181",
"0.6399379",
"0.6380492",
"0.62758684",
"0.62361205",
"0.6062782",
"0.6051841",
"0.60133886",
"0.5980715",
"0.59735763",
"0.59555346",
"0.5934122",
"0.59037524",
"0.5877481",
"0.5844952",
"0.579769",
"0.5739661",
"0.573119... | 0.76562095 | 0 |
Get last weather update | def last_weather
weathers.last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_updated\n self.dig_for_datetime(\"lastUpdateOn\")\n end",
"def last_update_at\n connection.get_metric_last_update_at(@id)\n end",
"def last_updated_time\n data[:last_updated_time]\n end",
"def current_weather_data\n get_weather[:currently]\n end",
"def last_updated\n\t\tupd... | [
"0.73394704",
"0.7171134",
"0.7029702",
"0.7011882",
"0.69019264",
"0.68487895",
"0.6818536",
"0.6809728",
"0.6807462",
"0.6783188",
"0.67661095",
"0.67661095",
"0.67661095",
"0.67661095",
"0.6732376",
"0.65903205",
"0.6580078",
"0.65748245",
"0.65702015",
"0.65686506",
"0.65... | 0.7867124 | 0 |
User get read access to device ( owner or public device) | def get_read_access( u)
return (u == self.user) || (self.public)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_allowed?(user)\n true\n end",
"def read_access_check\n resource_check('read')\n end",
"def read_access_check\n resource_check('read')\n end",
"def read_access_check\n resource_check('read')\n end",
"def permits_read_acccess_for(user)\n end",
... | [
"0.6786784",
"0.6721274",
"0.6721274",
"0.6721274",
"0.6633686",
"0.660852",
"0.6447477",
"0.6434396",
"0.64334863",
"0.6424191",
"0.6318311",
"0.61437434",
"0.6141246",
"0.6107873",
"0.6100798",
"0.6100798",
"0.6100798",
"0.6083467",
"0.6074477",
"0.6074477",
"0.6059687",
... | 0.7119225 | 0 |
GET /album_genres/1 GET /album_genres/1.json | def show
@album_genre = AlbumGenre.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @album_genre }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @song_genre = SongGenre.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song_genre }\n end\n end",
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def index\n @pictures = @album.pictures... | [
"0.7151078",
"0.7113311",
"0.6989473",
"0.68686765",
"0.6833885",
"0.6801455",
"0.6775186",
"0.67685854",
"0.67642325",
"0.6763039",
"0.6731936",
"0.66824716",
"0.6646332",
"0.66308904",
"0.65979886",
"0.65918297",
"0.6586351",
"0.6584316",
"0.6570412",
"0.65621275",
"0.65616... | 0.7639327 | 0 |
GET /album_genres/new GET /album_genres/new.json | def new
@album_genre = AlbumGenre.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @album_genre }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end",
"def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end"... | [
"0.7584945",
"0.7584945",
"0.7580584",
"0.7531309",
"0.7515149",
"0.7432592",
"0.74296856",
"0.7324332",
"0.7315353",
"0.73125166",
"0.7295713",
"0.72591764",
"0.7183082",
"0.7149219",
"0.7142825",
"0.71232575",
"0.7122416",
"0.7118146",
"0.71158403",
"0.7112992",
"0.70868117... | 0.7940656 | 0 |
POST /album_genres POST /album_genres.json | def create
@album_genre = AlbumGenre.new(params[:album_genre])
respond_to do |format|
if @album_genre.save
format.html { redirect_to @album_genre, notice: 'Album genre was successfully created.' }
format.json { render json: @album_genre, status: :created, location: @album_genre }
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updategenres\n @album = Album.find(params[:id])\n album_param = params[:albums] \n album_param[:genres].each do |genre_id|\n genre = Genre.find(genre_id)\n @album.genres << genre \n end \n respond_to do |format|\n format.html { redirect_to(@album) }\n f... | [
"0.71542436",
"0.6566338",
"0.6526033",
"0.6405078",
"0.64028573",
"0.63616914",
"0.6355944",
"0.63066816",
"0.6290948",
"0.62879986",
"0.62090665",
"0.62071955",
"0.62071955",
"0.62071955",
"0.62004757",
"0.6187991",
"0.61867565",
"0.6170445",
"0.6166137",
"0.6166137",
"0.61... | 0.70034546 | 1 |
DELETE /album_genres/1 DELETE /album_genres/1.json | def destroy
@album_genre = AlbumGenre.find(params[:id])
@album_genre.destroy
respond_to do |format|
format.html { redirect_to album_genres_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @album.destroy\n render json: @album\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.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 @album.destroy\n\n respond_... | [
"0.7602658",
"0.7382387",
"0.7377284",
"0.736904",
"0.736904",
"0.736904",
"0.736904",
"0.736904",
"0.7354127",
"0.7354127",
"0.7354127",
"0.73396933",
"0.731502",
"0.7314097",
"0.7297047",
"0.72846013",
"0.7272589",
"0.7244382",
"0.7243497",
"0.72404754",
"0.7213964",
"0.7... | 0.7826642 | 0 |
crear un metodo initialize que inicialice las variables de instancia "revenue" y "costs" a cero | def initialize
@revenue = 0
@costs = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(discount = 0) #new optionally takes an employee discount on initialization\n @total = 0 #SETS AN INSTANCE VARIABLE @TOTAL ON INITIALIZATION TO ZERO\n @discount = discount # CashRegister ::new optionally takes an employee discount on initialization\n @items = [] #returns an array contain... | [
"0.69509363",
"0.69056004",
"0.6743452",
"0.67419595",
"0.66899025",
"0.6654327",
"0.6624689",
"0.6618325",
"0.64908767",
"0.6467",
"0.6452923",
"0.6414348",
"0.6412228",
"0.640696",
"0.6346843",
"0.6342039",
"0.6328918",
"0.6324803",
"0.63179314",
"0.63158774",
"0.631197",
... | 0.8083272 | 0 |
crear un metodo "credit" que reciba un parametro "amount" y se lo sume a la variable de instancia "revenue" | def credit(amount)
@revenue += amount
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def credit(postive_amount)\n Credit.create!(team: team,\n room_type: room_type,\n amount: postive_amount)\n end",
"def credit *args\n warn_on_positional args\n\n options = args.last.is_a?(Hash) ? args.pop : {}\n amount = args[0] || options.fetch(:amount) { n... | [
"0.70318425",
"0.6715307",
"0.6713559",
"0.6667777",
"0.664224",
"0.6625338",
"0.66235304",
"0.6605122",
"0.6574353",
"0.6569881",
"0.6449399",
"0.6412946",
"0.64040864",
"0.63758034",
"0.6359669",
"0.63437325",
"0.63192797",
"0.63162225",
"0.622324",
"0.62189704",
"0.6201884... | 0.74697095 | 0 |
has many clients through appointments | def clients
Appointments.all.collect do |appointment|
appointment.client
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client_appointments\n self.clients.map(&:appointments)\n end",
"def create\n # Create new client object, with nested appointment object\n @client = Client.new(client_params)\n # Set the new appointment's user_id equal to the current_user's id. This completes the association\n # between the c... | [
"0.76485354",
"0.68745774",
"0.66267776",
"0.65794945",
"0.654963",
"0.650973",
"0.6493033",
"0.6463341",
"0.6451692",
"0.64151096",
"0.64056396",
"0.638461",
"0.638461",
"0.63814384",
"0.6379531",
"0.63785684",
"0.63550484",
"0.63399714",
"0.63325363",
"0.63052034",
"0.62588... | 0.74405485 | 1 |
recursively crawls the parser rules and looks for elements that index values. Adds an empty index for each of these. | def setup_indexes rules
if rules[:children]
rules[:children].each_pair do |child_name,child_rules|
if index = child_rules[:index]
@indexes[index[:name]] = {}
end
setup_indexes(child_rules)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match parser, index\r\n raise \"no children added to sequence\" unless @list\r\n each do |element|\r\n index = element.match parser, index\r\n return NO_MATCH unless index\r\n end\r\n report index\r\n end",
"def first_nil_parse_index_assert\n idx = @children.index{... | [
"0.60973424",
"0.56917083",
"0.54896015",
"0.54325575",
"0.5408188",
"0.5391383",
"0.51944095",
"0.51584613",
"0.51584613",
"0.51584613",
"0.51584613",
"0.5144807",
"0.5136883",
"0.5091499",
"0.5091499",
"0.5091499",
"0.5091499",
"0.50706524",
"0.5065484",
"0.50407165",
"0.50... | 0.67908156 | 0 |
combo_changed event handlers for composite foreign key: carton_pack_type_id combo_changed event handlers for composite foreign key: basic_pack_id search combo_changed event handlers for the unique index on this table(carton_pack_products) | def carton_pack_product_type_code_search_combo_changed
type_code = get_selected_combo_value(params)
session[:carton_pack_product_search_form][:type_code_combo_selection] = type_code
@basic_pack_codes = CartonPackProduct.find_by_sql("Select distinct basic_pack_code from carton_pack_products where type_code = '#{type_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fg_product_item_pack_product_code_search_combo_changed\n\titem_pack_product_code = get_selected_combo_value(params)\n\tsession[:fg_product_search_form][:item_pack_product_code_combo_selection] = item_pack_product_code\n\t@unit_pack_product_codes = FgProduct.find_by_sql(\"Select distinct unit_pack_product_code ... | [
"0.62615204",
"0.61642337",
"0.6071932",
"0.6042467",
"0.60266316",
"0.60185677",
"0.59009135",
"0.58595985",
"0.57825226",
"0.5760937",
"0.56612283",
"0.56465",
"0.55218667",
"0.5261049",
"0.5147732",
"0.5133886",
"0.5129493",
"0.51280886",
"0.51261866",
"0.51144844",
"0.509... | 0.6645778 | 0 |
Render multiple boxes. Takes as argument a single array of Hash For the Hash options, please see render_box. The boxes are wrapped in a div with class "textboxes". You can pass individual styling using :textboxes_style => textboxes_style. You can specify a template Hash ( :template => template ) which will be merged wi... | def render_boxes(array = [], options = {})
boxes = ""
template = {}
if options[:template].class.to_s.eql?("Hash")
template = options[:template]
end
array.each do |individual_options|
box_options = template
box_options = template.merge(individual_options) unless individual_option... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_box(options = {})\n # list of classes for the outer div.\n outer_div_classes = [ \"textbox_container\" ]\n # inner div, same story\n inner_div_classes = [ \"textbox\" ]\n # heading\n heading_classes = [ \"heading\" ]\n\n content = yield if block_given?\n content ||= options[:cont... | [
"0.6464205",
"0.5841228",
"0.56698936",
"0.5520285",
"0.55042785",
"0.5450058",
"0.54241514",
"0.52830034",
"0.5258477",
"0.5247274",
"0.5208967",
"0.5190762",
"0.51529074",
"0.514873",
"0.5145886",
"0.5129254",
"0.50793684",
"0.5023993",
"0.50237775",
"0.5003811",
"0.4992348... | 0.81510353 | 0 |
Render a box. options: content (string) heading (string) float_left (true/false) text_align_center (true/false) highlight (true/false) background_image (url) bigfont (true/false) heading_color (color name, e.g. 'red') background_color (color name, e.g. 'blue') inner_div_style (css style, e.g. "width: 382px; height: 281... | def render_box(options = {})
# list of classes for the outer div.
outer_div_classes = [ "textbox_container" ]
# inner div, same story
inner_div_classes = [ "textbox" ]
# heading
heading_classes = [ "heading" ]
content = yield if block_given?
content ||= options[:content]
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prettybox(html_options, &proc)\n raise ArgumentError, \"Missing block\" unless block_given?\n concat(tag(\"div\", html_options, true), proc.binding)\n concat(\"<div class=\\\"prettybox_top\\\">\n <div> </div>\n </div><div class=\\\"prettybox_inside\\\">\", proc.binding)\n yield\n co... | [
"0.66518354",
"0.64276874",
"0.63438886",
"0.62945646",
"0.6275616",
"0.62258786",
"0.5826013",
"0.57734585",
"0.575188",
"0.5711554",
"0.5708607",
"0.5708331",
"0.56436723",
"0.56094885",
"0.5501951",
"0.5469089",
"0.54682136",
"0.5411976",
"0.54065824",
"0.5400691",
"0.5351... | 0.74547935 | 0 |
Set the value of the Selection input for this Choreo. | def set_Selection(value)
set_input("Selection", value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_selection\n @selection = Selection.find(params[:id])\n end",
"def selected=(selected)\n @selected = selected\n update_cursor\n end",
"def set_selection(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute... | [
"0.6730609",
"0.60064816",
"0.59250665",
"0.55305684",
"0.54792243",
"0.5294307",
"0.5193717",
"0.5160014",
"0.50771934",
"0.49670652",
"0.49642852",
"0.49552462",
"0.4897551",
"0.48896053",
"0.48892686",
"0.48653993",
"0.47962394",
"0.47817543",
"0.47708645",
"0.4731124",
"0... | 0.72626334 | 0 |
Set the value of the Title input for this Choreo. | def set_Title(value)
set_input("Title", value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_title(title)\n @title = title\n end",
"def title=(title)\n if title.nil?\n fail ArgumentError, 'invalid value for \"title\", title cannot be nil.'\n end\n @title = title\n end",
"def title=(title)\n if title.nil?\n fail ArgumentError, 'invalid value for \"title\... | [
"0.7805282",
"0.77696145",
"0.77696145",
"0.7668345",
"0.7668345",
"0.7668345",
"0.7668345",
"0.76442933",
"0.7638002",
"0.7638002",
"0.7638002",
"0.7638002",
"0.7638002",
"0.7638002",
"0.7638002",
"0.7618395",
"0.7618395",
"0.7618395",
"0.7618395",
"0.7618395",
"0.7618395",
... | 0.7820923 | 0 |
Set the value of the URL input for this Choreo. | def set_URL(value)
set_input("URL", value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url=(value)\n @url = value\n Curl.set_option(:url, value_for(value, :string), handle)\n end",
"def set_URL(value)\n set_input(\"URL\", value)\n end",
"def set_URL(value)\n set_input(\"URL\", value)\n end",
"def set_URL(value)\n set_input(\"URL\"... | [
"0.8073227",
"0.76355296",
"0.76355296",
"0.76355296",
"0.76355296",
"0.76355296",
"0.76355296",
"0.76355296",
"0.71796364",
"0.71796364",
"0.71796364",
"0.71796364",
"0.71796364",
"0.70758444",
"0.6956582",
"0.68834627",
"0.68829864",
"0.68481743",
"0.6793545",
"0.6757589",
... | 0.78341466 | 1 |
Show logout instead of link to adminpage on adminpanel | def show_logout
@show_logout = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logout\n if @user != nil and @user.admin?(@routes)\n show :logout, views: File.join(Classiccms::ROOT, 'views/cms')\n end\n end",
"def logout\n session.delete(:admin_password)\n redirect_to admin_login_path\n end",
"def logout\n @logout_message = \"You have successfully logged ... | [
"0.7869341",
"0.7371892",
"0.73304105",
"0.71523815",
"0.7088891",
"0.7064473",
"0.70633715",
"0.7058166",
"0.6968901",
"0.69150984",
"0.6904809",
"0.68289655",
"0.6823173",
"0.68124586",
"0.681163",
"0.681163",
"0.681163",
"0.6787559",
"0.6779616",
"0.6779616",
"0.6776586",
... | 0.7381453 | 1 |
Receiving messages from client and sending to other clients | def client_handler(client, all_clients)
client.puts 'Welcome to server, stranger!'
loop do
msg = client.gets
if msg.nil?
puts 'Client disconnected'
break
end
all_clients.each { |dest| send_msg(msg, dest) if dest != client }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_messages\n\t\t\tloop do\n\t\t\t\tchan, message = @redis_listener.blpop(\"#{PREFIX}.network:#{@network}.messages\", 0)\n\t\t\t\t@log.debug(\"A client sent the message : #{message}\")\n\t\t\t\tmsgid, command, args = parse(message)\n\t\t\t\tunless command\n\t\t\t\t\t@log.warn(\"A client sent an invalid me... | [
"0.73470896",
"0.7064501",
"0.69389194",
"0.69049066",
"0.68902683",
"0.68148494",
"0.680604",
"0.67075753",
"0.66322184",
"0.6594547",
"0.65687734",
"0.65055674",
"0.649664",
"0.64837456",
"0.6478959",
"0.646703",
"0.64556307",
"0.64452773",
"0.6444162",
"0.64072937",
"0.636... | 0.714587 | 1 |
Helper for model classes. Allows for convenient instantiation of current athlete. This is completely agnostic to class type, it can be a DB model, a PORO, etc. Usage: class Account Strava::Athlete Can also perform lookup through another method: class User < ApplicationRecord has_one :account include Strava.model as: :a... | def model(as: :strava_athlete, via: :access_token, id: nil)
Module.new.tap do |mod|
str = <<~EOF
def self.included(base)
base.send(:define_method, :#{as}) { ::Strava::Athlete.new(#{id ? "{'id' => #{id}}" : '{}' }, token: #{via}, current: true) }
end
EOF
mod.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def associate_one(person, account_class)\n return unless person\n\n account = account_class.find_by_secdn(person.dn)\n\n new(person, account)\n end",
"def ar_resource\n return unless type && id\n return unless self.class.union_models.include?(type.to_sym)\n\n ... | [
"0.52092934",
"0.511394",
"0.5069212",
"0.50299656",
"0.5023484",
"0.4993129",
"0.49767023",
"0.49451876",
"0.49443752",
"0.49165156",
"0.4914349",
"0.49054357",
"0.48659104",
"0.4865236",
"0.48552924",
"0.4853309",
"0.48528898",
"0.48528898",
"0.48528898",
"0.48528898",
"0.4... | 0.723099 | 0 |
Reverse the word order of a given string =begin doctest: reverse word order of a string >> s = "This is test line one." >> reverse_word_order(s) => "one. line test is This" doctest: Lines are handled this way >> s = "This is test line one.\nThis is test line two." >> reverse_word_order(s) => "two. line test is This one... | def reverse_word_order string
string.split.reverse.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_word_order(str)\n str.split.reverse.join(' ')\nend",
"def word_reverse(str)\n p str.split(' ').reverse.join(' ')\nend",
"def wordReverse(string)\n\tp string.split(\" \").reverse().join(\" \")\nend",
"def reverse_words(string)\n words = string.split()\n words.each_with_index { |word, index| ... | [
"0.7666444",
"0.7598045",
"0.7538827",
"0.741925",
"0.74179643",
"0.74103767",
"0.740417",
"0.7379643",
"0.7379643",
"0.7373929",
"0.73467344",
"0.73209673",
"0.7309497",
"0.7302201",
"0.7295405",
"0.7286302",
"0.72851825",
"0.7282557",
"0.7274572",
"0.72719157",
"0.72685456"... | 0.77907425 | 0 |
define equality between two entities by iterating over instance variables and comparing each field for equality | def ==(entity)
rval = true
self.instance_variables.each { |variable| rval &= self.instance_variable_get(variable) == entity.instance_variable_get(variable) }
rval
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_equal(obj1, obj2)\n vars1 = obj1.instance_variables\n vars2 = obj2.instance_variables\n return false unless vars1.length == vars2.length\n # if they don't have exactly the same instance_variables names then return false\n return false unless vars1.map(&:to_s).sort.to_s == vars2.map(&:to_s).sort.to_... | [
"0.6365919",
"0.6288923",
"0.6226688",
"0.62169",
"0.6111295",
"0.6087191",
"0.598765",
"0.5970042",
"0.59560186",
"0.59450203",
"0.5894917",
"0.5863724",
"0.58579576",
"0.5838317",
"0.58370423",
"0.58349097",
"0.5823593",
"0.58083266",
"0.5806187",
"0.5801017",
"0.58009577",... | 0.660682 | 1 |
undesignate_package params is passed from 'form_nested_params_for_undesignate' | def undesignate(undesignate_package = nil)
packages = undesignate_package ? undesignate_package : @params
OrdersPackage.undesignate_partially_designated_item(packages)
@package.reload.undesignate_from_stockit_order
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsolved_params\n \n end",
"def drop_extra_params!(form, params)\n form_data = form['properties']['data']['properties']\n allowed_params = form_data['attributes']['properties'].keys rescue nil\n params['data'].fetch('attributes', {}).slice!(*allowed_params) if allowed_params.present?\n ... | [
"0.5887348",
"0.5579017",
"0.550668",
"0.5481046",
"0.5415299",
"0.5408723",
"0.5318543",
"0.5298929",
"0.5264611",
"0.523779",
"0.5198984",
"0.51949567",
"0.51777846",
"0.50805336",
"0.5054774",
"0.50440156",
"0.5003783",
"0.49490967",
"0.49228296",
"0.4879456",
"0.48700336"... | 0.7438915 | 0 |
Tell this track's channel to use the given instrument, and also set the track's instrument display name. | def instrument=(instrument)
@events << MIDI::ProgramChange.new(@channel, instrument)
super(GM_PATCH_NAMES[instrument])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instrument=(instrument)\n @events << \nMIDI::ProgramChange.new(@channel, instrument)\n super(MIDI::GM_PATCH_NAMES[instrument])\n end",
"def instrument=(instrument)\n @events << MIDI::ProgramChange.new(@channel, instrument)\n super(MIDI::GM_PATCH_NAMES[instrument])\n end",
"def instrume... | [
"0.6368076",
"0.62432176",
"0.6185505",
"0.6185505",
"0.6185505",
"0.61758345",
"0.60637724",
"0.60637724",
"0.60637724",
"0.60637724",
"0.60637724",
"0.58738804",
"0.58738804",
"0.5730139",
"0.5724428",
"0.5724428",
"0.554737",
"0.53196824",
"0.5193287",
"0.51252496",
"0.506... | 0.63136387 | 1 |
Configure Vedeu using a simple configuration DSL. | def configure(&block)
fail InvalidSyntax, '`configure` requires a block.' unless block_given?
Vedeu::Configuration.configure(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure(args = [], opts = {}, &block)\n @options.merge!(opts)\n\n @options.merge!(Config::API.configure(&block)) if block_given?\n @options.merge!(Config::CLI.configure(args)) if args.any?\n\n Vedeu::Renderers.renderer(*@options[:renderers])\n\n Vedeu::Configuration\n end",
"def... | [
"0.650775",
"0.6432643",
"0.6432643",
"0.64055663",
"0.61986077",
"0.6190462",
"0.6190431",
"0.6138053",
"0.6106681",
"0.6049971",
"0.60169464",
"0.5942714",
"0.5928619",
"0.59283185",
"0.59283185",
"0.59080756",
"0.58889747",
"0.58865875",
"0.588558",
"0.58774656",
"0.585829... | 0.7594411 | 0 |
Register an interface by name which will display output from a event or command. This provides the means for you to define your application's views without their content. | def interface(name = '', &block)
API::Interface.define({ name: name }, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(interface)\n InvalidInterfaceError.check(interface)\n \n interfaces[interface.to_s.demodulize.underscore.to_sym] = interface\n end",
"def register_ui thing\n @uis << thing\n end",
"def name\n\t\t\"Interface Fingerprinter\"\n\tend",
"def register_outputter(na... | [
"0.5812963",
"0.57885903",
"0.57239634",
"0.5534636",
"0.54944015",
"0.54944015",
"0.54944015",
"0.5466492",
"0.5456569",
"0.5287779",
"0.52860355",
"0.5271038",
"0.526901",
"0.5255215",
"0.5211872",
"0.51988626",
"0.51811814",
"0.51612604",
"0.5107999",
"0.5107547",
"0.50589... | 0.59082633 | 0 |
Trigger a registered or system event by name with arguments. If the event stored returns a value, that is returned. If multiple events are registered for a name, then the result of each event will be returned as part of a collection. | def trigger(name, *args)
Events.use(name, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def registered_events\n return repository.find(name) if repository.registered?(name)\n\n Vedeu::Events::Aliases.find(name).map do |event_name|\n Vedeu::Events::Trigger.trigger(event_name, *args)\n end\n\n []\n end",
"def registered_events\n return repository.find(... | [
"0.63373756",
"0.63373756",
"0.63167703",
"0.6304516",
"0.6193974",
"0.61852914",
"0.6161528",
"0.6115156",
"0.6016299",
"0.59253484",
"0.5922085",
"0.5793874",
"0.5752463",
"0.5727183",
"0.5715739",
"0.56951404",
"0.56702304",
"0.56689626",
"0.56689507",
"0.5660282",
"0.5638... | 0.662765 | 0 |
Unregisters the event by name, effectively deleting the associated events bound with it also. | def unevent(name)
Events.remove(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def off(event_name)\n events.delete(event_name.to_sym)\n end",
"def unregister name\n @tags.delete(name)\n end",
"def unregister name\n @tags.delete(name)\n end",
"def off(event_type = ANY_EVENT, name = ANY_STATE, &callback)\n sync_exclusive do\n hooks.unregister e... | [
"0.7441557",
"0.6746965",
"0.6746965",
"0.67336833",
"0.67336833",
"0.6647178",
"0.66150576",
"0.6588004",
"0.6495706",
"0.6373919",
"0.63577336",
"0.6313051",
"0.6273848",
"0.6216565",
"0.62098235",
"0.619146",
"0.6179944",
"0.61641043",
"0.6109086",
"0.6096646",
"0.60931474... | 0.8343725 | 0 |
Removes all unnessesary data from the traces | def remove_useless_traces_data(params)
convert_list_of_json_traces_to_objects(params[0])
create_new_traces
@traces_json_string = '[' + @traces_json_string[0...-1] + ']'
puts @traces_json_string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear\n trace.elegibility.transform_values { |_| 0 }\n trace.extended.each_value do |ext|\n ext.transform_values { |_| 0 }\n end\n\n error.responsibility = error.projected = error.gated = 0\n end",
"def discardAllTreasures\n \n end",
"def clear_transformed_data!\n ... | [
"0.67180717",
"0.6350163",
"0.61820173",
"0.59679735",
"0.5958402",
"0.5931395",
"0.58900374",
"0.58790004",
"0.5877097",
"0.5816887",
"0.5800543",
"0.57929695",
"0.57839453",
"0.57833207",
"0.5782553",
"0.57753074",
"0.575557",
"0.57200986",
"0.5714017",
"0.57020986",
"0.566... | 0.722608 | 0 |
Converts a trace string to JSON Object | def convert_json_trace_to_object(trace)
JSON.parse(trace[1...-1].insert(0, '{'), object_class: OpenStruct)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_json_string\n @traces_json_string\n end",
"def to_json(*_args)\n @trace.to_json\n end",
"def load(string)\n ActiveSupport::JSON.decode string\n end",
"def load(string)\n ActiveSupport::JSON.decode string\n end",
"def meta_to_json(str)\n key_pairs = str.... | [
"0.6320628",
"0.6235496",
"0.578373",
"0.578373",
"0.5767151",
"0.56942123",
"0.5670016",
"0.56492263",
"0.5531835",
"0.55062896",
"0.5493804",
"0.546757",
"0.5374033",
"0.5363098",
"0.53590876",
"0.5348716",
"0.52849364",
"0.52409697",
"0.5237889",
"0.52342045",
"0.52288604"... | 0.6937454 | 0 |
Generate the traces that will be used in the visualization process. This is done by 1 extract the variables names form the trace 2 extract the encoded locals from the trace 3 extract the heap values form the trace 4 extract the code from the trace | def create_new_traces
@traces.each do |trace|
trace_stack = trace.stack_to_render[0]
unless(trace_stack.func_name.include? '<init>')
trace_stack_ordered_variable_names = trace_stack.ordered_varnames
trace_stack_encoded_locals = trace_stack.encoded_locals
trace_heap = trace.heap
t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_trace(params)\n trace = {}\n trace['stack'] = {}\n trace['stack']['ordered_variable_names'] = params[0]\n trace['stack']['encoded_locals'] = {}\n params[1].each_pair do |key, value|\n trace['stack']['encoded_locals'][key] = value\n end\n trace['heap'] = {}\n params[2].each_p... | [
"0.644559",
"0.6297783",
"0.58538085",
"0.56983066",
"0.5570515",
"0.5535104",
"0.5380226",
"0.5338043",
"0.5216844",
"0.52124184",
"0.5202664",
"0.5117278",
"0.5096113",
"0.5090454",
"0.50670594",
"0.5060551",
"0.50140655",
"0.50054634",
"0.49925035",
"0.4990763",
"0.4983535... | 0.694777 | 0 |
getter method to return the new trace as JSON string | def return_json_string
@traces_json_string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(*_args)\n @trace.to_json\n end",
"def to_s\n @trace.to_s\n end",
"def to_hash\n @trace\n end",
"def json()\n @trace_arr.map{|trace| \n tile = trace.json \n @tiles[trace.id] = trace\n trace.id\n }\n end",
"def trace\n attributes.fetch(:trace... | [
"0.77254003",
"0.7145027",
"0.6813827",
"0.6757803",
"0.66630393",
"0.6413217",
"0.63729984",
"0.6330249",
"0.6316424",
"0.63129944",
"0.6271973",
"0.62525904",
"0.6241202",
"0.6188315",
"0.61733526",
"0.6162095",
"0.6154478",
"0.6142723",
"0.61175704",
"0.6100477",
"0.609032... | 0.82976204 | 0 |
Generates the full execution trace for the complete source code by executing the command related to Java_Jail | def generate_backend_trace(junit_test_file,
files_path,
peruser_files_path,
student_file_name)
raw_code = junit_test_file
raw_code.gsub! "\n", "\\n" + "\n"
raw_code.gsub! "\t", "\\t"
lines = raw_code.split("\n")
jUnit_test = ''
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_caller_stack\n return unless $ITEST2_TRACE_EXECUTION\n begin\n caller.each_with_index do |position, idx|\n next unless position =~ /\\A(.*?):(\\d+)/\n file = $1\n # TODO: send multiple trace to be parse with pages.rb\n # next if file =~ /example\\/examp... | [
"0.5608189",
"0.5282671",
"0.52793324",
"0.5163975",
"0.5157312",
"0.5133898",
"0.51140076",
"0.5084825",
"0.508095",
"0.50801665",
"0.50302386",
"0.5028595",
"0.50142825",
"0.49818859",
"0.4976015",
"0.49694765",
"0.49694765",
"0.4936821",
"0.493411",
"0.49049076",
"0.490453... | 0.57624656 | 0 |
Sets the line number | def set_line(line_number)
@line_number = line_number
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lineno=(num)\n num = Maglev::Type.coerce_to(num, Fixnum, :to_int)\n @_st_lineno = num\n $. = num\n num\n end",
"def line_number\n @line_number_overwrite || default_line_number\n end",
"def line_numbering(value)\n @document_builder.line_numbering = value\n end",
... | [
"0.80674815",
"0.7915055",
"0.7709483",
"0.7512962",
"0.7491955",
"0.7491835",
"0.73757076",
"0.7301996",
"0.7254114",
"0.7139814",
"0.7121126",
"0.7121126",
"0.7120693",
"0.7105037",
"0.7105037",
"0.7105037",
"0.7085615",
"0.7085615",
"0.7085615",
"0.7085615",
"0.7085615",
... | 0.8918514 | 0 |
gets the line number if the trace at the specified index | def get_line_number(index)
if @list_of_events.length.zero?
puts 'list is empty'
else
temp_event = @list_of_events[index]
temp_event.line_number
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_number\n return unless backtrace and backtrace[0]\n\n backtrace[0].split(\":\")[1].to_i\n end",
"def line_number\n\t\t\t@line_index + 1\n\t\tend",
"def line_number(pos=pos)\n line_index(pos) + 1\n end",
"def line_number(pos=pos())\n line_index(pos) + 1\n end",
"def lin... | [
"0.77366424",
"0.7610707",
"0.7297889",
"0.72958374",
"0.7276237",
"0.72306144",
"0.7224381",
"0.72243",
"0.7223026",
"0.7218484",
"0.7212791",
"0.7212791",
"0.7212791",
"0.7212791",
"0.7212791",
"0.7212791",
"0.7212791",
"0.7108751",
"0.7079458",
"0.7079458",
"0.7079458",
... | 0.7773393 | 0 |
Adds the event to the list of events | def add_event(event)
@list_of_events << event
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_events(new_events); end",
"def <<(add)\n @_events << add \n end",
"def push(event)\n @events.push(event)\n end",
"def record_event(event)\n @events_mutex.synchronize do\n @events << event\n end\n end",
"def add_event(event_id)\n\t\treturn ERR_UNSUCCESSFUL... | [
"0.77535295",
"0.7713343",
"0.7484306",
"0.7373104",
"0.73165375",
"0.71663284",
"0.7020312",
"0.7010055",
"0.69903207",
"0.69689035",
"0.6899304",
"0.6890351",
"0.68839157",
"0.68167365",
"0.67840266",
"0.67667526",
"0.67644536",
"0.67023915",
"0.6662739",
"0.66297203",
"0.6... | 0.90519327 | 0 |
Prints the events one by one | def print_events
if @filtered_events.length.zero?
puts 'List of events is empty'
else
(0..@filtered_events.length).each do |x|
temp_event = @filtered_events[x]
puts temp_event.trace
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_events(events)\n events.each do |name, description|\n puts \"Event: #{name}\"\n puts \"Description: #{description} \\n\\n\"\n end\n end",
"def print_event\n clear\n @talks.sort_by {|task| task.start_time }.each do |t|\n puts \"#{t.start_time.strftime(\"%I:%M%p\... | [
"0.8099862",
"0.74389297",
"0.7233531",
"0.72172785",
"0.7173616",
"0.71060103",
"0.69325256",
"0.69086456",
"0.6794468",
"0.6791981",
"0.66129893",
"0.6533328",
"0.6512295",
"0.64493334",
"0.64128244",
"0.6406028",
"0.63991565",
"0.63930964",
"0.6180031",
"0.61016333",
"0.60... | 0.7645054 | 1 |
Extract the execution trace for the student solution only. THis is done by finding the execution trace for the code that is surrounded by startTraceNow and endTraceNow function calls. | def exe_Point_Finder(trace)
symbol_stack = []
other_list = []
top_symbol = ''
exe = ''
exe_point = ' '
on = false
off = false
trace.split('').each do |i|
current_symbol = i
exe_point += current_symbol
if i == '{' or i == '[' or i == '('
symbol_stack << i
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trace(begX, begY, endX, endY)\n if solve(begX, begY, endX, endY)\n node = @tnode\n trace = Array.new\n while node != nil do\n trace.unshift(node.to_S)\n node = node.prev\n end\n\n trace.each do |elem|\n print elem, \" \"\n end\n print \"\\n\"\n else... | [
"0.61676794",
"0.61020243",
"0.5964391",
"0.5948465",
"0.59072137",
"0.58359414",
"0.57576954",
"0.5685536",
"0.5553746",
"0.55075586",
"0.5504756",
"0.54980147",
"0.54239726",
"0.54068494",
"0.5302817",
"0.53017026",
"0.52682984",
"0.52546424",
"0.52263254",
"0.5190801",
"0.... | 0.63415736 | 0 |
GET /podvals GET /podvals.xml | def index
@podvals = Podval.find(:all)
@podval = Podval.find_by_main(1)
if @podval == nil
@podvals = Podval.find_all_by_vis(1)
@podval = @podvals.choice
end
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @podvals }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def values(params = {})\n @client.get(\"#{path}/values\", params)\n end",
"def new\n @podval = Podval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @podval }\n end\n end",
"def get_prop(values)\n cmd = \"{\\\"id\\\":1,\\\"method\\\":\\... | [
"0.60993767",
"0.57483554",
"0.56734437",
"0.5239529",
"0.5156862",
"0.5083917",
"0.50354815",
"0.5031465",
"0.49419847",
"0.492067",
"0.49194166",
"0.49026126",
"0.4887002",
"0.48712024",
"0.48311663",
"0.481108",
"0.48047805",
"0.4791674",
"0.47803277",
"0.47778094",
"0.476... | 0.66280293 | 0 |
GET /podvals/new GET /podvals/new.xml | def new
@podval = Podval.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @podval }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @prop_value = PropValue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prop_value }\n end\n end",
"d... | [
"0.62041026",
"0.5975784",
"0.59499407",
"0.58696115",
"0.5821277",
"0.58180106",
"0.5790565",
"0.5777775",
"0.5769915",
"0.5724539",
"0.56767046",
"0.5672125",
"0.56688523",
"0.5617821",
"0.5609206",
"0.5586452",
"0.55854684",
"0.558404",
"0.55838054",
"0.5582039",
"0.556662... | 0.7312344 | 0 |
DELETE /podvals/1 DELETE /podvals/1.xml | def destroy
@podval = Podval.find(params[:id])
@podval.destroy
respond_to do |format|
format.html { redirect_to(podvals_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req... | [
"0.64152956",
"0.6399643",
"0.6387767",
"0.6370322",
"0.6267758",
"0.6196657",
"0.6159628",
"0.613705",
"0.61281145",
"0.61144996",
"0.60902584",
"0.6066382",
"0.6052238",
"0.6052238",
"0.60420334",
"0.6035436",
"0.6028942",
"0.60017455",
"0.59953773",
"0.5993745",
"0.5993745... | 0.7289542 | 0 |
GET /properties/new GET /properties/new.json | def new
@property = Property.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @property }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @property = Property.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @property }\n end\n end",
"def new\n @property = Property.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @property ... | [
"0.7802905",
"0.7802905",
"0.7802905",
"0.7802905",
"0.7802905",
"0.7799518",
"0.77899367",
"0.77023524",
"0.7676439",
"0.7641626",
"0.7340625",
"0.7294141",
"0.72753036",
"0.72743183",
"0.7229975",
"0.7199456",
"0.71836406",
"0.70413727",
"0.6951421",
"0.6927972",
"0.6655688... | 0.780913 | 0 |
Reset all associated sheets total_response_count to nil to trigger refresh of sheet answer coverage | def reset_sheet_total_response_count
sheets.where(missing: false).update_all(response_count: nil, total_response_count: nil, percent: nil)
sheets.where(missing: true).update_all(response_count: 0, total_response_count: 0, percent: 100)
SubjectEvent.where(id: sheets.select(:subject_event_id)).update_all(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset\n @results = @hits = @verified_hits = @total = @solr_response = @doc_ids = nil\n end",
"def reset\n @results = @hits = @verified_hits = @total = @solr_response = @doc_ids = nil\n end",
"def reset\n total_calls.clear\n total_success_calls.clear\n total_failed_cal... | [
"0.6726427",
"0.6726427",
"0.66224194",
"0.6501848",
"0.6456136",
"0.6179454",
"0.61737",
"0.6166184",
"0.6092449",
"0.6084171",
"0.6077026",
"0.6005463",
"0.5977864",
"0.5970744",
"0.59525883",
"0.59525883",
"0.5930283",
"0.5920953",
"0.5910665",
"0.5909001",
"0.59019107",
... | 0.8666964 | 0 |
POST /api/favourites?key= curl X POST v u admin:admin | def create
favourite=current_user.add_favourite(params[:key])
if favourite
respond_to do |format|
format.json { render :json => jsonp(favourites_to_json([favourite])) }
format.xml { render :xml => favourites_to_xml([favourite]) }
format.text { render :text => text_not_supported }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end",
"def favorite(action, value)\n raise ArgumentError, \"Invalid favorite action provided: #{action}\" unless @@FAVORITES_URIS.keys.member?(action)\n value = value.to_i.to_s unless value.is_a?(String)\n uri = \"#{@@FAVORITES_URIS[act... | [
"0.6387259",
"0.6329252",
"0.6308692",
"0.6107945",
"0.60683686",
"0.60001296",
"0.5972972",
"0.5876344",
"0.5863978",
"0.58421916",
"0.5823987",
"0.58015203",
"0.5791557",
"0.5779967",
"0.57413447",
"0.57254255",
"0.56926626",
"0.5689076",
"0.56798154",
"0.56775385",
"0.5673... | 0.6386259 | 1 |
Description Sets that the notification has been seen by the user (see Notificationhas_been_seen) Mode Ajax Specific filters NotificationsControllerinitialize_notification_with_owner | def seen
if @ok
@ok = @notification.has_been_seen
end
@new_notifications = current_user.number_notifications_not_seen
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saw_notification\n current_user.notice_seen = true\n current_user.save\n end",
"def notifications_count\n notifications_count ||= self.notifications_to_show_user.where(:seen_by_user => false).count\n end",
"def show\n @notification.seen = true\n @notification.save\n end",
"def notificat... | [
"0.6892667",
"0.66317225",
"0.65939784",
"0.63638735",
"0.61339563",
"0.59575915",
"0.59058136",
"0.58849347",
"0.5855978",
"0.5805134",
"0.5784054",
"0.5756029",
"0.5728686",
"0.5715061",
"0.5695581",
"0.56925845",
"0.5641947",
"0.56171817",
"0.5608322",
"0.5569345",
"0.5559... | 0.70680195 | 0 |
Initializes the notifications offset | def initialize_notification_offset
@offset_notifications = (correct_integer?(params[:offset]) ? params[:offset].to_i : NOTIFICATIONS_LOADED_TOGETHER)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_notifications\n @notifications = Notification.all\n end",
"def init_position\n @init_position\n end",
"def set_notifications\n\t\t@notifications = Notification.where(reciever_id: current_user).order(\"created_at DESC\")\n\tend",
"def offset!(offset)\n @offset = offset || 0\... | [
"0.5799061",
"0.57546103",
"0.5683678",
"0.5666489",
"0.5606115",
"0.55998945",
"0.5530408",
"0.55098337",
"0.55013764",
"0.54930305",
"0.54706126",
"0.54706126",
"0.54706126",
"0.5445654",
"0.5392907",
"0.53885037",
"0.53631544",
"0.53539306",
"0.5348342",
"0.5306498",
"0.53... | 0.84568256 | 0 |
Updates the last visited | def last_visited
Deck.find(params[:id]).update_attribute(:last_visited, DateTime.now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visited\n self.visited_at = Time.now\n self.save!\n end",
"def visited!\n self.count = self.count.to_i + 1\n self.last_used = Time.now\n save!\n end",
"def visit\n self.update(last_visit: DateTime.now);\n self.update(visit_count: (self.visit_count + 1));\n end",
"def update_... | [
"0.73839927",
"0.721183",
"0.66453266",
"0.6333308",
"0.5924842",
"0.5876325",
"0.58687824",
"0.58549196",
"0.58478695",
"0.5814965",
"0.57685786",
"0.56967264",
"0.56853765",
"0.5658096",
"0.565176",
"0.55385536",
"0.5486038",
"0.5485777",
"0.54771256",
"0.54714674",
"0.5465... | 0.7327326 | 1 |
Checks if the current user is the creator of the deck | def creator?
unless current_user.id == Deck.find(params[:id]).user_id
flash[:error] = "You do not have permission to modify this deck"
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owned?(user_to_check = current_user)\n user_to_check ? self.creator == user_to_check : false\n end",
"def creator?(object)\n current_user == object.user ? true : false\n \n end",
"def created_by?(user)\n unless user.nil?\n userid = user.send(BigbluebuttonRails.configuration.user_attr_id)\... | [
"0.77848387",
"0.77739817",
"0.7398696",
"0.73590356",
"0.7240787",
"0.7201834",
"0.7200356",
"0.71779436",
"0.7176693",
"0.7141878",
"0.7140763",
"0.7075012",
"0.70477724",
"0.70252395",
"0.7017225",
"0.69944763",
"0.6974815",
"0.6963963",
"0.6956399",
"0.6948928",
"0.691777... | 0.82552415 | 0 |
Rails 5.2 moved from a unary Migrator class to MigrationContext, that can be scoped to a given path. Rails 6.0 requires the schema migration object as an argument. | def migration_context
klass = ActiveRecord::MigrationContext
case klass.instance_method(:initialize).arity
when 1
klass.new(migration_path)
else
klass.new(migration_path, schema_migration)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migration(&block)\n if caller[0].rindex(/\\/(?:[0-9]+)_([_a-z0-9]*).rb:\\d+(?::in `.*')?$/)\n m = Object.const_set $1.camelize, Class.new(ActiveRecord::Migration)\n m.class_eval(&block) # 3.1\n else\n raise ArgumentError, \"Could not create migration at: #{caller[0]}\"\n end\n end",
... | [
"0.60223454",
"0.5730504",
"0.5651764",
"0.55012083",
"0.54448247",
"0.5438543",
"0.53481907",
"0.52664554",
"0.52230257",
"0.5205954",
"0.5120648",
"0.50873554",
"0.50873554",
"0.5083134",
"0.50599277",
"0.5045491",
"0.50440073",
"0.5040061",
"0.5036226",
"0.50357646",
"0.49... | 0.6889356 | 0 |
Write a value array to multiple pwm ports (or a single port if the param is a hash) | def write(values)
if values.is_a? Hash # TODO: hacky - refactor
fail "wrong hash format, expected the keys 'port' and 'value'" unless values.key?(:port) && values.key?(:value)
write_to_port(values[:port], values[:value])
elsif values.is_a? Array
log.error('more values than configured... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_port(port, value)\n value = value.to_i\n @values[port.to_i] = value\n # log.debug \"write bar #{port} value #{value}\"\n client.pwm_write(@ports[port.to_i], value)\n end",
"def pwm(value)\n GPIO.write \"gpio#{@number}/value\", value\n end",
"def ports *ports\n @port... | [
"0.7004192",
"0.5874171",
"0.5744025",
"0.5642534",
"0.5557398",
"0.5477633",
"0.5468817",
"0.54197204",
"0.5395847",
"0.53791815",
"0.53435653",
"0.5329575",
"0.53013176",
"0.5265486",
"0.52597994",
"0.5255402",
"0.51564205",
"0.51431113",
"0.5107263",
"0.5103409",
"0.508473... | 0.7972539 | 0 |
Write a value to a pwm port | def write_to_port(port, value)
value = value.to_i
@values[port.to_i] = value
# log.debug "write bar #{port} value #{value}"
client.pwm_write(@ports[port.to_i], value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pwm(value)\n GPIO.write \"gpio#{@number}/value\", value\n end",
"def pwm(v)\n regdata = @@i2c.read(0x08, 1)\n @@i2c.write([0x08, regdata[0] | (1 << @id)])\n @@i2c.write([@ion, v])\n @@i2c.write([0x08, regdata[0]])\n end",
"def update(value)\n @serial_port.puts value\... | [
"0.87874556",
"0.76924926",
"0.70983934",
"0.7093962",
"0.69010884",
"0.67103577",
"0.6678591",
"0.6648178",
"0.6571475",
"0.6500164",
"0.6472061",
"0.64682066",
"0.64077723",
"0.6370701",
"0.62217563",
"0.61374813",
"0.6110579",
"0.6110504",
"0.60622525",
"0.60194933",
"0.59... | 0.8472275 | 1 |
GET /days/new GET /days/new.xml | def new
@trip = Trip.find(params[:trip_id])
@prev_day = @trip.days[-1]
@day = Day.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @day }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @the_day = TheDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @the_day }\n end\n end",
"def new\n @user_day = UserDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_day }... | [
"0.7310398",
"0.69277835",
"0.6785754",
"0.67822",
"0.6775603",
"0.6694091",
"0.65848374",
"0.65452087",
"0.64741373",
"0.64677095",
"0.6448222",
"0.64481646",
"0.64406395",
"0.63979113",
"0.63979113",
"0.63979113",
"0.63979113",
"0.63979113",
"0.6370935",
"0.63697785",
"0.63... | 0.70595556 | 1 |
Query the API server for the root device | def root_device
begin
@root_device = open('http://instance-data/latest/meta-data/block-device-mapping/root').read
rescue
message.fatal 'Could not get the root device!'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_device_name\n data[:root_device_name]\n end",
"def root_device_type\n data[:root_device_type]\n end",
"def query_device_management\n @devices = query(\"select * from device_management \")\n end",
"def get_root\n http = Net::HTTP.start(@server_ip, @server_port)\n request... | [
"0.6693326",
"0.6457548",
"0.61086637",
"0.59151244",
"0.5870444",
"0.5663838",
"0.5659754",
"0.56459373",
"0.56307954",
"0.5594551",
"0.55858386",
"0.5581615",
"0.55655944",
"0.55509573",
"0.55283517",
"0.5521352",
"0.5515588",
"0.5510941",
"0.5438437",
"0.5416547",
"0.54066... | 0.7180721 | 0 |
Autodetect Devise scope using +Devise.default_scope+. Used to make the linkhelpers smart if like in most cases only one devise scope will be used, e.g. "user" or "account". | def auto_detect_scope(*args)
options = args.extract_options!
if options.key?(:for)
options[:scope] = options[:for]
::ActiveSupport::Deprecation.warn("DEPRECATION: " <<
"Devise scope :for option is deprecated. " <<
"Use: facebook_*_link(:some_scope... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_scope\n @default_scope ||= 'entitlements'\n end",
"def devise_scope(scope); end",
"def selected_scope\n (params[:scope] || :default).to_sym\n end",
"def default_search_scope\n @default_search_scope ||= default_search_scopes[controller_name.to_sym][:actions][action_name.to_sym] ... | [
"0.66070735",
"0.6594775",
"0.6593576",
"0.63586944",
"0.63586944",
"0.63369197",
"0.62723523",
"0.62362134",
"0.59804624",
"0.59734815",
"0.59291697",
"0.5908682",
"0.58899844",
"0.5889887",
"0.5889887",
"0.5771757",
"0.57378805",
"0.57091737",
"0.57091737",
"0.5700931",
"0.... | 0.73611414 | 0 |
Generate agnostic hidden sign in/out (connect) form for Facebook Connect. | def facebook_connect_form(scope, options = {})
sign_out_form = options.delete(:sign_out)
options.reverse_merge!(
:id => (sign_out_form ? 'fb_connect_sign_out_form' : 'fb_connect_sign_in_form'),
:style => 'display:none;'
)
scope = ::Devise::Mapping.fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fb_sign_out_tab\n %{\n <form action=\"/users/sign_out\" id=\"fb_connect_sign_out_form\" method=\"get\" style=\"display:none;\"></form>\n <li><a href=\"#\" onclick=\"FB.Connect.logoutAndRedirect('/users/sign_out')\"><span>Sign out</span></a></li>\n }\n end",
"def html_logout_form(cgi_dir)\n ... | [
"0.6992346",
"0.5685852",
"0.5656324",
"0.5525541",
"0.53849596",
"0.5353388",
"0.5326352",
"0.53056586",
"0.5285196",
"0.5282517",
"0.5274615",
"0.5268719",
"0.5264819",
"0.52586305",
"0.52490914",
"0.5213328",
"0.52072877",
"0.5185584",
"0.5177293",
"0.5154246",
"0.51484555... | 0.75580984 | 0 |
Test data: (;PB[Honinbo Shusaku]BR[6d]PW[Honinbo Shuwa]WR[8d]) | def test_data_hash
[{
'PB' => 'Honinbo Shusaku',
'BR' => '6d',
'PW' => 'Honinbo Shuwa',
'WR' => '8d',
'GC' => 'game from Hikaru no Go chapter 2, this version only in the anime',
'RE' => 'W+4'
}]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_DR_PDB\n data = \"DR PDB; 1NB3; X-ray; A/B/C/D=116-335, P/R/S/T=98-105.\"\n sp = SPTR.new(data)\n assert_equal([[\"1NB3\", \"X-ray\", \"A/B/C/D=116-335, P/R/S/T=98-105\"]],\n sp.dr['PDB'])\n end",
"def strand; @data[8]; end",
"def process_data(data)\n ... | [
"0.55512685",
"0.53138405",
"0.52826405",
"0.5220785",
"0.5218726",
"0.5201712",
"0.5189527",
"0.5176986",
"0.51764995",
"0.5163787",
"0.5154532",
"0.5125206",
"0.506041",
"0.5060026",
"0.5042854",
"0.50314355",
"0.50238216",
"0.49907583",
"0.49907136",
"0.4989221",
"0.496920... | 0.60254514 | 0 |
Append 'phrase' and 'translation'. If this 'phrase' already exists as key, then simply append 'translation' to the value array. | def append(phrase, translation)
phrase.strip!
translation.strip!
if @value_hash[phrase].nil?
@value_hash[phrase] = [translation]
else
@value_hash[phrase] << translation
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_translation(first, second)\r\n @dictionary[second] = first\r\n @dictionary[first] = second\r\n end",
"def add_translation(from, to)\n @dictionary[to] = from\n @dictionary[from] = to\n end",
"def add_word word #Function shovels individual strings into ... | [
"0.6549509",
"0.58722985",
"0.58677083",
"0.5681713",
"0.5624002",
"0.5559441",
"0.55037403",
"0.55037403",
"0.55036044",
"0.54069334",
"0.5338864",
"0.5314179",
"0.5296966",
"0.526507",
"0.5226372",
"0.5176444",
"0.5171205",
"0.5166237",
"0.5166237",
"0.5161603",
"0.51430196... | 0.83789486 | 0 |
Imports the dict.cc file given in the constructor and builds/writes the database files. | def import
read_dict_file(:langA)
write_database(:langA)
read_dict_file(:langB)
write_database(:langB)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(file)\n\t\t#Initializes superclass -- creates database.\n\t\tsuper\n\t\t#Creates tables if they not exist\n\t\tTABLES.each do |table|\n\t\t\tsql = \"CREATE TABLE IF NOT EXISTS #{table.header} (\"\n\t\t\ttable.columns.each {|column| sql += \"#{column.header} \" +\n\t\t\t\t\"#{column.type_constraint},... | [
"0.6305885",
"0.6237008",
"0.6169982",
"0.6139616",
"0.60817873",
"0.60049087",
"0.5991264",
"0.5945808",
"0.5920002",
"0.5895195",
"0.5876167",
"0.5869841",
"0.5865554",
"0.5822463",
"0.58046085",
"0.5761357",
"0.5747154",
"0.5736692",
"0.56692624",
"0.564758",
"0.5620761",
... | 0.66139275 | 0 |
Cause the CSVfile contains phrases we cannot be sure what is the most important word. This method strikes out everything between parenthesis, and if multiple words stay over, simply takes the longes one. | def extract_word( phrase )
w = phrase.gsub(/(\([^(]*\)|\{[^{]*\}|\[[^\[]*\])/, '').strip.downcase
return nil if w.empty? # No empty strings
# Now return the longest word, hoping that it's the most important, too
ary = w.gsub(/[.,\-<>]/, ' ').strip.split do |i| i.strip! end
ary.sort!{ |x,y| y.length ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_ambigious_words(file_name)\n File.open(file_name, 'w') do |f|\n sentences.each do |s|\n s.words.each do |w|\n tag_strings = w.get_correct_tags().collect { |t| t.clean_out_tag }\n f.puts w.string + \"\\t\" + tag_strings.sort.join(\"\\t\") if tag_strings.count > 1\n e... | [
"0.56514716",
"0.5527386",
"0.5458064",
"0.54185283",
"0.5280017",
"0.5211028",
"0.51405776",
"0.5105221",
"0.5092543",
"0.5079871",
"0.5069431",
"0.5043012",
"0.5033231",
"0.5020461",
"0.5016071",
"0.49755785",
"0.49654907",
"0.49645582",
"0.49581897",
"0.49507964",
"0.49314... | 0.5826419 | 0 |
Fulltext regexp lookup. Complexity: O(n) | def query_fulltext_regexp( query )
read_db do |dbm|
dbm.each_value do |raw_val|
val = RDictCcEntry.format_str(raw_val)
match_line_found = false
val.each_line do |line|
if line =~ /^\s+/
if match_line_found
puts line
else
# S... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(regexp); end",
"def match(keyword); end",
"def make_regexp\n @intent = self.intent\n regexp = self.pattern.dup.downcase\n words = regexp.split(\" \")\n words.each do |word|\n if word.include? '/'\n regexp = regexp.gsub(word,\"(#{word})\")\n\n end\n\n end\n regexp = ... | [
"0.68299747",
"0.6342473",
"0.62648624",
"0.61767787",
"0.617327",
"0.61730075",
"0.61099666",
"0.60797215",
"0.6057485",
"0.6057485",
"0.60552454",
"0.60254884",
"0.600918",
"0.5985297",
"0.5951371",
"0.59369147",
"0.59265125",
"0.59112245",
"0.59112245",
"0.58205426",
"0.57... | 0.68641853 | 0 |
Public: Setup callback on headers parsing complete block Block the block of code Examples headers = HttpProxy::HeadersParser.new headers.process do |parsing_result| p parsing_result["UserAgent"] end Returns nothing | def process(&block)
@parser.on_headers_complete = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parser_init\n @http = Http::Parser.new\n @http.on_headers_complete = proc do\n p @http.headers\n end\n @http.on_body = proc do |chunk|\n # One chunk of the body\n p chunk\n end\n\n @http.on_message_complete = proc do |env|\n # Headers and body is all pa... | [
"0.7018227",
"0.69397557",
"0.692272",
"0.66465926",
"0.65960246",
"0.6448536",
"0.61827725",
"0.61497754",
"0.61497754",
"0.61497754",
"0.61497754",
"0.60907024",
"0.59932834",
"0.596692",
"0.59114987",
"0.5881159",
"0.58745456",
"0.58024544",
"0.5777607",
"0.5706517",
"0.56... | 0.83165455 | 0 |
Move the cursor to specified row. The main window and the headers will be updated reflecting the displayed files and directories. The row number can be out of range of the current page. | def move_cursor(row = nil)
if row
if (prev_item = items[current_row])
main.draw_item prev_item
end
page = row / max_items
switch_page page if page != current_page
main.activate_pane row / maxy
@current_row = row
else
@current_row = 0
en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_row(row)\n \n set RGhost::Cursor.goto_row(row) \n end",
"def jump_rows(row)\n @rows+=row\n set RGhost::Cursor.jump_rows(row)\n end",
"def select_row(row_number = 0)\n set_cursor(Gtk::TreePath.new(row_number), nil, false)\n end",
"def update_head_vertical_location(row)\n l... | [
"0.72010726",
"0.68817645",
"0.6806795",
"0.64135754",
"0.64131194",
"0.6307145",
"0.6255472",
"0.6245421",
"0.62252295",
"0.61407685",
"0.60533386",
"0.6020533",
"0.59794873",
"0.5968704",
"0.5912319",
"0.5890729",
"0.5836306",
"0.583052",
"0.5828907",
"0.58208406",
"0.58069... | 0.84249705 | 0 |
Sort the whole files and directories in the current directory, then refresh the screen. ==== Parameters +direction+ Sort order in a String. nil : order by name r : reverse order by name s, S : order by file size sr, Sr: reverse order by file size t : order by mtime tr : reverse order by mtime c : order by ctime cr : re... | def sort(direction = nil)
@direction, @current_page = direction, 0
sort_items_according_to_current_direction
switch_page 0
move_cursor 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_items_according_to_current_direction\n case @direction\n when nil\n @items = items.shift(2) + items.partition(&:directory?).flat_map(&:sort)\n when 'r'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort.reverse}\n when 'S', 's'\n @it... | [
"0.6753547",
"0.62339425",
"0.6180216",
"0.605791",
"0.5885136",
"0.57776505",
"0.5731589",
"0.57272637",
"0.5712036",
"0.5698475",
"0.5698475",
"0.5698475",
"0.5698475",
"0.5698475",
"0.56878465",
"0.56710196",
"0.56634325",
"0.56546617",
"0.56546617",
"0.5644094",
"0.564409... | 0.7013775 | 0 |
Change the file permission of the selected files and directories. ==== Parameters +mode+ Unix chmod string (e.g. +w, gr, 755, 0644) | def chmod(mode = nil)
return unless mode
begin
Integer mode
mode = Integer mode.size == 3 ? "0#{mode}" : mode
rescue ArgumentError
end
FileUtils.chmod mode, selected_items.map(&:path)
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chmod(mode) File.chmod(mode, path) end",
"def chmod(mode, options={})\n #list = list.to_a\n fileutils.chmod(mode, list, options)\n end",
"def chmod(file, mode)\n if File.stat(file).mode != mode\n FileUtils.chmod(mode, file, :verbose => verbose?) \n end\n end",
"def c... | [
"0.7961633",
"0.79208547",
"0.79111606",
"0.7789717",
"0.7640511",
"0.76338196",
"0.7572123",
"0.75515854",
"0.7550537",
"0.7530089",
"0.751246",
"0.7440374",
"0.7425923",
"0.7330557",
"0.72711575",
"0.724482",
"0.7224371",
"0.72054064",
"0.72024363",
"0.7167651",
"0.7126878"... | 0.7932743 | 1 |
Change the file owner of the selected files and directories. ==== Parameters +user_and_group+ user name and group name separated by : (e.g. alice, nobody:nobody, :admin) | def chown(user_and_group)
return unless user_and_group
user, group = user_and_group.split(':').map {|s| s == '' ? nil : s}
FileUtils.chown user, group, selected_items.map(&:path)
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_owner(username, group, path)\n %x(sudo chown -R #{Shellwords.escape(username)}:#{Shellwords.escape(group)} #{path})\n\n $?.success?\n end",
"def set_owner\n user = @conf['user'] || Process.uid\n group = @conf['group'] || Process.gid\n\n begin\n FileUtils.chown_R(use... | [
"0.7031798",
"0.6613002",
"0.64483887",
"0.6332136",
"0.63318396",
"0.63233644",
"0.62693286",
"0.62464225",
"0.6110811",
"0.61022156",
"0.5947538",
"0.5878171",
"0.58744186",
"0.5788736",
"0.5786735",
"0.57764375",
"0.5693316",
"0.5679787",
"0.5665396",
"0.5661425",
"0.56358... | 0.7470499 | 0 |
Fetch files from current directory or current .zip file. | def fetch_items_from_filesystem_or_zip
unless in_zip?
@items = Dir.foreach(current_dir).map {|fn|
load_item dir: current_dir, name: fn
}.to_a.partition {|i| %w(. ..).include? i.name}.flatten
else
@items = [load_item(dir: current_dir, name: '.', stat: File.stat(current_dir))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_files\n retrieve_files_in_main_dir\n end",
"def retrieve_files_in_main_dir\n ensure_file_open!\n @file.glob('*').map do |entry|\n next if entry.directory?\n\n entry_file_name = Pathname.new(entry.name)\n [entry_file_name, entry.get_input_stream(&:read)]\n end.compact.to_h\n ... | [
"0.6927383",
"0.6580163",
"0.65114397",
"0.6503587",
"0.64773613",
"0.6402373",
"0.62845725",
"0.62720746",
"0.6225117",
"0.6222155",
"0.62179345",
"0.6168878",
"0.6163954",
"0.61059165",
"0.60978436",
"0.6096858",
"0.6085929",
"0.6067498",
"0.606264",
"0.6007258",
"0.600525"... | 0.7121194 | 0 |
Rename selected files and directories. ==== Parameters +pattern+ new filename, or a shash separated Regexp like string | def rename(pattern)
from, to = pattern.sub(/^\//, '').sub(/\/$/, '').split '/'
if to.nil?
from, to = current_item.name, from
else
from = Regexp.new from
end
unless in_zip?
selected_items.each do |item|
name = item.name.gsub from, to
FileUtils.mv ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_all(pattern, replace)\n Dir.new('.').each do |f|\n File.rename(f, f.gsub(pattern, replace)) if f.match(pattern)\n end\nend",
"def rename(root, pattern, replacement, force: false, excluding: nil)\n options = {force: force, excluding: excluding}\n\n ::Find.find(root) do |path|\n ... | [
"0.6490024",
"0.6006657",
"0.5734607",
"0.57127804",
"0.5549183",
"0.5548546",
"0.55439925",
"0.55129874",
"0.5512433",
"0.5495125",
"0.54512054",
"0.5416406",
"0.5378884",
"0.53518045",
"0.53289044",
"0.52556765",
"0.5229619",
"0.5212441",
"0.51935375",
"0.51900387",
"0.5175... | 0.736625 | 0 |
Change the timestamp of the selected files and directories. ==== Parameters +timestamp+ A string that can be parsed with `Time.parse`. Note that this parameter is not compatible with UNIX `touch t`. | def touch_t(timestamp)
FileUtils.touch selected_items, mtime: Time.parse(timestamp)
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modified_at(file, timestamp = nil)\n require 'date'\n time = timestamp ? DateTime.parse(\"#{timestamp}\") : DateTime.now\n timestamp = time.strftime('%Y%m%d%H%M')\n execute(\"/bin/touch -mt #{timestamp} #{file}\")\n end",
"def timestamp=(timestamp)\n @timestamp = _check_timestamp(timestamp)... | [
"0.6365125",
"0.6343466",
"0.6308022",
"0.6152845",
"0.5780877",
"0.5666242",
"0.5505432",
"0.53912926",
"0.5374339",
"0.52755016",
"0.5058137",
"0.50204706",
"0.5016717",
"0.5002579",
"0.49970952",
"0.49921483",
"0.49688482",
"0.49676868",
"0.49618778",
"0.4936849",
"0.49342... | 0.7202312 | 0 |
Paste yanked files / directories here. | def paste
if @yanked_items
if current_item.directory?
FileUtils.cp_r @yanked_items.map(&:path), current_item
else
@yanked_items.each do |item|
if items.include? item
i = 1
while i += 1
new_item = load_item dir: current_dir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blacklisted_dir_entries\n %w[. ..]\n end",
"def replicate_dir(f)\n out_original = f.sub($queue,$original)\n out_watermarked = f.sub($queue,$watermarked)\n if !File.exist?(out_original) && !File.exist?(out_watermarked)\n FileUtils.mkdir(out_original)\n FileUtils.mkdir(out_watermarke... | [
"0.563246",
"0.5365304",
"0.53574353",
"0.53080815",
"0.5290943",
"0.5287722",
"0.5275275",
"0.52750075",
"0.52619284",
"0.52032536",
"0.5198403",
"0.51540506",
"0.513296",
"0.5128863",
"0.5099883",
"0.50897795",
"0.50862366",
"0.50715935",
"0.5070146",
"0.5068272",
"0.506636... | 0.7160363 | 0 |
Copy selected files and directories' path into clipboard on OSX. | def clipboard
IO.popen('pbcopy', 'w') {|f| f << selected_items.map(&:path).join(' ')} if osx?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_clipboard_copy\n return nil unless sel=@selection and dat=@data[sel]\n # XXX i feel dirty\n if Wx::PLATFORM == \"WXMAC\"\n IO.popen(\"pbcopy\", \"w\") {|io| io.write dat}\n stat = $?.success?\n else\n dobj = RawDataObject.new(dat)\n stat = Wx::Clipboard.open {... | [
"0.7115079",
"0.7002764",
"0.69583875",
"0.6808353",
"0.6765171",
"0.6653057",
"0.663103",
"0.6491936",
"0.64842623",
"0.64713055",
"0.6452405",
"0.6452405",
"0.64059824",
"0.6365171",
"0.6360526",
"0.63305914",
"0.63264066",
"0.6302481",
"0.62640446",
"0.61834943",
"0.611143... | 0.8589144 | 0 |
Unarchive .zip and .tar.gz files within selected files and directories into current_directory. | def unarchive
unless in_zip?
zips, gzs = selected_items.partition(&:zip?).tap {|z, others| break [z, *others.partition(&:gz?)]}
zips.each do |item|
FileUtils.mkdir_p current_dir.join(item.basename)
Zip::File.open(item) do |zip|
zip.each do |entry|
File... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpack( archive, into = Dir.pwd )\n Dir.chdir( into ) do \n if archive.match( /\\.tar\\.gz\\Z/ ) or archive.match(/\\.tgz\\Z/) then\n tgz = ::Zlib::GzipReader.new( File.open( local_source, 'rb') )\n ::Archive::Tar::Minitar.unpack( tgz, into )\n elsif archive.match( /\\.gem\... | [
"0.62768906",
"0.61366785",
"0.598008",
"0.5943704",
"0.59319764",
"0.59226274",
"0.58503044",
"0.5823995",
"0.5799449",
"0.57321995",
"0.5729694",
"0.5718601",
"0.5682455",
"0.567469",
"0.5632223",
"0.56250256",
"0.557718",
"0.5564379",
"0.5561875",
"0.55276746",
"0.5514639"... | 0.70867246 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.