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 |
|---|---|---|---|---|---|---|
Running Totals exercise Small Problems exercises from LaunchSchool | def running_total(arr)
sum = 0
arr.map do |n|
sum += n
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem_six\n (1.upto(100).reduce(:+)) ** 2 - (1.upto(100).map { |n| n ** 2 }).reduce { |sum, n| sum + n }\n end",
"def total\n count = 0\n self.total_time_exercise_workouts.each do |ex|\n count += ex.duration\n end\n count\n end",
"def cupcake_solver(cupcake_counts, number_of_s... | [
"0.6290539",
"0.62784636",
"0.6101511",
"0.60707974",
"0.6009038",
"0.5996178",
"0.5981915",
"0.5974999",
"0.5909027",
"0.5888089",
"0.57509065",
"0.57407546",
"0.5734557",
"0.5728926",
"0.5708297",
"0.5687988",
"0.5655382",
"0.5652746",
"0.56473696",
"0.5620232",
"0.5604142"... | 0.0 | -1 |
Gets a Blob at a path for a specific revision. This method will check that the Blob exists and contains readable text. revision The String SHA1. path The String file path. Returns a Blob | def read_blob(ref, filename)
blob = repository&.blob_at(ref, filename)
raise 'Blob not found' unless blob
raise 'File is not readable' unless blob.readable_text?
blob
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blob(id, commit_sha=nil, path=nil)\n blob = self.lookup(id); blob_entry={}\n if commit_sha && path\n commit = self.lookup(commit_sha)\n unless commit\n root_tree = commit.tree\n blob_entry = Gitlab::Git::Blob.find_entry_by_path(self, root_tree.oid, path)\n ... | [
"0.64253104",
"0.6189137",
"0.6151744",
"0.60514784",
"0.5978542",
"0.5820494",
"0.5800391",
"0.5717419",
"0.56746423",
"0.56132966",
"0.5612641",
"0.5598876",
"0.55854297",
"0.554598",
"0.55346954",
"0.55052537",
"0.55003595",
"0.54978174",
"0.5492217",
"0.5423687",
"0.53947... | 0.5585678 | 12 |
Resolves the given relative path of file in repository into canonical path based on the specified base_path. Examples: File in the same directory as the current path resolve_relative_path("users.adoc", "doc/api/README.adoc") => "doc/api/users.adoc" File in the same directory, which is also the current path resolve_relative_path("users.adoc", "doc/api") => "doc/api/users.adoc" Going up one level to a different directory resolve_relative_path("../update/7.14to8.0.adoc", "doc/api/README.adoc") => "doc/update/7.14to8.0.adoc" Returns a String | def resolve_relative_path(path, base_path)
p = Pathname(base_path)
p = p.dirname unless p.extname.empty?
p += path
p.cleanpath.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolvePath(possiblyRelativePath, rootDir)\n\t\tpath = Pathname.new(possiblyRelativePath)\n\t\tif(path.absolute?()) then\n\t\t\treturn path.to_s()\n\t\telse\n\t\t\trootPath = Pathname.new(rootDir)\n\t\t\treturn rootPath.join(path)\n\t\tend\n\tend",
"def getFullPath(relativePath)\n return baseDir + relat... | [
"0.67939013",
"0.66590774",
"0.65517515",
"0.6457611",
"0.63275474",
"0.6311323",
"0.6311323",
"0.6248949",
"0.62245446",
"0.62243205",
"0.62130475",
"0.617739",
"0.61402327",
"0.60703576",
"0.60664487",
"0.60357606",
"0.6007003",
"0.5976108",
"0.5955329",
"0.59388083",
"0.59... | 0.78591824 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_item
@inventory = collection.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Called from setup block. Can be overridden to customize behaviour. | def define_one_to_many_association(klass, attributes)
belongs_to_id = :"#{belongs_to}_id"
belongs_to_type = :"#{belongs_to}_type"
# Track all attributes for this association, so that we can limit the scope
# of keys for the association to only these attributes. We need to track the
# attributes assigned to the association in case this setup code is called
# multiple times, so we don't "forget" earlier attributes.
#
attrs_method_name = :"#{association_name}_attributes"
association_attributes = (klass.instance_variable_get(:"@#{attrs_method_name}") || []) + attributes
klass.instance_variable_set(:"@#{attrs_method_name}", association_attributes)
klass.one_to_many association_name,
reciprocal: belongs_to,
key: belongs_to_id,
reciprocal_type: :one_to_many,
conditions: { belongs_to_type => klass.to_s, key_column => association_attributes },
adder: proc { |translation| translation.update(belongs_to_id => pk, belongs_to_type => self.class.to_s) },
remover: proc { |translation| translation.update(belongs_to_id => nil, belongs_to_type => nil) },
clearer: proc { send_(:"#{association_name}_dataset").update(belongs_to_id => nil, belongs_to_type => nil) },
class: class_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\n # override this if needed\n end",
"def setup\n yield self\n self\n end",
"def post_setup\n end",
"def setup\n yield self\n end",
"def setup\n yield self\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t... | [
"0.8152407",
"0.7820052",
"0.7755252",
"0.7691046",
"0.7691046",
"0.7658678",
"0.7658678",
"0.76574504",
"0.7641826",
"0.76380664",
"0.76375043",
"0.7626126",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.7479922",
"0.7444528",
"0.7435... | 0.0 | -1 |
Called from setup block. Can be overridden to customize behaviour. | def define_save_callbacks(klass, attributes)
b = self
callback_methods = Module.new do
define_method :before_save do
super()
send(b.association_name).select { |t| attributes.include?(t.__send__(b.key_column)) && Util.blank?(t.__send__(b.value_column)) }.each(&:destroy)
end
define_method :after_save do
super()
attributes.each { |attribute| mobility_backends[attribute].save_translations }
end
end
klass.include callback_methods
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\n # override this if needed\n end",
"def setup\n yield self\n self\n end",
"def post_setup\n end",
"def setup\n yield self\n end",
"def setup\n yield self\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t... | [
"0.8152407",
"0.7820052",
"0.7755252",
"0.7691046",
"0.7691046",
"0.7658678",
"0.7658678",
"0.76574504",
"0.7641826",
"0.76380664",
"0.76375043",
"0.7626126",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.7479922",
"0.7444528",
"0.7435... | 0.0 | -1 |
Called from setup block. Can be overridden to customize behaviour. | def define_after_destroy_callback(klass)
# Clean up *all* leftover translations of this model, only once.
b = self
translation_classes = [class_name, *Mobility::Backends::Sequel::KeyValue::Translation.descendants].uniq
klass.define_method :after_destroy do
super()
@mobility_after_destroy_translation_classes = [] unless defined?(@mobility_after_destroy_translation_classes)
(translation_classes - @mobility_after_destroy_translation_classes).each do |translation_class|
translation_class.where(:"#{b.belongs_to}_id" => id, :"#{b.belongs_to}_type" => self.class.name).destroy
end
@mobility_after_destroy_translation_classes += translation_classes
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\n # override this if needed\n end",
"def setup\n yield self\n self\n end",
"def post_setup\n end",
"def setup\n yield self\n end",
"def setup\n yield self\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t... | [
"0.8152407",
"0.7820052",
"0.7755252",
"0.7691046",
"0.7691046",
"0.7658678",
"0.7658678",
"0.76574504",
"0.7641826",
"0.76380664",
"0.76375043",
"0.7626126",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.75058967",
"0.7479922",
"0.7444528",
"0.7435... | 0.0 | -1 |
Returns translation for a given locale, or initializes one if none is present. | def translation_for(locale, **)
translation = model.send(association_name).find { |t| t.__send__(key_column) == attribute && t.locale == locale.to_s }
translation ||= class_name.new(locale: locale, key_column => attribute)
translation
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translation_for(locale, **)\n translation = translations.in_locale(locale)\n translation ||= translations.build(locale: locale)\n translation\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def get(locale = ... | [
"0.7780166",
"0.727604",
"0.7247916",
"0.72272277",
"0.7226953",
"0.6931552",
"0.6842021",
"0.683636",
"0.6807036",
"0.6772945",
"0.6765306",
"0.67650527",
"0.67630595",
"0.675863",
"0.6719674",
"0.67099804",
"0.6677008",
"0.6658764",
"0.6655869",
"0.66468155",
"0.662237",
... | 0.6766814 | 10 |
Saves translation which have been built and which have nonblank values. | def save_translations
cache.each_value do |translation|
next unless present?(translation.__send__ value_column)
translation.id ? translation.save : model.send("add_#{singularize(association_name)}", translation)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save!\n FileUtils.mkdir_p File.dirname(self.file)\n\n File.open(self.file, \"w+\") do |f|\n f << %(#{self.namespace}.translations || (#{self.namespace}.translations = {});\\n)\n self.translations.each do |locale, translations_for_locale|\n f << %(#{self.namespace}.tra... | [
"0.6678037",
"0.66374016",
"0.65838206",
"0.63941294",
"0.6159064",
"0.6127903",
"0.5987292",
"0.58886397",
"0.5859988",
"0.5749931",
"0.5739476",
"0.57113284",
"0.56413764",
"0.55731034",
"0.5547592",
"0.55446863",
"0.5525683",
"0.54671293",
"0.53629845",
"0.5337515",
"0.533... | 0.6576093 | 3 |
Strictly these are not "descendants", but to keep terminology consistent with ActiveRecord KeyValue backend. | def descendants
@descendants ||= Set.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def child_keys() []; end",
"def keys_visible_to_children\n keys - nonheritable_keys.to_a\n end",
"def descendants\n @hash.select { |attr, value| value == :undefined }.map do |attr, value|\n attributes[attr].map do |value|\n self.class.new(@hash.merge({ attr => value }))\n... | [
"0.68670523",
"0.6032264",
"0.59837484",
"0.5922664",
"0.5858872",
"0.5787854",
"0.57714003",
"0.5755171",
"0.5750787",
"0.5734562",
"0.5703299",
"0.56742525",
"0.56597453",
"0.5655811",
"0.5655781",
"0.5638693",
"0.56327105",
"0.5613099",
"0.5578368",
"0.556059",
"0.5519804"... | 0.56262094 | 17 |
get an immediate quote | def quote(sym)
throw new DatafeedException("Must be implemented by the vendor class.")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quote\n %q[(?:\"|')?]\n end",
"def quote(value); end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def... | [
"0.73918986",
"0.72340447",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
"0.7169205",
... | 0.0 | -1 |
register to listen for given list of symbols syms is either a single symbol or an array of symbols to listen for. The block of code gets called with (symbol, ostruct), and the ostruct object will contain the particulars. This method returns the block passed in, so it can be used to unregister later. | def registerQuotes(syms, &block)
raise DatafeedException("Block Needed for updates!") if block.nil?
syms = [syms] unless syms.kind_of? Array
syms.each { |sym|
register(:quote, sym.to_sym, &block)
}
puts "\nregistered #{syms.join(' ')} to callback #{block}"
@block_hash[block.hash] = block
block.hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listen(symbol, &block)\n @listeners << [symbol, block]\n end",
"def each_registered_block(type, &block); end",
"def each() @symbols.each {|s| yield s if block_given? } end",
"def register_block_for(type, &blk); end",
"def register_subscriber(protocol, block)\n @subscribers[protocol] ||... | [
"0.5968555",
"0.59312075",
"0.57577866",
"0.57144195",
"0.5472704",
"0.53074557",
"0.5116038",
"0.50879526",
"0.5086322",
"0.5073798",
"0.49017787",
"0.48971698",
"0.48659536",
"0.4834836",
"0.48323596",
"0.4797704",
"0.47896737",
"0.47896737",
"0.47772986",
"0.4769264",
"0.4... | 0.5906569 | 2 |
Transmit the quote to registered listeners. | def transmitQuote(sym, ob)
transmit(:quote, sym.to_sym, ob)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quote_received(quote)\n @quote = quote\n\n mail to: quote.email, :subject => \"Your Quote Received\"\n end",
"def send_price_quote(price_quote)\n @price_quote = price_quote\n mail to: @price_quote.request.user.email, subject: 'New price quote on Stabstr'\n end",
"def transmit\n @transmitte... | [
"0.6196423",
"0.6081592",
"0.5622751",
"0.5618846",
"0.55836076",
"0.5583138",
"0.5554993",
"0.5489212",
"0.54704297",
"0.5378231",
"0.53777385",
"0.5374911",
"0.5352129",
"0.52698386",
"0.52685434",
"0.5248264",
"0.52461725",
"0.5235718",
"0.5229767",
"0.5194808",
"0.5172952... | 0.6076859 | 2 |
Generalized tick fetch. If the block is used, the arrays will be retured in chunks, which should be accumulated. This is to eliminate the problem of passing large arrays across DRb. | def fetchTicks(symbol, days=nil, startTime=nil, endTime=nil, eos=true, &block)
brokerFetchTicks(symbol, days, startTime, endTime, eos, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch!\n fetch0(Array, true)\n end",
"def fetch\n fetch0(Array, false)\n end",
"def loop(num_ticks, tick_time)\n @tick_time = tick_time\n \n (0..num_ticks).each do |tick|\n time = java.lang.System.currentTimeMillis\n\n @tick = tick\n yield tick\n\n sleep_time = ... | [
"0.50891334",
"0.49669623",
"0.49631178",
"0.4961839",
"0.490971",
"0.490971",
"0.490971",
"0.4906705",
"0.48321116",
"0.48271874",
"0.47950685",
"0.47831956",
"0.47815818",
"0.47815818",
"0.47524658",
"0.4751764",
"0.47227207",
"0.4715458",
"0.46931627",
"0.4640604",
"0.4640... | 0.50351614 | 1 |
Generalized interval fetch interval may be the number of seconds, or :day for day, :week for week, or :month for month. | def fetchInterval(symbol, interval, days=nil, startTime=nil, endTime=nil, eos=true, &block)
brokerFetchInterval(symbol, interval, days, startTime, endTime, eos, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_interval(interval)\n case interval\n when :custom\n return {}\n when :hourly\n @start = (@run_time - 1.hour).beginning_of_hour\n @end = (@run_time - 1.hour).end_of_hour\n return {@field => @start..@end}\n when :daily\n @start = @run_time.yesterday.beginn... | [
"0.72452635",
"0.66549474",
"0.64540917",
"0.6380006",
"0.63788915",
"0.63715595",
"0.63715595",
"0.6349416",
"0.6122129",
"0.6097323",
"0.6057489",
"0.6036541",
"0.60301656",
"0.60289913",
"0.59038234",
"0.5896634",
"0.58185697",
"0.58180076",
"0.57938343",
"0.57362056",
"0.... | 0.62033725 | 8 |
my_min(list) => 5 bubble_sort time complexity => O(n^2) space complexity => O(3) => O(1) | def bubble_sort(arr)
sorted = false
while !sorted
sorted = true
(0...arr.length-1).each do |idx|
(idx+1...arr.length).each do |idx2|
if arr[idx2] < arr[idx]
sorted = false
arr[idx],arr[idx2] = arr[idx2],arr[idx]
end
end
end
end
arr.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend",
"def my_min_2(list)\r\n min = 0 ... | [
"0.7644112",
"0.7457935",
"0.7445393",
"0.72094166",
"0.71763396",
"0.7145923",
"0.7111722",
"0.70860785",
"0.70649827",
"0.7056367",
"0.7053715",
"0.7049627",
"0.70383024",
"0.70220256",
"0.70214504",
"0.70082605",
"0.6998128",
"0.6974119",
"0.69708174",
"0.6944229",
"0.6913... | 0.0 | -1 |
find_min time complexity => O(n), n = number of inputs space complexity => => O(2) => O(1) | def find_min(arr)
min = arr.first
(1...arr.length).each do |idx|
min = arr[idx] if arr[idx] < min
end
min
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_min(array)\n min_val = array.first\n array.each_with_index do |el1, idx1| # O(n)\n array.each_with_index do |el2, idx2| # O(n)\n if idx1 < idx2 # O(1)\n if el1 < el2# O(1)\n if el1 < min_val# O(1)\n min_val = el1# O(1)\n end\n else\n ... | [
"0.7919791",
"0.78667307",
"0.78354055",
"0.78174794",
"0.7806548",
"0.7799494",
"0.7693248",
"0.7590483",
"0.74761957",
"0.74744046",
"0.74281037",
"0.74083525",
"0.7408269",
"0.7391194",
"0.73565954",
"0.7332359",
"0.717463",
"0.71652013",
"0.715451",
"0.7143035",
"0.712130... | 0.7058958 | 31 |
time complexity => O(n^2) space complexity => O(n^3) | def largest_contiguous_subsum(arr)
subsets = []
(0...arr.length).each do |idx1|
(idx1...arr.length).each do |idx2|
subsets << arr[idx1..idx2]
end
end
largest_sum = subsets.first.sum
subsets.each do |subset|
if subset.sum > largest_sum
largest_sum = subset.sum
end
end
print subsets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\... | [
"0.6873727",
"0.67022043",
"0.6699853",
"0.6250622",
"0.62420523",
"0.619073",
"0.6177757",
"0.6155271",
"0.61480576",
"0.6124618",
"0.61172706",
"0.61075157",
"0.6079605",
"0.60767865",
"0.6074992",
"0.60698587",
"0.6057346",
"0.6043837",
"0.60178995",
"0.60108644",
"0.60007... | 0.0 | -1 |
list = [2, 3, 6, 7, 6, 7] p largest_contiguous_subsum(list) => 8 (from [7, 6, 7]) O(3) => O(1) | def better_largest_contiguous_subsum(arr)
largest_sum = 0
current_sum = 0
i = 0
while i < arr.length
if arr[i] + current_sum >= 0
current_sum += arr[i]
else
current_sum = 0
end
largest_sum = current_sum if current_sum > largest_sum
i += 1
end
largest_sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def largest_contiguous_subsum(list)\n # debugger\n results = [] # O(1)\n\n list.each_with_index do |el1, idx1| # O(n)\n list.each_with_index do |el2, idx2| # O(n) => O(n^2)\n next if idx2 < idx1 # O(1)\n results << list[idx1..idx2] # O(1)\n end\n end\n\n results.map! { |subsum| subsum.reduce(:... | [
"0.93374616",
"0.933168",
"0.9298666",
"0.92411894",
"0.92378217",
"0.9217345",
"0.9188184",
"0.91436994",
"0.9129251",
"0.9118206",
"0.91158617",
"0.90972686",
"0.90844226",
"0.9083572",
"0.9082254",
"0.9057543",
"0.90487903",
"0.9016314",
"0.9013195",
"0.9004385",
"0.898805... | 0.0 | -1 |
get all primes < n | def sieve(n)
primes = []
a = Array.new(n, true)
2.step(Math.sqrt(n).to_i) do |i|
if a[i]
primes.push(i)
i.step(n-1, i) do |k|
a[k] = false
end
end
end
Math.sqrt(n).to_i.step(n-1) do |i|
if a[i]
primes.push(i)
end
end
return primes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes_to_n n\n non_primes = []\n non_primes[1] = 1\n (2..(n/2)).each do |factor|\n ((factor*2)..n).step(factor).each do |multiple_of_factor|\n non_primes[multiple_of_factor] = 1\n end\n end\n (1..n).reject {|i| non_primes[i]}\nend",
"def prime_set(n)\n\t\tprimes_arr =[]\n\t\ti = 1\n\t\t# kee... | [
"0.7922111",
"0.7906795",
"0.7886934",
"0.78534544",
"0.7810002",
"0.76985395",
"0.76866746",
"0.7658129",
"0.7637938",
"0.76033574",
"0.7594692",
"0.7573855",
"0.75184184",
"0.7511612",
"0.75033766",
"0.7495162",
"0.7492114",
"0.74821246",
"0.74722934",
"0.74686134",
"0.7451... | 0.7414597 | 23 |
Don't run it until you've attempted to answer. | def meal
return 'Breakfast'
'Dinner'
puts 'Dinner'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ask(question)\n while true\n\n ### Fill in with your code ###\n\n end\nend",
"def serve_dish\n puts \"You've added all ingredients in the correct way, well done!\"\n puts \"You can now enjoy your meal!\"\n puts \"Good bye!!\"\n sleep 2\n puts \"Do you want to try my other programme?\"\n pu... | [
"0.6832916",
"0.6705427",
"0.6659139",
"0.66144544",
"0.65732825",
"0.65438634",
"0.6540016",
"0.6535206",
"0.6520224",
"0.6520224",
"0.6490427",
"0.64826244",
"0.6474503",
"0.64708143",
"0.64344907",
"0.64245856",
"0.6366567",
"0.63441664",
"0.6341052",
"0.6331784",
"0.63280... | 0.0 | -1 |
Returns formatted and highlighted code fragments | def markdown(text)
renderer = HTMLwithPygments.new(hard_wrap: true, filter_html: false, with_toc_data: false)
options = {
autolink: true,
no_intra_emphasis: true,
fenced_code_blocks: true,
lax_html_blocks: true,
tables: true,
strikethrough: true,
superscript: true,
xhtml: true
}
Redcarpet::Markdown.new(renderer, options).render(text).html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highlight(code, options = T.unsafe(nil)); end",
"def render_code(code)\n render_block(Pygments.highlight(code, formatter: 'terminal256', lexer: 'ruby', options: {style: 'bw'}))\nend",
"def highlight(code, lang, options = T.unsafe(nil), format = T.unsafe(nil)); end",
"def highlight_codes\n #@content... | [
"0.7659844",
"0.76062167",
"0.7587745",
"0.7522093",
"0.74182373",
"0.7362476",
"0.7346485",
"0.73151934",
"0.72900045",
"0.7274319",
"0.71643126",
"0.70952666",
"0.7092259",
"0.7092259",
"0.7092259",
"0.7054929",
"0.70209813",
"0.7004703",
"0.6998386",
"0.6971673",
"0.693313... | 0.0 | -1 |
Returns links in active or inactive state for highlighting current page | def nav_link(link_text, link_path)
recognized = Rails.application.routes.recognize_path(link_path)
class_name = recognized[:controller] == params[:controller] ? 'active' : ''
content_tag(:li, class: class_name) do
link_to link_text, link_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_actived?(link_path)\n \"active\" if current_page?(link_path)\n end",
"def active_navigation(link_path)\n\t current_page?(link_path) ? 'active' : ''\n\tend",
"def css_class\n (page.link_to.split('/')[1] == @href.split('/')[1] || page.link_to?(@href)) && \"active\"\n end",
"def active_cla... | [
"0.64624894",
"0.63613015",
"0.6321796",
"0.626717",
"0.6240386",
"0.6238003",
"0.62308353",
"0.62029403",
"0.617763",
"0.61372536",
"0.61217487",
"0.6096431",
"0.60955954",
"0.60955954",
"0.6036149",
"0.5947694",
"0.5893371",
"0.5801775",
"0.5801775",
"0.5801775",
"0.5799032... | 0.0 | -1 |
Returns HTML with all authors of an article | def display_article_authors(article, with_info=false)
authors = article.authors.map{|author| author.gplus_profile.blank? ? author.name : link_to(author.name, author.gplus_profile)}.to_sentence(two_words_connector: " & ", last_word_connector: " & ").html_safe
if with_info
authors += (" — " + article.authors.map{|author| content_tag(:span, "#{author.description}", class: 'author_description') }.join(" — ")).html_safe
end
authors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_all_article_titles_with_authors\n @all = all_article_titles_with_authors\n @all.each do |title, author|\n puts \"#{author} - #{title}\"\n end\n return @all\n end",
"def authors\n document.search(\"[@id='bookAuthors']/[@itemprop='author']/a/span\").map { |elem| elem.innerHTML.strip... | [
"0.7708442",
"0.7538625",
"0.7473535",
"0.7401987",
"0.73058116",
"0.71103686",
"0.7078655",
"0.7023631",
"0.6996439",
"0.6994805",
"0.6988791",
"0.69733304",
"0.69548464",
"0.69210076",
"0.6910337",
"0.68971044",
"0.6881655",
"0.68402195",
"0.67442596",
"0.6728819",
"0.66628... | 0.77495617 | 0 |
Renders the navigation bar for logged in users | def render_navbar(&block)
action_link = get_action_link
if !action_link
action_link = CONFIG[:title_short]
end
html = content_tag(:div, id: 'navbar') do
content_tag(:div, class: 'navbar-inner') do
if current_lines_user
content_tag(:span, class: 'buttons', &block) + "<div class='btn-menu'><div class='stripes'></div></div>".html_safe +
"<div class='submenu'>
<div class='submenu-inner'>
<ul>
<li>#{link_to("Dashboard", admin_articles_path)}</li>
<li>#{link_to(t('activerecord.models.lines/author', count: 1).html_safe, admin_authors_path)}</li>
</ul>
<ul>
<li class='small'>#{t('lines.logged_in_as').html_safe} #{current_lines_user.email}</li>
<li>#{link_to(t('lines.buttons.logout').html_safe, logout_path)}</li>
</ul>
<ul>
<li>#{link_to(t('lines.buttons.formating_help').html_safe, "#", class: "btn-cheatsheet")}</li>
<li>#{link_to(t('lines.buttons.about').html_safe, "http://lines.opoloo.com")}</li>
</ul>
</div>
</div>".html_safe
else
content_tag(:span, link_to('', root_path), class: 'backlink') + content_tag(:span, action_link, class: 'actionlink')
end
end
end
html
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def navbar\n if logged_in\n render 'layouts/logged_in_navbar'\n else\n render 'layouts/logged_out_navbar'\n end\n end",
"def navbar\n if logged_in?\n render 'layouts/logged_in_navbar'\n else\n render 'layouts/logged_out_navbar'\n end\n end",
"de... | [
"0.80729604",
"0.7991006",
"0.77432674",
"0.7552554",
"0.7259378",
"0.6888242",
"0.6786213",
"0.66048086",
"0.65513957",
"0.64602655",
"0.633531",
"0.6228377",
"0.6198695",
"0.61848515",
"0.61843866",
"0.61781484",
"0.61545825",
"0.61456376",
"0.6070461",
"0.6028583",
"0.6025... | 0.66066456 | 7 |
Returns site name for actionbar, dependend on current site | def get_action_link
if controller_path == 'admin/articles'
case action_name
when 'index' then t('buttons/all_articles').html_safe
when 'new' then t('buttons/new_article').html_safe
when 'edit' then t('buttons/edit_article').html_safe
when 'show' then t('buttons/preview').html_safe
end
elsif controller_path == 'admin/authors'
case action_name
when 'index' then t('buttons/all_authors').html_safe
when 'new' then t('buttons/new_author').html_safe
when 'edit' then t('buttons/edit_author').html_safe
when 'show' then t('buttons/author').html_safe
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def site_name\n SITE_NAME\n end",
"def site_title\n if content_for?(:title)\n \"#{content_for(:title)} - \"\n elsif ['static'].include?(controller_name)\n if action_name == 'home'\n ''\n else\n \"#{action_name.humanize} - \"\n end\n elsif @breadcrumbs && @breadcrumb... | [
"0.7467426",
"0.7223307",
"0.715887",
"0.7113593",
"0.7081",
"0.7034416",
"0.698488",
"0.69227564",
"0.69054407",
"0.6782017",
"0.66539085",
"0.65367424",
"0.64602864",
"0.6431634",
"0.63876444",
"0.63821167",
"0.6381091",
"0.63328344",
"0.63316774",
"0.6323689",
"0.63007426"... | 0.0 | -1 |
Returns HTML for code blocks formatted with Pygment | def format_code(text)
simple_format( truncate( Sanitize.clean(markdown(text)).html_safe, escape: false, length: 299, separator: ' ', omission: ' …' ))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pygment_code_block(block)\n write_data block, 'code.rb', false\n system 'pygmentize -o block.html code.rb'\n File.open('block.html', 'r').read\n end",
"def render_code(code)\n render_block(Pygments.highlight(code, formatter: 'terminal256', lexer: 'ruby', options: {style: 'bw'}))\nend",
"def repl... | [
"0.82708204",
"0.7398464",
"0.73400646",
"0.7310136",
"0.71995157",
"0.7175097",
"0.6974562",
"0.6914219",
"0.6911271",
"0.67414504",
"0.6704593",
"0.66861206",
"0.66762227",
"0.6658763",
"0.66263986",
"0.6597498",
"0.6522186",
"0.6481362",
"0.64424443",
"0.6422328",
"0.63878... | 0.62506694 | 28 |
POST /cyclists POST /cyclists.json | def create
@cyclist = Cyclist.new(cyclist_params)
@cyclist.shift_id = params["shift"]["id"]
respond_to do |format|
if @cyclist.save
format.html { redirect_to "/shifts/#{params['shift']['id']}", notice: "Cyclist data was successfully submitted at #{Time.now.localtime.strftime("%a, %b %d %Y, %I:%M %P")}." }
format.json { render :show, status: :created, location: @cyclist }
else
format.html { render :new }
format.json { render json: @cyclist.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @cyclist = Cyclist.new(params[:cyclist])\n\n respond_to do |format|\n if @cyclist.save\n format.html { redirect_to @cyclist, notice: 'Cyclist was successfully created.' }\n format.json { render json: @cyclist, status: :created, location: @cyclist }\n else\n format.... | [
"0.7611551",
"0.6480665",
"0.6416619",
"0.61685336",
"0.6167848",
"0.61156625",
"0.58950394",
"0.5883342",
"0.5850696",
"0.57932186",
"0.57357115",
"0.5664974",
"0.5620122",
"0.55992705",
"0.55777174",
"0.55715436",
"0.5565492",
"0.55392015",
"0.5537278",
"0.5516368",
"0.5485... | 0.67147046 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_cyclist
@cyclist = Cyclist.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 cyclist_params
params.require(:cyclist).permit(:quantity, :sex, :helmet, :sidewalk, :wrong_way)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /students/1 GET /students/1.json | def show
redirect_to root_path, notice: "Survey submitted!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_student\n @student = Student.find(params[:std_id])\n render json: @student\n end",
"def show\n student = Student.find(params[:id])\n render json: student\nend",
"def show\n @student = User.find params[:id]\n respond_to do |format|\n format.html # index.html.erb\n format.jso... | [
"0.79915404",
"0.77167404",
"0.764098",
"0.7618442",
"0.7569385",
"0.75570226",
"0.75570226",
"0.75570226",
"0.75570226",
"0.75570226",
"0.75570226",
"0.75570226",
"0.75570226",
"0.749562",
"0.749562",
"0.7488676",
"0.74655014",
"0.74655014",
"0.74454695",
"0.74425215",
"0.74... | 0.0 | -1 |
POST /students POST /students.json | def create
@student = Student.new(params[:student])
respond_to do |format|
if @student.save
format.html { redirect_to @student, notice: 'Student was successfully created.' }
format.json { render json: @student, status: :created, location: @student }
else
format.html { render action: "new" }
format.json { render json: @student.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @student = Student.new(student_params)\n\n if @student.save\n render json: @student, status: :created\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end",
"def create\n @student = current_user.students.create(student_params)\n\n respond_... | [
"0.7276993",
"0.71327525",
"0.71093845",
"0.71093845",
"0.70346844",
"0.6977986",
"0.6972182",
"0.69504297",
"0.69486904",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6947548",
"0.6938531... | 0.7029056 | 10 |
Never trust parameters from the scary internet, only allow the white list through. | def senkyoku_params
params.permit(:pref_code, :senkyoku_no)
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 |
SQL Injection attacks If we just pulled the values from our instance variables a malicious user could do damage to our database unless the passed arg is sanitized. Ex. playwright_id == '3; DROP TABLE plays' This would send the playwright_id, signal the end of a command then drop our plays table. SQL injection attacks are common and need to be defended against. A user could do a lot of damage to a app by dropping a user table etc. Essentially your giving users an oppurtunity to run any SQL commands they want without sanatizing it first | def update
raise "#{self} not in database" unless @id
PlayDBConnection.instance.execute(<<-SQL, @title, @year, @playwright_id, @id)
UPDATE plays
SET title = ?, year = ?, playwright_id = ? WHERE id = ?
SQL
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_sql(*args)\n klass.send(:sanitize_sql, args)\n end",
"def escape_sql(args)\n return @text if args.empty?\n sql = @text.dup\n vars = args.dup\n\n replacements = 0\n mismatch = false\n\n sql.gsub!(/'[^']*'|\"[^\"]*\"|`[^`]*`|\\?/) do |x|\n next x un... | [
"0.68672246",
"0.6751757",
"0.64046997",
"0.64045584",
"0.6281214",
"0.6206387",
"0.6143647",
"0.60640997",
"0.60109633",
"0.5913247",
"0.5863718",
"0.58425814",
"0.5779374",
"0.57738566",
"0.57726157",
"0.57431674",
"0.57018197",
"0.56976336",
"0.56765336",
"0.56712276",
"0.... | 0.0 | -1 |
This avoids a refactor to pass more task data around | def task_name_from_path(path)
path = File.absolute_path(path)
parts = path.split(File::Separator)
if parts.length < 3 || parts[-2] != 'tasks'
raise ArgumentError, "Task path was not inside a module."
end
mod = parts[-3]
name = File.basename(path).split('.')[0]
if name == 'init'
mod
else
"#{mod}::#{name}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task\n end",
"def prepare_task\n end",
"def jeweler_tasks=(_arg0); end",
"def tasks() []; end",
"def jeweler_tasks; end",
"def initialize(task)\n @task = task\n end",
"def load_tasks\n end",
"def taskOpts\nend",
"def initialize(task)\n super()\n @task= task \n end"... | [
"0.71333736",
"0.68506306",
"0.6676017",
"0.6413276",
"0.6253609",
"0.61941403",
"0.616741",
"0.61225724",
"0.6121424",
"0.6115851",
"0.60889715",
"0.6076551",
"0.6072162",
"0.6043144",
"0.60217136",
"0.60198337",
"0.60119",
"0.60106444",
"0.6006436",
"0.6001326",
"0.5954585"... | 0.0 | -1 |
run_task generates a result that makes sense for a generic task which needs to be unwrapped to extract stdout/stderr/exitcode. | def unwrap_bolt_result(result)
if result.error_hash
# something went wrong return the failure
return result
end
Bolt::Result.for_command(@target, result.value['stdout'], result.value['stderr'], result.value['exit_code'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result\n wait_for\n # If the task threw an exception during execution we raise that here.\n @task_error ? raise(@task_error) : @task_result\n end",
"def run_errored_task(broker, targets, task, files, input: {}, metadata: nil)\n run_task(broker, targets, task, files, input: input, metadata:... | [
"0.61210275",
"0.6050874",
"0.57300586",
"0.5714251",
"0.5665131",
"0.56597817",
"0.56028163",
"0.556722",
"0.55197155",
"0.55180764",
"0.5510208",
"0.54618657",
"0.5458577",
"0.54489684",
"0.539753",
"0.5381986",
"0.53605723",
"0.53220755",
"0.52634",
"0.5251962",
"0.5243449... | 0.47446814 | 89 |
GET /high_schools GET /high_schools.json | def index
@high_schools = HighSchool.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @user = User.find(session[:user_id])\n @schools = @user.schools\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @schools }\n end\n end",
"def show\n\t\trecords = University.where(['name LIKE ?', \"#{params[:name]}%\"])\n\t\tschools = Array.n... | [
"0.7190601",
"0.7041431",
"0.6871373",
"0.6644633",
"0.653639",
"0.64757884",
"0.6472032",
"0.6472032",
"0.6472032",
"0.6472032",
"0.6472032",
"0.6472032",
"0.6472032",
"0.64653105",
"0.6441137",
"0.638774",
"0.63849664",
"0.6382589",
"0.63516265",
"0.63516265",
"0.6349064",
... | 0.741594 | 1 |
GET /high_schools/1 GET /high_schools/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @user = User.find(session[:user_id])\n @schools = @user.schools\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @schools }\n end\n end",
"def index\n @high_schools = HighSchool.all\n end",
"def index\n @high_schools = HighSchool.all... | [
"0.7350893",
"0.729722",
"0.729722",
"0.7264609",
"0.7054956",
"0.69284385",
"0.6867495",
"0.6665839",
"0.6655831",
"0.6600115",
"0.65766007",
"0.6574666",
"0.6574666",
"0.6574666",
"0.6574666",
"0.6574666",
"0.6574666",
"0.6574666",
"0.6573847",
"0.6558147",
"0.65252066",
... | 0.0 | -1 |
POST /high_schools POST /high_schools.json | def create
@high_school = HighSchool.new(high_school_params)
respond_to do |format|
if @high_school.save
format.html { redirect_to @high_school, notice: 'High school was successfully created.' }
format.json { render :show, status: :created, location: @high_school }
else
format.html { render :new }
format.json { render json: @high_school.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def high_school_params\n params.require(:high_school).permit(:city, :state, :name, :uid, :county)\n end",
"def create\n @school = School.new(school_params)\n respond_to do |format|\n if @school.save\n format.html { redirect_to schools_path }\n format.json { render :show, status: ... | [
"0.66235936",
"0.64127934",
"0.63907987",
"0.63736504",
"0.6356734",
"0.6312544",
"0.63091415",
"0.63091415",
"0.63091415",
"0.6308481",
"0.62944937",
"0.6293078",
"0.6271033",
"0.6243532",
"0.6243532",
"0.6225897",
"0.6220088",
"0.62183994",
"0.6212547",
"0.620444",
"0.61520... | 0.7236414 | 1 |
PATCH/PUT /high_schools/1 PATCH/PUT /high_schools/1.json | def update
respond_to do |format|
if @high_school.update(high_school_params)
format.html { redirect_to @high_school, notice: 'High school was successfully updated.' }
format.json { render :show, status: :ok, location: @high_school }
else
format.html { render :edit }
format.json { render json: @high_school.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @student = Student.find(params[:student_id])\n @inschool = @student.inschools.find(params[:id])\n\n respond_to do |format|\n if @inschool.update_attributes(params[:inschool])\n format.html { redirect_to :back, notice: 'Inschool was successfully updated.' }\n format.json { h... | [
"0.6817056",
"0.6743827",
"0.6743827",
"0.6704701",
"0.6696226",
"0.66632456",
"0.6616371",
"0.6563845",
"0.6563845",
"0.6563845",
"0.6563845",
"0.6558982",
"0.6539282",
"0.6526617",
"0.64916337",
"0.6483248",
"0.6470588",
"0.64704317",
"0.6466912",
"0.64638954",
"0.6459862",... | 0.7044703 | 1 |
DELETE /high_schools/1 DELETE /high_schools/1.json | def destroy
@high_school.destroy
respond_to do |format|
format.html { redirect_to high_schools_url, notice: 'High school was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @school = School.find(params[:id])\n @school.destroy\n\n respond_to do |format|\n format.html { redirect_to cms_schools_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @school = School.find(params[:id])\n @school.destroy\n\n respond_to do |format|\n ... | [
"0.7446309",
"0.73377365",
"0.73377365",
"0.7284948",
"0.72463757",
"0.7223396",
"0.7195795",
"0.71851903",
"0.70984054",
"0.7093525",
"0.70910907",
"0.70910907",
"0.70910907",
"0.70910907",
"0.70576614",
"0.70258963",
"0.70234764",
"0.6968764",
"0.6954573",
"0.6947198",
"0.6... | 0.7578352 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_high_school
@high_school = HighSchool.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 high_school_params
params.require(:high_school).permit(:highSchoolName, :notes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /pickup_point_time_details GET /pickup_point_time_details.json | def index
@pickup_point_time_details = PickupPointTimeDetail.includes(:route, :location, :pickup_route_start_time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pickup_point_time_detail\n @pickup_point_time_detail = PickupPointTimeDetail.find(params[:id])\n end",
"def show\n @time_point = TimePoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_point }\n end\n end",
"def... | [
"0.73081887",
"0.7270402",
"0.71565807",
"0.688972",
"0.6757597",
"0.67381096",
"0.6684565",
"0.6590121",
"0.65166855",
"0.6437241",
"0.64303213",
"0.64291006",
"0.63696826",
"0.6330444",
"0.63184285",
"0.63182986",
"0.63182986",
"0.6307483",
"0.6300095",
"0.62642473",
"0.626... | 0.76053977 | 0 |
GET /pickup_point_time_details/1 GET /pickup_point_time_details/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pickup_point_time_details = PickupPointTimeDetail.includes(:route, :location, :pickup_route_start_time)\n end",
"def show\n @time_point = TimePoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_point }\n end\n en... | [
"0.7552405",
"0.7360442",
"0.7295135",
"0.7019691",
"0.6847505",
"0.68133426",
"0.6767781",
"0.6653837",
"0.66423935",
"0.65563494",
"0.6537323",
"0.64888066",
"0.64761895",
"0.6466538",
"0.639411",
"0.639411",
"0.63795376",
"0.6366404",
"0.63595194",
"0.6343129",
"0.6317913"... | 0.0 | -1 |
POST /pickup_point_time_details POST /pickup_point_time_details.json | def create
@pickup_point_time_detail = PickupPointTimeDetail.new(pickup_point_time_detail_params)
respond_to do |format|
if @pickup_point_time_detail.save
format.html { redirect_to pickup_point_time_details_path, notice: 'Pickup point time detail was successfully created.' }
format.json { render :show, status: :created, location: @pickup_point_time_detail }
else
format.html { render :new }
format.json { render json: @pickup_point_time_detail.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pickup_point_time_detail_params\n #params[:pickup_point_time_detail]\n params.require(:pickup_point_time_detail).permit(:route_id, :location_id, :pickup_route_start_time_id, :pickup_time)\n end",
"def set_pickup_point_time_detail\n @pickup_point_time_detail = PickupPointTimeDetail.find(para... | [
"0.76083297",
"0.7414556",
"0.7245251",
"0.67128",
"0.6640143",
"0.66362816",
"0.6511833",
"0.64674044",
"0.6441322",
"0.64413005",
"0.64108527",
"0.6384961",
"0.6375037",
"0.6370077",
"0.6355481",
"0.6317949",
"0.62920445",
"0.6280445",
"0.625384",
"0.62518287",
"0.62374717"... | 0.7998177 | 0 |
PATCH/PUT /pickup_point_time_details/1 PATCH/PUT /pickup_point_time_details/1.json | def update
respond_to do |format|
if @pickup_point_time_detail.update(pickup_point_time_detail_params)
format.html { redirect_to pickup_point_time_details_path, notice: 'Pickup point time detail was successfully updated.' }
format.json { render :show, status: :ok, location: @pickup_point_time_detail }
else
format.html { render :edit }
format.json { render json: @pickup_point_time_detail.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @time_point = TimePoint.find(params[:id])\n\n respond_to do |format|\n if @time_point.update_attributes(params[:time_point])\n format.html { redirect_to @time_point, notice: 'Time point was successfully updated.' }\n format.json { head :no_content }\n else\n format... | [
"0.7049888",
"0.7009255",
"0.67103887",
"0.66318226",
"0.65971214",
"0.64411294",
"0.6431845",
"0.6430065",
"0.6395657",
"0.6385543",
"0.6366297",
"0.63523287",
"0.6340919",
"0.6332876",
"0.6331364",
"0.63246447",
"0.6321546",
"0.6306469",
"0.6304709",
"0.6286071",
"0.6271091... | 0.7767961 | 0 |
DELETE /pickup_point_time_details/1 DELETE /pickup_point_time_details/1.json | def destroy
@pickup_point_time_detail.destroy
respond_to do |format|
format.html { redirect_to pickup_point_time_details_url, notice: 'Pickup point time detail was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @time_point = TimePoint.find(params[:id])\n @time_point.destroy\n\n respond_to do |format|\n format.html { redirect_to time_points_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @touchpoint = Touchpoint.find(params[:id])\n @touchpoint.destroy\n\n ... | [
"0.71817905",
"0.6950857",
"0.68433964",
"0.6753407",
"0.6737451",
"0.6728959",
"0.67184174",
"0.6683086",
"0.6678557",
"0.6666907",
"0.66424465",
"0.66377705",
"0.66283524",
"0.6628253",
"0.6627046",
"0.66243964",
"0.66201854",
"0.6614446",
"0.66093975",
"0.6606172",
"0.6571... | 0.7754922 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_pickup_point_time_detail
@pickup_point_time_detail = PickupPointTimeDetail.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 pickup_point_time_detail_params
#params[:pickup_point_time_detail]
params.require(:pickup_point_time_detail).permit(:route_id, :location_id, :pickup_route_start_time_id, :pickup_time)
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 |
=begin def start_date start_date end def rental_days rental_days end =end | def last_day
start_date + rental_days.days
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def day_calculations\n\t\t@prev_beg_range = @beg_range.to_date-1.day\n\t\t@prev_end_range = @beg_range.to_date-1.day\n\t\t@next_beg_range = @beg_range.to_date+1.day\n\t\t@next_end_range = @beg_range.to_date+1.day\n\tend",
"def estimated_end_date\n start_date + 12.days\n end",
"def number_of_days(rental)\n\... | [
"0.688894",
"0.6758236",
"0.6753731",
"0.666843",
"0.655105",
"0.6413499",
"0.6404946",
"0.63953614",
"0.63264555",
"0.6317546",
"0.63113",
"0.630452",
"0.6297992",
"0.62641895",
"0.6260592",
"0.624658",
"0.6229436",
"0.6225248",
"0.6224174",
"0.62112546",
"0.62010264",
"0.... | 0.7659485 | 0 |
Remove writability checks in the install script. Homebrew checks that its install targets are writable, or fails with appropriate messaging if not. The check that luarocks does has been seen to have false positives, so remove it. TODO: better document the false positive cases, or remove this patch. | def patches
DATA
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shouldUseSudo(localOption, warnIfMismatch = true)\n if localOption\n\n unless DoSudoInstalls\n\n if warnIfMismatch\n\n warning \"Sudo is globally disabled, but a command should be ran as sudo.\\n\" \\\n 'If something breaks please rerun with sudo allowed.'\n end\n\n ret... | [
"0.5491674",
"0.54504997",
"0.5352602",
"0.53212565",
"0.53028977",
"0.5277081",
"0.51996326",
"0.51235723",
"0.5097927",
"0.49523583",
"0.49447295",
"0.49367172",
"0.49296775",
"0.48929352",
"0.48810324",
"0.4877049",
"0.48682562",
"0.48554957",
"0.4842242",
"0.483272",
"0.4... | 0.0 | -1 |
find_by takes one hash argument, where key is lookup method, which starts with customer or product, and then after underscore must be existing attribute of customer or product f.e.: find_by(cutomer_name: 'Walter Latimer') => reutrns an array with customers purchases | def find_by(lookup)
resource, attribute = lookup.keys[0].to_s.split('_')
lookup_value = lookup.values[0]
@@transactions.select { |transaction| transaction.send(resource).send(attribute) == lookup_value }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by()\n\n end",
"def test_it_finds_an_object_by_specific_column_data\n # --- Merchant Repo ---\n found = FinderClass.find_by(@merchants.all, :name, \"Shopin1901\")\n assert_equal @merchant1.name, found.name\n found = FinderClass.find_by(@merchants.all, :id, 12334112)\n assert_equal @mer... | [
"0.6217773",
"0.607036",
"0.6006252",
"0.60057706",
"0.5900803",
"0.5824234",
"0.5796892",
"0.56199753",
"0.5570208",
"0.55602634",
"0.5516516",
"0.55039614",
"0.5485317",
"0.5485317",
"0.54714483",
"0.5429326",
"0.5414795",
"0.53975606",
"0.53968984",
"0.5380491",
"0.5362616... | 0.5795165 | 7 |
Wait section ==================================================== This function wait for Freelancer page to be visible | def wait_for_freelancer_page_visible
sleep 15
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_page\n sleep 0.7\n end",
"def wait_for_browser\r\n # NOTE: no need any more\r\n end",
"def wait_to_load\n activity_div.wait_until(&:exists?)\n @page = @bank_page.load_page\n end",
"def wait_for_ready(wait: 10)\n Support::Waiter.wait_until(max_duration: wait, reloa... | [
"0.76040167",
"0.72971225",
"0.71547556",
"0.71169984",
"0.70667595",
"0.69891137",
"0.66882175",
"0.6648524",
"0.6646172",
"0.6641512",
"0.6608792",
"0.65810823",
"0.6574439",
"0.6566478",
"0.65220696",
"0.65143555",
"0.6474001",
"0.64476734",
"0.64396656",
"0.64186007",
"0.... | 0.8818552 | 0 |
This function wait for Freelancer Skills to Be displayed | def wait_for_freelancer_skills_displayed
wait_for_element_present@driver.find_elements(:xpath, FREELANCER_SKILLS)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_freelancer_page_visible\n sleep 15\n end",
"def wait_for_company_skills_displayed\n wait_for_element_present@driver.find_elements(:xpath, COMPANY_SKILLS)\n end",
"def is_freelancer_skills_displayed\n @driver.find_element(:xpath, FREELANCER_SKILLS).displayed?\n end",
"def flash_card_t... | [
"0.7320436",
"0.6873017",
"0.6355161",
"0.63391227",
"0.61390126",
"0.6137762",
"0.6122016",
"0.6011918",
"0.59464854",
"0.59044504",
"0.5866783",
"0.585784",
"0.5830147",
"0.5822819",
"0.5813866",
"0.5791037",
"0.5791037",
"0.5791037",
"0.5778776",
"0.5774143",
"0.5770044",
... | 0.7697839 | 0 |
This function wait for Company Skills to bo visible | def wait_for_company_skills_displayed
wait_for_element_present@driver.find_elements(:xpath, COMPANY_SKILLS)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_freelancer_skills_displayed\n wait_for_element_present@driver.find_elements(:xpath, FREELANCER_SKILLS)\n end",
"def is_company_skills_displayed\n @driver.find_element(:xpath, COMPANY_SKILLS).displayed?\n end",
"def wait_for_freelancer_page_visible\n sleep 15\n end",
"def app_sign_cit... | [
"0.6856827",
"0.66906625",
"0.5963678",
"0.5916244",
"0.579606",
"0.5784677",
"0.5731739",
"0.5718268",
"0.5717535",
"0.56803304",
"0.56781155",
"0.5630464",
"0.56303316",
"0.55838555",
"0.5582438",
"0.5582438",
"0.55660903",
"0.5564731",
"0.5564731",
"0.55552554",
"0.5540803... | 0.784874 | 0 |
Is Displayed Section ============================================ This function verifying is Freelancer title visible | def is_freelancer_title_displayed
@driver.find_element(:xpath, FREELANCER_TITLE).displayed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def third_screen_visible?\n @third_screen_title.visible?\n end",
"def second_screen_visible?\n @second_screen_title.visible?\n end",
"def display_header?\n !@request.hide_title?\n end",
"def post_title_displayed?\n wait = Selenium::WebDriver::Wait.new(timeout: 15)\n wait.until {... | [
"0.764265",
"0.740151",
"0.709556",
"0.6934321",
"0.6927972",
"0.68464124",
"0.68008417",
"0.6769768",
"0.67285717",
"0.66852236",
"0.66709924",
"0.6662933",
"0.6656356",
"0.66417414",
"0.66417414",
"0.6620933",
"0.6610969",
"0.65987206",
"0.6582707",
"0.65347195",
"0.6534719... | 0.779525 | 0 |
This function verifying is Company title visible | def is_company_title_displayed
@driver.find_element(:xpath, COMPANY_TITLE).displayed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visible?(title)\n @driver.wait { @driver.text(title).displayed? }\n @driver.wait do\n @driver.find_element(\n @rows[:type], @rows[:value]\n ).displayed?\n end\n end",
"def title_check\n \n\n if self.title\n \n if !self.title.include? \"Believe\" || \"Won't\"... | [
"0.67883676",
"0.672336",
"0.66816527",
"0.6651884",
"0.6413975",
"0.63672215",
"0.633768",
"0.62695855",
"0.62595093",
"0.62374586",
"0.62158734",
"0.6193987",
"0.61713064",
"0.61666167",
"0.6162868",
"0.61390465",
"0.6122508",
"0.6108706",
"0.6087422",
"0.6087422",
"0.60873... | 0.78528446 | 0 |
This function verifying is Freelancer description displayed | def is_freelancer_description_displayed
@driver.find_element(:xpath, FREELANCER_DESCRIPTION).displayed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_description?\n true\n end",
"def compare_description?(freelancer_descr, profile_descr)\n serialized_freelance_descr = freelancer_descr.chomp(\"...\").split(\" \")\n serialized_profile_descr = profile_descr.gsub(\"\\n\", \" \").split(\" \")[0..serialized_freelance_descr.size-1]\n... | [
"0.69349825",
"0.678449",
"0.65462655",
"0.65162784",
"0.64722085",
"0.6456985",
"0.6433818",
"0.6417562",
"0.640336",
"0.6402933",
"0.6396678",
"0.6365976",
"0.6354546",
"0.63342744",
"0.6312018",
"0.6241672",
"0.6222901",
"0.6215725",
"0.61958957",
"0.61919767",
"0.6135295"... | 0.7505479 | 0 |
This function verifying is Freelancer Skills displayed | def is_freelancer_skills_displayed
@driver.find_element(:xpath, FREELANCER_SKILLS).displayed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_company_skills_displayed\n @driver.find_element(:xpath, COMPANY_SKILLS).displayed?\n end",
"def verify_persinfo\n\t\t@browser.url == \"https://www.autogravity.com/credit/application/personal\"\n\t\t@browser.div(:visible_text, /Personal Information$/).present?\n\tend",
"def verify_admission_preview(o... | [
"0.6313923",
"0.6224503",
"0.6219658",
"0.61862093",
"0.61831677",
"0.59142196",
"0.5908934",
"0.5901913",
"0.58925664",
"0.5890618",
"0.5883302",
"0.5859034",
"0.580531",
"0.5792772",
"0.57713014",
"0.5737664",
"0.5715716",
"0.56702536",
"0.5661672",
"0.56448835",
"0.5631394... | 0.7369797 | 0 |
This function verifying is Company Skills displayed | def is_company_skills_displayed
@driver.find_element(:xpath, COMPANY_SKILLS).displayed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_company_skills_displayed\n wait_for_element_present@driver.find_elements(:xpath, COMPANY_SKILLS)\n end",
"def is_freelancer_skills_displayed\n @driver.find_element(:xpath, FREELANCER_SKILLS).displayed?\n end",
"def partner_info_verify(partner)\n h3_section.text.eql?(partner.company_in... | [
"0.63267136",
"0.6303509",
"0.60321546",
"0.58982456",
"0.5890195",
"0.5854142",
"0.58538437",
"0.58419794",
"0.57609874",
"0.5738396",
"0.56913054",
"0.5656232",
"0.5619824",
"0.55785066",
"0.5562495",
"0.5556789",
"0.55514973",
"0.5525279",
"0.54784787",
"0.5469178",
"0.545... | 0.7352047 | 0 |
Get Text Section =============================================== | def get_freelancer_name_text
get_element_text('Get text from Freelancer name', @driver.find_element(:xpath, FREELANCER_NAME))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text\n @text[range]\n end",
"def entry\n return @text_entry\n end",
"def get_text\n raise NotImplementedError\n end",
"def text(section_type: :default)\n img = @image \n \n # resample if an image 4\"x4\" is less than 300dpi \n if img.columns * img.rows < 144000\n img = i... | [
"0.6577787",
"0.6419153",
"0.6394493",
"0.62899107",
"0.6284542",
"0.6281603",
"0.6253381",
"0.6242007",
"0.62102425",
"0.6183733",
"0.6175559",
"0.6175559",
"0.6168673",
"0.6143737",
"0.61370146",
"0.6123455",
"0.61049443",
"0.6087697",
"0.60389054",
"0.6019091",
"0.6015713"... | 0.0 | -1 |
GET /users GET /users.json | def index
@users = User.all
respond_to do |format|
format.html
format.pdf do
pdf = PDF::Writer.new
@users.each do |user|
pdf.text user.name
end
send_data pdf.render, :filename => 'products.pdf', :type => 'application/pdf', :disposition => 'inline'
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def GetUsers params = {}\n\n para... | [
"0.82109934",
"0.7873764",
"0.7860689",
"0.78108346",
"0.78067017",
"0.7678852",
"0.76586664",
"0.76318866",
"0.7582366",
"0.75291824",
"0.7487637",
"0.74485743",
"0.7439024",
"0.7437192",
"0.7427442",
"0.73978853",
"0.73978853",
"0.73978853",
"0.73978853",
"0.7377353",
"0.73... | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
# puts "----------------------1-------"
# @pub_key = File.read("#{Rails.root}/public/public.pem")
# string = 'MDQ2YzhkZmM1YzQ5YTFjYzUzMDI3ZjNjNTU4MDljNjM5ZDhhNmVjNSZlbWFpbD1rcmlzdGluZS5laXNzaW5nQHJhbmVuZXR3b3JrLmNvbQ==';
# public_key = OpenSSL::PKey::RSA.new(@pub_key)
# encrypted_string = Base64.encode64(public_key.public_encrypt(string))
# puts encrypted_string
# puts "----------------------2-------"
@user = User.find(1)
respond_to do |format|
format.html
format.pdf do
pdf = UserPdf.new(@user)
send_data pdf.render, :filename => 'products.pdf', :type => 'application/pdf', :disposition => 'inline'
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.8105987",
"0.77028173",
"0.77012515",
"0.76255774",
"0.75825965",
"0.7481543",
"0.74611485",
"0.7446646",
"0.73058766",
"0.7299786",
"0.72892565",
"0.7277604",
"0.72351575",
"0.7232825",
"0.7232825",
"0.7232825",
"0.7232825",
"0.7232825",
"0.7232825",
"0.7232825",
"0.72246... | 0.0 | -1 |
POST /users POST /users.json | def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77179813",
"0.75206673",
"0.73831296",
"0.72405374",
"0.719841",
"0.7140812",
"0.71038526",
"0.7058827",
"0.7041636",
"0.70236504",
"0.7003128",
"0.70021695",
"0.70021695",
"0.70021695",
"0.69936967",
"0.6990463",
"0.6980393",
"0.6979075",
"0.69788617",
"0.69788617",
"0.69... | 0.0 | -1 |
PATCH/PUT /users/1 PATCH/PUT /users/1.json | def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { render :show, status: :ok, location: @user }
else
format.html { render :edit }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.7225568",
"0.7129473",
"0.70036036",
"0.6903525",
"0.6821961",
"0.68157715",
"0.6708618",
"0.66936064",
"0.66810983",
"0.6673763",
"0.6672601",
"0.6664346",
"0.6664346",
"0.6659468",
"0.6659468",
"0.6654875",
"0.66486204",
"0.66436917",
"0.6641295",
"0.6635214",
"0.6618464... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\... | [
"0.78750724",
"0.77518034",
"0.7713981",
"0.7610077",
"0.747295",
"0.74073994",
"0.74073994",
"0.7369968",
"0.7346072",
"0.7340465",
"0.7328618",
"0.7309635",
"0.73095363",
"0.7306841",
"0.7297868",
"0.72917855",
"0.7291585",
"0.7289111",
"0.7284347",
"0.7250935",
"0.7250935"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_params
params.require(:user).permit(:name, :email)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /promotions GET /promotions.json | def index
@title = t('admin.promotions.index.title')
@promotions = ( @product ? @product.promotions : Promotion.all )
respond_to do |format|
format.html # index.html.erb
format.json { render json: @promotions }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def api_promotions_get(params, opts = {})\n data, _status_code, _headers = api_promotions_get_with_http_info... | [
"0.7526315",
"0.7378621",
"0.7359634",
"0.72931325",
"0.72931325",
"0.72931325",
"0.6741252",
"0.67093587",
"0.64522964",
"0.640619",
"0.6332135",
"0.62668365",
"0.6240661",
"0.6093199",
"0.6066163",
"0.60601115",
"0.60323346",
"0.6001653",
"0.5979596",
"0.5902597",
"0.575571... | 0.7152811 | 6 |
GET /promotions/1 GET /promotions/1.json | def show
@promotion = Promotion.includes(:promotion_lines).find(params[:id])
@promotion_lines = @promotion.promotion_lines
@title = "Promocion: #{@promotion.title}"
respond_to do |format|
format.html # show.html.erb
format.json { render json: @promotion }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def index\n @title = t('admin.promotions.index.title')\n @promotions = ( @product ? @product.promotions : P... | [
"0.7495955",
"0.7160924",
"0.713132",
"0.713132",
"0.713132",
"0.7083866",
"0.7001781",
"0.6545356",
"0.63462114",
"0.62295157",
"0.6149369",
"0.6104724",
"0.60289294",
"0.5991333",
"0.59727514",
"0.59671384",
"0.5879082",
"0.5832251",
"0.57910156",
"0.57566065",
"0.5746031",... | 0.5366916 | 44 |
GET /promotions/new GET /promotions/new.json | def new
@title = t('admin.promotions.new.title')
@promotion = Promotion.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @promotion }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @promotion = Promotion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @promotion }\n end\n end",
"def new\n @promotion = Promotion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prom... | [
"0.6773825",
"0.6773825",
"0.6723257",
"0.67167276",
"0.6670944",
"0.66099197",
"0.6547896",
"0.6534966",
"0.6522893",
"0.6518899",
"0.6454145",
"0.6409984",
"0.64054096",
"0.6387803",
"0.6377172",
"0.6376353",
"0.6376353",
"0.63630754",
"0.6361718",
"0.6357101",
"0.6351314",... | 0.7212576 | 0 |
POST /promotions POST /promotions.json | def create
@title = t('admin.promotions.new.title')
@promotion = Promotion.new params[:promotion]
@promotion.state = 'not-published'
respond_to do |format|
if @promotion.save
format.html { redirect_to ['admin', @promotion], notice: 'Promotion was successfully created.' }
format.json { render json: @promotion, status: :created, location: @promotion }
else
format.html { render action: 'new' }
format.json { render json: @promotion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_promotions\n @new_promotions ||= []\n end",
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def create\n @promotion = Promotion.new(params[:pro... | [
"0.61129576",
"0.6003724",
"0.5930134",
"0.5900632",
"0.5900632",
"0.5900632",
"0.5849472",
"0.5800277",
"0.5748506",
"0.573991",
"0.5670667",
"0.56652546",
"0.558862",
"0.555045",
"0.55195886",
"0.5505017",
"0.550316",
"0.54850113",
"0.5484974",
"0.54847103",
"0.5421864",
... | 0.531593 | 27 |
PUT /promotions/1 PUT /promotions/1.json | def update
@title = t('admin.promotions.edit.title')
@promotion = Promotion.find(params[:id])
params[:promotion][:state] = 'not-published'
respond_to do |format|
if @promotion.update_attributes(params[:promotion])
format.html { redirect_to ['admin', @promotion], notice: 'Promotion was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @promotion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @promoter.update(promoter_params)\n format.html { redirect_to root_url, notice: 'Promoter was successfully updated.' }\n format.json { render :show, status: :ok, location: @promoter }\n else\n format.html { render :e... | [
"0.63557005",
"0.60426205",
"0.60355294",
"0.6011776",
"0.584064",
"0.584064",
"0.584064",
"0.5823515",
"0.57860595",
"0.5748086",
"0.5730741",
"0.572601",
"0.5669982",
"0.56466687",
"0.5631083",
"0.559828",
"0.559828",
"0.55969816",
"0.558667",
"0.5583874",
"0.5571751",
"0... | 0.56627405 | 13 |
DELETE /promotions/1 DELETE /promotions/1.json | def destroy
@promotion = Promotion.find(params[:id])
if @promotion.destroy
js_notify message: t('admin.promotions.destroy.success'), type: 'alert-error', time: 2500
render nothing: true, content_type: 'text/html'
else
message = "#{t('admin.promotions.destroy.error')}: #{@promotion.errors[:base].first}"
js_notify message: message, type: 'alert-info', time: 2500
render nothing: true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to promotions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to ... | [
"0.6879028",
"0.68678474",
"0.68394583",
"0.67702013",
"0.6688265",
"0.6614795",
"0.6603827",
"0.660365",
"0.6586388",
"0.65862375",
"0.65211374",
"0.65166795",
"0.65166795",
"0.65166795",
"0.64893615",
"0.6456399",
"0.6427913",
"0.6420008",
"0.6420008",
"0.64042103",
"0.6393... | 0.59750915 | 78 |
Return the current loggedin author (if any) | def current_author
Author.find(current_user.id) unless current_user.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_author\n @current_author ||= session[:current_user_id] && Author.find(session[:current_user_id])\n end",
"def author; User.get(self.author_id); end",
"def author\n return User.find(self.user_id).user_name\n end",
"def author\n @author ||= begin\n UnfuddleAPI::People.find(self[... | [
"0.8496916",
"0.8378038",
"0.8239637",
"0.8208727",
"0.818924",
"0.81181395",
"0.808904",
"0.8052152",
"0.8044936",
"0.79666424",
"0.7950728",
"0.7943942",
"0.79297084",
"0.7906964",
"0.78874916",
"0.78838074",
"0.7875883",
"0.7835582",
"0.78184617",
"0.77619386",
"0.7719598"... | 0.8601786 | 0 |
Our PROPFIND handler Here we set a contenttype, if the node didn't already have one. | def prop_find(prop_find, _node)
prop_find.handle(
'{DAV:}getcontenttype',
lambda do
file_name = Http::UrlUtil.split_path(prop_find.path)[1]
return content_type(file_name)
end
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_type=(content_type); end",
"def node_content_class\n raise ArgumentError, \"invalid content_type\" unless ActsAsNode.classes.include? params[:content_type]\n params[:content_type].constantize\n end",
"def content_type=(_arg0); end",
"def content_type=(_arg0); end",
"def content_type=(_ar... | [
"0.6146144",
"0.580601",
"0.578352",
"0.578352",
"0.578352",
"0.57451564",
"0.5740801",
"0.573596",
"0.5703806",
"0.5683967",
"0.56773126",
"0.5675816",
"0.5668588",
"0.5667127",
"0.5665622",
"0.5658394",
"0.5619547",
"0.5560904",
"0.5559502",
"0.55587536",
"0.554366",
"0.5... | 0.51784456 | 61 |
Simple method to return the contenttype | def content_type(file_name)
# Just grabbing the extension
extension = ::File.extname(file_name.downcase)[1..-1]
return @extension_map[extension] if @extension_map.key?(extension)
'application/octet-stream'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_type\n return @content_type\n end",
"def get_content_type\n self.content_type\n end",
"def content_type\n end",
"def content_type\n instance_read(:content_type)\n end",
"def content_type\n @content_type || object.content_type\n ... | [
"0.88751155",
"0.8828655",
"0.8769342",
"0.8735177",
"0.85232854",
"0.85230976",
"0.8461848",
"0.8458344",
"0.8441408",
"0.8408258",
"0.84015274",
"0.8399596",
"0.8392392",
"0.8359205",
"0.8316669",
"0.8275507",
"0.82740635",
"0.82681924",
"0.8247097",
"0.82447106",
"0.824471... | 0.78074664 | 81 |
Creates the Move method that takes a array, position and value. | def move(array,position,value = "X")
array[position.to_i - 1] = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move( array, index, value=\"X\" )\n array[index] = value\nend",
"def move(array, index, value = \"X\")\n array[index] = value\nend",
"def move(array, position ,value = \"X\")\n position = position.to_i\n position = position - 1\n if array[position] != \"X\" and array[position] != \"O\"\n array[po... | [
"0.7541419",
"0.7452942",
"0.7298216",
"0.7074355",
"0.6769837",
"0.6632056",
"0.65359604",
"0.64776385",
"0.6392817",
"0.6362932",
"0.63206774",
"0.6312236",
"0.6212682",
"0.6212682",
"0.618601",
"0.6169062",
"0.61350507",
"0.6134265",
"0.61115277",
"0.6077917",
"0.6077917",... | 0.7676141 | 0 |
Checks to see if the position is taken and returns false if it is taken | def position_taken?(board, location)
!(board[location].nil? || board[location] == " ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?(index)\n if @board[index] == nil or @board[index] == \"\" or @board[index] == \" \"\n return false\n elsif @board[index] == \"X\" or @board[index] == \"O\"\n return true\n end\n end",
"def position_taken?(board, position)\n return false if valid_move?(board, position)\n ... | [
"0.7846578",
"0.7846038",
"0.7845192",
"0.7813574",
"0.77931523",
"0.77890176",
"0.77831715",
"0.7768618",
"0.7768487",
"0.7768484",
"0.77593327",
"0.77428347",
"0.77269983",
"0.7717083",
"0.7715577",
"0.7698482",
"0.7698482",
"0.76864856",
"0.767383",
"0.7662372",
"0.7653318... | 0.0 | -1 |
Checks to see if this was a valid move and returns | def valid_move?(board, position)
position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validMove(piece, newLocation)\n # piece can move to any empty adjacent space.\n # might need to account for placing pieces. can be counted as a fly move i guess \n\n if newLocation == nil || piece == nil\n return false\n end\n\n # check if its a fly move. \n ... | [
"0.7423581",
"0.74104947",
"0.740964",
"0.7400391",
"0.73149",
"0.7304227",
"0.72920257",
"0.72742397",
"0.7266016",
"0.72623706",
"0.72468233",
"0.7239165",
"0.7232027",
"0.71552336",
"0.71332973",
"0.71287954",
"0.7124243",
"0.71148866",
"0.71080226",
"0.710551",
"0.7087490... | 0.0 | -1 |
takes in the user input and validates the user input | def turn(board)
puts "Please enter 1-9:"
input = gets.strip
if valid_move?(board,input)
move(board,input,current_player(board))
else
turn(board)
end
display_board(board)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_input\n user_input_valid gets.chomp\n end",
"def put_in_user\n #setting variables\n name, cohort, city, hobby = placeholder\n #prompting the user for input and receiving it\n puts \"Hey there, type your name\".center(50)\n name = STDIN.gets.chomp\n\n puts \"Put your cohort\".center(50)\n ... | [
"0.7627663",
"0.75430083",
"0.7424897",
"0.7317495",
"0.7211651",
"0.7206336",
"0.72022456",
"0.71905965",
"0.71548915",
"0.7104862",
"0.7097084",
"0.69968647",
"0.69934005",
"0.6963793",
"0.6861714",
"0.68343115",
"0.6821985",
"0.6802902",
"0.6800713",
"0.6762449",
"0.675976... | 0.0 | -1 |
Create the PLAY Method to bring it all together | def play(board)
until over?(board)
turn(board)
end
if won?(board)
puts "Congratulations #{winner(board)}!"
else
puts "Cats Game!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play\n \n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play; end",
"def play \n end",
"def play\n\tend",
"def play\n #calls to all the methods that produce game!\n end",
"def get_play() \n # \n end",
"def play\n ... | [
"0.80753106",
"0.80039287",
"0.79763395",
"0.79763395",
"0.79763395",
"0.79763395",
"0.79606795",
"0.7910502",
"0.7835546",
"0.76925325",
"0.76023877",
"0.73977685",
"0.73465925",
"0.7305119",
"0.73027754",
"0.73027754",
"0.7300075",
"0.7211189",
"0.7137941",
"0.6954433",
"0.... | 0.0 | -1 |
This is a contrived transaction that mirrors the transaction documented by the manual signing example written by xeroc: | def test_to_bytes
vote = {
type: :vote,
voter: 'xeroc',
author: 'xeroc',
permlink: 'piston',
weight: 10000,
extensions: [],
}
@transaction.operations << vote
refute_nil bytes = @transaction.send(:to_bytes)
hex = hexlify(bytes)
# Here, we're going to take apart our contrived serialization so we can
# verify each substring individually.
chain_id = hex[0..63]
ref_block_num = hex[64..67]
ref_block_prefix = hex[68..75]
exp = hex[76..83]
op_len = hex[84..85]
op_id = hex[86..87]
voter = hex[88..99]
author = hex[100..111]
permlink = hex[112..125]
weight = hex[126..129]
extensions = hex[130..131]
hex_segments = {
chain_id: chain_id, ref_block_num: ref_block_num,
ref_block_prefix: ref_block_prefix, exp: exp, op_len: op_len,
op_id: op_id, voter: voter, author: author, permlink: permlink,
weight: weight, extensions: extensions
}
# This example serialization was documented by xeroc:
# https://steemit.com/steem/@xeroc/steem-transaction-signing-in-a-nutshell
example_hex = 'bd8c5fe26f45f179a8570100057865726f63057865726f6306706973746f6e102'
assert hex.include?(example_hex), 'expect example_hex in our result'
# Later correction by xeroc:
# https://steemit.com/steem/@xeroc/steem-transaction-signing-in-a-nutshell#@xeroc/re-steem-transaction-signing-in-a-nutshell-20160901t151404
example_hex2 = 'bd8c5fe26f45f179a8570100057865726f63057865726f6306706973746f6e102700'
assert hex.include?(example_hex2), 'expect example_hex2 in our result'
# The only thing that should remain if we remove the second example is the
# chain_id.
remaining_hex = hex.gsub example_hex2, ''
assert_equal Radiator::ChainConfig::NETWORKS_HIVE_CHAIN_ID,
remaining_hex, 'expect nothing but the chain_id'
# Here, we're going to take apart our contrived serialization so we can
# verify each substring.
assert_equal Radiator::ChainConfig::NETWORKS_HIVE_CHAIN_ID,
hex_segments[:chain_id], 'expect chain_id'
assert_equal 'bd8c', hex_segments[:ref_block_num], 'expect ref_block_num'
assert_equal '5fe26f45', hex_segments[:ref_block_prefix], 'expect ref_block_prefix'
assert_equal 'f179a857', hex_segments[:exp], 'expect exp'
assert_equal '01', hex_segments[:op_len], 'expect op_len'
assert_equal '00', hex_segments[:op_id], 'expect op_id'
assert_equal '057865726f63', hex_segments[:voter], 'expect voter'
assert_equal '057865726f63', hex_segments[:author], 'expect author'
assert_equal '06706973746f6e', hex_segments[:permlink], 'expect permlink'
assert_equal '1027', hex_segments[:weight], 'expect weight'
assert_equal '00', hex_segments[:extensions], 'expect extensions'
assert_equal hex, hex_segments.values.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signature_base\n tx = Stellar::Transaction.from_xdr(\n # TransactionV0 is a transaction with the AccountID discriminant\n # stripped off, we need to put it back to build a valid transaction\n # which we can use to build a TransactionSignaturePayloadTaggedTransaction\n Stellar::... | [
"0.64489174",
"0.6299867",
"0.62841564",
"0.628355",
"0.62298733",
"0.6201105",
"0.61977506",
"0.6188881",
"0.61878294",
"0.6126257",
"0.6126257",
"0.5987242",
"0.59748185",
"0.5967082",
"0.5910438",
"0.5910438",
"0.5898333",
"0.58685046",
"0.58685046",
"0.5831936",
"0.582940... | 0.6036052 | 11 |
=begin neo4j data location on mac osx with homebrew: cd /usr/local/Cellar/neo4j/community1.9.2unix/libexec to clear the db: neo4j stop && rm rf data/ && neo4j start BigQuery query: SELECT repository_name, repository_url, actor_attributes_login, type FROM [githubarchive:github.timeline] WHERE type IN ("FollowEvent", "ForkEvent", "ForkApplyEvent", "IssueCommentEvent", "IssuesEvent", "MemberEvent", "PullRequestEvent", "PullRequestReviewCommentEvent", "PushEvent", "WatchEvent") AND created_at > '20130101 00:00:00' AND repository_name IS NOT NULL AND actor_attributes_login IS NOT NULL GROUP EACH BY repository_name, repository_url, actor_attributes_login, type LIMIT 100000 to test the indexes: (make sure irclogs is inside the dataset) START repo = node:nodes_index(type = "repo") WHERE repo.name = "irclogs" RETURN ID(repo), repo.name; find duplicates: START n=node(), m=node() WHERE HAS(n.name) AND HAS(m.name) AND n.name = m.name RETURN n, m; =end detect if rake is running | def is_rake
File.basename($0) == 'rake'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_repos(neo)\n\n\t# return repo's that have more than 1 connection\n\t# TODO: try this; n<-r[follows*2..]-m\n\tcypher_query = ' START n = node:nodes_index(type = \"repo\")'\n\tcypher_query << ' MATCH n<-[r:follows]-m'\n\tcypher_query << ' WITH n, count(m) AS follow_count'\n\tcypher_query << ' WHERE follow_c... | [
"0.5616407",
"0.5507869",
"0.54831976",
"0.5285926",
"0.51739055",
"0.51308024",
"0.5121129",
"0.50801903",
"0.5068621",
"0.4980295",
"0.49163735",
"0.48961207",
"0.48404622",
"0.47866452",
"0.47632173",
"0.47542253",
"0.47284454",
"0.47284454",
"0.47101265",
"0.46870038",
"0... | 0.0 | -1 |
get all users in the graph | def get_users(neo)
cypher_query = ' START me = node:nodes_index(type = "user")'
cypher_query << ' RETURN ID(me), me.name'
cypher_query << ' ORDER BY ID(me)'
neo.execute_query(cypher_query)['data']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_users()\n response = HTTParty.get(\"https://graph.microsoft.com/v1.0/users\", { \n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Host\" => 'graph.microsoft.com' \n ... | [
"0.7535191",
"0.7437218",
"0.74323624",
"0.73720616",
"0.73589134",
"0.7345213",
"0.73325175",
"0.7277267",
"0.72661966",
"0.72155476",
"0.7213228",
"0.72066355",
"0.7196767",
"0.7187327",
"0.71700126",
"0.71645075",
"0.7152486",
"0.7141491",
"0.7122641",
"0.712086",
"0.71167... | 0.75305843 | 1 |
get all repo's with a follow_count > 2 | def get_repos(neo)
# return repo's that have more than 1 connection
# TODO: try this; n<-r[follows*2..]-m
cypher_query = ' START n = node:nodes_index(type = "repo")'
cypher_query << ' MATCH n<-[r:follows]-m'
cypher_query << ' WITH n, count(m) AS follow_count'
cypher_query << ' WHERE follow_count > 2'
cypher_query << ' RETURN ID(n), n.name, follow_count'
cypher_query << ' ORDER BY ID(n)'
neo.execute_query(cypher_query)['data']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repositories\n Repository.where(user_id: group_ids).or(membered_repositories).order(\"updated_at desc\")\n end",
"def activity_watching_following()\n\t Activity.where('$or' => [{ :project_id => { \"$in\" => self[:watching] } }, { :project_id => { \"$in\" => repo_ids } }, {:author_id => { \"$in\" => self... | [
"0.5932431",
"0.5884256",
"0.58509874",
"0.5850755",
"0.5832055",
"0.569113",
"0.56283444",
"0.5611019",
"0.54878515",
"0.5467303",
"0.54627734",
"0.5409336",
"0.53812915",
"0.5371475",
"0.5336227",
"0.5296693",
"0.5284301",
"0.5277139",
"0.52546793",
"0.5250612",
"0.52483416... | 0.66640586 | 0 |
get the users for a repo | def get_users_for_repo(neo, repo)
neo.traverse(repo, 'nodes', {
:order => 'breadth first',
:uniqueness => 'node global',
:relationships => {
:type => 'follows',
:direction => 'in'
},
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_repo_users\n repo_users = Array.new\n github = Github.new :oauth_token => github_token\n\n github.repos.list.body.each do |repo|\n repo_users << repo[\"owner\"][\"login\"]\n end\n\n repo_users\n end",
"def get_all_user_repos\n user = User.find_by(uuid: params[:uuid])\n\n client... | [
"0.8831717",
"0.7594455",
"0.733468",
"0.7199064",
"0.7116713",
"0.7096837",
"0.7087345",
"0.7025816",
"0.7003137",
"0.6926963",
"0.6855608",
"0.6847159",
"0.6806955",
"0.6793283",
"0.67886394",
"0.6774231",
"0.6760473",
"0.67336935",
"0.6683094",
"0.66607404",
"0.6646639",
... | 0.7610166 | 1 |
get the relationships for a repo, with user id and user name | def get_relationships_for_repo(neo, repo)
cypher_query = ' START user = node:nodes_index(type = "user"), repo = node:nodes_index(type = "repo")'
cypher_query << ' MATCH user-[r:follows]->repo'
cypher_query << ' WHERE ID(repo) = {repo_id}'
cypher_query << ' RETURN ID(user), user.name'
neo.execute_query(cypher_query, { :repo_id => repo[0] })['data']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relationships\n model.relationships(repository.name)\n end",
"def find_repos(user)\n user.repos\n end",
"def get_users_for_repo(neo, repo)\n\n\tneo.traverse(repo, 'nodes', {\n\t\t:order => 'breadth first',\n\t\t:uniqueness => 'node global',\n\t\t:relationships => {\n\t\t\t:type ... | [
"0.721598",
"0.68205875",
"0.652867",
"0.6370234",
"0.63568276",
"0.6260161",
"0.62548524",
"0.60606635",
"0.6008354",
"0.6002312",
"0.59954065",
"0.5979937",
"0.59636974",
"0.59211624",
"0.58956385",
"0.5737095",
"0.57164115",
"0.57111883",
"0.5703567",
"0.5692235",
"0.56865... | 0.7237486 | 0 |
find the longest paths | def find_longest_path(neo)
cypher_query = ' START user = node:nodes_index(type = "user")'
cypher_query << ' MATCH path=user-[:follows*]-repo'
cypher_query << ' WITH path, LENGTH(path) AS cnt'
cypher_query << ' RETURN extract(n in nodes(path): [ID(n), n.name, n.type])'
cypher_query << ' ORDER BY cnt DESC'
cypher_query << ' LIMIT 5'
neo.execute_query(cypher_query)['data']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_path_1(edges)\nend",
"def find_max_path_length_recursively\n if self.outgoing_edges.exists?\n available_path_lengths = self.next_vertices.map do |vertex|\n [vertex.id, 1 + vertex.find_max_path_length_recursively]\n end\n longest = available_path_lengths.max{|a,b| a[1] <=> b[1... | [
"0.80841786",
"0.78725123",
"0.7828093",
"0.7268104",
"0.6891458",
"0.6769048",
"0.6687513",
"0.6597584",
"0.650628",
"0.650417",
"0.6497579",
"0.6488037",
"0.6461223",
"0.6448632",
"0.64292836",
"0.6405151",
"0.64033705",
"0.6378165",
"0.63506556",
"0.6334335",
"0.6332442",
... | 0.60309684 | 63 |
build json for longest paths | def get_longest_path(clear_cache = false)
File.delete(longest_cache_file) if clear_cache && File.exist?(longest_cache_file)
if File.exist?(longest_cache_file)
content_type :json unless is_rake
send_file longest_cache_file
else
neo = Neography::Rest.new(ENV['NEO4J_URL'] || 'http://localhost:7474')
out = {
:nodes => [],
:links => [],
}
i = 0
find_longest_path(neo).each do |path|
path[0].each_with_index do |n, index|
out[:nodes] << {
:name => n[1],
:type => n[2],
:id => n[0],
:group => n[2] == 'user' ? 2 : 1,
}
if index < path[0].length - 1
out[:links] << {
:source => i,
:target => i + 1,
:value => 1,
}
end
i = i + 1
end
end
File.open(longest_cache_file, 'w'){ |f| f << out.to_json }
unless is_rake
content_type :json
#JSON.pretty_generate(out) # pretty print
out.to_json # normal out
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paths_to_json\n JSON.unparse(paths_to_array) \n end",
"def longest_path_1(edges)\nend",
"def generate_json\n if @path\n output = formatted_output\n File.open(@path, 'w') { |f| f.write(output.to_json) }\n end\n end",
"def generate_json\n ... | [
"0.6154557",
"0.5814891",
"0.5700766",
"0.5700766",
"0.56640106",
"0.5627103",
"0.5567338",
"0.552168",
"0.5510911",
"0.5458932",
"0.5442601",
"0.5441034",
"0.5424834",
"0.5400485",
"0.53824484",
"0.53822553",
"0.5371723",
"0.5341395",
"0.53331554",
"0.5294324",
"0.52785754",... | 0.6817712 | 0 |
build json for all nodes | def get_relationships(clear_cache = false)
File.delete(node_cache_file) if clear_cache && File.exist?(node_cache_file)
if File.exist?(node_cache_file)
content_type :json unless is_rake
send_file node_cache_file
else
neo = Neography::Rest.new(ENV['NEO4J_URL'] || 'http://localhost:7474')
out = {
:nodes => [],
:links => [],
}
users = {}
repos = []
repo_index = 0
user_index = 0
get_repos(neo).each do |repo|
relationships = get_relationships_for_repo(neo, repo)
repos << {
:name => repo[1],
:type => :repo,
:id => repo[0],
:group => 1,
}
relationships.each do |n|
unless users.has_key?(n[0])
users[n[0]] = {
:name => n[1],
:type => :user,
:id => n[0],
:group => 2,
:index => user_index,
}
user_index = user_index + 1
end
out[:links] << {
:source => repo_index,
:target => n[0],
:value => 1,
}
end
repo_index = repo_index + 1
end
# set the target index correctly for the javascript
out[:links].each do |l|
l[:target] = users[l[:target]][:index] + repo_index
end
out[:nodes] = repos.concat(users.values.to_a).flatten
File.open(node_cache_file, 'w'){ |f| f << out.to_json }
unless is_rake
content_type :json
#JSON.pretty_generate(out) # pretty print
out.to_json # normal out
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json\n @nodes.map(&:to_json)\n end",
"def as_json(*)\n {\n JSON.create_id => self.class.name,\n node_name: node_name, node_type: node_type,\n node_count: node_count, nodes: nodes,\n icons: icons, title: title,\n note: note, io: io\n }\n e... | [
"0.6977531",
"0.6825319",
"0.6772934",
"0.67488813",
"0.66589576",
"0.66501456",
"0.66181034",
"0.63208383",
"0.6315895",
"0.6177996",
"0.61653864",
"0.61204296",
"0.6077013",
"0.6068352",
"0.6061612",
"0.60474",
"0.604183",
"0.6036265",
"0.60155046",
"0.60061306",
"0.5948582... | 0.5570575 | 65 |
PUSH Push the register value on to the stack. Leave the value in the register. ADD Pops a value from the stack and adds it to the register value, storing the result in the register. SUB Pops a value from the stack and subtracts it from the register value, storing the result in the register. MULT Pops a value from the stack and multiplies it by the register value, storing the result in the register. DIV Pops a value from the stack and divides it into the register value, storing the integer result in the register. MOD Pops a value from the stack and divides it into the register value, storing the integer remainder of the division in the register. POP Remove the topmost item from the stack and place in register PRINT Print the register value | def string_is_integer?(n)
n == n.to_i.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mod\n x, y = stack.pop(2)\n push x % y\n end",
"def div\n x, y = stack.pop(2)\n push x / y\n end",
"def stackEval(cmdStack, resStack, memState)\n # cmdStack => the command stack implemented using a list\n # resStack => the results stack implemented using ... | [
"0.6116837",
"0.6102596",
"0.59521824",
"0.59485286",
"0.591534",
"0.5882558",
"0.5867398",
"0.5863072",
"0.5847665",
"0.5843689",
"0.5841853",
"0.5830007",
"0.58064175",
"0.5754235",
"0.57235336",
"0.5722366",
"0.572175",
"0.5720563",
"0.5720343",
"0.57072103",
"0.5670372",
... | 0.0 | -1 |
This method should be called to reset dirty information before dump | def clear_changes!
remove_instance_variable(:@original_hash) if defined?(@original_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_dirty_flag\n\t\t@dirty = false\n\tend",
"def dirty!\n @dirty = true\n end",
"def dirty!\n @dirty = true\n end",
"def dirty!\n @dirty = true\n end",
"def dirty; end",
"def _dump() end",
"def dump!\n @dump = true\n end",
"def restore; end",
"def dump\... | [
"0.70948994",
"0.70257753",
"0.70257753",
"0.7000007",
"0.6939666",
"0.6887448",
"0.68706995",
"0.68345654",
"0.6794764",
"0.67717564",
"0.65945256",
"0.65343106",
"0.6477704",
"0.6464261",
"0.6459617",
"0.6453976",
"0.6423587",
"0.6374783",
"0.63198507",
"0.63198507",
"0.628... | 0.0 | -1 |
Show the details of one place | def show
@place = Place.find_by(:id=> params["id"])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @place = Place.find(params[:id])\n end",
"def show_place_detail(params, options = {})\n query_str = params[:text]\n query_str = query_str.match(/「(.*)」の情報/)\n query_str = query_str[1]\n res = get_place_info(query_str)\n place_info = JSON.load(res.body)\n i... | [
"0.79349697",
"0.75223684",
"0.75033444",
"0.7499598",
"0.74456936",
"0.74244684",
"0.734506",
"0.734506",
"0.734506",
"0.7254699",
"0.7235666",
"0.7235666",
"0.7235666",
"0.7235666",
"0.7235666",
"0.72238415",
"0.7218615",
"0.72095394",
"0.7178379",
"0.7168021",
"0.7164558",... | 0.766379 | 1 |
Delete a place from the database | def delete
@place = Place.find_by(:id => params["id"]) # Find out what link has been clicked
@place.delete # Delete the item which has been clicked
redirect_to root_url # Show home page to verify that the place has been deleted
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @place.destroy\n \n \n end",
"def destroy\n @place = Place.find(params[:id])\n @place.destroy\n redirect_to places_path\n end",
"def destroy\n @place.destroy\n head :no_content\n end",
"def delete\n\t\t@place = Place.find_by(:id => params[\"id\"])\n\n\t\tif @plac... | [
"0.7879893",
"0.77100843",
"0.7655565",
"0.75244796",
"0.7475509",
"0.744981",
"0.74018425",
"0.7312178",
"0.72758377",
"0.7233697",
"0.71646184",
"0.71539354",
"0.70906746",
"0.70906746",
"0.70906746",
"0.70906746",
"0.70906746",
"0.70906746",
"0.70906746",
"0.707276",
"0.70... | 0.7719449 | 1 |
Create a new place along with its description | def new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_place\n @place = Place.new\n @category = get_lookup_values(\"Place_Type\")\n end",
"def new\n @place = Place.new\n end",
"def new\n \t@place = Place.new\n end",
"def place\n Place.new(place_name, organisation_name)\n end",
"def new_city_workplace \n new_city_workplace ... | [
"0.78425795",
"0.6871505",
"0.68252426",
"0.6783428",
"0.67754894",
"0.6685155",
"0.6683857",
"0.6683857",
"0.6633084",
"0.65508616",
"0.65299225",
"0.65247804",
"0.65154636",
"0.6500561",
"0.6500561",
"0.6481588",
"0.6447001",
"0.6410156",
"0.6408066",
"0.6408066",
"0.640806... | 0.0 | -1 |
Edit an exisiting place | def edit
@place = Place.find_by(:id => params["id"])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; e... | [
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"0.6929099",
"... | 0.0 | -1 |
Update the details of an existing place | def update
@place = Place.find_by(:id => params["id"])
@place.title = params["title"]
@place.photo_url = params["photo_url"]
@place.admission_price = params["price"]
@place.description = params["description"]
@place.save
redirect_to "/places/#{@place.id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @place.update(place_params)\n render :show, status: :ok, location: @place\n else\n render json: @place.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @place.update(place_params)\n redirect_to @place, notice: \"Place was successfully up... | [
"0.7869142",
"0.7840684",
"0.7805384",
"0.7679539",
"0.75550485",
"0.7553718",
"0.7553718",
"0.7553718",
"0.7553718",
"0.74998826",
"0.7481315",
"0.74808025",
"0.74399173",
"0.7431598",
"0.7425476",
"0.7425476",
"0.7425476",
"0.7425476",
"0.7425476",
"0.74167114",
"0.74167114... | 0.78253436 | 2 |
TODO: Split this up into multiple methods Normalizes the guide by flattening the file paths | def normalize!
normalize
save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize\n @epub.log \"Normalizing guide...\"\n doc = xmldoc\n\n # TODO: Handle this better\n if doc.size < 1\n return\n end\n\n normalize_paths\n to_s\n end",
"def normalize!\n begin\n create_base_directories!\n\n # Ensure all files are proper... | [
"0.6913567",
"0.669432",
"0.6129934",
"0.58422315",
"0.58422315",
"0.57970256",
"0.579325",
"0.57706195",
"0.5717497",
"0.5534543",
"0.5534543",
"0.54787713",
"0.5421049",
"0.5421049",
"0.5421049",
"0.5421049",
"0.5421049",
"0.53937674",
"0.5380835",
"0.5379329",
"0.522008",
... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.