query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Insertion Sort in Ruby Input: A sequence of numbers in any order. Output: An ordered sequence from smallest number to largest. | def insertion_sort(numbers)
# Iterate through the length of the array,
# beginning with the second element numbers[i].
(1...numbers.length).each do |i|
key = numbers[i]
j = i - 1
# If element to left of key is larger then
# move it one position over at a time.
while (j >= 0) && (numbers[j] > key)
numbers[j + 1] = numbers[j]
j -= 1
end
# Update key position.
numbers[j + 1] = key
puts numbers.inspect
end
# Return sorted array.
numbers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertion_sort(a)\n array = a\n \n 1.upto(array.length-1) do |i|\n if array[i] < array[i-1]\n # need to shift everything over until it isn't\n i.downto(1) do |j|\n if array[j] < array[j-1]\n array[j], array[j-1] = array[j-1], array[j]\n end\n end\n end\n end\n \... | [
"0.8061423",
"0.8012473",
"0.7992144",
"0.79891974",
"0.79742914",
"0.7911019",
"0.7890844",
"0.78466815",
"0.7846371",
"0.7817174",
"0.78171116",
"0.77965105",
"0.77932614",
"0.77490896",
"0.7710184",
"0.7703099",
"0.7703099",
"0.7701267",
"0.76940566",
"0.7677537",
"0.76372... | 0.78812414 | 7 |
Render file With given path and filename, pdf can be rendered to a specific location. If no arguments are given, filename will be set to SimpleCV.pdf and pdf will be rendered to current working dir. | def render_file filename: "SimpleCV", path: nil
output_path = File.join(path || Dir.pwd, "#{filename.chomp('.pdf')}.pdf")
Layout.new(config: @config).render_file(output_path)
output_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_pdf_to_file(path)\n Payday::PdfRenderer.render_to_file(self, path)\n end",
"def render_file(filename)\n to_file(filename)\n end",
"def render_file(filename)\n to_file(filename)\n end",
"def render_pdf src, *opts\n render src, {render: {format: 'pdf'}}, *opts\n end",
"def ... | [
"0.6964741",
"0.668092",
"0.668092",
"0.6573279",
"0.65596604",
"0.65410566",
"0.6501449",
"0.64676464",
"0.6445028",
"0.6436728",
"0.6385988",
"0.63768154",
"0.6341754",
"0.63127446",
"0.6298513",
"0.61958516",
"0.6185528",
"0.61521304",
"0.6151419",
"0.6125221",
"0.6078691"... | 0.8965462 | 0 |
Parse config Currently yml and json files are supported. Will parse file content to hash. | def parse_config_file config_path
File.open(config_path, "r") do |file|
case File.extname(file).delete(".")
when "json" then JSON.parse(file.read)
when "yml" then YAML.load_file(file)
else
file.close
raise LoadError, "Type of file is not supported."
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_config_file(file)\n return {} unless File.exist?(file)\n\n case File.extname(file)\n when /\\.conf$/i\n parse_conf_file(file)\n when /\\.json$/i\n Oj.load_file(file, mode: :strict, symbol_keys: true)\n when /\\.ya?ml$/i\n begin\n re... | [
"0.7548743",
"0.73195314",
"0.72051847",
"0.7066246",
"0.6971313",
"0.68963796",
"0.68358713",
"0.68199104",
"0.6790183",
"0.6786673",
"0.6775816",
"0.6760532",
"0.6688929",
"0.65386873",
"0.64809805",
"0.6452259",
"0.64205426",
"0.64149135",
"0.63795435",
"0.63592905",
"0.63... | 0.75382453 | 1 |
Struct tree Since i prefere to use dot notation to navigate through medium size hashes, parse hash into open structs | def build_struct_tree data
data.to_hashugar
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_structural_subhashes\n hashes = []\n self.deep_each do |node|\n hashes << node.structural_hash\n end\n hashes\n end",
"def hash_from_git(tree)\n ({}).tap do |objs|\n tree.each do |b|\n objs[b.name] = (\n case b\n when Grit::Tree\n ... | [
"0.61766213",
"0.60950655",
"0.60317254",
"0.5922331",
"0.5878212",
"0.5801947",
"0.5774349",
"0.5732302",
"0.56896484",
"0.56864244",
"0.56756496",
"0.56640905",
"0.5663623",
"0.5644442",
"0.56422615",
"0.5599507",
"0.55769235",
"0.55693793",
"0.5562669",
"0.5562669",
"0.554... | 0.68475395 | 0 |
PUT /module/1 PUT /module/1.json | def update
if @current_category.update_attributes(params[:module])
head :no_content
else
render json: @current_category.errors.full_messages,
status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @ects_module.update(ects_module_params)\n format.html { redirect_to @ects_module, notice: 'ects module was successfully updated.' }\n format.json { render :show, status: :ok, location: @ects_module }\n else\n format.html { render :edit }\n ... | [
"0.6414825",
"0.6318561",
"0.605133",
"0.5977314",
"0.59211814",
"0.5901132",
"0.5881119",
"0.5881119",
"0.58130157",
"0.5806737",
"0.5796075",
"0.5790087",
"0.5787361",
"0.5775115",
"0.5707838",
"0.56898606",
"0.5657163",
"0.5620753",
"0.5611822",
"0.55807686",
"0.55742365",... | 0.5586647 | 19 |
DELETE /module/1 DELETE /module/1.json | def destroy
if @current_category.destroy
head :no_content
else
render json: @current_category.errors.full_messages,
status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_module(org_unit_id, module_id) # DELETE\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/modules/#{module_id}\"\n _delete(query_string)\nend",
"def destroy\n @modrequest.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n ... | [
"0.7672092",
"0.7077842",
"0.7015859",
"0.7001552",
"0.69457036",
"0.69308305",
"0.6892164",
"0.673723",
"0.6700789",
"0.66643244",
"0.66528094",
"0.6623733",
"0.65581876",
"0.6543506",
"0.6541895",
"0.6529357",
"0.6529357",
"0.6529357",
"0.6529357",
"0.6521631",
"0.6520757",... | 0.0 | -1 |
Accepts various types of input and returns an array of hex digit chars Invalid input is disregarded | def process(*args)
args.map { |arg| convert(arg) }.flatten.compact.map(&:upcase)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hex_to_chars(hex_string)\n hex_to_bytes(hex_string).map(&:chr).join\nend",
"def to_ints(hex)\n hex.scan(/\\w\\w/).map(&:hex)\nend",
"def to_ints(hex)\n r,g,b = hex.scan(/\\w\\w/)\n [r,g,b].map do |s|\n s.hex\n end\nend",
"def hex() end",
"def hexlify\n offset = 0\n while (str = $stdin.read(16... | [
"0.6509117",
"0.63288623",
"0.6288194",
"0.62833667",
"0.6274612",
"0.6131243",
"0.60909766",
"0.6072862",
"0.6028295",
"0.60215044",
"0.6005417",
"0.5994793",
"0.5990408",
"0.59466136",
"0.59134424",
"0.5898328",
"0.58977294",
"0.581699",
"0.58114934",
"0.5784939",
"0.578486... | 0.0 | -1 |
Convert a single value to hex chars | def convert(value)
case value
when Array then value.map { |arr| process(*arr) }.reduce(:+)
when String then TypeConversion.hex_str_to_hex_chars(filter_string(value))
when Integer then TypeConversion.numeric_byte_to_hex_chars(filter_numeric(value))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hex\n @value.unpack(\"H*\").join\n end",
"def hex(value)\n \"0x\" + value.to_s(16)\n end",
"def hex(value)\n value[1..-1].hex + 0xff000000\n end",
"def to_hex(val)\n HEXVAL[val / 16] + HEXVAL[val % 16]\n end",
"def get_hex(x)\n val = x.to_i.to_s(16)\n val = \"0#{val... | [
"0.83374125",
"0.8015882",
"0.78711987",
"0.78222567",
"0.77254903",
"0.7682318",
"0.75690764",
"0.7472246",
"0.73356205",
"0.7331216",
"0.73104787",
"0.7227832",
"0.7206409",
"0.7172951",
"0.7170176",
"0.7071756",
"0.70586485",
"0.705404",
"0.70298505",
"0.70136595",
"0.7007... | 0.0 | -1 |
Limit the given number to bytes usable in MIDI ie values (0..240) returns nil if the byte is outside of that range | def filter_numeric(num)
num if (0x00..0xFF).include?(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_allowed_bytesize(v, max)\n end",
"def convertRawEntry(num)\n @num = num\n if @num > 8192 || @num < -8192\n puts \"Please enter a number between -8192 and 8192\"\n else\n @num = @num + 8192\n end\n return @num\nend",
"def specific_max_size(number); end",
"def specific_max_... | [
"0.60715604",
"0.5771188",
"0.5708443",
"0.5658267",
"0.5602081",
"0.54920053",
"0.54898477",
"0.54592913",
"0.5426192",
"0.54230154",
"0.54219615",
"0.5401221",
"0.53822684",
"0.5352553",
"0.52794874",
"0.5266962",
"0.52569425",
"0.52297264",
"0.52167976",
"0.51918733",
"0.5... | 0.51065975 | 32 |
Only return valid hex string characters | def filter_string(string)
string.gsub(/[^0-9a-fA-F]/, '').upcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_hexword(s)\n s.match(/^[0-9a-fA-F]{8}$/) != nil\nend",
"def hex?(c)\n return false if c.nil?\n c =~ /[a-fA-F0-9]/\n end",
"def from_hex(str)\n str.to_s.hex\nend",
"def to_hex(s); s && s.unpack('H*').first; end",
"def validate(string)\n error = \"Invalid: arg must be h... | [
"0.7764451",
"0.73407316",
"0.69129",
"0.6869009",
"0.68079203",
"0.6793661",
"0.6762764",
"0.66947204",
"0.66905653",
"0.6675717",
"0.6617603",
"0.659672",
"0.655707",
"0.65444756",
"0.6533307",
"0.65140843",
"0.648486",
"0.6439213",
"0.64186203",
"0.63672054",
"0.63584685",... | 0.62408924 | 27 |
initializes the shell with command line argments: +options+ is expected to be the hash structure as provided by GetOptions.new(..) +args+ is the remaining command line arguments | def initialize(options, args)
defaults = {
interval: 1
}
@options = defaults.merge((options || {}).each { |k, v| { k => v } })
return unless args.first
resolve_addressing args.first
normalise_options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(args = [])\n self.args = args\n self.options = default_options\n extract_options!\n end",
"def initialize(given_args=ARGV)\n @options, @arguments, @extras = self.class.parse_options!(given_args)\n end",
"def initialize(args)\n @options = parse_arguments(ar... | [
"0.7345227",
"0.70937043",
"0.7091874",
"0.7082233",
"0.7075618",
"0.69920796",
"0.6934902",
"0.6834547",
"0.6807191",
"0.67901874",
"0.6720319",
"0.67198807",
"0.6711431",
"0.6685116",
"0.66299623",
"0.6621281",
"0.6602926",
"0.65914834",
"0.6577038",
"0.6455143",
"0.6453674... | 0.0 | -1 |
decodes the +host+ string to type, host, port and sets the uri | def resolve_addressing(host)
@uri = URI.parse(host)
unless uri.scheme
@options[:type] = :icmp
@options[:host] = uri.to_s
@options[:url] = "#{@options[:type]}://#{@options[:host]}"
return
end
@options[:url] = uri.to_s
@options[:type] = uri.scheme.to_sym
@options[:port] = uri.port
@options[:host] = uri.host
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host_set(host)\n rebuild_uri :host => host\n end",
"def host=(host)\n @uri = host.is_a?(::URI) ? host : ::URI.parse(host)\n reset_http_client!\n @uri\n end",
"def uri(string)\n return if string.blank?\n\n string = URI(string) unless string.is_a?(URI)\n\n # Rewrite... | [
"0.6690252",
"0.65427667",
"0.6499733",
"0.6479265",
"0.6479265",
"0.64782375",
"0.641376",
"0.6391005",
"0.63698196",
"0.6353286",
"0.63482046",
"0.6335675",
"0.62840605",
"0.62735975",
"0.6254349",
"0.62458897",
"0.6216646",
"0.6211964",
"0.62074643",
"0.617109",
"0.6169184... | 0.73271245 | 0 |
sets defaults where required | def normalise_options
@options[:interval] = @options[:interval].to_i
@options[:limit] = @options[:limit].to_i if @options[:limit]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults\n end",
"def set_defaults\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"de... | [
"0.873658",
"0.873658",
"0.86410475",
"0.86410475",
"0.86410475",
"0.86410475",
"0.86410475",
"0.86410475",
"0.8239994",
"0.8239994",
"0.8239994",
"0.8239994",
"0.8239994",
"0.8239994",
"0.8239994",
"0.8239994",
"0.8239994",
"0.8239994",
"0.7934886",
"0.7934886",
"0.7925624",... | 0.0 | -1 |
runs the ping task | def run
case options[:type]
when :icmp, :http, :https, :tcp, :udp, :ldap, :ldaps
Igp::Base.new(options).run
else
usage
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ping(t)\n \n end",
"def ping\n end",
"def ping\n send_command(\"ping\")\n end",
"def ping()\n\n ip = Resolv.getaddress(@host)\n puts ('ip: ' + ip.inspect).debug if @debug\n valid = pingecho(ip)\n puts ('valid: ' + valid.inspect).debug if @debug \n \n ... | [
"0.7655423",
"0.7639167",
"0.7534804",
"0.75288725",
"0.7496398",
"0.73843414",
"0.7235293",
"0.7175965",
"0.71324396",
"0.7118831",
"0.7077445",
"0.70688343",
"0.6993442",
"0.69611835",
"0.6960561",
"0.6952976",
"0.6932198",
"0.6929964",
"0.6927017",
"0.69077367",
"0.6907190... | 0.0 | -1 |
Returns the value as a signed byte | def as_signed_byte(value)
[ value ].pack("c").unpack("c").first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_byte(ret_val)\n ret_val = [ret_val].pack(\"c\").unpack(\"c\")[0]\n return ret_val\n end",
"def byte\n Util.from_bytes :byte, value\n end",
"def bytea(value)\n \"'\\\\x#{value.unpack1('H*')}'::bytea\"\n end",
"def b(value)\n (value & 0x0000ff00) >> 8\n end",
"def b(... | [
"0.8348625",
"0.7233188",
"0.669972",
"0.6645432",
"0.6645432",
"0.6573223",
"0.65700823",
"0.65375465",
"0.65131336",
"0.649424",
"0.6427628",
"0.63983047",
"0.63928485",
"0.63245356",
"0.6301652",
"0.6282306",
"0.6276423",
"0.6262695",
"0.6262695",
"0.62183076",
"0.6142884"... | 0.8857956 | 0 |
The block is executed to write data to the source. The interface is exactly as IO::write, ie. it should write the string and return the number of bytes written. | def on_write &block
signal_connect "write" do |p, len|
chunk = p.get_bytes(0, len)
bytes_written = block.call chunk
chunk.clear
bytes_written
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(&block)\n @write_block = block\n end",
"def write(data); end",
"def write(data); end",
"def write(data); end",
"def write(data); end",
"def write( &block )\n compile!( :write!, &block )\n end",
"def write(string)\n\t\t\t\t@write_buffer << string\n\t\t\t\t\n\t\t\t\tif @writ... | [
"0.67735183",
"0.64229625",
"0.64229625",
"0.64229625",
"0.64229625",
"0.6407237",
"0.63582295",
"0.6170242",
"0.61543965",
"0.6147088",
"0.60991687",
"0.5980544",
"0.5953409",
"0.5945571",
"0.5929148",
"0.59152246",
"0.59150356",
"0.59150356",
"0.5913757",
"0.5908059",
"0.59... | 0.6469137 | 2 |
The block is executed at the end of write. It should do any necessary finishing action, such as closing a file. | def on_finish &block
signal_connect "finish" do
block.call
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_write() end",
"def close_write() end",
"def close_write() end",
"def close_write; end",
"def close_write(*) end",
"def _close_write\n @_write_closed = true\n end",
"def close_write\n io.close_write\n succeed\n end",
"def write(&block)\n @write_block = block\n end",
... | [
"0.74283844",
"0.74283844",
"0.74283844",
"0.7352182",
"0.72666043",
"0.70557076",
"0.6976947",
"0.69148356",
"0.6856135",
"0.6731622",
"0.6723429",
"0.65208274",
"0.64199257",
"0.6413462",
"0.63588524",
"0.6348959",
"0.6334827",
"0.6312477",
"0.63093424",
"0.6282862",
"0.628... | 0.0 | -1 |
Initialize and parse command line arguments. | def initialize(argv)
@max = 10000
@ceil = nil
args = cli argv,
'-n --num' => lambda{ |d| @num = d.to_i },
'-m --max' => lambda{ |m| @max = m.to_i },
'-a --abs' => lambda{ @abs = true },
'-c --ceil' => lambda{ |c| @ceil = c.to_i },
'-d --debug' => lambda{ $DEBUG = true },
'-h --help' => lambda{ show_help }
directory = args.first
@letters = Analysis::Letters.new(directory)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(args = {})\n parse_args(args)\n end",
"def initialize(given_args=ARGV)\n @options, @arguments, @extras = self.class.parse_options!(given_args)\n end",
"def initialize(*args)\n return self if args.empty?\n parsed_args = args.first.is_a?(Hash) ? args.first : parse_string_args(arg... | [
"0.8002239",
"0.7895949",
"0.78590864",
"0.7708795",
"0.76359856",
"0.7456838",
"0.7358723",
"0.72892344",
"0.7278524",
"0.7196554",
"0.71808124",
"0.7143765",
"0.7133567",
"0.71302783",
"0.7102815",
"0.7100616",
"0.7068929",
"0.7066295",
"0.7064324",
"0.6982161",
"0.69805294... | 0.6531448 | 51 |
Delete a record from the session, if it exists. Does nothing if no such record can be found. | def delete_record(rec_label)
record = records.find { |r| r.label == rec_label }
return unless record
File.delete(record.path)
records.delete(record)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete record\n db_name = database_name_for(record)\n coll_name = collection_name_for(record)\n case\n when id = id_for(record)\n pointer = \"/#{db_name}/#{coll_name}/#{id}\"\n res = collection_for(record).remove({:_id => id})\n if res[\"err\"]\n ... | [
"0.7314655",
"0.70252",
"0.6989838",
"0.69799626",
"0.681745",
"0.6814504",
"0.6765275",
"0.67612517",
"0.67224896",
"0.6697067",
"0.6597046",
"0.65364236",
"0.65319914",
"0.64074844",
"0.64063644",
"0.6406193",
"0.63687676",
"0.6356418",
"0.6282666",
"0.6279634",
"0.62649745... | 0.66272336 | 10 |
Delete the entire session. | def unlink!
FileUtils.rm_rf(directory)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n if @session\n @session.destroy\n @session = nil\n end\n end",
"def delete\n return unless @session\n @session.destroy\n @session = nil\n end",
"def destroy\n self.class.delete_all(\"session_id='#{session_id}'\")\n end",
"def destroy\n @sessio... | [
"0.8182993",
"0.8102169",
"0.80801123",
"0.79682916",
"0.75319916",
"0.75301474",
"0.74564266",
"0.7426628",
"0.73337364",
"0.73242813",
"0.73221934",
"0.72605556",
"0.7186315",
"0.71732634",
"0.71707475",
"0.71438247",
"0.71438247",
"0.71438247",
"0.71438247",
"0.7137324",
"... | 0.0 | -1 |
Load all records associated with the session. | def load_records!
record_paths.map do |path|
Record.load_record! self, path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load\n records.load\n end",
"def load\n records.__send__(:load)\n end",
"def load_records\n native_instance(true)\n native_instance.top(limit) if limit.present?\n Array(service.native_instance.execute)\n end",
"def records(refresh = false)\n @con... | [
"0.7531697",
"0.7095353",
"0.6769842",
"0.66366005",
"0.6508354",
"0.6499976",
"0.646691",
"0.6442296",
"0.64020395",
"0.61730653",
"0.6165642",
"0.61101776",
"0.6095337",
"0.5988551",
"0.59546685",
"0.5908408",
"0.5859155",
"0.5852138",
"0.5844064",
"0.5840702",
"0.5815225",... | 0.6778582 | 2 |
If the index was not given a name during creation, the index name is __idx. | def drop_index(index_name)
keyspace_execute "DROP INDEX #{index_name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_name=(name)\n @index_name = name\n end",
"def index_name=(name)\n @index_name = name\n end",
"def index_name\n @index_name ||= @options[:index_name] ||\n __get_class_value(:index_name) ||\n DEFAULT_INDEX_NAME\n ... | [
"0.7845004",
"0.7845004",
"0.78225756",
"0.76646703",
"0.7491866",
"0.7345467",
"0.73281467",
"0.73145217",
"0.7235547",
"0.72177774",
"0.70905447",
"0.7048802",
"0.7007219",
"0.69598895",
"0.69598895",
"0.68929946",
"0.68712324",
"0.68582404",
"0.6827721",
"0.67970467",
"0.6... | 0.0 | -1 |
where n is is the number of dates where k is the number of unique site names for that day Space complexity is O(n) | def print_by_count(organized_data)
organized_dates_only = organized_data.keys.sort
puts "***RESULTS START***"
puts ""
organized_dates_only.each do |date|
puts date
site_to_hits = organized_data[date].sort_by {|site, hits| -hits}
site_to_hits.each do |hit|
site_name = hit[0]
total_hits = hit[1]
puts "#{site_name} #{total_hits}"
end
puts ""
end
puts "***RESULTS END***"
puts ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_distinct(*date)\n distinct_in_structure(@content.dig(*date))\n end",
"def k_most_visited input, k\n \n hotels_to_visits = Hash.new\n \n input.each do |user|\n user.each do |hotel_id|\n hotels_to_visits[hotel_id] = (hotels_to_visits[hotel_id] || 0) + 1\n end\n end\... | [
"0.57775056",
"0.5750949",
"0.55561167",
"0.5530313",
"0.55183893",
"0.5513594",
"0.55036014",
"0.5491988",
"0.5481052",
"0.5476581",
"0.5471541",
"0.54636353",
"0.5452884",
"0.5435395",
"0.5430349",
"0.5415292",
"0.5389234",
"0.53735954",
"0.53735954",
"0.53735954",
"0.53735... | 0.53074306 | 30 |
The requirements guarantee that the columns will always be in the same order | def process_row(purchaser_name, item_description, item_price, purchase_count, merchant_address, merchant_name)
purchaser = Purchaser.find_or_create!(purchaser_name)
merchant = Merchant.find_or_create!(name: merchant_name, address: merchant_address)
Order.create!(purchaser: purchaser,
merchant: merchant,
item_description: item_description,
item_price: item_price,
purchase_count: purchase_count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_columns; end",
"def columns_in_order\n @columns.values.sort_by { |c| c.order }\n end",
"def test_column_ordering_is_deterministic\n assert @cluster.keyspace('simplex').has_table?('users')\n table_meta = @cluster.keyspace('simplex').table('users')\n table_cql = Regexp.new(/CREATE T... | [
"0.7005286",
"0.6302801",
"0.62985027",
"0.6292036",
"0.6234711",
"0.62173575",
"0.62168217",
"0.6070424",
"0.60405487",
"0.60398906",
"0.5907115",
"0.59044605",
"0.58853406",
"0.5868458",
"0.58411574",
"0.58401835",
"0.58366984",
"0.5828762",
"0.5823161",
"0.5819658",
"0.580... | 0.0 | -1 |
Fetch something from the cache | def fetch(&block)
Rails.cache.fetch(cache_key, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch(name)\n load_cache(name)\n end",
"def fetch_from_cache\n get_cache_object().get make_key\n end",
"def cache_get(ck)\n cache_op(:get, ck)\n end",
"def _fetch\n cache_get(:_fetch) || @opts[:fetch]\n end",
"def cached_fetch(key)\n fetch(key) do\n ... | [
"0.7958161",
"0.7952505",
"0.77422714",
"0.7691141",
"0.7654914",
"0.7634677",
"0.75412375",
"0.7474474",
"0.745316",
"0.7402858",
"0.7396903",
"0.73209745",
"0.72966564",
"0.72963315",
"0.72902596",
"0.72869694",
"0.7285655",
"0.72521025",
"0.72309065",
"0.7230904",
"0.72134... | 0.79600537 | 0 |
Returns the cache key to use for /universe, which varies based on the protocol | def cache_key
"#{protocol}-universe"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_key\n name.to_s\n end",
"def cache_key; @cache.to_sym; end",
"def key_for_cached\n [ @options[:namespace], MD5.hexdigest(@url) ].join('_')\n end",
"def cache_key\n end",
"def cache_key\n Digest::SHA1.hexdigest \"#{self.class.name}#{base_url}#{hashable_string_for(option... | [
"0.71318364",
"0.71232295",
"0.6977518",
"0.692502",
"0.68707466",
"0.68319166",
"0.67640275",
"0.6648342",
"0.66339076",
"0.6605882",
"0.6554034",
"0.6542055",
"0.6542055",
"0.65287966",
"0.6510044",
"0.64487195",
"0.64036626",
"0.63921636",
"0.639211",
"0.6388468",
"0.63884... | 0.901165 | 0 |
Returns the protocol in a way appropriate for cache key usage, e.g. for a protocol string of " this method will return "http" | def protocol
@protocol ||= @raw_protocol[0..-4]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def protocol_name\n PROTOCOLS[protocol.to_s]\n end",
"def protocol\n @protocol.sub(\"://\",\"\")\n end",
"def protocol\n if secure?\n 'https'\n else\n 'http'\n end\n end",
"def protocol_name\n rc, name = Cproton.pn_ssl_get_protocol_name(@impl, 128)\n name... | [
"0.75846523",
"0.7490993",
"0.7387386",
"0.7313816",
"0.718322",
"0.7179665",
"0.7096763",
"0.7047822",
"0.697919",
"0.6890377",
"0.6885786",
"0.68761355",
"0.67880076",
"0.6778918",
"0.6698436",
"0.66763115",
"0.66452813",
"0.66047794",
"0.6600837",
"0.6580738",
"0.6574952",... | 0.72707283 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_homework
@homework = Homework.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def homework_params
params.require(:homework).permit(:title, :question, :due)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
get current config options | def uberopts
{ primary_key: primary_key }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options\n config.options\n end",
"def parsed_options\n config\n end",
"def config\n @options[:config]\n end",
"def options \n self.merge!(@config.opts)\n end",
"def get_options\n @options\n end",
"def options\n return @options\n end",
"def getOptions\n ... | [
"0.8339608",
"0.8055936",
"0.79382837",
"0.7855729",
"0.7833166",
"0.7491788",
"0.7444636",
"0.7440861",
"0.7387899",
"0.7339923",
"0.73306304",
"0.732798",
"0.7297994",
"0.7297994",
"0.72947264",
"0.7286764",
"0.7286764",
"0.7262555",
"0.7240018",
"0.723328",
"0.723328",
"... | 0.0 | -1 |
check if key represents a method/attribute name and return it if so | def method_name?(key)
key.is_a?(Symbol) && /^__(?<name>.+)__$/ =~ key ? name.to_sym : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attribute_from_method( methodname )\n\n\t\tcase methodname.to_s\n\t\twhen /^(?:has_)?([a-z]\\w*)\\?$/i\n\t\t\treturn $1.to_sym, :predicate\n\t\twhen /^([a-z]\\w*)(=)?$/i\n\t\t\treturn $1.to_sym, ($2 ? :writer : :reader )\n\t\tend\n\tend",
"def [](key)\n key = key.to_s.downcase.to_sym if !key.is_a?(Sym... | [
"0.682143",
"0.65445495",
"0.6511295",
"0.64244694",
"0.6334658",
"0.62815267",
"0.6281349",
"0.6270441",
"0.62697816",
"0.61963433",
"0.6165948",
"0.61318135",
"0.61260223",
"0.61199695",
"0.6117545",
"0.609504",
"0.60790306",
"0.6073715",
"0.6033027",
"0.6032683",
"0.602020... | 0.81646335 | 0 |
check if item responds to a given key/attribute name | def item_respond_to?(item, key)
method = method_name?(key) || :[]
item.respond_to?(method)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key?(key)\n @attr.key?(key)\n end",
"def attribute?(key)\n self.class.attributes.include? key.to_sym\n end",
"def item_send_if_respond_to?(item, key)\n can_respond, result = nil, nil\n method = method_name?(key)\n if method\n can_respond = item.respond_to?(method)\n resul... | [
"0.7096533",
"0.7077355",
"0.7031355",
"0.69895864",
"0.6903521",
"0.6776814",
"0.67670137",
"0.67391884",
"0.67391884",
"0.67063427",
"0.66927135",
"0.6639642",
"0.66304743",
"0.6619748",
"0.6581077",
"0.6549393",
"0.65316284",
"0.6519602",
"0.6509437",
"0.6496329",
"0.64615... | 0.7332642 | 0 |
invoke the given key/attribute name as a method on item | def item_send(item, key)
method = method_name?(key)
method ? item.send(method) : item[key]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing method_name,*method_args, &method_block\n if method_name.end_with?('_name') || method_name.end_with?('_names')\n attribute = method_name.to_s.gsub(/_name(s)?$/,'')\n args.fetch(attribute)\n elsif method_name.end_with?('_value')\n attribute = met... | [
"0.70943743",
"0.66423684",
"0.6602976",
"0.647188",
"0.64050996",
"0.6335735",
"0.63292325",
"0.63164234",
"0.6306362",
"0.6306362",
"0.6306362",
"0.62613916",
"0.6259552",
"0.6201184",
"0.6183899",
"0.61750394",
"0.61465126",
"0.6110553",
"0.6099001",
"0.608923",
"0.6079091... | 0.7279246 | 0 |
send a key/method name to an item if the item responds to it | def item_send_if_respond_to?(item, key)
can_respond, result = nil, nil
method = method_name?(key)
if method
can_respond = item.respond_to?(method)
result = item.send(method) if can_respond
else
can_respond = item.respond_to?(:[])
result = item[key] if can_respond
end
[can_respond, result]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_send(item, key)\n method = method_name?(key)\n method ? item.send(method) : item[key]\n end",
"def item_respond_to?(item, key)\n method = method_name?(key) || :[]\n item.respond_to?(method)\n end",
"def method_missing(method, *args, &block)\n if @hash.key?(method.to_s.to_sym)\n @... | [
"0.7981321",
"0.72997797",
"0.6481786",
"0.63499093",
"0.63352495",
"0.62338084",
"0.61906755",
"0.61854136",
"0.6111815",
"0.60584176",
"0.6039698",
"0.60257345",
"0.6024853",
"0.60192114",
"0.6012572",
"0.5920178",
"0.5908149",
"0.58724767",
"0.5870245",
"0.5869465",
"0.584... | 0.7706772 | 1 |
=begin Problem 2 Project Euler =end | def fibevensum xmax
a, b = 1, 2
sum = 0
while a < xmax
sum += a if a.even?
a, b = b, a + b
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euler028 n\n (4*n**3 + 3*n**2 + 8*n - 9) / 6\nend",
"def euler006\n square_of_sum = (1..100).reduce(:+) ** 2\n sum_of_squares = (1..100).inject { |sum, n| sum + n*n }\n\n return square_of_sum - sum_of_squares\nend",
"def euler001\n (1...1000).select { |i| i % 3 == 0 or i % 5 == 0 }.reduce(:+)\nend",
... | [
"0.8120694",
"0.80925536",
"0.8058708",
"0.79192775",
"0.7829732",
"0.78265375",
"0.7706266",
"0.7619269",
"0.7610111",
"0.7563717",
"0.7475554",
"0.7398235",
"0.73874766",
"0.73060536",
"0.7274859",
"0.7210135",
"0.71120185",
"0.7101138",
"0.70900255",
"0.70800173",
"0.70446... | 0.0 | -1 |
Exposes the set keys | def keys
self.parameters.table.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getset(key); end",
"def exchange_keys; end",
"def exchange_keys; end",
"def getset(key, value); end",
"def getset(key, value); end",
"def keys(*) end",
"def keys() end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; end",
"def keys; en... | [
"0.75359994",
"0.7056924",
"0.7056924",
"0.68931484",
"0.68931484",
"0.6864186",
"0.6782588",
"0.66718566",
"0.66718566",
"0.66718566",
"0.66718566",
"0.66718566",
"0.66718566",
"0.66718566",
"0.66718566",
"0.66718566",
"0.66494983",
"0.65578663",
"0.6541058",
"0.6541058",
"0... | 0.0 | -1 |
can be used in a data_frame filter. | def filter(row)
self.keys.each do |key|
value = self.parameters.send(key)
case value
when Array
return false unless value.include?(row[key])
when Range
return false unless value.include?(row[key])
else
return false unless value === row[key]
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_filter\n end",
"def Filter=(arg0)",
"def filter\n end",
"def filter_index\n filter\n end",
"def filter; end",
"def filter; end",
"def filter; end",
"def where_from_groupfilter (groupfilter, groupby)\n @groupfilter = groupfilter # Instanzvariablen zur nachfolgenden N... | [
"0.6661223",
"0.6336333",
"0.621939",
"0.61818784",
"0.61293",
"0.61293",
"0.61293",
"0.6105103",
"0.6038068",
"0.60194695",
"0.60194695",
"0.60026836",
"0.6002243",
"0.59850514",
"0.5943293",
"0.5942697",
"0.5838202",
"0.5770127",
"0.5720864",
"0.57100064",
"0.5708388",
"0... | 0.0 | -1 |
for simulation of the execution failing for the first time | def something_should_fail!
@should_fail = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_failed; end",
"def failed?; failed_to_start? || (@success == false) end",
"def failure!\n @count += 1\n end",
"def failures; end",
"def failures; end",
"def failures; end",
"def final_test\n return unless MiniApivore.all_test_ran?\n\n @errors = MiniApivore.prepare_untested_errors\... | [
"0.71622014",
"0.6576587",
"0.64363503",
"0.6428883",
"0.6428883",
"0.6428883",
"0.6412876",
"0.6349412",
"0.6343966",
"0.6186746",
"0.6134944",
"0.61215633",
"0.61198586",
"0.61050195",
"0.61032075",
"0.6072263",
"0.6072263",
"0.6041308",
"0.59861994",
"0.598579",
"0.5969471... | 0.55156124 | 86 |
for simulation of the execution failing for the first time | def something_should_fail?
@should_fail
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_failed; end",
"def failed?; failed_to_start? || (@success == false) end",
"def failure!\n @count += 1\n end",
"def failures; end",
"def failures; end",
"def failures; end",
"def final_test\n return unless MiniApivore.all_test_ran?\n\n @errors = MiniApivore.prepare_untested_errors\... | [
"0.7161905",
"0.6577732",
"0.6437586",
"0.6429412",
"0.6429412",
"0.6429412",
"0.6412642",
"0.6350998",
"0.6344757",
"0.6185194",
"0.61353606",
"0.6122182",
"0.61190283",
"0.6106187",
"0.6104635",
"0.607291",
"0.607291",
"0.6042151",
"0.5987564",
"0.59853315",
"0.5970363",
... | 0.0 | -1 |
Lists all activities (redemption and feedback) by the user | def activities
activities = [];all_activities = []
all_activities << RedemptionLog.user_activities(self)
all_activities << FeedbackLog.user_activities(self)
sorted_activities = all_activities.flatten.compact.sort_by!{|activity| activity.updated_at }.reverse
sorted_activities.each do |activity|
activities << {points: activity.points, outlet_id: activity.outlet_id, outlet_name: activity.outlet_name,
type: activity.class.name.gsub(/Log/i,''), updated_at: activity.updated_at}
end
activities
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @activities = current_user.activities\n end",
"def index\n @activities = current_user.attending_activities\n render :index\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end... | [
"0.73962325",
"0.7252241",
"0.7163148",
"0.7163148",
"0.7163148",
"0.7163148",
"0.7163148",
"0.7163148",
"0.7163148",
"0.7163148",
"0.7163148",
"0.7163148",
"0.7150237",
"0.714329",
"0.7139769",
"0.7139769",
"0.7139769",
"0.7054996",
"0.7030819",
"0.7018375",
"0.6961807",
"... | 0.67160857 | 30 |
Will yield data format similar to above both will be ?q=1,5,10 | def from_keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_params\n ref_path = request.path_info;\n ref_query = URI.decode(request.query_string)\n query_options = ref_query.split('&').select{|r| !r.blank?}\n res = []\n query_path = []\n \n query_options[0..-2].each do |qo|\n qo.match(/q\\[(\\w+)\\]\\[\\]=(.+)/)\n attribute = $1\n ... | [
"0.6484666",
"0.64485383",
"0.622919",
"0.61342055",
"0.60842663",
"0.60784566",
"0.60538083",
"0.59848267",
"0.5938932",
"0.5933774",
"0.58312726",
"0.580804",
"0.5799802",
"0.57909286",
"0.57209206",
"0.5703838",
"0.5701136",
"0.568452",
"0.56704724",
"0.566917",
"0.565191"... | 0.0 | -1 |
Yields a snippet of HTML that represents the text field useful if you are utilizing the autocompleter externally and just want to render the widget | def widget
respond_to do |format|
format.html { render :inline => <<-EOS
<html>
<body>
<input type="textfield" name="the_textfield" acs_source="/acs/jqb/dogs" id="the_textfield"/>
<input type="textfield" name="the_textfield2" acs_source="/acs/jqb/dogs" id="the_textfield2"/>
<%= javascript_include_tag 'jquery-1.4.2' %>
<% javascript_tag do %>
// Top Level function to bind an Auto-Completer to an HTML element
// Should eventually extract autocompleter client name from a acs_source like "/acs/jqb_v2/dogs"
// to invoke JqbV2.attach(element)
jQuery.fn.extend({
bindAcs:function() {
this.each(function() {
var element = jQuery(this);
Jqb.attach(element);
})
}
});
// A namespace to hold all references to all Autocompleter client bindings
// on this page
var Acs = {
instances:[]
}
// jQuery Basic Autocompleter for ACS API
//
var Jqb = {
loaded:false,
// This is like the constructor--where all of the base-line behavior associated
// with a Jqb client can added to the page
attach:function(element) {
// Move the
element.data("acs_source", element.attr('acs_source'));
element.focus(function(){
//Do nothing
}),
element.keyup(this.handleKeyUp)
},
handleKeyUp:function(event) {
var keyupped = event.target;
console.log('[handleKeyUp] ' + $(keyupped).val());
// Catch arrows, enter, tab
// pass other stuff through to ajax request
// should buffer key strokes and wait for the user
// to finish typing (i think)
//
switch (event.keyCode) {
//Catch/buffer/ depending on the key pressed
// see here for details: http://unixpapa.com/js/key.html
}
// Fire off request
$.getJSON($(keyupped).attr('acs_source'), {q:$(keyupped).val()}, function(json) {
jQuery.each(json, function() {
// BIG TODO: <dog> should be dynamic not hard coded...
console.log(this.dog.name);
});
})
}
}
// Starting point to attach the autocompleter server
// to all clients on the page
$(document).ready(function(){
$("input[acs_source]").bindAcs();
});
<% end %>
</body>
</html>
EOS
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ui_text_field(content = nil, options = nil, html_options = nil, &block)\n UiBibz::Ui::Core::Forms::Texts::TextField.new(content, options, html_options, &block).render\n end",
"def ui_auto_complete_field(content = nil, options = nil, html_options = nil, &block)\n UiBibz::Ui::Core::Forms::Texts::AutoCom... | [
"0.6978883",
"0.6902676",
"0.67753786",
"0.6753565",
"0.66369504",
"0.6503744",
"0.6327633",
"0.6326458",
"0.6159718",
"0.6132257",
"0.6124466",
"0.61181605",
"0.61152947",
"0.6111965",
"0.60718924",
"0.6045809",
"0.6044474",
"0.60425836",
"0.6023409",
"0.60190564",
"0.599678... | 0.6051416 | 15 |
Renders a server side code that can be used by external sites to bind to this autocompleter | def proxy
respond_to do |format|
format.ruby {}
format.perl {}
format.php {}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def widget\n respond_to do |format|\n format.html { render :inline => <<-EOS\n <html>\n <body>\n <input type=\"textfield\" name=\"the_textfield\" acs_source=\"/acs/jqb/dogs\" id=\"the_textfield\"/>\n \n <input type=\"textfield\" name=\"the_textfield2\" acs_source=\"/acs/j... | [
"0.6381085",
"0.6192176",
"0.59413445",
"0.5923678",
"0.59021944",
"0.58848274",
"0.5880096",
"0.57871145",
"0.57591903",
"0.5747235",
"0.57216597",
"0.5662446",
"0.5613755",
"0.5563221",
"0.55335826",
"0.5452531",
"0.54513985",
"0.54314405",
"0.542522",
"0.5419748",
"0.53940... | 0.0 | -1 |
Specifies the model, primary, key, attribute result set mappings, tags, and filters to the client | def interface
respond_to do |format|
format.json {}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datasource_params\n {\n # We want to make sure we don't load the collection record, but only\n # records that belong to that collection record.\n fq: 'sm_collection_code:theliberator',\n\n rows: rows,\n sort: 'id asc',\n start: start,\n... | [
"0.5734448",
"0.56940305",
"0.56940305",
"0.5649944",
"0.5403335",
"0.536993",
"0.5369402",
"0.53585225",
"0.53502077",
"0.5334857",
"0.5334228",
"0.5309919",
"0.5294534",
"0.5274588",
"0.52476805",
"0.52303773",
"0.52003366",
"0.51949006",
"0.5187585",
"0.5183422",
"0.517666... | 0.0 | -1 |
Javascript include files to make the widget work | def js_includes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_js\n AssetManager.include_contrib_library [:core_ui, :jquery_tab]\n AssetManager.include_local_library [ 'ckeditor/init']\n\n AssetManager.include_css [:blog_global]\n end",
"def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_PLANS, JS_DATEPICKER, JS_JSON... | [
"0.7150531",
"0.69625443",
"0.6783061",
"0.6696878",
"0.6672852",
"0.6530239",
"0.6510228",
"0.6460087",
"0.64364386",
"0.6421073",
"0.6421073",
"0.6421073",
"0.64161867",
"0.64161867",
"0.6370897",
"0.63416016",
"0.6308936",
"0.63011867",
"0.62925243",
"0.6263266",
"0.626010... | 0.70728403 | 1 |
The method has no idea what 'limit' is and therefore throws a undefined variable error One way of fixing it would be as follows: | def fib(first_num, second_num, limit)
while second_num < limit
sum = first_num + second_num
first_num = second_num
second_num = sum
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def miter_limit(limit)\n end",
"def limit(limit); end",
"def limit; end",
"def limit; end",
"def limit; end",
"def limit(_limit)\n @limit = _limit\n self\n end",
"def limit; @opts['limit']; end",
"def limit=(_arg0); end",
"def default_limit\n 10\n end",
"def li... | [
"0.8589746",
"0.8563955",
"0.83301204",
"0.83301204",
"0.83301204",
"0.7822259",
"0.7733703",
"0.7639037",
"0.75909376",
"0.7586321",
"0.7542859",
"0.7517462",
"0.74932384",
"0.74825174",
"0.74141806",
"0.7404241",
"0.7397705",
"0.7376787",
"0.73616374",
"0.7349545",
"0.73120... | 0.0 | -1 |
Another way with a fixed limit would be as follows: | def fib2(first_num, second_num)
limit = 100
while second_num < limit
sum = first_num + second_num
first_num = second_num
second_num = sum
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def limit(limit); end",
"def miter_limit(limit)\n end",
"def limit; end",
"def limit; end",
"def limit; end",
"def limit=(_arg0); end",
"def limit\n limit = @params[:limit].to_i\n limit = 1 if limit < 1\n [limit, MAX_LIMIT].min\n end",
"def default_limit\n 10\n end",
"d... | [
"0.8090238",
"0.77420384",
"0.76027906",
"0.76027906",
"0.76027906",
"0.7016673",
"0.69887495",
"0.68734676",
"0.68405706",
"0.6837483",
"0.68142015",
"0.678236",
"0.66800934",
"0.6629414",
"0.65858066",
"0.6563903",
"0.6542637",
"0.64669013",
"0.64436805",
"0.6439073",
"0.64... | 0.0 | -1 |
Returns the size of the given snapshot (runs du, may be slow) Would much prefer to take advantage of this feature: but it's not currently in Debian/wheezy. | def du
`du -s -b #{path}`.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n size = popen(%W(du -s), full_path).first.strip.to_i\n (size.to_f / 1024).round(2)\n end",
"def size(full_path)\n\t\t`du -s #{Rush.quote(full_path)}`.match(/(\\d+)/)[1].to_i\n\tend",
"def size(full_path)\n\t\t`du -sb #{full_path}`.match(/(\\d+)/)[1].to_i\n\tend",
"def volume_size... | [
"0.69211185",
"0.68723005",
"0.68584746",
"0.6291885",
"0.6291287",
"0.62494826",
"0.62494826",
"0.6174684",
"0.6162379",
"0.6154457",
"0.6142682",
"0.60752034",
"0.6061317",
"0.6057714",
"0.597724",
"0.5953462",
"0.5925355",
"0.5873285",
"0.5847328",
"0.5847328",
"0.583452",... | 0.5809321 | 24 |
Returns every snapshot in every backup directory | def all_snapshots
all.map(&:snapshots).flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snapshots\n @dir.entries.map do |entry|\n next if entry[0] == '.' || entry == 'current'\n snapshot_path = File.expand_path(@dir.path + '/' + entry)\n next unless File.directory?(snapshot_path)\n begin\n Snapshot.new(self, snapshot_path)\n rescue ArgumentError =>... | [
"0.7256081",
"0.693527",
"0.680474",
"0.6449682",
"0.64451116",
"0.63530445",
"0.6350734",
"0.6326416",
"0.6322718",
"0.6294519",
"0.6247808",
"0.6243447",
"0.61555487",
"0.6092596",
"0.60596895",
"0.60504925",
"0.6033094",
"0.5875139",
"0.5870942",
"0.58356476",
"0.5811272",... | 0.6738616 | 3 |
Return total amount of free space in backup directory (bytes) | def free
df = DiskFree.new(@dir.path)
df.total - df.used
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disk_usage_mb \n return disk_usage \n end",
"def total_free_space\n self.free_spaces.reduce(0, :+)\n end",
"def file_total_size_gb\n ((total_ram_mb.to_f * 2).to_f / 1024).ceil\n end",
"def bytes_used\n bytes_total - bytes_free\n end",
"def used_space\n size - free_space\n... | [
"0.7297495",
"0.7253806",
"0.7168741",
"0.71464616",
"0.705521",
"0.70274055",
"0.695743",
"0.6955561",
"0.68714875",
"0.6860618",
"0.6803333",
"0.67885745",
"0.676479",
"0.6675499",
"0.66485864",
"0.6631917",
"0.662385",
"0.66142464",
"0.6607658",
"0.6588273",
"0.6587793",
... | 0.7739653 | 0 |
Return an array of Times representing the current list of snapshots. | def snapshots
@dir.entries.map do |entry|
next if entry[0] == '.' || entry == 'current'
snapshot_path = File.expand_path(@dir.path + '/' + entry)
next unless File.directory?(snapshot_path)
begin
Snapshot.new(self, snapshot_path)
rescue ArgumentError => ae
# directory name must represent a parseable Time
nil
end
end.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_fragments\n []\n end",
"def times\n @stamps\n end",
"def sorted_snapshot_list()\n snapshot_list().sort{|a,b| b.time <=> a.time }\n end",
"def getTimes()\n return @times\n end",
"def get_runtime_timestamps\n all_events = events.to_a\n start_time = DateTime.pa... | [
"0.70737505",
"0.7031269",
"0.68772733",
"0.6757009",
"0.6728475",
"0.66566586",
"0.63024265",
"0.6243834",
"0.61909425",
"0.61821204",
"0.61410683",
"0.61278594",
"0.61171097",
"0.6082148",
"0.60308075",
"0.60211223",
"0.60001576",
"0.5968387",
"0.59641826",
"0.59522307",
"0... | 0.66370183 | 6 |
Create a new snapshot of 'current' | def new_snapshot!(time = Time.now)
snapshot_path = time.strftime(dir.path + '/%Y-%m-%dT%H:%M%z')
Snapshot.new(self, snapshot_path).create!(current.path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_snapshot\n @current_snapshot = @bitmap.to_json if @bitmap\n end",
"def snapshot()\n puts \"TODO\"\n end",
"def snap()\n @snap_id += 1\n @snap[@snap_id] = @current.clone\n @snap_id\n end",
"def current_snapshot\n @snapshots[0][1]\n end",
"def create_h... | [
"0.72667515",
"0.6857233",
"0.6687775",
"0.65194905",
"0.6383693",
"0.6292883",
"0.624228",
"0.61132556",
"0.60821414",
"0.6037091",
"0.5992292",
"0.596696",
"0.59196645",
"0.5887104",
"0.58747053",
"0.58036643",
"0.5798451",
"0.57934105",
"0.57830846",
"0.5777031",
"0.573172... | 0.70683515 | 1 |
only allow a single topic IDL file | def idl(idlfiles = nil)
if idlfiles
BRIX11.log_fatal("SE interface recipe #{self.recipe_file.full_path} only allows a single topic IDL to be defined!") if idlfiles.size > 1
end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fixup_topic(topic)\n case topic\n when 'S', 's', 'string'\n 'String'\n when 'A', 'a', 'array'\n 'Array'\n when 'H', 'h', 'hash'\n 'Hash'\n when 'File::new'\n # See qri bug at http://rubyforge.org/tracker/index.php?func=detail&aid=23504&group_id=2545&atid=9811\n 'File#new... | [
"0.5636572",
"0.5536413",
"0.5515926",
"0.5458782",
"0.53802407",
"0.53393847",
"0.5333502",
"0.52744305",
"0.5270698",
"0.5262732",
"0.5257876",
"0.5250077",
"0.51652867",
"0.51374584",
"0.5084099",
"0.50793636",
"0.5077788",
"0.50685894",
"0.506702",
"0.50661653",
"0.506616... | 0.6519598 | 0 |
translate to database ranges | def from_ranges
self[:date_time_slot] = RangeSupport.range_to_string(self[:date_time_slot])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_ranges_linear\n min, max = @data.values.sort.first, @data.values.sort.last\n value = ( ( max - min ) / File.open(@palette).readlines.size ).to_i + 1\n offset = (( value / 10 ** (value.to_s.size - 1) ).round + 1)* 10 ** (value.to_s.size - 1)\n last = offset > min ? offset : min\n @... | [
"0.69175166",
"0.67638844",
"0.66931885",
"0.66673666",
"0.6626047",
"0.6499977",
"0.6471593",
"0.6471593",
"0.64590913",
"0.639793",
"0.6367198",
"0.63502026",
"0.6308973",
"0.6290079",
"0.6270681",
"0.6260771",
"0.6259991",
"0.62576425",
"0.62470055",
"0.6229567",
"0.619304... | 0.0 | -1 |
Following Operation expects AcaEntities domain class as subject | def create_eligibility(eligibility_options)
AcaEntities::Eligible::AddEligibility.new.call(
subject:
"AcaEntities::BenefitSponsors::BenefitSponsorships::BenefitSponsorship",
eligibility: eligibility_options
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject\n raise \"Override #subject in the service class\"\n end",
"def subject\n @subject ||= Ken::Collection.new(@data.map { |r| object_type? ? Ken::Resource.new(r) : r[\"value\"] })\n end",
"def entityResolver; @entityResolver; end",
"def subject_class\n self.class.subject_class\n ... | [
"0.552123",
"0.5493443",
"0.5467553",
"0.53420746",
"0.5337837",
"0.52500737",
"0.52251977",
"0.52251977",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
"0.5208239",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_itinerary
if current_user.present?
@itinerary = Itinerary.find(params[:id])
else
@itinerary = Itinerary.find(params[:id])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def itinerary_params
params.require(:itinerary).permit(:title, :description, :phone, :address, :city, :state, :zip, :twitter, :facebook, :instagram, :travel, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /flag_classes GET /flag_classes.json | def index
@flag_classes = FlagClass.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_classes\n classes = Rails.cache.fetch(\"#{current_user.cache_key}/allClasses\", expires_in: 1.hours) do\n keytechAPI.classes.loadAllClasses\n end\n\n # Filter only to files, office file and folders, ignore all CAD-related types\n @classes = []\n classes.each do |element_class|\n ... | [
"0.66259485",
"0.6537445",
"0.64669865",
"0.6028631",
"0.5963626",
"0.5951353",
"0.5862992",
"0.5851865",
"0.583796",
"0.58307666",
"0.58143777",
"0.5766775",
"0.56945425",
"0.5672708",
"0.5654918",
"0.5648989",
"0.5648989",
"0.56015784",
"0.55759645",
"0.5553175",
"0.5553175... | 0.75103104 | 0 |
GET /flag_classes/1 GET /flag_classes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @flag_classes = FlagClass.all\n end",
"def create\n @flag_class = FlagClass.new(flag_class_params)\n\n respond_to do |format|\n if @flag_class.save\n format.html { redirect_to @flag_class, notice: 'Flag class was successfully created.' }\n format.json { render :show, stat... | [
"0.7301313",
"0.66073793",
"0.6510063",
"0.6364087",
"0.6193133",
"0.6054789",
"0.5931414",
"0.5866188",
"0.5865581",
"0.5831664",
"0.57411915",
"0.5738073",
"0.5730512",
"0.57241106",
"0.5706222",
"0.5661375",
"0.56525916",
"0.56399375",
"0.5628321",
"0.5543825",
"0.55419564... | 0.0 | -1 |
POST /flag_classes POST /flag_classes.json | def create
@flag_class = FlagClass.new(flag_class_params)
respond_to do |format|
if @flag_class.save
format.html { redirect_to @flag_class, notice: 'Flag class was successfully created.' }
format.json { render :show, status: :created, location: @flag_class }
else
format.html { render :new }
format.json { render json: @flag_class.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flag_class_params\n params.require(:flag_class).permit(:name, :color)\n end",
"def set_flag_class\n @flag_class = FlagClass.find(params[:id])\n end",
"def create\n @flag = Flag.new(flag_params)\n\n respond_to do |format|\n if @flag.save\n format.html { redirect_to @flag, n... | [
"0.66812557",
"0.63667405",
"0.6021186",
"0.59496367",
"0.5853588",
"0.5824248",
"0.5639524",
"0.56314784",
"0.55439484",
"0.55062145",
"0.5434271",
"0.53245205",
"0.5315154",
"0.5287511",
"0.5234766",
"0.52197737",
"0.52042043",
"0.51845425",
"0.51816225",
"0.51814026",
"0.5... | 0.75247705 | 0 |
PATCH/PUT /flag_classes/1 PATCH/PUT /flag_classes/1.json | def update
respond_to do |format|
if @flag_class.update(flag_class_params)
format.html { redirect_to @flag_class, notice: 'Flag class was successfully updated.' }
format.json { render :show, status: :ok, location: @flag_class }
else
format.html { render :edit }
format.json { render json: @flag_class.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_flag_class\n @flag_class = FlagClass.find(params[:id])\n end",
"def update\n @flag = Flag.find(params[:id])\n\n respond_to do |format|\n if @flag.update_attributes(params[:flag])\n format.html { redirect_to @flag, notice: 'Flag was successfully updated.' }\n format.json {... | [
"0.6727472",
"0.6265729",
"0.62176394",
"0.61411476",
"0.61075246",
"0.6068555",
"0.60654753",
"0.5951342",
"0.5948125",
"0.58850735",
"0.5878432",
"0.58618796",
"0.583107",
"0.5770587",
"0.57610965",
"0.57594526",
"0.5742825",
"0.5739023",
"0.57128",
"0.57128",
"0.5711617",
... | 0.764611 | 0 |
DELETE /flag_classes/1 DELETE /flag_classes/1.json | def destroy
@flag_class.destroy
respond_to do |format|
format.html { redirect_to flag_classes_url, notice: 'Flag class was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @flag = Flag.find(params[:id])\n @flag.destroy\n\n respond_to do |format|\n format.html { redirect_to flags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flag.destroy\n respond_to do |format|\n format.html { redirect_to flags_url, notice: '... | [
"0.67861575",
"0.6620649",
"0.6620649",
"0.66052645",
"0.65721387",
"0.6536396",
"0.65146506",
"0.6474303",
"0.64718634",
"0.643535",
"0.6431455",
"0.6398102",
"0.6388779",
"0.6374379",
"0.63716024",
"0.63409954",
"0.63192415",
"0.63045084",
"0.6303332",
"0.62897027",
"0.6280... | 0.7687253 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_flag_class
@flag_class = FlagClass.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def flag_class_params
params.require(:flag_class).permit(:name, :color)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Create a new ChefSecretsFile | def initialize(opts = {})
@path = (opts[:path] && File.expand_path(opts[:path])) || "/etc/opscode/private-chef-secrets.json"
@version = opts[:version] || 1
super(opts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_chef_secure_path\n chef_secure_path.run_action(:create)\n\n unless new_resource.encrypted_data_bag_secret.nil?\n r = Chef::Resource::File.new(::File.join(new_resource.chef_secure_path, 'encrypted_data_bag_secret'), run_context)\n r.content(new_resource.encrypted_data_ba... | [
"0.6753238",
"0.6612297",
"0.6263194",
"0.6254702",
"0.6242081",
"0.6161188",
"0.61003214",
"0.6021674",
"0.6020031",
"0.60118914",
"0.59448403",
"0.59292555",
"0.59255475",
"0.5920176",
"0.58975995",
"0.5848309",
"0.57894844",
"0.57712626",
"0.5741199",
"0.5708261",
"0.57068... | 0.55621463 | 35 |
Set the secrets file path | def path=(path)
@path = File.expand_path(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(secret)\n if File.exist?(path)\n backup_path = \"#{path}.bak\"\n Simple::CLI.logger.info \"Backing up secret in #{backup_path}\"\n FileUtils.mv path, backup_path\n end\n\n File.write(path, secret)\n File.chmod(0400, path)\n Simple::CLI.logger.info \"Generated #... | [
"0.7180841",
"0.69860256",
"0.6885005",
"0.6810075",
"0.64239675",
"0.64239675",
"0.64239675",
"0.64239675",
"0.6403457",
"0.6164929",
"0.61227196",
"0.60963136",
"0.60963136",
"0.6091091",
"0.6060993",
"0.6048865",
"0.6042328",
"0.6038943",
"0.5955364",
"0.5939478",
"0.59115... | 0.0 | -1 |
Save the CredentialCollection to file | def save
FileUtils.mkdir_p(File.dirname(path)) unless File.directory?(File.dirname(path))
File.open(path, "w+") { |f| f.puts(JSON.pretty_generate(secrets_hash)) }
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_settings\n open(@@FN_CREDENTIALS, \"wb\") { |fd| fd.write(YAML::dump(@credentials)) }\n open(@@FN_CONFIG, \"wb\") { |fd| fd.write(YAML::dump(@configuration)) }\n open(@@FN_SETTINGS, \"wb\") { |fd| fd.write(YAML::dump(@settings)) }\n end",
"def save_collection_to_file(filename, collection)\n\tc... | [
"0.63596165",
"0.6160385",
"0.6071792",
"0.6005463",
"0.6000993",
"0.59470963",
"0.58873904",
"0.5834877",
"0.5834877",
"0.57554317",
"0.5743752",
"0.5713706",
"0.5662796",
"0.5662689",
"0.5647738",
"0.560859",
"0.5604914",
"0.5596479",
"0.5577788",
"0.55634654",
"0.55451953"... | 0.56759423 | 12 |
Return the instance as a secrets style hash | def secrets_hash
{ "veil" => to_h }.merge(legacy_credentials_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\n if show_secret\n secret\n else\n Digest::SHA1.hexdigest secret\n end\n end",
"def to_hash\n {\n type: self.class.name,\n secret: secret,\n salt: salt,\n iterations: iterations,\n hash_function: hash_function.class.name\n ... | [
"0.7561871",
"0.7461178",
"0.69188744",
"0.6877238",
"0.6785563",
"0.67620796",
"0.67419904",
"0.66890895",
"0.6653137",
"0.6625735",
"0.6554048",
"0.65257543",
"0.65213877",
"0.6496753",
"0.6479778",
"0.6479778",
"0.6464349",
"0.64514416",
"0.6443592",
"0.6443592",
"0.644359... | 0.6589953 | 10 |
Return the credentials in a legacy chef secrets hash | def legacy_credentials_hash
hash = Hash.new
to_h[:credentials].each do |namespace, creds|
hash[namespace] = {}
creds.each { |name, cred| hash[namespace][name] = cred[:value] }
end
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chef_credentials\n creds = Hash.new\n File.open(ENV['HOME'] + '/.chef/knife.rb').each do |line|\n creds['c_uri'] = line.scan(/'([^']*)'/).join(' ') if line.match('chef_server_url')\n creds['c_key'] = line.scan(/'([^']*)'/).join(' ') if line.match('client_key')\n creds['c_node'] = line.scan(/'([^']... | [
"0.6856485",
"0.6776639",
"0.66316146",
"0.66316146",
"0.6592836",
"0.6487848",
"0.64665365",
"0.64665365",
"0.6416885",
"0.6405355",
"0.6282346",
"0.6264896",
"0.6264896",
"0.62518054",
"0.62518054",
"0.6217043",
"0.61612624",
"0.6121071",
"0.61005354",
"0.6083065",
"0.60704... | 0.61220604 | 17 |
Describes a player's role in the team using a combination of role and bowling style (for bowlers) | def role_description(player)
case player.role
when /bowler/i
player.bowling_style ? [player.bowling_style, player.role].join(' ') : player.role
else
player.role
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role_label\n if user.is_admin?\n colored_label('Admin', :success)\n elsif user.has_role?(:manager)\n colored_label('Manager', :info)\n elsif user.has_role?(:content_manager) || user.has_role?(:event_manager) || user.has_role?(:forum_manager)\n colored_label('Submanager', :warning)\n ... | [
"0.5984045",
"0.59559685",
"0.5947152",
"0.59019476",
"0.5867107",
"0.58486265",
"0.5753213",
"0.57401425",
"0.56894994",
"0.5674468",
"0.5674468",
"0.5671275",
"0.56709623",
"0.5655568",
"0.56533074",
"0.5650831",
"0.5634191",
"0.5627806",
"0.5624978",
"0.56228864",
"0.55280... | 0.80037737 | 0 |
Styled form tag helpers | def casein_text_field form, obj, attribute, options = {}
casein_form_tag_wrapper(form.text_field(attribute, strip_casein_options(options_hash_with_merged_classes(options, 'caseinTextField'))), form, obj, attribute, options).html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def casein_text_field form, model, attribute, options = {}\n\t casein_form_tag_wrapper form.text_field(attribute, options.merge({:class => 'caseinTextField'})), form, model, attribute, options\n\tend",
"def form_tag(url_for_options = T.unsafe(nil), options = T.unsafe(nil), &block); end",
"def form_field_contr... | [
"0.6601072",
"0.6310223",
"0.62983435",
"0.61879504",
"0.6169183",
"0.6148011",
"0.61381394",
"0.610998",
"0.60992587",
"0.60912144",
"0.60898685",
"0.60436016",
"0.5988853",
"0.5976429",
"0.59471107",
"0.59381306",
"0.5929077",
"0.5927237",
"0.5912864",
"0.59117526",
"0.5898... | 0.60028225 | 12 |
GET /main_sliders GET /main_sliders.json | def index
@main_sliders = MainSlider.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @food_sliders = FoodSlider.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @food_sliders }\n end\n end",
"def index\n @sliders = Slider::Carrousel.all\n end",
"def index\n @slider_servs = SliderServ.all\n end",
"def index\... | [
"0.70779747",
"0.7065575",
"0.69972956",
"0.6888802",
"0.68752587",
"0.68453115",
"0.6582684",
"0.6428673",
"0.6374249",
"0.6359734",
"0.6322008",
"0.62209743",
"0.61047643",
"0.60516",
"0.60431916",
"0.6020928",
"0.60163546",
"0.60163546",
"0.60060275",
"0.5972614",
"0.59636... | 0.79418665 | 0 |
GET /main_sliders/1 GET /main_sliders/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @main_sliders = MainSlider.all\n end",
"def index\n @food_sliders = FoodSlider.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @food_sliders }\n end\n end",
"def index\n @sliders = Slider::Carrousel.all\n end",
"def set_ma... | [
"0.7710489",
"0.70562303",
"0.69050753",
"0.6876763",
"0.6813497",
"0.6767077",
"0.6758539",
"0.66743684",
"0.6585249",
"0.6562837",
"0.6366448",
"0.6366448",
"0.62974674",
"0.62355727",
"0.6192288",
"0.61622685",
"0.61454403",
"0.60803455",
"0.60467476",
"0.60305446",
"0.598... | 0.0 | -1 |
POST /main_sliders POST /main_sliders.json | def create
@main_slider = MainSlider.new(main_slider_params)
respond_to do |format|
if @main_slider.save
format.html { redirect_to @main_slider, notice: 'Main slider was successfully created.' }
format.json { render :show, status: :created, location: @main_slider }
else
format.html { render :new }
format.json { render json: @main_slider.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @main_sliders = MainSlider.all\n end",
"def create\n @roll = Slider.new(roll_params)\n\n respond_to do |format|\n if @roll.save\n format.html { redirect_to sliders_path, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @... | [
"0.67455095",
"0.63917536",
"0.63890076",
"0.635628",
"0.6174838",
"0.6132786",
"0.61149645",
"0.60990506",
"0.60755867",
"0.602616",
"0.60015255",
"0.5945913",
"0.59140116",
"0.5876445",
"0.58728933",
"0.58658886",
"0.58370715",
"0.5828106",
"0.5785171",
"0.57414424",
"0.573... | 0.7196698 | 0 |
PATCH/PUT /main_sliders/1 PATCH/PUT /main_sliders/1.json | def update
respond_to do |format|
if @main_slider.update(main_slider_params)
format.html { redirect_to @main_slider, notice: 'Main slider was successfully updated.' }
format.json { render :show, status: :ok, location: @main_slider }
else
format.html { render :edit }
format.json { render json: @main_slider.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @food_slider = FoodSlider.find(params[:id])\n\n respond_to do |format|\n if @food_slider.update_attributes(params[:food_slider])\n format.html { redirect_to food_sliders_url, notice: 'Food slider was successfully updated.' }\n format.json { head :no_content }\n else\n ... | [
"0.66918725",
"0.6593579",
"0.6396745",
"0.634145",
"0.6333606",
"0.6255398",
"0.6180539",
"0.61779636",
"0.61483085",
"0.60796225",
"0.60705435",
"0.6009962",
"0.6006343",
"0.59944373",
"0.5986182",
"0.59702766",
"0.5965979",
"0.5950758",
"0.5888336",
"0.5888146",
"0.5887991... | 0.7132615 | 0 |
DELETE /main_sliders/1 DELETE /main_sliders/1.json | def destroy
@main_slider.destroy
respond_to do |format|
format.html { redirect_to main_sliders_url, notice: 'Main slider was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @food_slider = FoodSlider.find(params[:id])\n @food_slider.destroy\n\n respond_to do |format|\n format.html { redirect_to food_sliders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @slider.destroy\n respond_to do |format|\n format.html { red... | [
"0.71927434",
"0.71124005",
"0.6997944",
"0.69549847",
"0.67659575",
"0.6760514",
"0.67497945",
"0.66226465",
"0.6541374",
"0.6538831",
"0.65330696",
"0.65330696",
"0.65330696",
"0.6523602",
"0.65202695",
"0.6512614",
"0.65054893",
"0.6464359",
"0.6451607",
"0.644672",
"0.643... | 0.73047084 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_main_slider
@main_slider = MainSlider.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def main_slider_params
params.require(:main_slider).permit(:name, :image, :image_1, :image_2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
PATCH/PUT /people/1 PATCH/PUT /people/1.json | def update
respond_to do |format|
if @person.update(person_params)
format.html { redirect_to contestants_path, notice: 'Contestant was successfully updated.' }
else
format.html { render :edit }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_requ... | [
"0.7045833",
"0.6954952",
"0.68785477",
"0.6685791",
"0.6621935",
"0.6621935",
"0.6621935",
"0.6621935",
"0.6621935",
"0.661958",
"0.66084397",
"0.66084397",
"0.6599645",
"0.65843546",
"0.65771157",
"0.6542934",
"0.6542934",
"0.6542934",
"0.6539216",
"0.650552",
"0.6504401",
... | 0.0 | -1 |
GET /arts GET /arts.json | def index
@ability = Ability.new(current_user)
@arts = Art.all
@artists = Artist.all
@filterrific = initialize_filterrific(
Art,
params[:filterrific],
select_options: {
sorted_by: Art.options_for_sorted_by,
},
persistence_id: 'shared_key',
) or return
@arts = @filterrific.find.page(params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @arts = Art.all.all_with_comment_counts.order('updated_at DESC')\n # curl -H \"Accept: application/json\" http://localhost:3000/arts\n respond_to do |format|\n format.html {render}\n format.json {render json: @arts}\n end\n end",
"def index \n artists = Artist.all \n ... | [
"0.6883352",
"0.68268865",
"0.6682478",
"0.6682478",
"0.66728795",
"0.6586924",
"0.6575227",
"0.65612304",
"0.6469494",
"0.64101046",
"0.6402044",
"0.63317144",
"0.63189954",
"0.63090134",
"0.63090134",
"0.63090134",
"0.62965655",
"0.6295717",
"0.6265703",
"0.62483597",
"0.62... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_art
@user = current_user
@art = Art.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
GET /spotify_artists GET /spotify_artists.json | def index
@spotify_artists = SpotifyArtist.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def artists\n if RESPONSE.code == 200\n # Return data to page\n JSON.parse(RESPONSE.to_s)['topartists']['artist']\n else\n # print error message\n \"Error Code #{RESPONSE.code}\"\n end\n end",
"def artists\n # TODO: add param for albums and songs\n a = Artist.all\n render j... | [
"0.79333514",
"0.7874889",
"0.77640116",
"0.7610003",
"0.75879294",
"0.7498766",
"0.74117315",
"0.7402991",
"0.73423576",
"0.73321235",
"0.7229641",
"0.7186568",
"0.71315277",
"0.7053374",
"0.7046585",
"0.7044824",
"0.70389664",
"0.70389664",
"0.70389664",
"0.70389664",
"0.70... | 0.79103786 | 1 |
GET /spotify_artists/1 GET /spotify_artists/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @artists = Artist.find(params[:id])\n puts @artists\n render json:@artists, status: :ok\n end",
"def index\n @spotify_artists = SpotifyArtist.all\n end",
"def artists\n # TODO: add param for albums and songs\n a = Artist.all\n render json: a\n end",
"def artists\n if RES... | [
"0.792613",
"0.78099495",
"0.7762171",
"0.7748609",
"0.76960367",
"0.75193536",
"0.75139636",
"0.7480799",
"0.7229657",
"0.7220784",
"0.7212045",
"0.72066164",
"0.7199253",
"0.71934754",
"0.71435505",
"0.7097372",
"0.70595735",
"0.7023606",
"0.69955",
"0.6948375",
"0.69359696... | 0.0 | -1 |
POST /spotify_artists POST /spotify_artists.json | def create
@spotify_artist = SpotifyArtist.new(spotify_artist_params)
respond_to do |format|
if @spotify_artist.save
format.html { redirect_to @spotify_artist, notice: 'Spotify artist was successfully created.' }
format.json { render :show, status: :created, location: @spotify_artist }
else
format.html { render :new }
format.json { render json: @spotify_artist.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @artist = Artist.new(artist_params)\n @artist.artist_echo_info\n @artist.related_artists_echo\n @artist.twitter_echo\n\n respond_to do |format|\n if @artist.save\n format.html { redirect_to @artist }\n format.json { render :show, status: :created, location: @artist }\... | [
"0.713064",
"0.70214343",
"0.70214343",
"0.69814485",
"0.69729537",
"0.6970485",
"0.6970485",
"0.68908054",
"0.68765837",
"0.684792",
"0.67762256",
"0.6739029",
"0.66893643",
"0.66750735",
"0.6658324",
"0.66092604",
"0.6568759",
"0.6541966",
"0.6533642",
"0.64617187",
"0.6439... | 0.7677821 | 0 |
PATCH/PUT /spotify_artists/1 PATCH/PUT /spotify_artists/1.json | def update
respond_to do |format|
if @spotify_artist.update(spotify_artist_params)
format.html { redirect_to @spotify_artist, notice: 'Spotify artist was successfully updated.' }
format.json { render :show, status: :ok, location: @spotify_artist }
else
format.html { render :edit }
format.json { render json: @spotify_artist.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @artist.update(artist_params)\n format.html { redirect_to @artist, notice: 'Artist was successfully updated.' }\n format.json { render :show, status: :ok, location: @artist }\n else\n format.html { render :edit }\n format.json { rend... | [
"0.7032894",
"0.7032894",
"0.7032894",
"0.7032894",
"0.70303077",
"0.70265126",
"0.69979584",
"0.69893533",
"0.694156",
"0.6825043",
"0.67763805",
"0.6747176",
"0.6747176",
"0.67294043",
"0.6669171",
"0.66257894",
"0.66208696",
"0.6615505",
"0.6581187",
"0.65551955",
"0.65172... | 0.7683566 | 0 |
DELETE /spotify_artists/1 DELETE /spotify_artists/1.json | def destroy
@spotify_artist.destroy
respond_to do |format|
format.html { redirect_to spotify_artists_url, notice: 'Spotify artist was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @artist = Artist.find(params[:id])\n @artist.destroy\n\n respond_to do |format|\n format.html { redirect_to artists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @artist = Artist.find(params[:id])\n @artist.destroy\n\n respond_to do |format|\n... | [
"0.77168685",
"0.77168685",
"0.76976156",
"0.76063246",
"0.7493656",
"0.74673736",
"0.74673736",
"0.74673736",
"0.74673736",
"0.7461734",
"0.745863",
"0.745863",
"0.745863",
"0.7456557",
"0.743699",
"0.74277925",
"0.7374217",
"0.7340254",
"0.7320184",
"0.7223882",
"0.72010154... | 0.79943776 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_spotify_artist
@spotify_artist = SpotifyArtist.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def spotify_artist_params
params.require(:spotify_artist).permit(:name, :spotifyID, :images, :popularity, :genres)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Other is a symbol? | def ==(other)
name == other
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def ==(other)\n self.symbol == other.symbol \n end",
"def ==(other)\n other.is_a?(Symbol) && to_s == other.to_s\n end",
"def symbol\n @symbol\n end",
"def symbol\n... | [
"0.6987032",
"0.6987032",
"0.6987032",
"0.6987032",
"0.6987032",
"0.6987032",
"0.6866642",
"0.6821684",
"0.6711705",
"0.668881",
"0.65771985",
"0.650439",
"0.64355946",
"0.63778",
"0.63588166",
"0.623209",
"0.622912",
"0.61434686",
"0.6136974",
"0.61349934",
"0.6118233",
"0... | 0.0 | -1 |
Handles the case where we create an attribute writer via: attr :foo, true | def attr_with_writable_flag?
method_name == :attr && args.any? && args.last.type == :true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_writer(sym, *more) end",
"def attr_bool_writer *symbols\n attr_writer *symbols\n end",
"def attr_writer(*vars)\n # avoid tracking attributes that are added by the class_attribute\n # as these are class attributes and not instance attributes.\n tracked_vars = vars.reject {|var|... | [
"0.717995",
"0.7166141",
"0.671812",
"0.67000234",
"0.665908",
"0.6633851",
"0.6630387",
"0.6569358",
"0.6563676",
"0.64921796",
"0.64921796",
"0.6488026",
"0.6457926",
"0.64503294",
"0.644107",
"0.63758",
"0.634652",
"0.6321198",
"0.6284968",
"0.62391526",
"0.62095726",
"0... | 0.6746414 | 2 |
Ruby allows us to make a method a singleton_method using the class << self syntax. To check for this we check if the parent node is of type :sclass. | def singleton_method_via_class_self_notation?
return unless parent
parent.type == :sclass
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_sclass(node)\n parent = node.children[0]\n definition = evaluate_node(parent)\n @method_type = parent.self? ? :method : definition.method_call_type\n\n associate_node(node, definition)\n\n push_scope(definition)\n end",
"def in_sklass\n @sclass.push true\n\n with_... | [
"0.71230423",
"0.6166511",
"0.590421",
"0.5876964",
"0.5837864",
"0.5825088",
"0.5728021",
"0.5717428",
"0.5707048",
"0.5668195",
"0.5639189",
"0.5626256",
"0.55458003",
"0.5539423",
"0.5517556",
"0.5513014",
"0.5510418",
"0.54874754",
"0.5479524",
"0.5456563",
"0.5443579",
... | 0.8198557 | 0 |
The final section of the module or class name. For example, for a module with name 'Foo::Bar' this will return 'Bar'; for a module with name 'Foo' this will return 'Foo'. | def simple_name
name.split('::').last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def module_name\n (i = name.index(\"::\")) ? name[0..i-1] : name\n end",
"def name\n klass.name.split('::').last\n end",
"def full_name\n m = self.module\n RDoc::ClassModule === m ? m.full_name : @name\n end",
"def name\n has_module?(klass) ? klass[(klass.index(\"::\")+2)..-1] :... | [
"0.735979",
"0.69277936",
"0.68646634",
"0.67803484",
"0.6774826",
"0.67240804",
"0.66429216",
"0.66389954",
"0.66365534",
"0.66284",
"0.6589307",
"0.6563976",
"0.65066123",
"0.6481436",
"0.6447274",
"0.6407937",
"0.6403459",
"0.639473",
"0.63859826",
"0.63772416",
"0.6289899... | 0.63927937 | 19 |
there are two valid forms of the casgn sexp (casgn ) and (casgn ) used in orasgn and mlhs source = "class Hi; THIS ||= 3; end" (class (const nil :Hi) nil (orasgn (casgn nil :THIS) (int 3))) | def value
children[2]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def or_asgn!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 74 )\n\n type = OR_ASGN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 195:11: '||='\n match( \"||=\" )\n\n \n @state.typ... | [
"0.60005796",
"0.56712073",
"0.546097",
"0.5387938",
"0.53828984",
"0.53555423",
"0.5348134",
"0.5295373",
"0.52943325",
"0.52864",
"0.52155685",
"0.5214359",
"0.52130216",
"0.5212327",
"0.5212252",
"0.5211918",
"0.5193526",
"0.51474494",
"0.51436514",
"0.5140829",
"0.5068774... | 0.0 | -1 |
This function is used to create teams with random names. | def create_teams
parent = Object.const_get(session[:team_type]).find(params[:id])
Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)
undo_link("Random teams have been created successfully. ")
redirect_to :action => 'list', :id => parent.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_teams\n number_of_teams.to_i.times do |i|\n self.teams << Team.create!(:name => TEAM_NAMES[i])\n end\n end",
"def generate_random_teams(players)\n\n\t\t#randomize\n\t\tplayers = players.shuffle\n\n\t\tassign_players_to_teams(players)\n\tend",
"def generate_teams(teams_by_division, divisi... | [
"0.76513994",
"0.7608811",
"0.72945654",
"0.7072894",
"0.69927526",
"0.6992364",
"0.6941347",
"0.6762927",
"0.6694502",
"0.66524255",
"0.6644855",
"0.66304165",
"0.6602369",
"0.6594327",
"0.6572071",
"0.6568015",
"0.65579695",
"0.65099424",
"0.64555013",
"0.641953",
"0.641782... | 0.69767475 | 6 |
Copies existing teams from a course down to an assignment The team and team members are all copied. | def inherit
assignment = Assignment.find(params[:id])
if assignment.course_id >= 0
course = Course.find(assignment.course_id)
teams = course.get_teams
if teams.length > 0
teams.each{
|team|
team.copy(assignment.id)
}
else
flash[:note] = "No teams were found to inherit."
end
else
flash[:error] = "No course was found for this assignment."
end
redirect_to :controller => 'teams', :action => 'list', :id => assignment.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(course_id)\n new_team = CourseTeam.create_team_and_node(course_id)\n new_team.name = name\n new_team.save\n copy_members(new_team)\n end",
"def copy(assignment_id)\n new_team = AssignmentTeam.create_team_and_node(assignment_id)\n new_team.name = name\n new_team.save\n copy_membe... | [
"0.7154794",
"0.70387626",
"0.67921823",
"0.65528363",
"0.6476905",
"0.58432746",
"0.5694363",
"0.5659808",
"0.5626696",
"0.5622441",
"0.5591388",
"0.5583769",
"0.5444997",
"0.54351366",
"0.53736246",
"0.5347273",
"0.5328683",
"0.5310043",
"0.5305086",
"0.52605164",
"0.516247... | 0.68209565 | 2 |
Copies existing teams from an assignment up to a course The team and team members are all copied. | def bequeath
team = AssignmentTeam.find(params[:id])
assignment = Assignment.find(team.parent_id)
if assignment.course_id >= 0
course = Course.find(assignment.course_id)
team.copy(course.id)
flash[:note] = "\""+team.name+"\" was successfully copied to \""+course.name+"\""
else
flash[:error] = "This assignment is not #{url_for(:controller => 'assignment', :action => 'assign', :id => assignment.id)} with a course."
end
redirect_to :controller => 'teams', :action => 'list', :id => assignment.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(course_id)\n new_team = CourseTeam.create_team_and_node(course_id)\n new_team.name = name\n new_team.save\n copy_members(new_team)\n end",
"def copy(assignment_id)\n new_team = AssignmentTeam.create_team_and_node(assignment_id)\n new_team.name = name\n new_team.save\n copy_membe... | [
"0.71417814",
"0.70029426",
"0.6680531",
"0.6658726",
"0.65184194",
"0.5881589",
"0.58024985",
"0.5733687",
"0.5716652",
"0.5591258",
"0.556984",
"0.5564006",
"0.5438052",
"0.54364854",
"0.5433269",
"0.54076564",
"0.5404156",
"0.53820944",
"0.53406274",
"0.52544975",
"0.52540... | 0.6444904 | 5 |
Draw the Background for the window | def draw_background(windowskin)
self.contents.clear
bitmap = RPGCache.windowskin(windowskin)
self.contents.blt(0, 0, bitmap, bitmap.rect)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_background\n Gosu.draw_rect(0, 0, 1000, 700, @background, ZOrder::BACKGROUND, mode=:default)\n\tend",
"def draw_background\n draw_quad( 0, 0, TOP_COLOR,\n @width, 0, TOP_COLOR,\n 0, @height, BOTTOM_COLOR,\n @width, @height, BOTTOM_COLOR,\n ... | [
"0.8203587",
"0.817699",
"0.81456244",
"0.8075224",
"0.80631274",
"0.8004247",
"0.7823567",
"0.7546728",
"0.74883753",
"0.7472271",
"0.7405975",
"0.6978491",
"0.6975144",
"0.6690022",
"0.65894055",
"0.6588016",
"0.656845",
"0.65513456",
"0.65513456",
"0.6517032",
"0.6484218",... | 0.76345193 | 7 |
Reload the items being shown | def reload_data(inputData)
# Initialise the list of items being shown, the coordinates to show
# them at, and what do do if the item is selected.
@items = [ ]
@xy_pos = [ ]
@selected_data = []
# Check the inputData, when it is items
# Read the items input
for data in inputData
# If there is already an item at the XY position
if @xy_pos.include(data[2..3])
# Get the array's index where the item exists
index = @xy_pos.index(data[2..3])
# Delete the alraeady existing item
@items.delete_at(index)
@xy_pos.delete_at(index)
@selected_data.delete_at(index)
end
case data[0]
when item
@items $data_items[eval(data[1]).to_i]
when weapon
@items $data_weapons[eval(data[1]).to_i]
when armor
@items $data_armors[eval(data[1]).to_i]
when sym
@items data[1]
else
raise('Sorry, the item type ' + data[0].to_s + ' is not recognised')
end
# Store the x & y for the items separately (for speed)
@xy_pos data[2..3]
# Store what to do with the item if selected
@selected_data data[4..5]
end
# Add the toggles
@items += [ left_toggle, right_toggle ]
@xy_pos += ToggleCoords
# Draw the data, item name and move the cursor
draw_data
draw_item_name
@cursor.x, @cursor.y = @xy_pos[@index][0], @xy_pos[@index][1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reload_items\n @item_data = nil\n end",
"def refresh_items\n rows.clear\n\n items.each do |item|\n rows << [item]\n end\n end",
"def group_reload\n\t\tRails.application.load_seed \n\t\t@items = Item.all\n\t\trender 'index'\n\tend",
"def reload\n @items = nil\n\n ... | [
"0.75987786",
"0.689893",
"0.6847197",
"0.6763099",
"0.67515767",
"0.6382917",
"0.62953",
"0.6274821",
"0.622656",
"0.622656",
"0.62231314",
"0.61876774",
"0.61342746",
"0.5953241",
"0.5932395",
"0.59179705",
"0.5917457",
"0.590853",
"0.5881079",
"0.5876047",
"0.58575034",
... | 0.5740578 | 32 |
Draw the Items for the window | def draw_data
self.contents.font.name = AmmoFont
# Loop through every item
for i in 0...[@items.size, @xy_pos.size].min
# Skip drawing the icon if the item is diabled
next if item_disabled(i)
next if not @items[i].methods.include( 'icon_name' )
# Get the bitmap
bitmap = RPGCache.icon(@items[i].icon_name)
# If COG - Extra Frames is being used
if defined(COG_ExtraFrames)
# If the icon name includes the regexp, restrict to the first frame
if @items[i].icon_name[COG_ExtraFramesREGEXP]
rect = Rect.new(0, 0, bitmap.width $1.to_i, bitmap.height)
# If it's a normal item, use its size
else
rect = bitmap.rect
end
else
# Make the graphic's size the icon's size
rect = bitmap.rect
end
x, y = @xy_pos[i][0] - rect.width 2, @xy_pos[i][1] - rect.height 2
#set opacity depending on whether the item is usable
opacity = (item_usable(@items[i]) 255 DisabledOpacity)
# copy the bitmap onto the window
self.contents.blt(x, y, bitmap, rect, opacity)
#if the data is an item
if @items[i].is_a(RPGItem)
#get the id of the consumable used by the item
id = XASITEM_COST[XASXASITEM_ID[@items[i].id]] rescue next
#skip if there is no consumable
next if id.nil
#get the amount of that item
ammount = $game_party.item_number(id)
#check if the amount is capped
if defined(ZeldaHUD_Customization) &&
!ZeldaHUD_CustomizationItemCapVar[id].nil
value = $game_variables[ZeldaHUD_CustomizationItemCapVar[id]]
cap = (ammount == value)
else
cap = (ammount == 99)
end
#get the font color
color = cap Color.new(0,255,0,opacity) Color.new(255,255,255,opacity)
self.contents.font.color = color
#draw the ammount of the consumable
self.contents.draw_text(x, y + 16, bitmap.width,
bitmap.height, ammount.to_s, 0)
end
end
#Reset the font details
self.contents.font.name = Font.default_name
self.contents.font.color = Font.default_color
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_items\n main.newpad items\n @displayed_items = items[current_page * max_items, max_items]\n main.display current_page\n header_l.draw_path_and_page_number path: current_dir.path, current: current_page + 1, total: total_pages\n end",
"def draw()\n @ucIcon.draw()\n @cItemName.... | [
"0.73968995",
"0.7391104",
"0.7391104",
"0.725459",
"0.7199135",
"0.67582524",
"0.67238986",
"0.6719763",
"0.6649119",
"0.6600666",
"0.6580535",
"0.65372175",
"0.6521077",
"0.64906764",
"0.64576834",
"0.6455013",
"0.6446715",
"0.6443809",
"0.6439264",
"0.6418111",
"0.6407384"... | 0.66857064 | 8 |
Get Mini Menu Item | def get_minimenu_item(minimenu, selection_type = nil)
#initialize selection_type if needed
selection_type = 0 if selection_type == nil
#flag window as waiting
@waiting = true
#create the minimenu sprite
menu = Sprite_ZeldaCMS_Minimenu.new(minimenu, @cursor)
menu.x, menu.y = @xy_pos[@index]
#loop until an item has been selected or cancelled
loop do
Graphics.update
Input.update
menu.update
break if Input.trigger(InputC) Input.trigger(InputB)
Input.trigger(XAS_COMMANDITEM_ACTION[0])
Input.trigger(XAS_COMMANDITEM_ACTION[1])
Input.trigger(XAS_COMMANDITEM_ACTION[2])
end
#get the item
item = menu.item
item = nil if Input.trigger(InputB)
selection_type = 0 if Input.trigger(XAS_COMMANDITEM_ACTION[0])
selection_type = 1 if Input.trigger(XAS_COMMANDITEM_ACTION[1])
selection_type = 2 if Input.trigger(XAS_COMMANDITEM_ACTION[2])
#dispose the menu
menu.dispose
#move menu cursor
@cursor.x, @cursor.y = @xy_pos[@index][0], @xy_pos[@index][1]
#return the item
return item, selection_type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item(item_name)\n return @menu[item_name]\n end",
"def current_menu_item\n if action_name == \"index\"\n loaded_menu_items[-2]\n else\n loaded_menu_items[-1]\n end\n end",
"def current_menu_item\n controller.current_menu_item\n end",
"def get_Menu... | [
"0.76899165",
"0.74035805",
"0.7232537",
"0.69825333",
"0.68216926",
"0.67833173",
"0.65860575",
"0.6471512",
"0.64550775",
"0.6447882",
"0.6359394",
"0.6355422",
"0.6353981",
"0.63283044",
"0.6324302",
"0.6321177",
"0.6312615",
"0.6310601",
"0.63082165",
"0.62935156",
"0.622... | 0.7375899 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.