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 |
|---|---|---|---|---|---|---|
Increments an integer value in the cache. Note that it uses binary collection interface, therefore will fail if the value is not represented as ASCIIencoded number using +:raw+. | def increment(name, amount = 1, expires_in: nil, initial: nil, **options)
instrument :increment, name, amount: amount do
failsafe :increment do
key = normalize_key(name, options)
res = collection.binary.increment(
key, ::Couchbase::Options::Increment(delta: amount, expiry: expires_in, initial: initial)
)
@last_mutation_token = res.mutation_token
res.content
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment\n Dictionary.db.zincrby @key, 1, @value\n end",
"def _inc(key,value)\n _set(key, (_get(key) || 0) + value)\n end",
"def test_increment_existing_numeric\n @cache.add('Key', '100', 0, Time.now.to_i + 60)\n result = @cache.increment('Key', '1')\n cache = @cache.get('Key').args\... | [
"0.7057279",
"0.7033475",
"0.6877507",
"0.67166203",
"0.67045677",
"0.6575232",
"0.64644945",
"0.64644945",
"0.6450084",
"0.6442746",
"0.64252675",
"0.6388007",
"0.63565826",
"0.63565826",
"0.6354197",
"0.63503367",
"0.63503367",
"0.62753695",
"0.61862975",
"0.61835223",
"0.6... | 0.53901947 | 99 |
Decrements an integer value in the cache. Note that it uses binary collection interface, therefore will fail if the value is not represented as ASCIIencoded number using +:raw+. Note that the counter represented by nonnegative number on the server, and it will not cycle to maximum integer when decrementing zero. | def decrement(name, amount = 1, expires_in: nil, initial: nil, **_options)
instrument :decrement, name, amount: amount do
failsafe :decrement do
key = normalize_key(name, options)
res = collection.binary.decrement(
key, ::Couchbase::Options::Decrement(delta: amount, expiry: expires_in, initial: initial)
)
@last_mutation_token = res.mutation_token
res.content
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decr(key, value = 1)\n mon_synchronize do\n perform [\"decr\", key, value], :proc => T_INT\n end\n end",
"def decr(key, value = 1)\n mon_synchronize do\n perform [\"decr\", key, value], proc: T_INT\n end\n end",
"def _dec(key,value)\n _set(key, (_get(key) || 0) - value)\n e... | [
"0.70615005",
"0.70514256",
"0.6881012",
"0.67374736",
"0.6720277",
"0.6688909",
"0.6557013",
"0.6502052",
"0.6488873",
"0.6480518",
"0.64728826",
"0.64721453",
"0.639025",
"0.63682127",
"0.6363964",
"0.63257253",
"0.6307742",
"0.6255738",
"0.6215971",
"0.621369",
"0.60852164... | 0.5635099 | 41 |
Clears the entire cache. Be careful with this method since it could affect other processes if shared cache is being used. When +use_flush+ option set to +true+ it will flush the bucket. Otherwise, it uses N1QL query and relies on default index. | def clear(use_flush: false, **_options)
failsafe(:clear) do
if use_flush
cluster.buckets.flush_bucket(@couchbase_options[:bucket_name])
else
operation_options = ::Couchbase::Options::Query.new
operation_options.consistent_with(::Couchbase::MutationState.new(@last_mutation_token)) if @last_mutation_token
cluster.query("DELETE FROM #{scope_qualifier}", operation_options)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_clear\n @client.flushall\n end",
"def clear\r\n @cache.flush\r\n end",
"def clear\n @cache.clear\n end",
"def clear\n cache.clear\n end",
"def clearQueryCache\r\n result = request(\"DELETE\", \"_api/query-cache\")\r\n return return_delete(result)\... | [
"0.7180498",
"0.67801994",
"0.6739185",
"0.668363",
"0.65690064",
"0.65552306",
"0.65313053",
"0.6516901",
"0.6507856",
"0.6496872",
"0.6467607",
"0.64550734",
"0.6424165",
"0.6414535",
"0.6414535",
"0.641091",
"0.641091",
"0.6392268",
"0.6362332",
"0.6361445",
"0.63609797",
... | 0.7751576 | 0 |
Reads an entry from the cache | def read_entry(key, **options)
deserialize_entry(read_serialized_entry(key, **options), **options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(key)\n @cache[key]\n end",
"def cache_read(key)\n @mutex.synchronize do\n @cache[key]\n end\n end",
"def read_entry(key, options) # :nodoc:\n deserialize_entry(@data.get(key))\n rescue => e\n logger.error(\"Error reading cache entry from redis: #{e}\") if logger\... | [
"0.82879543",
"0.80549276",
"0.77597314",
"0.7743806",
"0.7681336",
"0.7637326",
"0.76272464",
"0.76076245",
"0.7509261",
"0.74261063",
"0.7415713",
"0.7410827",
"0.7386746",
"0.7386746",
"0.7369477",
"0.73349637",
"0.7243369",
"0.7207706",
"0.7184428",
"0.7182006",
"0.711321... | 0.0 | -1 |
Reads multiple entries from the cache implementation. Subclasses MAY implement this method. | def read_multi_entries(names, **options)
return {} if names.empty?
keys = names.map { |name| normalize_key(name, options) }
return_value = {}
failsafe(:read_multi_entries, returning: return_value) do
results = collection.get_multi(keys, ::Couchbase::Options::GetMulti(transcoder: nil))
results.each_with_index do |result, index|
next unless result.success?
entry = deserialize_entry(result.content, raw: options[:raw])
unless entry.nil? || entry.expired? || entry.mismatched?(normalize_version(names[index], options))
return_value[names[index]] = entry.value
end
end
return_value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_multi(*names)\n options = names.extract_options!\n return {} if names == []\n\n keys = names.map{|name| normalize_key(name, options)}\n args = [keys, options]\n args.flatten!\n\n instrument(:read_multi, names) do |payload|\n failsafe(:read_multi, returnin... | [
"0.72037786",
"0.71382344",
"0.70031166",
"0.67433906",
"0.6733432",
"0.63727015",
"0.63149184",
"0.6310927",
"0.6240829",
"0.62241054",
"0.6194542",
"0.6142272",
"0.6059888",
"0.6029876",
"0.59996563",
"0.59968984",
"0.5987757",
"0.5987068",
"0.5980668",
"0.5945351",
"0.5926... | 0.60689557 | 12 |
Writes an entry to the cache | def write_entry(key, entry, raw: false, **options)
write_serialized_entry(key, serialize_entry(entry, raw: raw, **options), raw: raw, **options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_entry(key, entry, options) # :nodoc:\n value = serialize_entry(entry)\n if (options && options[:expires_in])\n expires_in = options[:expires_in].to_i\n response = @data.setex(key, expires_in, value)\n else\n response = @data.set(key, value)\n end\n ... | [
"0.796262",
"0.7884245",
"0.78670335",
"0.7747756",
"0.76534295",
"0.7595529",
"0.7469992",
"0.7443536",
"0.7425927",
"0.7342955",
"0.72985774",
"0.709497",
"0.7039198",
"0.70159525",
"0.700047",
"0.6958491",
"0.69418466",
"0.6864184",
"0.68355346",
"0.6819205",
"0.6805944",
... | 0.60887575 | 81 |
Deletes an entry from the cache implementation. Subclasses must implement this method. | def delete_entry(key, **_options)
failsafe(:delete_entry, returning: false) do
res = collection.remove(key)
@last_mutation_token = res.mutation_token
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(entry)\n if index = @cache.delete(entry)\n entries.delete_at(index)\n end\n end",
"def delete(entry)\n deleted_index = @cache.delete(key_for(entry))\n if deleted_index\n @cache.each do |key, index|\n @cache[key] -= 1 if index > deleted_inde... | [
"0.84373236",
"0.78725857",
"0.76261675",
"0.72274303",
"0.71454823",
"0.7133182",
"0.70640075",
"0.7055703",
"0.70554477",
"0.7048757",
"0.6982963",
"0.69795656",
"0.69541943",
"0.69132334",
"0.69060886",
"0.6882095",
"0.68051064",
"0.6798982",
"0.67727005",
"0.6738487",
"0.... | 0.67925274 | 18 |
Deletes multiple entries in the cache. Returns the number of entries deleted. | def delete_multi_entries(entries, **_options)
return if entries.empty?
failsafe(:delete_multi_entries, returning: nil) do
successful = collection.remove_multi(entries).select(&:success?)
return 0 if successful.empty?
@last_mutation_token = successful.max_by { |r| r.mutation_token.sequence_number }
successful.count
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_multi_entries(entries, **options)\n entries.count { |key| delete_entry(key, **options) }\n end",
"def delete!\n count = 0\n uniq.bulk_job { |e| count += 1; e.delete! }\n count\n end",
"def delete_entries(entries)\n delete_all(:id => entries)\n en... | [
"0.7474177",
"0.6824208",
"0.6674753",
"0.6643579",
"0.66373324",
"0.66033",
"0.65767527",
"0.6558294",
"0.6550996",
"0.6542089",
"0.63723123",
"0.6368551",
"0.6355705",
"0.6317323",
"0.624858",
"0.62176305",
"0.61805487",
"0.61711884",
"0.61625236",
"0.6123495",
"0.61027884"... | 0.73292744 | 1 |
Truncate keys that exceed 250 characters | def normalize_key(key, options)
truncate_key super&.b
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncated_key(key)\n digest = digest_class.hexdigest(key)\n \"#{key[0, prefix_length(digest)]}#{TRUNCATED_KEY_SEPARATOR}#{digest}\"\n end",
"def max_key_width; end",
"def max_key_width=(_arg0); end",
"def truncate(length = 30)\n return self if self.length < length\n self[0..length].gsu... | [
"0.7043864",
"0.6650059",
"0.66317433",
"0.6457402",
"0.6442561",
"0.63482064",
"0.63448626",
"0.6339948",
"0.6316657",
"0.62807345",
"0.62536436",
"0.6243715",
"0.6239133",
"0.62176424",
"0.6201254",
"0.61772496",
"0.6173947",
"0.6154703",
"0.61207646",
"0.6118617",
"0.61165... | 0.6032665 | 29 |
Connects to the Couchbase cluster | def build_cluster
::Couchbase::Cluster.connect(
@couchbase_options[:connection_string],
::Couchbase::Options::Cluster(authenticator: ::Couchbase::PasswordAuthenticator.new(
@couchbase_options[:username], @couchbase_options[:password]
))
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_cassandra\n @client = Cql::Client.connect(hosts: ['localhost'])\n @client.use('oink')\nend",
"def connect\n @cluster.connect\n end",
"def connect_to_cassandra\n if @client\n @client.disconnect! rescue nil\n end\n @client = nil\n\n @cassandra_servers.ea... | [
"0.69977397",
"0.6931105",
"0.64401364",
"0.6336397",
"0.6302618",
"0.62917763",
"0.62834406",
"0.6269196",
"0.6245404",
"0.61693275",
"0.6110907",
"0.60501176",
"0.59861284",
"0.5985573",
"0.5923251",
"0.59085757",
"0.5895992",
"0.5877469",
"0.5876451",
"0.58695453",
"0.5846... | 0.76647305 | 0 |
Connects to the Couchbase cluster, opens specified bucket and returns collection object. | def build_collection
bucket = cluster.bucket(@couchbase_options[:bucket])
if @couchbase_options[:scope] && @couchbase_options[:collection]
bucket.scope(@couchbase_options[:scope]).collection(@couchbase_options[:collection])
else
bucket.default_collection
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_cluster\n ::Couchbase::Cluster.connect(\n @couchbase_options[:connection_string],\n ::Couchbase::Options::Cluster(authenticator: ::Couchbase::PasswordAuthenticator.new(\n @couchbase_options[:username], @couchbase_options[:password]\n ))\n )\n end",... | [
"0.5900005",
"0.5791184",
"0.5688879",
"0.55614185",
"0.5553416",
"0.5511002",
"0.543184",
"0.54155535",
"0.53867275",
"0.53394616",
"0.53394616",
"0.5237352",
"0.5195417",
"0.51768064",
"0.5157064",
"0.51562643",
"0.51496845",
"0.5148446",
"0.51438856",
"0.5143261",
"0.51256... | 0.6535918 | 0 |
once fluent v0.14 is released we might be able to use Fluent::Parser::TimeParser, but it doesn't quite do what we want if gives [sec,nsec] where as we want something we can call `strftime` on... | def create_time_parser
if @time_key_format
begin
# Strptime doesn't support all formats, but for those it does it's
# blazingly fast.
strptime = Strptime.new(@time_key_format)
Proc.new { |value| strptime.exec(value).to_datetime }
rescue
# Can happen if Strptime doesn't recognize the format; or
# if strptime couldn't be required (because it's not installed -- it's
# ruby 2 only)
Proc.new { |value| DateTime.strptime(value, @time_key_format) }
end
else
Proc.new { |value| DateTime.parse(value) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_format(seconds)\nend",
"def time_format(seconds)\nend",
"def create_time_formatter(expr)\n begin\n f = eval('lambda {|__arg_time__| ' + expr.gsub(\"$time\", \"__arg_time__\") + '}')\n return f\n rescue SyntaxError\n raise Fluent::ConfigError, \"SyntaxError at t... | [
"0.66272694",
"0.66272694",
"0.6323898",
"0.625732",
"0.6161273",
"0.6096188",
"0.60335296",
"0.5905873",
"0.58548117",
"0.58484715",
"0.5842492",
"0.58343554",
"0.58323324",
"0.5796436",
"0.5791222",
"0.5783446",
"0.5731633",
"0.5722742",
"0.5692227",
"0.56890213",
"0.565390... | 0.5671098 | 20 |
not complete. currently can only check for the first club does not factor in for if bully stole the money student would no longer meet membership requirements. | def bully
if self.name[0,1] == "J"
# binding.pry
self.budget -= 150
# binding.pry
return "The bully stole half of my money!"
else
return "AHH i'm running away!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def club_protect\n if session[:club_id]\n @current_membership = Membership.find_by_user_id_and_club_id(session[:user_id], session[:club_id], :conditions => [\"status=?\", \"current\"])\n if session[:user_id] == 6\n @current_membership = true\n end\n \n if !@current_membership \n ... | [
"0.67090636",
"0.66647357",
"0.64367205",
"0.6360402",
"0.61423296",
"0.61119545",
"0.6102576",
"0.60052264",
"0.59736264",
"0.59422004",
"0.59222513",
"0.5799681",
"0.5764733",
"0.5761775",
"0.5727484",
"0.5721266",
"0.56899226",
"0.5656122",
"0.56472737",
"0.56111866",
"0.5... | 0.0 | -1 |
Creates a MageeTextEdit param parent, name: The QWidget's parent and name | def initialize(parent = nil, name = nil)
super(parent, name)
viewport.set_w_flags(Qt::WNoAutoErase | Qt::WStaticContents)
set_static_background(true)
@invalid_rows = []
@model = TextModel.new()
@model.set_first_line_in_view_handler { first_line_in_view }
@model.set_last_line_in_view_handler { last_line_in_view }
@model.set_changed_handler { |invalid_rows| @invalid_rows = invalid_rows; repaint_contents(false) }
set_enabled(true)
set_focus_policy(Qt::Widget::StrongFocus)
resize(500, 500)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_NewParent(value)\n set_input(\"NewParent\", value)\n end",
"def new_parent=(a_parent)\n @new_parent = a_parent\n end",
"def t(name, *args)\n field = JTextField.new *args\n field.name = name\n field\n end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent... | [
"0.5725541",
"0.566465",
"0.55839866",
"0.5578601",
"0.5578601",
"0.5578601",
"0.5578601",
"0.5578601",
"0.5421841",
"0.5369704",
"0.5368662",
"0.53488046",
"0.5293775",
"0.52565765",
"0.5227468",
"0.52261025",
"0.52227575",
"0.51928705",
"0.51928705",
"0.51874185",
"0.516187... | 0.59607655 | 0 |
Returns the display coordinate of line 'n' | def line_num_to_coord(n)
(n + 1) * font_metrics.height
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line(n)\n @lines[n]\n end",
"def line_number\n number[6..-1]\n end",
"def line_for_position(position); end",
"def line_for_position(position); end",
"def line_for_position(position); end",
"def line(number); end",
"def coord_to_line_num(y)\n\t\ty / font_metrics.height - 1\n\tend",
"de... | [
"0.70057374",
"0.698374",
"0.68126297",
"0.68126297",
"0.68126297",
"0.669584",
"0.6666673",
"0.6630187",
"0.65918994",
"0.6552892",
"0.654642",
"0.65192235",
"0.6505281",
"0.64988106",
"0.64967704",
"0.6445515",
"0.6402056",
"0.63383925",
"0.6314022",
"0.6314022",
"0.6314022... | 0.8330883 | 0 |
Returns the line number of the display ycoordinate 'y' | def coord_to_line_num(y)
y / font_metrics.height - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gety\n (@lines[0...@str_idx].map(&:ymax).reduce(:+) || 0) + @str_y_idx - @start_y\n end",
"def gety\n (@lines[0...@str_idx].map(&:ymax).reduce(:+) || 0) + @str_y_idx - @start_y\n end",
"def row_at(y)\n return (((y.to_f - window.container.header_height.to_f) - @view.y_offset.to_f) / @... | [
"0.7560261",
"0.7560261",
"0.7400839",
"0.73583233",
"0.73583233",
"0.6976197",
"0.6957617",
"0.6895108",
"0.68886316",
"0.6864265",
"0.6864265",
"0.68411833",
"0.68350965",
"0.67754537",
"0.6716687",
"0.6647342",
"0.66415983",
"0.6626125",
"0.6626125",
"0.65804946",
"0.65545... | 0.83822256 | 0 |
Returns the line number of the first visible line | def first_line_in_view()
coord_to_line_num(contents_y)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visible_line_number\n return 1\n end",
"def visible_line_number\n return 1\n end",
"def visible_line_number\r\n return 5\r\n end",
"def visible_line_number\n return 4\n end",
"def visible_line_number\n return 4\n end",
"def visible_line_number\n Window_Message.line_number\n en... | [
"0.84921986",
"0.84921986",
"0.819771",
"0.8082292",
"0.8082292",
"0.78687614",
"0.7747879",
"0.7476649",
"0.7349445",
"0.7349445",
"0.7349445",
"0.7349445",
"0.73332626",
"0.7236543",
"0.72307825",
"0.71180785",
"0.7107594",
"0.70821154",
"0.7026024",
"0.7020337",
"0.7017442... | 0.80477166 | 5 |
Returns the line number of the last visible line | def last_line_in_view()
coord_to_line_num(contents_y + height)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visible_line_number\n return ROWS_MAX\n end",
"def visible_line_number\n return 1\n end",
"def visible_line_number\n return 1\n end",
"def visible_line_number\r\n return 5\r\n end",
"def visible_line_number\n return 4\n end",
"def visible_line_number\n return 4\n end",
"def ... | [
"0.8016296",
"0.78399557",
"0.78399557",
"0.78125125",
"0.7704984",
"0.7704984",
"0.7699743",
"0.7699743",
"0.7699743",
"0.7699743",
"0.76581144",
"0.75609624",
"0.74392617",
"0.73366356",
"0.7335133",
"0.7335133",
"0.7335133",
"0.7335133",
"0.7335133",
"0.7335133",
"0.733513... | 0.8150478 | 0 |
Returns the number of lines that are visible | def num_lines_in_view()
last_line_in_view() - first_line_in_view() + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_lines() @line_indices.length + 1 end",
"def visible_line_number\n @ev_height\n end",
"def line_count\n\t\tlines.size\n\tend",
"def line_count\n\t\tlines.size\n\tend",
"def visible_line_number\r\n return 5\r\n end",
"def visible_line_number\n return 1\n end",
"def visible_line_number... | [
"0.7354008",
"0.7268611",
"0.7230812",
"0.7230812",
"0.7180098",
"0.7135837",
"0.7135837",
"0.6989307",
"0.6989307",
"0.6962526",
"0.6962526",
"0.6962526",
"0.6962526",
"0.694949",
"0.69361705",
"0.69325227",
"0.68812764",
"0.67878985",
"0.67862135",
"0.6758374",
"0.6754014",... | 0.7968226 | 0 |
Gets the index of the n'th newline character. | def line_index(num)
if num == 0
return -1
elsif num <= @line_indices.length
return @line_indices[num - 1]
elsif num == @line_indices.length + 1
return @text.length
else
return -999 # todo
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_at(char)\n return nil unless char\n text[0..char].count(\"\\n\") + 1\n end",
"def line_index(pos=pos())\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end",
"def line_at(io, char)\n ... | [
"0.7387125",
"0.69991666",
"0.6984622",
"0.6936094",
"0.6918486",
"0.6593659",
"0.6475847",
"0.64593613",
"0.6398444",
"0.63612634",
"0.6360189",
"0.63082767",
"0.6301517",
"0.6263164",
"0.6260434",
"0.62538785",
"0.6223898",
"0.62192756",
"0.62011427",
"0.61791855",
"0.60642... | 0.6994547 | 2 |
Returns the index of 'row', 'col' in the singledimensional array | def index_of_position(row, col = 0)
line_index(row) + col + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getArrayIndex(row, col)\n index = 0\n case row\n when '1'\n if col == 'A'\n index = 0\n elsif col == 'D'\n index = 1\n else index = 2\n end\n when '2'\n if col == 'B'\n index = 3\n elsif col == 'D'\n index = 4\n ... | [
"0.7620627",
"0.76191115",
"0.7141633",
"0.6696994",
"0.66085047",
"0.6593831",
"0.655882",
"0.65429103",
"0.6529742",
"0.65205866",
"0.64939433",
"0.6442951",
"0.6433444",
"0.6403113",
"0.6400754",
"0.63894373",
"0.63894373",
"0.63887095",
"0.63776755",
"0.63762736",
"0.6360... | 0.7217415 | 2 |
Given an absolute index returns the line number and index | def index_line_and_col(index)
i = 0
i += 1 while index_of_position(i) <= index
i -= 1
[i, index - index_of_position(i)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_line_index\n from_line - 1\n end",
"def line_index()\n end",
"def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo... | [
"0.7658351",
"0.76503146",
"0.7352164",
"0.7191136",
"0.71612537",
"0.7147532",
"0.7088944",
"0.7041154",
"0.6985347",
"0.69707566",
"0.69030946",
"0.6849574",
"0.6845614",
"0.6836286",
"0.6831197",
"0.6813527",
"0.6813527",
"0.6813527",
"0.6787191",
"0.6787191",
"0.6787191",... | 0.72391075 | 3 |
Adds 'amount' to all line indices with a current value greater than or equal to 'threshold' | def adjust_line_indices_after(threshold, amount)
@line_indices.map! { |l| l >= threshold ? l + amount : l }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threshold=(threshold)\n @threshold = threshold\n \n @threshold = 100 if threshold > 100\n @threshold = 1 if threshold < 1\n end",
"def relaxed_threshold(threshold)\n\t\tif threshold > @threshold_gap\n\t\t\trelaxed_threshold = threshold - @threshold_gap\n\t\telse\n\t\t\trelaxed_thresh... | [
"0.5497338",
"0.51628816",
"0.49867752",
"0.4970769",
"0.4927415",
"0.47238207",
"0.4689792",
"0.46662536",
"0.4647617",
"0.46465495",
"0.46371502",
"0.46313834",
"0.46305835",
"0.46239343",
"0.46220207",
"0.46083945",
"0.46038696",
"0.45898765",
"0.45389003",
"0.45345128",
"... | 0.85977507 | 0 |
Removes the line numbered 'line_num' | def remove_line(line_num)
if @line_indices == []
@text = ""
else
length = line_index(line_num + 1) - line_index(line_num)
@text[line_index(line_num) + 1 .. line_index(line_num + 1)] = ""
@line_indices.delete_at(line_num)
(line_num...@line_indices.length).each { |i| @line_indices[i] -= length }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_at(line_number)\n self[line_number].delete\n super(line_number)\n update_line_numbers!\n end",
"def noteboard_delete(line_number)\n \n\n end",
"def remove_line(line)\n\t\t@lines.delete(line)\n\tend",
"def removeLine(lineNumber)\n \n\n\tlineNumber = lineNumber - 1\n\tnewQuestio... | [
"0.75238675",
"0.72559553",
"0.71756136",
"0.6893151",
"0.68463844",
"0.6694514",
"0.6635316",
"0.6474661",
"0.6412143",
"0.637273",
"0.6341321",
"0.63086516",
"0.6296507",
"0.62349516",
"0.6228228",
"0.6216985",
"0.61865336",
"0.61761105",
"0.6110079",
"0.60851204",
"0.60775... | 0.8547995 | 0 |
Removes from 'line_from', 'index_from' up to but not including 'line_to', 'index_to' | def remove_range(line_from, index_from, line_to, index_to)
ix1 = index_of_position(line_from, index_from)
ix2 = index_of_position(line_to, index_to)
@text[ix1 ... ix2] = ""
@line_indices.delete_if { |i| i.between?(ix1, ix2) }
adjust_line_indices_after(ix2, -(ix2 - ix1))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_preceding(node_or_range, size); end",
"def remove_line(line_num)\n\t\tif @line_indices == []\n\t\t\t@text = \"\"\n\t\telse\n\t\t\tlength = line_index(line_num + 1) - line_index(line_num)\n\t\t\t@text[line_index(line_num) + 1 .. line_index(line_num + 1)] = \"\"\n\t\t\t@line_indices.delete_at(line_num)\... | [
"0.62792844",
"0.6189214",
"0.6107818",
"0.61052537",
"0.61052537",
"0.61052537",
"0.61052537",
"0.61052537",
"0.61052537",
"0.61052537",
"0.61052537",
"0.6097464",
"0.6032891",
"0.59996",
"0.59461457",
"0.5907957",
"0.5883209",
"0.58761173",
"0.5823448",
"0.58043784",
"0.578... | 0.82596976 | 0 |
Gets text from 'line_from', 'index_from' up to but not including 'line_to', 'index_to' | def get_range(line_from, index_from, line_to, index_to)
ix1 = index_of_position(line_from, index_from)
ix2 = index_of_position(line_to, index_to)
@text[ix1 ... ix2]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_range(line_from, index_from, line_to, index_to) \n\t\tix1 = index_of_position(line_from, index_from)\n\t\tix2 = index_of_position(line_to, index_to)\n\t\t@text[ix1 ... ix2] = \"\"\n\t\t@line_indices.delete_if { |i| i.between?(ix1, ix2) }\n\t\tadjust_line_indices_after(ix2, -(ix2 - ix1))\n\tend",
"def ... | [
"0.74373615",
"0.69180185",
"0.68700963",
"0.66062117",
"0.6275667",
"0.6266768",
"0.61057496",
"0.61057496",
"0.61057496",
"0.6042144",
"0.5999725",
"0.59089905",
"0.58547854",
"0.5843117",
"0.5837925",
"0.582337",
"0.58171666",
"0.5802001",
"0.57992876",
"0.57536846",
"0.57... | 0.8064715 | 0 |
Inserts text 'text' at line 'line', before column 'col' | def insert_text(line, col, text)
index = index_of_position(line, col)
@text.insert(index, text)
i = 0
i += 1 while i < @line_indices.length and @line_indices[i] < index
(0...text.length).each do |c|
if text[c,1] == "\n"
@line_indices.insert(i, index + c)
i += 1
end
end
(i ... @line_indices.length).each { |i| @line_indices[i] += text.length }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_text_at_cursor(text) \n\t\tinsert_text(@cursor_row, @cursor_col, text)\n\t\n\t\tif text.include?(\"\\n\")\n\t\t\t#todo what about multiple \\n's\n\t\t\t@cursor_row += 1\n\t\t\t@cursor_col = 0\n\t\t\t#resize_contents(500, line_num_to_coord(@text.num_lines + 1))\n\t\t\temit_changed(@cursor_row - 1)\n\t\te... | [
"0.7264024",
"0.6832584",
"0.6745029",
"0.66017145",
"0.6530093",
"0.63915396",
"0.6282005",
"0.6271797",
"0.62317735",
"0.61838007",
"0.6153853",
"0.614321",
"0.6102728",
"0.6093982",
"0.606195",
"0.60552585",
"0.60202473",
"0.600556",
"0.5996389",
"0.598623",
"0.59469384",
... | 0.84449697 | 0 |
Changes the text of line 'line_num' to 'text | def change_line(line_num, text)
raise "no newlines here yet please" if text =~ /\n/
ix1, ix2 = line_index(line_num) + 1, line_index(line_num + 1)
@text[ix1...ix2] = text
(line_num...@line_indices.length).each { |i| @line_indices[i] += text.length - (ix2 - ix1) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_line(text)\n end",
"def remove_line(line_num)\n\t\tif @line_indices == []\n\t\t\t@text = \"\"\n\t\telse\n\t\t\tlength = line_index(line_num + 1) - line_index(line_num)\n\t\t\t@text[line_index(line_num) + 1 .. line_index(line_num + 1)] = \"\"\n\t\t\t@line_indices.delete_at(line_num)\n\t\t\t(line_num... | [
"0.6719064",
"0.66787726",
"0.6625625",
"0.6545188",
"0.6476965",
"0.64592564",
"0.64402807",
"0.6407536",
"0.6332513",
"0.6291928",
"0.62585914",
"0.6197664",
"0.6172941",
"0.61715883",
"0.6155007",
"0.6151595",
"0.61308306",
"0.6128319",
"0.60884655",
"0.60676867",
"0.60272... | 0.8175392 | 0 |
Returns the line numbered 'num' (first line is 0) | def line(num) lines(num, 1) end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend",
"def line_number\n number[6..-1]\n end",
"def line_n... | [
"0.84106016",
"0.79114735",
"0.77193195",
"0.77130175",
"0.76239145",
"0.75851053",
"0.75791425",
"0.7510495",
"0.7502307",
"0.7428788",
"0.71273696",
"0.7097533",
"0.704864",
"0.704864",
"0.704864",
"0.704864",
"0.704864",
"0.704864",
"0.704864",
"0.7036752",
"0.70050186",
... | 0.79931754 | 1 |
Returns 'num' lines starting from line 'start' | def lines(start, num)
@text[index_of_position(start)...index_of_position(start + num) - 1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_lines(start_line, num_lines)\n start_idx =\n if start_line >= 0\n @lines.index { |loc| loc.lineno >= start_line } || @lines.length\n else\n [@lines.length + start_line, 0].max\n end\n\n alter do\n @lines = @lines.slice(start_idx, num_lines)\n en... | [
"0.72183967",
"0.71518797",
"0.6923758",
"0.6923758",
"0.67764974",
"0.6596829",
"0.6540667",
"0.6475989",
"0.64405864",
"0.6342851",
"0.6335547",
"0.6253575",
"0.62462795",
"0.62190163",
"0.620429",
"0.61829734",
"0.6128401",
"0.60797524",
"0.6043772",
"0.6015493",
"0.597166... | 0.79685843 | 0 |
Returns the number of lines | def num_lines() @line_indices.length + 1 end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_count\n\t\tlines.size\n\tend",
"def line_count\n\t\tlines.size\n\tend",
"def getNumLines()\n contents.split(\"\\n\").length - 1\n end",
"def line_count\n\t\t\treturn @contents.nil? ? 0 : @contents.count\n\t\tend",
"def count_lines\n linecount = 0\n\n @output_buffer.each do |line|\n ... | [
"0.9101023",
"0.9101023",
"0.87184674",
"0.8558411",
"0.8494818",
"0.844529",
"0.8258071",
"0.8162386",
"0.7946143",
"0.7926586",
"0.7897918",
"0.7733357",
"0.772134",
"0.772134",
"0.76482654",
"0.76154155",
"0.759892",
"0.75958043",
"0.7586319",
"0.75692225",
"0.7563106",
... | 0.8742464 | 2 |
stuff can be various things (document this) | def emit_changed(stuff)
if stuff == nil
@changed_handler.call(RangeList.new((0...num_lines)))
else
@changed_handler.call(RangeList.new(stuff))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stuff\n end",
"def writethis; end",
"def doc; end",
"def doc; end",
"def doc; end",
"def doc; end",
"def extra; end",
"def base_docstring; end",
"def weber; end",
"def doc=(_arg0); end",
"def doc=(_arg0); end",
"def doc=(_arg0); end",
"def docstring; end",
"def docstring; end",
"de... | [
"0.6749312",
"0.601931",
"0.5891246",
"0.5891246",
"0.5891246",
"0.5891246",
"0.5870815",
"0.57917994",
"0.571982",
"0.57120335",
"0.57120335",
"0.57120335",
"0.56779754",
"0.56779754",
"0.56731564",
"0.56731564",
"0.56731564",
"0.562318",
"0.562318",
"0.562318",
"0.562318",
... | 0.0 | -1 |
Sets the cursor's position to 'row', 'col' | def set_cursor_position(row, col)
invalid_rows = [@cursor_row, row]
@cursor_row, @cursor_col = row, col
if @cursor_row < first_line_in_view
set_contents_pos(0, line_num_to_coord(@cursor_row))
emit_changed(nil)
elsif @cursor_row > last_line_in_view
set_contents_pos(0, line_num_to_coord(@cursor_row - num_lines_in_view))
emit_changed(nil)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore_cursor_position() set_cursor_position(@event[\"line\"], @event[\"column\"]) end",
"def set_position(row, col)\n if row.between?(0, 7) && col.between?(0, 7)\n @position[:row] = row\n\t @position[:col] = col\n\tend\n end",
"def cursor_home\n @curpos = 0\n @pcol = 0\n set_col_offset... | [
"0.76773417",
"0.7410794",
"0.7367086",
"0.72834444",
"0.7256796",
"0.723927",
"0.72136575",
"0.72136575",
"0.72136575",
"0.7210068",
"0.7180605",
"0.7059563",
"0.70543504",
"0.6995929",
"0.69584244",
"0.68167746",
"0.6764925",
"0.6745875",
"0.67443615",
"0.6712027",
"0.67118... | 0.83647645 | 0 |
Inserts text at the cursor's current position and updates cursor | def insert_text_at_cursor(text)
insert_text(@cursor_row, @cursor_col, text)
if text.include?("\n")
#todo what about multiple \n's
@cursor_row += 1
@cursor_col = 0
#resize_contents(500, line_num_to_coord(@text.num_lines + 1))
emit_changed(@cursor_row - 1)
else
@cursor_col += text.length
emit_changed(@cursor_row)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_text_insertion pos, text\n add_command InsertionCommand.new(pos, text)\n end",
"def insert(text, at: caret)\n editable? and @native.insert_text(at.to_i, text.to_s, text.to_s.length)\n end",
"def insertText cursor, text\n if @fileContent.size == 1 and @fileContent[0] == \"\"\n ... | [
"0.78739834",
"0.7795639",
"0.7627861",
"0.75727004",
"0.72709006",
"0.72687006",
"0.72687006",
"0.72526455",
"0.7165091",
"0.7125943",
"0.70980746",
"0.70634115",
"0.70015275",
"0.6886459",
"0.6852852",
"0.6845627",
"0.6751516",
"0.6738957",
"0.67093945",
"0.66722345",
"0.66... | 0.8378789 | 0 |
Deletes the character before the cursor (like pressing backspace) | def backspace()
#todo
if @cursor_col > 0
line = line(@cursor_row)
line[@cursor_col - 1.. @cursor_col - 1] = ""
change_line(@cursor_row, line)
@cursor_col -= 1
emit_changed(@cursor_row)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_current_character() \n\t\tif @selection_start != -1\n\t\t\tl1, i1 = index_line_and_col(@selection_start)\n\t\t\tl2, i2 = index_line_and_col(@selection_end)\n\t\t\tremove_range(l1, i1, l2, i2)\n\t\t\tclear_selection\n\t\t\temit_changed((l1...num_lines)) #todo\n\t\telse\n\t\t\tline = line(@cursor_row)\n\t... | [
"0.7839138",
"0.76375204",
"0.7370505",
"0.7297016",
"0.72069186",
"0.7041504",
"0.6990519",
"0.69695044",
"0.69440466",
"0.6920794",
"0.68249846",
"0.6771089",
"0.6688815",
"0.6669755",
"0.6600718",
"0.6580403",
"0.6573684",
"0.65690404",
"0.6564683",
"0.6563899",
"0.6563899... | 0.7675729 | 1 |
Deletes the character at the cursor (like pressing delete) | def delete_current_character()
if @selection_start != -1
l1, i1 = index_line_and_col(@selection_start)
l2, i2 = index_line_and_col(@selection_end)
remove_range(l1, i1, l2, i2)
clear_selection
emit_changed((l1...num_lines)) #todo
else
line = line(@cursor_row)
line[@cursor_col.. @cursor_col] = ""
change_line(@cursor_row, line)
emit_changed(@cursor_row)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_character\n @lines = lines.delete_character(y, x - 1)\n\n left\n\n refresh\n end",
"def editor_delete_character!\n Vedeu.bind(:_editor_delete_character_) do |name|\n Vedeu.documents.by_name(name).delete_character\n end\n end",
"def delete_charact... | [
"0.80851126",
"0.77552146",
"0.74847394",
"0.74847394",
"0.7448047",
"0.7275868",
"0.7258426",
"0.69643384",
"0.69332397",
"0.6917795",
"0.68581516",
"0.67701685",
"0.65531725",
"0.6525773",
"0.6491013",
"0.64766586",
"0.64537454",
"0.6432829",
"0.62588584",
"0.6229734",
"0.6... | 0.82607466 | 0 |
Highlights all instances of 'pattern' in the text | def highlight(pattern)
pattern = Regexp.new(pattern) if pattern.is_a?(String)
@highlights = [[0, Qt::black]] # todo factor this
invalid_rows = []
(0...num_lines).each do |index|
line = line(index)
if line =~ pattern
#todo
#@highlights << HighlightData.new(index, $~.begin(0), index, $~.end(0), Qt::yellow, Qt::black)
#invalid_rows << index
end
end
##repaint_rows(invalid_rows)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highlight(keywords, replacement_pattern)\n s = self.clone\n keywords.each do|kw|\n r = replacement_pattern.is_a?(Array) ? \"#{replacement_pattern.first}\\\\1#{replacement_pattern}\" : replacement_pattern\n s.gsub!(/(#{kw})/i, replacement_pattern)\n end\n s\n end",
"def highlight(keywor... | [
"0.7007881",
"0.6570006",
"0.6157934",
"0.61531353",
"0.61190563",
"0.6077356",
"0.60678107",
"0.601119",
"0.601119",
"0.601119",
"0.5939517",
"0.5928957",
"0.5888052",
"0.58456266",
"0.584248",
"0.58179927",
"0.57969415",
"0.5784149",
"0.57815874",
"0.5753481",
"0.57060385",... | 0.7619761 | 0 |
Returns a 2D array [[render1, text1], [render2, text2], ..., [rendern, textn]] | def get_line_render_instructions(line_num)
start_line_index = index_of_position(line_num)
line = line(line_num)
instructions = []
highlight_index = @highlights.length - 1
highlight_index -= 1 while highlight_index > 0 and @highlights[highlight_index][0] > start_line_index
highlight = @highlights[highlight_index][1]
highlight_index += 1
part_start_index = 0
(0..line.length).each do |c|
if c == line.length or (highlight_index < @highlights.length and @highlights[highlight_index][0] == c + start_line_index)
instructions << [highlight, line[part_start_index ... c]]
break if c == line.length
highlight = @highlights[highlight_index][1]
highlight_num += 1
end
end
instructions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix(text)\n row1, row2, row3 = rows_as_char_arrays(text)\n row1.zip(row2, row3)\n end",
"def characters_array # That's a terrible name.\n convert_to_chars\n highlight_squares\n self.rows\n end",
"def create\n\t\t\tobj = []\n\t\t\t@@fonts[@font]['n'].size.times do\n\t\t\t\tobj << []\n... | [
"0.645829",
"0.5959358",
"0.5882848",
"0.58606184",
"0.5860072",
"0.5827875",
"0.5827059",
"0.57310015",
"0.57167274",
"0.56647253",
"0.5659097",
"0.55576104",
"0.55306387",
"0.55274045",
"0.5516862",
"0.55161095",
"0.550755",
"0.55003744",
"0.54650366",
"0.5388109",
"0.53813... | 0.0 | -1 |
Write a function sum_to(n) that uses recursion to calculate the sum from 1 to n (inclusive of n). | def sum_to(n)
if n == 1
return 1
elsif n < 1
return nil
end
n + sum_to(n - 1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_to(n)\n return nil if n < 0\n return 0 if n == 0\n \n n += sum_to(n-1)\n end",
"def sum_to(n)\n return nil if n <= 0 #negatives and 0\n return 1 if n == 1 #base step\n #inclusive step 1 + sum_to(n)\n n + sum_to(n - 1)\nend",
"def sum_to(n)\n return n if n == 1\n n +... | [
"0.8673652",
"0.86240727",
"0.86119795",
"0.8595396",
"0.8589504",
"0.8567511",
"0.85596436",
"0.8507498",
"0.8500545",
"0.84943825",
"0.84879327",
"0.8453495",
"0.84448504",
"0.8416314",
"0.8341449",
"0.8336774",
"0.8321511",
"0.82756466",
"0.82407045",
"0.82068515",
"0.8190... | 0.83986896 | 14 |
=> returns nil Exercise 2 add_numbers Write a function add_numbers(nums_array) that takes in an array of Fixnums and returns the sum of those numbers. Write this method recursively. | def add_numbers(nums_array)
if nums_array.length == 1
return nums_array.last
elsif nums_array.empty?
return nil
end
nums_array.pop + add_numbers(nums_array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_numbers(nums_array)\n return nums_array.first if nums_array.length == 1 #=> base case if the array is length 1 then just return the first element\n return nil if nums_array.length < 1 #=> return nil if the array length is less than 1\n \n nums_array.pop + add_numbers(nums_array) #=> inductive/r... | [
"0.8449055",
"0.8392316",
"0.83362216",
"0.8239925",
"0.8232353",
"0.82213223",
"0.82135147",
"0.81997126",
"0.81960714",
"0.818539",
"0.81810707",
"0.8166863",
"0.81329715",
"0.812441",
"0.81220436",
"0.8096984",
"0.8064034",
"0.8064034",
"0.80628866",
"0.8047653",
"0.803208... | 0.8054679 | 19 |
=> returns 5040 Exercise 4 Ice Cream Shop Write a function ice_cream_shop(flavors, favorite) that takes in an array of ice cream flavors available at the ice cream shop, as well as the user's favorite ice cream flavor. Recursively find out whether or not the shop offers their favorite flavor. | def ice_cream_shop(flavors, favorite)
if flavors.empty?
return false
end
return true if favorite == flavors.pop
ice_cream_shop(flavors, favorite)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ice_cream_shop(flavors, favorite)\n # Base step\n return false if flavors.empty?\n return true if flavors[0] == favorite\n # Recursive Step\n ice_cream_shop(flavors[1..-1], favorite)\nend",
"def ice_cream_shop(flavors, favorite)\n return false if flavors == []\n return true if flavors[0] == favorite\n... | [
"0.8377418",
"0.7770475",
"0.7662393",
"0.7660354",
"0.76519716",
"0.7648953",
"0.7648287",
"0.7633423",
"0.7615455",
"0.760103",
"0.75485975",
"0.75462985",
"0.7533894",
"0.7522362",
"0.7493256",
"0.74747753",
"0.74473643",
"0.73858213",
"0.73810697",
"0.7343126",
"0.7335998... | 0.7464782 | 16 |
=> returns false Exercise 5 Reverse Write a function reverse(string) that takes in a string and returns it reversed. | def reverse(string)
if string == ''
return ''
end
string.chars.pop + reverse((string.chars - [string.chars.pop]).join)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse(string)\nend",
"def reverse(str)\n return str.reverse()\nend",
"def reverse(str)\n return str.reverse()\nend",
"def reverse_string(string)\n answer = string.reverse\n return answer\nend",
"def Reverse(str)\n return str.reverse! # Okay, completely useless\nend",
"def reverse(s)\nend",
... | [
"0.8209055",
"0.81811655",
"0.81701505",
"0.811757",
"0.807593",
"0.8058038",
"0.8052876",
"0.8037358",
"0.8034767",
"0.80033046",
"0.8000448",
"0.7986728",
"0.79866797",
"0.7985523",
"0.7975693",
"0.79712987",
"0.79675597",
"0.79675597",
"0.7942086",
"0.79223895",
"0.7921533... | 0.0 | -1 |
GET /api/v1/poll_responses GET /api/v1/poll_responses.json | def index
@api_v1_poll_responses = Api::V1::PollResponse.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_api_v1_poll_response\n @api_v1_poll_response = Api::V1::PollResponse.find(params[:id])\n end",
"def api_v1_poll_response_params\n params.fetch(:api_v1_poll_response, {})\n end",
"def respond\n\t\t@poll = Poll.find(params[:id])\n\t\t@expert_user = @poll.expert_user\n\t\t@participants = @... | [
"0.6578214",
"0.6476995",
"0.6418129",
"0.6399645",
"0.6371288",
"0.6334123",
"0.62478423",
"0.623384",
"0.6232368",
"0.61980903",
"0.6183851",
"0.61230755",
"0.60523313",
"0.60523313",
"0.60523313",
"0.60523313",
"0.60523313",
"0.6037501",
"0.600481",
"0.5996631",
"0.5953638... | 0.7910411 | 0 |
GET /api/v1/poll_responses/1 GET /api/v1/poll_responses/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @api_v1_poll_responses = Api::V1::PollResponse.all\n end",
"def set_api_v1_poll_response\n @api_v1_poll_response = Api::V1::PollResponse.find(params[:id])\n end",
"def api_v1_poll_response_params\n params.fetch(:api_v1_poll_response, {})\n end",
"def get_single_poll(id,opts={}... | [
"0.7743532",
"0.7208182",
"0.6721901",
"0.6448035",
"0.6436729",
"0.6434451",
"0.6422756",
"0.6202063",
"0.61444414",
"0.6068865",
"0.60517454",
"0.6040167",
"0.6028721",
"0.60113466",
"0.5997825",
"0.5996945",
"0.5901361",
"0.59002596",
"0.5892823",
"0.58864284",
"0.5871122"... | 0.0 | -1 |
POST /api/v1/poll_responses POST /api/v1/poll_responses.json | def create
@api_v1_poll_response = Api::V1::PollResponse.new(api_v1_poll_response_params)
respond_to do |format|
if @api_v1_poll_response.save
format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully created.' }
format.json { render :show, status: :created, location: @api_v1_poll_response }
else
format.html { render :new }
format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @api_v1_poll_responses = Api::V1::PollResponse.all\n end",
"def create_single_poll(polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of ... | [
"0.65801",
"0.62844723",
"0.60589164",
"0.6054359",
"0.6022208",
"0.59708434",
"0.59641784",
"0.5954258",
"0.5930939",
"0.5907393",
"0.59044474",
"0.5894023",
"0.5887609",
"0.58723444",
"0.58723444",
"0.580967",
"0.5809335",
"0.5786081",
"0.5779321",
"0.57725215",
"0.5757535"... | 0.70459193 | 0 |
PATCH/PUT /api/v1/poll_responses/1 PATCH/PUT /api/v1/poll_responses/1.json | def update
respond_to do |format|
if @api_v1_poll_response.update(api_v1_poll_response_params)
format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully updated.' }
format.json { render :show, status: :ok, location: @api_v1_poll_response }
else
format.html { render :edit }
format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_single_poll(id,polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n raise \"polls__que... | [
"0.7025279",
"0.6797401",
"0.6657104",
"0.66203606",
"0.6583832",
"0.65541863",
"0.65541863",
"0.65536416",
"0.65536416",
"0.65536416",
"0.65229535",
"0.651808",
"0.64875567",
"0.6375086",
"0.63611084",
"0.63481206",
"0.63475144",
"0.6321016",
"0.63069594",
"0.6281272",
"0.62... | 0.70790887 | 0 |
DELETE /api/v1/poll_responses/1 DELETE /api/v1/poll_responses/1.json | def destroy
@api_v1_poll_response.destroy
respond_to do |format|
format.html { redirect_to api_v1_poll_responses_url, notice: 'Poll response was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to polls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to polls_url }\n format.json { head :no_content }\n e... | [
"0.7354495",
"0.7354495",
"0.7306613",
"0.7278086",
"0.72066855",
"0.7093404",
"0.7093404",
"0.7093404",
"0.7093404",
"0.70714635",
"0.7058218",
"0.7054363",
"0.70266366",
"0.697133",
"0.69615406",
"0.69369197",
"0.69322777",
"0.68988866",
"0.6846993",
"0.6840946",
"0.6832440... | 0.78573734 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_api_v1_poll_response
@api_v1_poll_response = Api::V1::PollResponse.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 api_v1_poll_response_params
params.fetch(:api_v1_poll_response, {})
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.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",... | 0.0 | -1 |
See codeline model for explanation of this pattern and how to utilize the associations. | def client_attributes=(params)
client_to_save = Client.find_or_create_by_name(params[:name])
self.client = client_to_save
client_to_save.birth_date = params[:birth_date]
client_to_save.address1 = params[:address1]
client_to_save.address2 = params[:address2]
client_to_save.city = params[:city]
client_to_save.state = params[:state]
client_to_save.zip_code = params[:zip_code]
client_to_save.medicare_num = params[:medicare_num]
client_to_save.medicaid_num = params[:medicaid_num]
client_to_save.member_num = params[:member_num]
client_to_save.soc_sec_care_mgr = params[:soc_sec_care_mgr]
client_to_save.sscm_ph = params[:sscm_ph]
client_to_save.nurse_care_mgr = params[:nurse_care_mgr]
client_to_save.ncm_ph = params[:ncm_ph]
client_to_save.emer_contact = params[:emer_contact]
client_to_save.ec_ph = params[:ec_ph]
client_to_save.pri_care_phy = params[:pri_care_phy]
client_to_save.pcp_ph = params[:pcp_ph]
client_to_save.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def associations; end",
"def setup_associations; end",
"def associated\n end",
"def model_relationships; end",
"def associations; self.class.class_eval(\"@@associations\") end",
"def child_relation; end",
"def association(association_name); end",
"def associated_records\n raise NotImplementedEr... | [
"0.73459053",
"0.7041705",
"0.68838805",
"0.6659784",
"0.66216457",
"0.654491",
"0.64321154",
"0.63897425",
"0.63080287",
"0.6208916",
"0.612364",
"0.6058486",
"0.6049167",
"0.60247934",
"0.5866024",
"0.5854072",
"0.58310837",
"0.5768192",
"0.5764886",
"0.57467175",
"0.574671... | 0.0 | -1 |
the folder at the root of the task scheduler | def root_folder
scheduler_service.GetFolder("\\")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cron_dot_d_directory\n end",
"def work_dir; end",
"def tasks_directory\n @cached_paths[:tasks_directory] ||= look_up_configured_path(\n :tasks_directory,\n :defaults => ['tasks']\n )\n end",
"def job_folder\n File.join(Session.current.root, job_key)\n end",
"def fold... | [
"0.7591735",
"0.71050394",
"0.6866237",
"0.66214055",
"0.6530276",
"0.64892966",
"0.647909",
"0.6475342",
"0.6454152",
"0.6454152",
"0.64404106",
"0.64137673",
"0.640872",
"0.6389779",
"0.63563234",
"0.6304272",
"0.6293728",
"0.62719685",
"0.62634647",
"0.6256626",
"0.6245746... | 0.82323426 | 0 |
Returns an array of scheduled task names. | def registered_tasks
# Get the task folder that contains the tasks.
taskCollection = root_folder.GetTasks(0)
array = []
taskCollection.each do |registeredTask|
array.push(registeredTask)
end
array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_names\n map do |task|\n task.name\n end\n end",
"def task_names\n @task_names ||= tasks.map { |task| task.name.underscore }\n end",
"def tasks\n @tasks.values.sort_by { |t| t.name }\n end",
"def get_available_tasks\n tasks_to_return = []\n @tasks_names.each{... | [
"0.8267654",
"0.7885229",
"0.6916532",
"0.6887011",
"0.68063265",
"0.68063265",
"0.6793123",
"0.6790763",
"0.67788714",
"0.67696404",
"0.67555577",
"0.6701266",
"0.66570085",
"0.65295386",
"0.65056837",
"0.6431892",
"0.6359984",
"0.6359984",
"0.6359984",
"0.63354063",
"0.6294... | 0.6828243 | 4 |
Array of states (04) based on the constants | def current_state(name)
task = get_task(name)
case
when task.nil?
"Not Created"
when task.State >= 0 && task.State <= 4
["Unknown", "Disabled", "Queued", "Ready", "Running"].fetch(task.State)
when task.State == 3 && task.LastTaskResult == 0
"Completed"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_array\n %w(AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY)\nend",
"def states\n\t[:shelf,:in_use,:borrowed,:misplaced,:lost]\nend",
"def state\n [\n [\"AC\",\"Acre\"],\n [\"AL\",\"A... | [
"0.7809702",
"0.73638105",
"0.7338036",
"0.73163986",
"0.73163986",
"0.71895164",
"0.70708686",
"0.6923798",
"0.6869856",
"0.684979",
"0.68013966",
"0.67171913",
"0.67171913",
"0.67171913",
"0.6686074",
"0.6683052",
"0.666808",
"0.65696436",
"0.6566295",
"0.6566295",
"0.65064... | 0.0 | -1 |
Load a local profile return the SharedCredentials object or nil | def loadProfile(profile=nil)
# CAUTION: We are returning if profile is nil because otherwise AWS will try to use "Default" profile
return nil if profile.nil?
begin #ruby syntax equivalant to try
# Read the credentials from the given profile
credentials = Aws::SharedCredentials.new(profile_name: profile)
# make sure profile exists before proceeding
rescue Exception => e # ruby syntax equivalant to catch
puts "\e[31mERROR: #{e.message}\e[0m"
exit 1
end
return credentials if credentials.loadable?
puts "\e[31mERROR: Credentials are not loadable. Make sure you have ~/.aws configured correctly.\e[0m"
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(profile='default')\n raise 'Config File does not exist' unless File.exists?(@file)\n\n @credentials = parse if @credentials.nil?\n raise 'The profile is not specified in the config file' unless @credentials.has_key?(profile)\n\n @credentials[profile]\n end",
"def load_profile(cred_... | [
"0.6701693",
"0.66836864",
"0.6428481",
"0.62075835",
"0.61399734",
"0.61399734",
"0.6092536",
"0.6067304",
"0.5955669",
"0.5914697",
"0.58984035",
"0.5882444",
"0.58014727",
"0.5735554",
"0.573396",
"0.5713375",
"0.569041",
"0.5667331",
"0.565998",
"0.56544197",
"0.5646244",... | 0.69604754 | 0 |
helper function to return a new RDS client | def createRDSClient(region,credentials)
begin
return Aws::RDS::Client.new(region: region,credentials: credentials)
rescue Exception => e
puts "\e[31mCould not create new RDS client."
puts "#{e.message}\e[0m"
exit 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dbconnection_instance(schezer)\n schezer.instance_eval do\n return @conn.dup\n end\n end",
"def new_connection(params)\n Pod4.logger.info(__FILE__){ \"Connecting to DB\" }\n client = TinyTds::Client.new(params)\n raise \"Bad Connection\" unless client.active?\n\n ... | [
"0.652982",
"0.64181215",
"0.63795197",
"0.63029474",
"0.6295826",
"0.6175796",
"0.61746156",
"0.6149308",
"0.61289483",
"0.6127377",
"0.6092965",
"0.603337",
"0.6030865",
"0.6028998",
"0.59967816",
"0.59921783",
"0.59913766",
"0.59859556",
"0.59725523",
"0.59002686",
"0.5895... | 0.73701465 | 0 |
helper function to return a new EC2 client | def createEC2Client(region,credentials)
begin
return Aws::EC2::Client.new(region: region,credentials: credentials)
rescue Exception => e
puts "\e[31mCould not create new EC2 client"
puts "#{e.message}\e[0m"
exit 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ec2_client(region)\n begin\n client = Aws::EC2::Client.new(region: region)\n rescue => e\n puts e\n exit\n end\nend",
"def ec2\n @ec2 ||= EC2::Base.new(:access_key_id => \"not a key\", :secret_access_key => \"not a key\")\n end",
"def ec2\n Fog::Compute::AWS.new(aws_access_key_id: @a... | [
"0.7484934",
"0.72039455",
"0.70676994",
"0.7025927",
"0.6948722",
"0.6874134",
"0.6756482",
"0.6730758",
"0.6627768",
"0.64340407",
"0.6351552",
"0.63447094",
"0.6336146",
"0.6331109",
"0.6328699",
"0.6328699",
"0.62763655",
"0.6245043",
"0.6204581",
"0.61604345",
"0.6118997... | 0.76579565 | 0 |
Helper function to create a snapshot of an EBS volume | def createEBSSnapshot(client=nil,description='',volume_id=nil)
return false if volume_id.nil? || client.nil?
# Fetch the Volume Name. This will be used in the description of the snapshot
resp = client.describe_volumes({dry_run: false, volume_ids: [volume_id] })
resp.volumes[0].tags.each do |t|
if t.key=='Name'
description = t.value unless t.value.empty?
break
end
end
# puts "Taking snapshot of volume #{volume_id}..."
return client.create_snapshot({
dry_run: false,
volume_id: volume_id,
description: description
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore_from_snap(last_snapshot, options = {})\n options[:device] = \"/dev/sdk\" unless options[:device]\n options[:vol_nickname] = last_snapshot[\"nickname\"] unless options[:vol_nickname]\n \n # 5 - Unmount and detach the current EBS volume (forcing to detach the device we're gonna need l... | [
"0.74545485",
"0.7209719",
"0.71685785",
"0.7164354",
"0.714413",
"0.712002",
"0.6957206",
"0.695592",
"0.69027597",
"0.6816179",
"0.6758193",
"0.6449254",
"0.6442236",
"0.64248896",
"0.6421977",
"0.6413579",
"0.6410388",
"0.6377427",
"0.63687897",
"0.6337966",
"0.62960404",
... | 0.7775452 | 0 |
Delete a snapshot of an ebs volume Can accept a single snapshot or an array of snapshots to delete. | def deleteEBSSnapshot(client=nil,snapshots_to_delete=[],dry_run=true)
return false if client.nil?
unless snapshots_to_delete.instance_of? Array
snapshots_to_delete = [snapshots_to_delete]
end
snapshots_to_delete.each do |snapshot|
if dry_run
printf "\e[33m\"Delete snapshot #{snapshot}?\" (y/n)? \e[0m"
prompt = STDIN.gets.chomp
next unless prompt == "y"
end
print "Deleting ec2 snapshot #{snapshot}..."
begin
# delete_snapshot API has no response
client.delete_snapshot({
dry_run: dry_run,
snapshot_id: snapshot
})
puts "\e[32msuccess\e[0m"
rescue Exception => e
puts "\e[31mfailed - #{e.message}\e[0m"
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snap_delete(volume,snapshot)\n output = @filer.invoke(\"snapshot-delete\",\"volume\",volume,\"snapshot\",snapshot)\n if (output.results_status() == \"failed\")\n raise \"Error #{output.results_errno} deleting snapshot #{snapshot} on #{volume}: #{output.results_reason()}\\n\"\n end\n end",
"def... | [
"0.83315086",
"0.8071649",
"0.7675575",
"0.7647696",
"0.76228946",
"0.7597437",
"0.747701",
"0.74748755",
"0.7357728",
"0.7287723",
"0.72469103",
"0.7159488",
"0.7154855",
"0.71026874",
"0.7101158",
"0.70001864",
"0.6991289",
"0.6960998",
"0.6926973",
"0.68717057",
"0.6871705... | 0.7583896 | 6 |
helper function to create RDS Snapshots return the response on success, otherwise false. | def createRDSSnapshot(client=nil,db_instance=nil,snapshot_name=nil,tags=[])
return false if db_instance.nil? || client.nil?
if snapshot_name.nil?
snapshot_name="#{db_instance}-#{Time.now.to_i}"
end
unless tags.instance_of? Array
puts "\e[31mtags must be an Array\e[0m"
return false
end
begin
puts "\e[32mTaking snapshot of db instance #{db_instance}. Snapshot will be named #{snapshot_name}\e[0m"
resp = client.create_db_snapshot({
db_snapshot_identifier: snapshot_name,
db_instance_identifier: db_instance,
tags: tags
})
rescue Exception => e
puts "\e[31m#{e.message}\e[0m"
return false
end
return resp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_snapshot(rds_resource, db_instance_name)\n id = \"snapshot-#{rand(10**6)}\"\n db_instance = rds_resource.db_instance(db_instance_name)\n db_instance.create_snapshot({\n db_snapshot_identifier: id\n })\nrescue Aws::Errors::ServiceError => e\n... | [
"0.6959942",
"0.67721385",
"0.65424186",
"0.6512461",
"0.64462155",
"0.64253855",
"0.63869953",
"0.6346291",
"0.63259506",
"0.60574883",
"0.6020189",
"0.6013806",
"0.5990513",
"0.58852404",
"0.5823208",
"0.57886815",
"0.5770304",
"0.57429475",
"0.5702567",
"0.5682292",
"0.560... | 0.7413599 | 0 |
GET /discipline_sections GET /discipline_sections.json | def index
@discipline_sections = DisciplineSection.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n course = Course.find(params[:course_id])\n sections = course.sections.all\n render json: sections.order(:id)\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def get_sections (subdomain,course_id)\n token = get_token\n courses = get_al... | [
"0.6833717",
"0.67551106",
"0.6714686",
"0.6649415",
"0.6637861",
"0.6535805",
"0.6535805",
"0.65237075",
"0.6502826",
"0.64867806",
"0.6430026",
"0.6425808",
"0.6383433",
"0.6356851",
"0.6354435",
"0.6317796",
"0.63121754",
"0.6298093",
"0.62769955",
"0.6209616",
"0.62046283... | 0.7759907 | 0 |
GET /discipline_sections/1 GET /discipline_sections/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @discipline_sections = DisciplineSection.all\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def show\n @discipline = Discipline.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { ... | [
"0.77392906",
"0.704878",
"0.6965042",
"0.69634855",
"0.6935452",
"0.68402404",
"0.6734015",
"0.6661768",
"0.6600624",
"0.6562233",
"0.65423656",
"0.6511122",
"0.6508988",
"0.65064764",
"0.64560604",
"0.64074576",
"0.64074576",
"0.63547015",
"0.63494515",
"0.63456553",
"0.632... | 0.0 | -1 |
POST /discipline_sections POST /discipline_sections.json | def create
@discipline_section = DisciplineSection.new(discipline_section_params)
respond_to do |format|
if @discipline_section.save
#format.html { redirect_to @discipline_section, notice: 'Discipline section was successfully created.' }
#format.json { render :show, status: :created, location: @discipline_section }
format.js { render('discipline_sections/create')}
else
#raise @discipline_section.errors.inspect
#format.html { render :new }
#format.json { render json: @discipline_section.errors, status: :unprocessable_entity }
format.js { render ('discipline_sections/error')}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @discipline_sections = DisciplineSection.all\n end",
"def set_discipline_section\n @discipline_section = DisciplineSection.find(params[:id])\n end",
"def create\n @section = Section.new(params[:section])\n\n Course.find(params[:section][:add_section]).sections << @section if param... | [
"0.6858734",
"0.66750294",
"0.6632172",
"0.6621222",
"0.6584435",
"0.651913",
"0.6359858",
"0.62716115",
"0.62380826",
"0.62144756",
"0.620074",
"0.6187932",
"0.6124004",
"0.6103947",
"0.6091024",
"0.6054053",
"0.60031754",
"0.5955929",
"0.59447634",
"0.5942246",
"0.5941796",... | 0.70951676 | 0 |
PATCH/PUT /discipline_sections/1 PATCH/PUT /discipline_sections/1.json | def update
respond_to do |format|
if @discipline_section.update(discipline_section_params)
format.html { redirect_to @discipline_section, notice: 'Раздел дисциплины был успешно обновлен' }
format.json { render :show, status: :ok, location: @discipline_section }
else
format.html { render :edit }
format.json { render json: @discipline_section.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\nlogger.debug \"update discipline: \"+@discipline.inspect\n discipline_params.each_pair do |property,value|\n @discipline.send(property+'=',value)if @discipline.respond_to?(property+'=')\n end\n @discipline.updater_id = current_user\n if @discipline.save\n s... | [
"0.7019297",
"0.6986113",
"0.68933535",
"0.6844664",
"0.6844664",
"0.67145896",
"0.670726",
"0.65858907",
"0.65282524",
"0.63720644",
"0.63639146",
"0.6342503",
"0.63086236",
"0.6301386",
"0.6289386",
"0.62810093",
"0.6272424",
"0.626786",
"0.62410516",
"0.6239754",
"0.623741... | 0.711616 | 0 |
DELETE /discipline_sections/1 DELETE /discipline_sections/1.json | def destroy
@discipline_section.destroy
respond_to do |format|
#format.html { redirect_to discipline_sections_url, notice: 'Раздел дисциплины был успешно удален' }
#format.json { head :no_content }
format.js { render ('discipline_sections/delete')}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @discipline = Discipline.find(params[:id])\n @discipline.destroy\n\n respond_to do |format|\n format.html { redirect_to disciplines_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @discipline.destroy\n respond_to do |format|\n format.html { redirect_t... | [
"0.7371484",
"0.7189136",
"0.71649116",
"0.70629275",
"0.7014427",
"0.7007249",
"0.7002153",
"0.69809365",
"0.69650245",
"0.67637247",
"0.67394334",
"0.67394334",
"0.6717208",
"0.6717208",
"0.6706647",
"0.6678262",
"0.66756576",
"0.6648608",
"0.6625008",
"0.6620597",
"0.66081... | 0.71084684 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_discipline_section
@discipline_section = DisciplineSection.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def discipline_section_params
params.require(:discipline_section).permit(:discipline_type, :section_name, :section_type, :weight, :min_score, :max_score, :require_type, :attenuation_constant, :optimal_time, :limit_time, :discipline_id, :community_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 |
Parse the name into its component parts | def parse
split_name
Governator::Name.new(original, first, middle, nickname, last, suffix)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_components\n @_name_components ||= name.scan(/[[:alnum:]]+/)\n end",
"def parse_name(name)\n words = name.path_to_name.strip.split(/\\s+/)\n first = words.shift\n { first: first, last: words.join('-') }\n end",
"def parts\n name.split(\" \")\n end",
"def parse_name(name)\n ... | [
"0.74915344",
"0.73031646",
"0.72734565",
"0.7090266",
"0.6967317",
"0.67970014",
"0.6673841",
"0.65575314",
"0.6501499",
"0.64541054",
"0.643271",
"0.63899785",
"0.63636893",
"0.62957394",
"0.62590694",
"0.62526435",
"0.6192063",
"0.61659515",
"0.6164098",
"0.6126027",
"0.61... | 0.61358863 | 19 |
Returns a bean from the +RequestStore+ RequestStore is a wrapper for Thread.current which clears it on each new HTTP request | def get_bean(bean_metadata)
RequestStore.store[:_iocrb_beans] ||= {}
if bean = RequestStore.store[:_iocrb_beans][bean_metadata.name]
bean
else
@bean_factory.create_bean_and_save(bean_metadata, RequestStore.store[:_iocrb_beans])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_store_id\n Thread.current[REQUEST_STORE_ID]\n end",
"def store\n @store ||= Store.new\n end",
"def request\n @request ||= Request.find request_id\n end",
"def request; return @request end",
"def store\r\n return @store\r\n end",
"def fetch_store\n @store ||= self.... | [
"0.60839844",
"0.58515716",
"0.5803903",
"0.57329524",
"0.5674762",
"0.56621367",
"0.5658496",
"0.56380916",
"0.5631599",
"0.5599377",
"0.5575453",
"0.5530602",
"0.5525201",
"0.5510733",
"0.54759634",
"0.54513603",
"0.54027766",
"0.5393321",
"0.53845966",
"0.53569484",
"0.534... | 0.5112336 | 30 |
Delete bean from scope | def delete_bean(bean_metadata)
RequestStore.store[:_iocrb_beans].delete(bean_metadata.name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_bean(bean_metadata)\n @beans.delete(bean_metadata.name)\n end",
"def delete(connection)\n connection.delete_engine(@id, @scope)\n end",
"def destroy; delete end",
"def del\n delete\n end",
"def _destroy_delete\n delete\n end",
"def _destroy_delete\n delet... | [
"0.6948997",
"0.61377937",
"0.60326993",
"0.60160136",
"0.60052586",
"0.60052586",
"0.5998532",
"0.59936553",
"0.5950794",
"0.58859587",
"0.5831397",
"0.58312243",
"0.58312243",
"0.58285487",
"0.5824112",
"0.58174294",
"0.58138067",
"0.5801735",
"0.5779715",
"0.5778879",
"0.5... | 0.7090844 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_trade_charge
@trade_charge = TradeCharge.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 trade_charge_params
params.require(:trade_charge).permit(:kind_class, :subtype, :premium, :runt, :revenue)
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 |
Method to find and return both the mean and the standard deviation | def mean_sigma(v)
mean = mean(v);
diff = [];
mean_delta = 0.0;
i=0;
v.each{|n|; mean_delta = (n-mean).abs; diff[i] = mean_delta; i += 1;}
std_dev = mean(diff);
return mean, std_dev;
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stddev()\n if mean == -1\n mean()\n end\n\n sum = 0\n @difference.each do |item|\n sum += (item - @mean) ** 2\n end\n\n stddev = (sum / difference.length) ** 0.5\n\n return stddev\n end",
"def calc_stdev(data)\n # Calculate the mean\n sum = 0\n count = data.length\n data.e... | [
"0.84271824",
"0.80154055",
"0.79858017",
"0.79836136",
"0.79429185",
"0.7905637",
"0.78093594",
"0.7772725",
"0.7747277",
"0.7726669",
"0.7688306",
"0.76777",
"0.7676736",
"0.76734895",
"0.7656445",
"0.76515436",
"0.76474184",
"0.7592434",
"0.75923306",
"0.75923306",
"0.7587... | 0.71512836 | 65 |
Use callbacks to share common setup or constraints between actions. | def set_address
@address = Address.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
GET /evaluations GET /evaluations.json | def index
session[:evaluation_id] = nil
if current_user.has_role? :admin
@evaluations = Evaluation.all
else
@lesson = Lesson.find(session[:lesson_id]) if session[:lesson_id]
@evaluations = Evaluation.where(user_id: current_user.id).order(updated_at: :desc)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend",
"def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.j... | [
"0.7649412",
"0.7279398",
"0.72450113",
"0.7144004",
"0.7141227",
"0.70988876",
"0.7048806",
"0.702481",
"0.702481",
"0.702481",
"0.702481",
"0.702481",
"0.6986356",
"0.68509716",
"0.679744",
"0.67658156",
"0.67023426",
"0.66693366",
"0.6639267",
"0.6623286",
"0.6612441",
"... | 0.5836772 | 57 |
GET /evaluations/1 GET /evaluations/1.json | def show
session[:evaluation_id] = @evaluation.id
@justices = Justice.where(evaluation_id: @evaluation.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend",
"def show\n @evaluations = Evaluation.find(params[:id])\n end",
"def evaluations(id)\n connection.get do |req|\n req.url \"job... | [
"0.77651966",
"0.6981567",
"0.69376636",
"0.68618554",
"0.68131685",
"0.673956",
"0.6719614",
"0.66970426",
"0.6682116",
"0.6674504",
"0.6674504",
"0.6674504",
"0.6674504",
"0.6674504",
"0.6662183",
"0.6624913",
"0.6612468",
"0.6604192",
"0.6585361",
"0.6463337",
"0.6439866",... | 0.0 | -1 |
POST /evaluations POST /evaluations.json | def create
if current_user.has_role? :admin
@evaluation = Evaluation.new(evaluation_params)
else
@practice = Practice.find(session[:practice_id])
@evaluation = Evaluation.new(evaluation_params)
@evaluation.lesson_id = session[:lesson_id]
@evaluation.user_id = current_user.id
@evaluation.practice_id = @practice.id
@evaluation.title = @practice.title
@evaluation.material = @practice.material
@evaluation.question = @practice.question
@evaluation.answer = @practice.answer
@evaluation.practice_score ||= @practice.score
if session[:papertest_id]
@papertest = Papertest.find(session[:papertest_id])
if Time.now < @papertest.end_at
@evaluation.end_at = @papertest.end_at
@evaluation.papertest_id = @papertest.id
else
session[:papertest_id] = nil
redirect_to paper_url(@papertest.paper_id), notice: "考试已结束!"
return
end
end
end
respond_to do |format|
if @evaluation.save
if @practice.answer.gsub(/(<(\w|\/)+[^>]*>|\s)/, "") == @evaluation.your_answer.gsub(/(<(\w|\/)+[^>]*>|\s)/, "") # 如果答对了
@justice = Justice.create!(
user_id: 1,
evaluation_user_id: @evaluation.user_id,
practice_id: @evaluation.practice_id,
evaluation_id: @evaluation.id,
score: @evaluation.practice_score, # 得到满分
p_score: @evaluation.practice_score,
remark: "完全正确!",
)
@evaluation.update(score: @evaluation.practice_score)
end
format.html { redirect_to @evaluation, notice: '答案提交成功' }
format.json { render :show, status: :created, location: @evaluation }
else
format.html { render :new }
format.json { render json: @evaluation.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n ... | [
"0.7273974",
"0.70637333",
"0.69349927",
"0.6858234",
"0.6858234",
"0.6789653",
"0.67693055",
"0.6732888",
"0.6721708",
"0.66040987",
"0.6552739",
"0.6520129",
"0.64986",
"0.6492909",
"0.64158195",
"0.6408603",
"0.63761246",
"0.6324832",
"0.63137615",
"0.63137615",
"0.6295575... | 0.56916785 | 86 |
PATCH/PUT /evaluations/1 PATCH/PUT /evaluations/1.json | def update
respond_to do |format|
if @evaluation.update(evaluation_params)
@practice = Practice.find(@evaluation.practice_id)
if @practice.answer == @evaluation.your_answer
@justice = Justice.create!(
user_id: 1,
evaluation_user_id: @evaluation.user_id,
practice_id: @evaluation.practice_id,
evaluation_id: @evaluation.id,
score: @evaluation.practice_score, # 得到满分
p_score: @evaluation.practice_score,
remark: "完全正确!",
)
@evaluation.update(score: @evaluation.practice_score)
end
format.html { redirect_to @evaluation, notice: "答案更新成功" }
format.json { render :show, status: :ok, location: @evaluation }
else
format.html { render :edit }
format.json { render json: @evaluation.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render ... | [
"0.6757492",
"0.6757492",
"0.6750937",
"0.66880345",
"0.65852636",
"0.65578616",
"0.6551743",
"0.6551743",
"0.6551743",
"0.6516151",
"0.6515917",
"0.6453893",
"0.6448572",
"0.6440103",
"0.64335555",
"0.6425717",
"0.6365227",
"0.6329448",
"0.6310252",
"0.62973964",
"0.6282295"... | 0.0 | -1 |
DELETE /evaluations/1 DELETE /evaluations/1.json | def destroy
@evaluation.destroy
respond_to do |format|
format.html { redirect_to evaluations_url, notice: '答题记录已被删除' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { h... | [
"0.7423415",
"0.7423415",
"0.742291",
"0.74181527",
"0.71981627",
"0.7197589",
"0.7195351",
"0.7195351",
"0.7195351",
"0.7195351",
"0.7195351",
"0.7195351",
"0.71747017",
"0.71078193",
"0.70771676",
"0.70721006",
"0.70721006",
"0.70574003",
"0.70446515",
"0.70344424",
"0.7000... | 0.6711852 | 39 |
Use callbacks to share common setup or constraints between actions. | def set_evaluation
@evaluation = Evaluation.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 evaluation_params
params.require(:evaluation).permit(:user_id, :lesson_id, :practice_id, :title, :material, :question, :answer, :your_answer, :score, :practice_score, :picture_ya, :end_at, :papertest)
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 |
Fetch our toplevel settings, which apply to all endpoints in the API. | def top_level_setting
@top_level_setting ||= build_top_level_setting
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end",
"def get_settings\n request :get, \"_settings\"\n end",
"def get_settings\n request :get, \"_settings\"\n ... | [
"0.71056044",
"0.7087893",
"0.7087893",
"0.7039612",
"0.67418766",
"0.67215997",
"0.666675",
"0.6639393",
"0.6449629",
"0.6420636",
"0.6358111",
"0.6343898",
"0.6293532",
"0.6276921",
"0.62553173",
"0.6214821",
"0.6155574",
"0.6150323",
"0.6084203",
"0.60667557",
"0.6047745",... | 0.637231 | 10 |
Fetch our current inheritable settings, which are inherited by nested scopes but not shared across siblings. | def inheritable_setting
@inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inheritable_settings\n return @inheritable_settings\n end",
"def settings\n @scope.settings\n end",
"def inheritable_settings=(value)\n @inheritable_settings = value\n end",
"def compute_effective_settings\n execution_context.inject({})... | [
"0.8205748",
"0.67785126",
"0.6500825",
"0.64961547",
"0.6437371",
"0.6434576",
"0.64129734",
"0.63033265",
"0.61839736",
"0.6166299",
"0.6158082",
"0.6036863",
"0.5952977",
"0.590812",
"0.58808297",
"0.58739185",
"0.58702785",
"0.58688277",
"0.5860874",
"0.58515215",
"0.5849... | 0.7279893 | 1 |
Fork our inheritable settings to a new instance, copied from our parent's, but separate so we won't modify it. Every call to this method should have an answering call to namespace_end. | def namespace_start
@inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_copy( original )\n\t\t@settings = original.settings.dup\n\t\t@overridden_settings = {}\n\tend",
"def update_descendant_settings\n return if changed_setting_attributes.nil? && settings_inheritance == :none\n\n case settings_inheritance\n when :merge\n merge_descendant_settings\n wh... | [
"0.6501519",
"0.611109",
"0.60726625",
"0.5822752",
"0.5822752",
"0.57910305",
"0.57194155",
"0.5694648",
"0.563503",
"0.56314284",
"0.56116605",
"0.5607835",
"0.55847454",
"0.55847454",
"0.5568596",
"0.5560046",
"0.55238324",
"0.5497667",
"0.547759",
"0.5459084",
"0.5447626"... | 0.7305435 | 0 |
Set the inheritable settings pointer back up by one level. | def namespace_end
route_end
@inheritable_setting = inheritable_setting.parent
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inheritable_settings=(value)\n @inheritable_settings = value\n end",
"def namespace_start\n @inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting }\n end",
"def inheritable_setting\n @inheri... | [
"0.68554926",
"0.65363944",
"0.64698386",
"0.63258374",
"0.6272368",
"0.62422377",
"0.5891196",
"0.5800336",
"0.5769383",
"0.5769383",
"0.5766804",
"0.5653603",
"0.55423373",
"0.53751326",
"0.53751326",
"0.53751326",
"0.53751326",
"0.53751326",
"0.5360351",
"0.5326902",
"0.53... | 0.0 | -1 |
Stop defining settings for the current route and clear them for the next, within a namespace. | def route_end
inheritable_setting.route_end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset!\n ATTRIBUTES.each {|attr| send(\"#{attr.to_s}=\", nil)}\n routes.clear\n end",
"def reset\n @routes.clear\n end",
"def reset!\n @root = Root.new(self)\n @request_methods_specified = Set.new\n @routes = []\n @named_routes = {}\n @variable_names = Set.new\n end",
... | [
"0.73625636",
"0.68651235",
"0.63947785",
"0.6388679",
"0.6387845",
"0.63765323",
"0.6315466",
"0.6292918",
"0.62262845",
"0.6219216",
"0.6209891",
"0.6151193",
"0.6113523",
"0.6109841",
"0.6081563",
"0.6061381",
"0.6055719",
"0.6049361",
"0.60243446",
"0.6005195",
"0.6001929... | 0.0 | -1 |
Execute the block within a context where our inheritable settings are forked to a new copy (see namespace_start). | def within_namespace(&block)
namespace_start
result = yield if block
namespace_end
reset_validations!
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespace_start\n @inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting }\n end",
"def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend",
"def call\n\t\tself.apply_overrides\n... | [
"0.6312879",
"0.62218815",
"0.62218815",
"0.59767395",
"0.586216",
"0.5690287",
"0.5593462",
"0.55868745",
"0.5499361",
"0.5481921",
"0.54791725",
"0.54714525",
"0.5461349",
"0.5431632",
"0.54289937",
"0.54289937",
"0.5412068",
"0.54108393",
"0.5407315",
"0.53949064",
"0.5372... | 0.0 | -1 |
Builds the current class :inheritable_setting. If available, it inherits from the superclass's :inheritable_setting. | def build_top_level_setting
Grape::Util::InheritableSetting.new.tap do |setting|
# Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to
# +inheritable_setting+, however, it doesn't contain any user-defined settings.
# Otherwise, it would lead to an extra instance of +Grape::Util::InheritableSetting+
# in the chain for every endpoint.
setting.inherit_from superclass.inheritable_setting if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API::Instance
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inheritable_setting\n @inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting }\n end",
"def inheritable_settings\n return @inheritable_settings\n end",
"def inheritable_settings=(value)\n ... | [
"0.7957203",
"0.7130535",
"0.6866926",
"0.62060326",
"0.60595685",
"0.5905518",
"0.57345766",
"0.56353176",
"0.562738",
"0.55533844",
"0.554984",
"0.5530771",
"0.5474511",
"0.5354502",
"0.5298053",
"0.519122",
"0.51908803",
"0.5186303",
"0.5158098",
"0.5152635",
"0.5135044",
... | 0.7307081 | 1 |
Generates the RBS lines for this method. | def generate_rbs(indent_level, options)
definition = "def #{class_method ? 'self.' : ''}#{name}: "
lines = generate_comments(indent_level, options)
# Handle each signature
signatures.each.with_index do |sig, i|
this_sig_lines = []
# Start off the first line of the signature, either with the definition
# for the first signature, or a pipe for the rest
if i == 0
this_sig_lines << options.indented(indent_level, definition)
else
this_sig_lines << options.indented(indent_level, "#{' ' * (definition.length - 2)}| ")
end
# Generate the signature's lines, we'll append them afterwards
partial_sig_lines = sig.generate_rbs(options)
# Merge the first signature line, and indent & concat the rest
first_line, *rest_lines = *partial_sig_lines
this_sig_lines[0] = T.unsafe(this_sig_lines[0]) + first_line
rest_lines&.each do |line|
this_sig_lines << ' ' * definition.length + options.indented(indent_level, line)
end
# Add on all this signature's lines to the complete lines
lines += this_sig_lines
end
lines
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ruling_lines\n get_ruling_lines!\n end",
"def get_ruling_lines!\n self.get_rulings\n end",
"def generate\n end",
"def generate; end",
"def generate; end",
"def generate()\n\t\t\t@out = []\n\t\t\t@context = []\n\n\t\t\ttrim_nil_lines\n\n\t\t\t@lines.each_with_index do |line, i|\n\t\t\t\... | [
"0.6484955",
"0.64685106",
"0.58297396",
"0.57131875",
"0.57131875",
"0.5706199",
"0.55833036",
"0.55117637",
"0.5476175",
"0.54385424",
"0.5436468",
"0.5436468",
"0.5375646",
"0.5360394",
"0.53524673",
"0.5348188",
"0.53149784",
"0.53030133",
"0.5284046",
"0.52635384",
"0.52... | 0.65714455 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_page
@page = @current_site.pages.find(params[:id])
@program = @page.program
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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def page_params
params.require(:page).permit(:slug, :title, :content)
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 |
This function has bee deprecated in favour of the separate profile? data? and drill? functions | def type
raise AMEE::Deprecated
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profiles; end",
"def profile; end",
"def profile; end",
"def profile\n end",
"def profile\n end",
"def profile\n end",
"def profile\n end",
"def profile\n end",
"def profile\n end",
"def profile\n \n end",
"def profile\n\n end",
"def profiles__potential_values(options = {})\r\n... | [
"0.637077",
"0.6257748",
"0.6257748",
"0.5986313",
"0.5986313",
"0.5986313",
"0.5986313",
"0.5986313",
"0.5986313",
"0.5930492",
"0.58486456",
"0.5842035",
"0.5842035",
"0.5834898",
"0.5795784",
"0.57316446",
"0.5707439",
"0.5523409",
"0.54929745",
"0.54835665",
"0.5441558",
... | 0.0 | -1 |
Version Modules ECC Level Data bits Numeric Alfanumeric Binary Kanji 1 21x21 L 152 41 25 17 10 M 128 34 20 14 8 Q 104 27 16 11 7 H 72 17 10 7 4 ... 40 177x177 L 23,648 7,089 4,296 2,953 1,817 M 18,672 5,596 3,391 2,331 1,435 Q 13,328 3,993 2,420 1,663 1,024 H 10,208 3,057 1,852 1,273 784 | def module_size
@version * 4 + 17
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version\na = unpack\nv = (a[2] & 0xF000).to_s(16)[0].chr.to_i\nreturn v if (1..5).include? v\nreturn nil\nend",
"def level_for(binary_code)\n binary_code_length = binary_code.to_s(2).length\n binary_code_length += 1 unless binary_code_length.even?\n binary_code_length / 2\n end",
"def sbc_a_hl\n ... | [
"0.5999004",
"0.55733955",
"0.55686146",
"0.5457292",
"0.54318637",
"0.5359448",
"0.5351872",
"0.5323534",
"0.5295974",
"0.52820617",
"0.52570695",
"0.52523667",
"0.52517265",
"0.52517265",
"0.52517265",
"0.52517265",
"0.52517265",
"0.5245727",
"0.5234033",
"0.52077717",
"0.5... | 0.4748205 | 83 |
This object's stroke alpha value | def stroke_alpha
dsl&.stroke&.alpha
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stroke_alpha\n dsl.stroke.alpha if dsl.stroke\n end",
"def alpha\n (rgba & 0x7F000000) >> 24\n end",
"def alpha(val=1.0)\n CGContextSetAlpha(@ctx, val)\n end",
"def alpha(value=nil)\n if !value.nil?\n value = value.alpha if value.is_a?(Sketchup::Color)\n r, g,... | [
"0.84100735",
"0.69870126",
"0.69254094",
"0.6897213",
"0.6622687",
"0.661469",
"0.64578193",
"0.64360726",
"0.63820887",
"0.633589",
"0.6205916",
"0.62009454",
"0.6080869",
"0.6026569",
"0.60219085",
"0.6017503",
"0.5967396",
"0.59634334",
"0.59552765",
"0.59451765",
"0.5942... | 0.8266243 | 1 |
Just clear it out and let next paint recreate and save our SWT color | def update_stroke
@cached_swt_stroke = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalidate_color_components\n @color_components = nil\n end",
"def invalidate_color_components\n @color_components = nil\n end",
"def reset!\n @color = @@colors[:white]\n end",
"def clear\n @bitmap = solid_canvas(DEFAULT_COLOR)\n end",
"def color_reset!(fill)\n save = backg... | [
"0.6805248",
"0.6805248",
"0.66695136",
"0.6562173",
"0.65481436",
"0.6455313",
"0.644509",
"0.6401377",
"0.6291436",
"0.62480426",
"0.6159281",
"0.6133729",
"0.6079227",
"0.6040476",
"0.60047877",
"0.5997728",
"0.59894615",
"0.5982495",
"0.5982495",
"0.5972957",
"0.59623754"... | 0.6655167 | 3 |
GET /question_option_selections GET /question_option_selections.json | def index
@question_option_selections = @question_answer.question_option_selections
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @selections = Selection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @selections }\n end\n end",
"def get_choices\n @choices = CONNECTION.execute(\"SELECT * FROM choices WHERE question_id = #{@id};\")\n end",
"def index\n @opt... | [
"0.66065097",
"0.6558567",
"0.65470684",
"0.64444864",
"0.6403623",
"0.63972723",
"0.6378797",
"0.63696617",
"0.634588",
"0.63029164",
"0.62848073",
"0.6263732",
"0.62483597",
"0.6207424",
"0.6025557",
"0.602436",
"0.60094285",
"0.5992142",
"0.5974422",
"0.59623593",
"0.59602... | 0.769497 | 0 |
GET /question_option_selections/1 GET /question_option_selections/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @question_option_selections = @question_answer.question_option_selections\n end",
"def show\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questions_option }\n end\n end",
"def se... | [
"0.7469291",
"0.666653",
"0.6534739",
"0.6514095",
"0.6494142",
"0.64826936",
"0.6421232",
"0.63739496",
"0.6372789",
"0.6346742",
"0.634618",
"0.6244067",
"0.61738575",
"0.61560106",
"0.6140834",
"0.6109289",
"0.60785156",
"0.60743695",
"0.60537857",
"0.6049564",
"0.60258484... | 0.0 | -1 |
POST /question_option_selections POST /question_option_selections.json | def create
@question_option_selection = @question_answer.question_option_selection.build(question_option_selection_params)
respond_to do |format|
if @question_option_selection.save
format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully created.' }
format.json { render :show, status: :created, location: @question_option_selection }
else
format.html { render :new }
format.json { render json: @question_option_selection.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @question_option_selections = @question_answer.question_option_selections\n end",
"def question_option_selection_params\n params.require(:question_option_selection).permit(:question_answer_id, :question_option_id)\n end",
"def add_option\n render json: Option.create_default_optio... | [
"0.67875326",
"0.6616982",
"0.65738964",
"0.6385959",
"0.63539124",
"0.6280465",
"0.61634994",
"0.6126046",
"0.61236984",
"0.6051213",
"0.60421056",
"0.6003916",
"0.59900224",
"0.5978536",
"0.5971318",
"0.59675455",
"0.59316427",
"0.5918343",
"0.59085405",
"0.5874556",
"0.586... | 0.6865646 | 0 |
PATCH/PUT /question_option_selections/1 PATCH/PUT /question_option_selections/1.json | def update
respond_to do |format|
if @question_option_selection.update(question_option_selection_params)
format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully updated.' }
format.json { render :show, status: :ok, location: @question_option_selection }
else
format.html { render :edit }
format.json { render json: @question_option_selection.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_correct_answer\n question_params = params.permit(:question_id, :question_type_id, :option_id)\n \n render json: Question.update_correct_option(question_params)\n end",
"def update\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n if... | [
"0.72698116",
"0.70224434",
"0.6931022",
"0.6925986",
"0.67867243",
"0.6774947",
"0.67558545",
"0.6726432",
"0.67178553",
"0.65660477",
"0.6469441",
"0.6468809",
"0.64565307",
"0.6449378",
"0.6439106",
"0.6426784",
"0.6392963",
"0.6388309",
"0.6382278",
"0.63695186",
"0.63202... | 0.70291024 | 1 |
DELETE /question_option_selections/1 DELETE /question_option_selections/1.json | def destroy
@question_option_selection.destroy
respond_to do |format|
format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @questions_option = QuestionsOption.find(params[:id])\n @questions_option.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_options_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_option = QuestionOption.find(params[:i... | [
"0.73644316",
"0.7339735",
"0.71845007",
"0.71193135",
"0.7078158",
"0.7072167",
"0.7020615",
"0.69713396",
"0.69449323",
"0.69287807",
"0.6923465",
"0.68403196",
"0.68374455",
"0.6823327",
"0.6809441",
"0.6798366",
"0.6747096",
"0.6739421",
"0.6727583",
"0.6703137",
"0.66992... | 0.7287374 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_question_option_selection
@question_option_selection = QuestionAnswer.question_option_selections.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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.