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 |
|---|---|---|---|---|---|---|
Returns the parent of the given node | def parent_of node
return is_valid(node) ? node.parent : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_node(node)\n return node.respond_to?(:parent) ? node.parent : node\n end",
"def parent_node(node)\n node.find(:xpath, '..', wait: 0, visible: false)\n end",
"def parent(node)\n parent = adjacent(node, :direction => :in)\n raise JumokuError, \"Inconsistent directed tree (mor... | [
"0.87993264",
"0.82078636",
"0.8191509",
"0.80812955",
"0.804595",
"0.7976806",
"0.7803221",
"0.775602",
"0.7676837",
"0.7553943",
"0.7402786",
"0.7358889",
"0.73332936",
"0.7318839",
"0.73108757",
"0.71889436",
"0.7099725",
"0.70975626",
"0.69850814",
"0.6962282",
"0.6937197... | 0.85704195 | 1 |
Returns the previous element of the current node | def prev_element
return prev_element_of @current_node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prev()\n return @prev_node\n end",
"def prev_element_of(node)\n\t\treturn valid(node) ? node.previous_element : nil\n\tend",
"def previous\n DOM::Element.from_node `#{@el}.previousElementSibling || Opal.nil`\n end",
"def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend",
"d... | [
"0.89247125",
"0.86669534",
"0.86544216",
"0.84210217",
"0.83924085",
"0.83458596",
"0.8042985",
"0.7991289",
"0.79548264",
"0.79286736",
"0.79207647",
"0.7859692",
"0.7843736",
"0.78401285",
"0.777309",
"0.77520114",
"0.773126",
"0.7729394",
"0.76284647",
"0.7594287",
"0.753... | 0.91436607 | 0 |
Returns the previous element of the given node | def prev_element_of(node)
return valid(node) ? node.previous_element : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prev()\n return @prev_node\n end",
"def prev_element\n\t\treturn prev_element_of @current_node\n\tend",
"def previous\n DOM::Element.from_node `#{@el}.previousElementSibling || Opal.nil`\n end",
"def prev_sibling_of(node)\n\t\treturn valid(node) ? node.previous_sibling : nil\n\tend",
"d... | [
"0.8735777",
"0.86872214",
"0.83443296",
"0.833913",
"0.8275222",
"0.8080957",
"0.8059967",
"0.8054861",
"0.7836243",
"0.78321314",
"0.7765692",
"0.7731378",
"0.7603952",
"0.7550879",
"0.75392854",
"0.7463779",
"0.7438966",
"0.7435683",
"0.74280757",
"0.7348391",
"0.73206437"... | 0.8985553 | 0 |
Returns the previous sibling of the current node | def prev_sibling
return prev_sibling_of @current_node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prev_sibling_of(node)\n\t\treturn valid(node) ? node.previous_sibling : nil\n\tend",
"def previous_sibling\n return nil if parent.nil? # self is root\n return nil if 1 == parent.children.size # self is parent's only child\n if 0 == own_child_index\n return nil # self is first child\n ... | [
"0.87419695",
"0.8696707",
"0.8630646",
"0.85605544",
"0.84713054",
"0.84206885",
"0.83649904",
"0.7981851",
"0.7932079",
"0.7851961",
"0.78427726",
"0.77472585",
"0.7678344",
"0.7561046",
"0.74988776",
"0.74839747",
"0.7367846",
"0.7330575",
"0.7320181",
"0.72175026",
"0.719... | 0.911287 | 0 |
Returns the previous sibling of the given node | def prev_sibling_of(node)
return valid(node) ? node.previous_sibling : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend",
"def previous_sibling\n return nil if parent.nil? # self is root\n return nil if 1 == parent.children.size # self is parent's only child\n if 0 == own_child_index\n return nil # self is first child\n else\n # ... | [
"0.86686254",
"0.8503803",
"0.85004866",
"0.8299519",
"0.82088727",
"0.8158872",
"0.80423623",
"0.78661317",
"0.7691367",
"0.766529",
"0.76146114",
"0.76119834",
"0.76002145",
"0.7580425",
"0.7485071",
"0.74039453",
"0.7376988",
"0.7258424",
"0.71953845",
"0.7175583",
"0.7064... | 0.89993024 | 0 |
Returns the next element of the current node | def next_element
return next_element_of @current_node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next()\n return @next_node\n end",
"def next\n DOM::Element.from_node `#{@el}.nextElementSibling || Opal.nil`\n end",
"def next_node\n @current_node = @current_node.children[0]\n end",
"def next_node\n @current_node = @current_node.children[0]\n end",
"def next\n value ... | [
"0.8395456",
"0.7913779",
"0.78747284",
"0.7857217",
"0.77050483",
"0.768974",
"0.7527583",
"0.75050586",
"0.7442074",
"0.739274",
"0.7337858",
"0.7234564",
"0.7219672",
"0.71539634",
"0.71497303",
"0.71329665",
"0.7107348",
"0.7075512",
"0.70687616",
"0.7050191",
"0.69945884... | 0.8747819 | 0 |
Returns the next element of the given node | def next_element_of(node)
return valid(node) ? node.next_element : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_element\n\t\treturn next_element_of @current_node\n\tend",
"def get_next()\n return @next_node\n end",
"def next\n DOM::Element.from_node `#{@el}.nextElementSibling || Opal.nil`\n end",
"def get_next_node(node)\n i = node.number + 1\n i = 0 if i >= nodes.size\n get_node(i)... | [
"0.794192",
"0.77441555",
"0.7472502",
"0.74486667",
"0.73922247",
"0.7379621",
"0.729231",
"0.7101187",
"0.7099507",
"0.7029849",
"0.69311917",
"0.6923216",
"0.6899006",
"0.6849636",
"0.6727263",
"0.669937",
"0.66752076",
"0.6628868",
"0.6565717",
"0.65427136",
"0.6518837",
... | 0.8305558 | 0 |
Returns the next sibling of the current node | def next_sibling
return next_sibling_of @current_node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_sibling\n return @links[:next_sibling]\n end",
"def next_sibling_of(node)\n\t\treturn valid(node) ? node.next_sibling : nil\n\tend",
"def nextSibling\n native_node.next_sibling && Browser.wrap_node(native_node.next_sibling)\n end",
"def next_element_sibling\n n = self.next_sib... | [
"0.81352",
"0.80332613",
"0.77566147",
"0.75963545",
"0.7527461",
"0.75008225",
"0.7399003",
"0.7388899",
"0.7334685",
"0.7251409",
"0.72411394",
"0.7180755",
"0.71534973",
"0.7129781",
"0.69619197",
"0.6934453",
"0.68840724",
"0.68248236",
"0.6730522",
"0.6714905",
"0.666482... | 0.88003904 | 0 |
Returns the next sibling of the current node. | def next_sibling_of(node)
return valid(node) ? node.next_sibling : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def next_sibling\n return @links[:next_sibling]\n end",
"def nextSibling\n native_node.next_sibling && Browser.wrap_node(native_node.next_sibling)\n end",
"def next_element_sibling\n n = self.next_sibling\n whi... | [
"0.859301",
"0.7917772",
"0.7579492",
"0.7487571",
"0.7276858",
"0.7193409",
"0.7192539",
"0.7075441",
"0.7037588",
"0.6996282",
"0.69843125",
"0.6909993",
"0.69076943",
"0.6900498",
"0.6832504",
"0.670869",
"0.6684521",
"0.6634229",
"0.66265196",
"0.6524457",
"0.6457342",
... | 0.7919493 | 1 |
Yields current node and all children of the current node to block. | def traverse(&block)
traverse(@current_node, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_node(&block)\n c = children # save children before yield\n yield(self)\n c.each do |n|\n n.each_node(&block)\n end\n end",
"def each\n self.traverse_down { |node| yield(node) }\n end",
"def each(&block)\n yield self\n children.each {|c| c.each(&block)}\n... | [
"0.79474133",
"0.7762521",
"0.7440448",
"0.735163",
"0.7344119",
"0.73345834",
"0.72829",
"0.72754395",
"0.7275258",
"0.72581697",
"0.7170762",
"0.71493",
"0.71463215",
"0.7119479",
"0.7107122",
"0.7079481",
"0.7079481",
"0.7048346",
"0.70361125",
"0.701071",
"0.70075876",
... | 0.7158805 | 11 |
Yields current node and all children of the current node to block. | def traverse(node, &block)
if valid(node) then
node.traverse(&block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_node(&block)\n c = children # save children before yield\n yield(self)\n c.each do |n|\n n.each_node(&block)\n end\n end",
"def each\n self.traverse_down { |node| yield(node) }\n end",
"def each(&block)\n yield self\n children.each {|c| c.each(&block)}\n... | [
"0.79474133",
"0.7762521",
"0.7440448",
"0.735163",
"0.7344119",
"0.73345834",
"0.72829",
"0.72754395",
"0.7275258",
"0.72581697",
"0.7170762",
"0.7158805",
"0.71493",
"0.71463215",
"0.7119479",
"0.7107122",
"0.7079481",
"0.7079481",
"0.7048346",
"0.70361125",
"0.701071",
"... | 0.616892 | 95 |
Returns set of elements by type | def elements_by_type(type)
return xpath('//' + type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def by_type\n return @by_type if @by_type\n\n @by_type = {}\n self.all.each do |set|\n next unless set[:types].count > 0\n\n set[:types].each do |t|\n @by_type[t] ||= []\n @by_type[t] << set\n end\n end\n\n @by_type\n end",
"def elements\n return @types.dup\n ... | [
"0.7372266",
"0.71640664",
"0.6970619",
"0.69129604",
"0.67684513",
"0.67684513",
"0.6729588",
"0.6680755",
"0.6673888",
"0.6650561",
"0.65323806",
"0.64995325",
"0.646765",
"0.64671856",
"0.64671856",
"0.627714",
"0.6265765",
"0.6245004",
"0.617194",
"0.61620355",
"0.6066770... | 0.7425538 | 0 |
Returns set of attributes by name | def attributes_by_name(name)
return xpath('//@' + name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_attributes(name)\n\t\t\tr=[]\n\t\t\tp=self\n\t\t\twhile(p)\n\t\t\t\tif(p.respond_to?(name))\n\t\t\t\t\tv=p.send(name)\n\t\t\t\t\tr << v if(v)\n\t\t\t\tend\n\t\t\t\tbreak if(!p.respond_to?(\"container\"))\n\t\t\t\tp=p.container\n\t\t\tend\n\t\t\tr\n\t\tend",
"def attributes *attr_names\n @attribut... | [
"0.7383498",
"0.7121259",
"0.7099978",
"0.69748557",
"0.6967677",
"0.69662964",
"0.6949781",
"0.6877779",
"0.6862206",
"0.6844416",
"0.6825001",
"0.6825001",
"0.68173236",
"0.6683584",
"0.6650696",
"0.65907425",
"0.6556645",
"0.65203613",
"0.65089077",
"0.6500382",
"0.6468757... | 0.6876673 | 8 |
Tests all of the data for the current node | def print_debug
print_divider
puts "Root Node: \n" + root.to_s
print_divider
puts "Current Node: \n" + @current_node.to_s
print_divider
puts "Attributes: \n" + attributes.to_s
print_divider
puts "Children: \n" + children.to_xml
print_divider
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test(data)\n if @nominal\n @children.each_with_index do |child, ind|\n child.test(data) if data.vals[@att] == @@nom_choices[@att][ind]\n end\n else # continuous\n if data.vals[@att].to_f < @thresh # > on one side, <= on oter\n @children.first.test(data)\n else\n @... | [
"0.6053136",
"0.59973353",
"0.59430426",
"0.57525593",
"0.5610898",
"0.5559573",
"0.5549556",
"0.5524015",
"0.55099815",
"0.5429856",
"0.536739",
"0.5362716",
"0.5348401",
"0.53454703",
"0.53054553",
"0.5304379",
"0.52848417",
"0.52740085",
"0.52465475",
"0.52420294",
"0.5234... | 0.0 | -1 |
Prints a horizontal line of '' characters | def print_divider
puts "------------------------------------------------------------"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_horizontal_line(length)\n print '+'\n (length - 2).times do |index|\n print '-'\n end\n print '+'\n print \"\\n\"\n end",
"def print_empty_line\n print_in_same_line(\" \")\n end",
"def ren... | [
"0.8005121",
"0.76812214",
"0.76274747",
"0.76106316",
"0.7433871",
"0.74207246",
"0.7286814",
"0.7189737",
"0.71714747",
"0.71148264",
"0.7102233",
"0.7086485",
"0.70694804",
"0.7062242",
"0.70052105",
"0.6995032",
"0.6995032",
"0.6977793",
"0.6972181",
"0.69254994",
"0.6857... | 0.6565153 | 41 |
Initializes a new keychain from the specified keychain file | def initialize(options={})
unless options.has_key?(:keychain_file) || options.has_key?(:keychain_data)
raise ArgumentError, 'Either a keychain_file or keychain_data is required to create a new keychain class'
end
@keychain = options[:keychain_data] || JSON.parse(IO.read(options[:keychain_file]))
# TODO: Validate that the hash is correct.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keychain\n @keychain ||= Keychain.new\n end",
"def open(path)\n raise ArgumentError unless path\n out_buffer = FFI::MemoryPointer.new(:pointer)\n status = Sec.SecKeychainOpen(path,out_buffer);\n Sec.check_osstatus(status)\n Keychain.new(out_buffer.read_pointer).release_on_gc\... | [
"0.6764559",
"0.6604155",
"0.65220153",
"0.65177053",
"0.62628347",
"0.625992",
"0.610372",
"0.6082258",
"0.6002221",
"0.599431",
"0.59017736",
"0.5871112",
"0.58412194",
"0.5766371",
"0.57511413",
"0.57114697",
"0.5698304",
"0.5624285",
"0.5613551",
"0.56077284",
"0.56032497... | 0.7851533 | 0 |
Lists the names of all keys in the keychain | def list
@keychain.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_keychains(params: {})\n call :get, '/keychain', params\n end",
"def list_keys()\n # TODO\n end",
"def list_keys\n @keydict.keys\n end",
"def list_keys\n @keys.keys\n end",
"def all_keys\n @cluster.client.list_keys(@name)\n end",
"def list_checkout_keys\n ... | [
"0.7622633",
"0.76178783",
"0.75705016",
"0.75571156",
"0.70517576",
"0.6900648",
"0.68866533",
"0.68799704",
"0.68799704",
"0.68628806",
"0.6859105",
"0.6853512",
"0.67059165",
"0.66911805",
"0.6687311",
"0.66767424",
"0.6670743",
"0.66431934",
"0.6604101",
"0.6594838",
"0.6... | 0.8521618 | 0 |
Array operator override to access keys by their name | def [](key)
@keychain[key]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [] k\n @values[k.to_sym]\n end",
"def [](k) data[k.to_sym] end",
"def [] name\n to_h[name.to_s]\n end",
"def []( name )\n @hash[name]\n end",
"def [](name); @hash[name.to_s]; end",
"def []( key ) send( key ); end",
"def keys\n [ name ]\n end",
"def ... | [
"0.73069924",
"0.7305951",
"0.7114895",
"0.6979752",
"0.6947191",
"0.69000113",
"0.6850709",
"0.6774187",
"0.6734963",
"0.67124546",
"0.67124546",
"0.67124546",
"0.67124546",
"0.67124546",
"0.67124546",
"0.67124546",
"0.67124546",
"0.67124546",
"0.67124546",
"0.67124546",
"0.... | 0.0 | -1 |
Get a hash of the position. This representation is suitable for use in the language server protocol. | def to_hash
{
line: line,
character: character
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n source_position.hash\n end",
"def hash\n offset.hash\n end",
"def position_digest\n hex_digest = @board.flatten.map(&:to_s).join.to_i(3).to_s(16)\n \"#{hex_to_base64_digest(hex_digest)};#{size};#{turn_color}\"\n end",
"def hash\n @offset.hash ^ @previous_offset.hash... | [
"0.7781621",
"0.7679458",
"0.6923816",
"0.6768183",
"0.6708193",
"0.6663256",
"0.6662692",
"0.6662692",
"0.65905654",
"0.654992",
"0.64730215",
"0.63291514",
"0.6317915",
"0.63122",
"0.6297588",
"0.62733406",
"0.6270021",
"0.6252283",
"0.6252283",
"0.6252283",
"0.6252283",
... | 0.0 | -1 |
Override to supress Text.check call | def element=( element )
@element = element
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repair(text); end",
"def has_text?; end",
"def validate_text\n errors.add(:text, :must_be_null_in_this_slide) if !self.allows_text? && !self.text.nil?\n end",
"def guard_text( text )\n # todo/fix 2: note we need to differentiate between blocks and inline\n # thus, to avoid runs - use guard_bl... | [
"0.6137159",
"0.61293745",
"0.6096938",
"0.60914934",
"0.6044499",
"0.5962476",
"0.5914449",
"0.5895591",
"0.58363694",
"0.5805118",
"0.57921046",
"0.57769644",
"0.5742918",
"0.5733017",
"0.5724954",
"0.5719928",
"0.5719928",
"0.5714669",
"0.5714669",
"0.5714669",
"0.5700171"... | 0.0 | -1 |
Index action to render all companies | def index
@companies = Company.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def... | [
"0.8519863",
"0.8519863",
"0.8519863",
"0.8519863",
"0.8519863",
"0.8519863",
"0.8468628",
"0.832885",
"0.83087826",
"0.82209325",
"0.8141195",
"0.81384903",
"0.80968875",
"0.8066812",
"0.8035232",
"0.80041826",
"0.8001578",
"0.7999802",
"0.79804623",
"0.7973436",
"0.7971096"... | 0.85308367 | 1 |
New action for creating company | def new
@company = Company.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @company = Company.new(params[:company])\n\n if @company.save\n flash[:success] = \"Company was successfully created.\"\n redirect_to crm_path\n else\n render :action => 'new'# Clear page\n end\n end",
"def create\n @company = Company.new(company_params)\n ... | [
"0.8238307",
"0.8067915",
"0.80352366",
"0.8024617",
"0.80087876",
"0.8000446",
"0.7984897",
"0.79737574",
"0.7935416",
"0.7934482",
"0.79234785",
"0.7916446",
"0.7916446",
"0.7916446",
"0.7916446",
"0.79163134",
"0.7916167",
"0.79161584",
"0.7906685",
"0.78983325",
"0.788426... | 0.7786426 | 38 |
Create action saves the company into database | def create
@company = Company.new(company_params)
if @company.save
flash[:notice] = "Successfully created company!"
redirect_to company_path(@company)
else
flash[:alert] = "Error creating new company!"
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @company = Company.create!(company_params)\n end",
"def create\n @company = Company.new(company_params)\n\n \n if @company.save\n redirect_to companies_path, notice: 'Company was successfully created.' \n else\n format.html { render :new }\n end\n end",
"def create\n ... | [
"0.8303029",
"0.8127907",
"0.807158",
"0.80383486",
"0.8025331",
"0.7981589",
"0.79738605",
"0.78923965",
"0.78797215",
"0.78650695",
"0.78329533",
"0.78236306",
"0.78170335",
"0.78170335",
"0.78170335",
"0.78170335",
"0.78170335",
"0.78029746",
"0.77784824",
"0.77784824",
"0... | 0.7542614 | 49 |
Edit action retrives the company and renders the edit page | def edit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n @company = Company.find(params[:id])\n end",
"def edit\n\t\t@roaster = Roaster.find(session[:roaster_id])\n\t\tif admin?\n\t\t\t@company = Company.find(params[:id])\n\t\telsif @roaster.company_id == params[:id]\n\t\t\t@company = Company.find(params[:id])\n\t\telse\n\t\t\tredirect_to beanformed_com... | [
"0.84720045",
"0.79543686",
"0.79157513",
"0.7898176",
"0.76353866",
"0.7452758",
"0.710841",
"0.70802593",
"0.7077142",
"0.7071543",
"0.7069447",
"0.6996391",
"0.69850296",
"0.697513",
"0.6961961",
"0.6961909",
"0.6955674",
"0.6950118",
"0.6950118",
"0.69466066",
"0.69426185... | 0.0 | -1 |
Update action updates the company with the new information | def update
if @company.update_attributes(company_params)
flash[:notice] = "Successfully updated company!"
redirect_to company_path(@company)
else
flash[:alert] = "Error updating company!"
render :edit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\t\t@company = Company.find(params[:id])\n\t\t@company.update(company_params)\n\t\tredirect_to company_path(@company)\n\tend",
"def update\n if @company.update(company_params)\n redirect_to @company, notice: \"Company was successfully updated.\"\n else\n render :edit, status: :unproce... | [
"0.8254352",
"0.81927496",
"0.8167805",
"0.8164558",
"0.8137533",
"0.8134285",
"0.80130804",
"0.7998484",
"0.7988416",
"0.79785246",
"0.79724103",
"0.79520226",
"0.7938241",
"0.7932582",
"0.7926068",
"0.7920895",
"0.79143786",
"0.79143786",
"0.79143786",
"0.79143786",
"0.7914... | 0.80741525 | 6 |
The show action renders the individual company after retrieving the the id | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @company = Company.find(params[:company_id])\n end",
"def show\n @companies = Company.all\n end",
"def show\r\n @company = Company.find(params[:id])\r\n set_seo_meta(\"#{@company.name}\",\"#{Setting.app_name}#{t(\"companycommon.yellowpage\")}\")\r\n drop_breadcrumb(t(\"companies.m... | [
"0.8319527",
"0.77378297",
"0.77033097",
"0.7667692",
"0.755856",
"0.75167996",
"0.7502622",
"0.7499609",
"0.7493004",
"0.7480807",
"0.746824",
"0.7455381",
"0.743616",
"0.7433101",
"0.74198264",
"0.740923",
"0.7402561",
"0.7391672",
"0.7391672",
"0.7391672",
"0.7391672",
"... | 0.0 | -1 |
The destroy action removes the company permanently from the database | def destroy
if @company.destroy
flash[:notice] = "Successfully deleted company!"
redirect_to companies_path
else
flash[:alert] = "Error updating company!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @intelcompany.destroy\n end",
"def destroy\n @company.destroy\n redirect_to(companies_url)\n end",
"def destroy\n @company.destroy\n\n head :no_content\n end",
"def destroy\n @company.destroy\n redirect_to companies_url, notice: \"Company was successfully destroyed.\"\... | [
"0.86034006",
"0.8572705",
"0.8494708",
"0.84766626",
"0.83959895",
"0.83357334",
"0.8330473",
"0.8252475",
"0.815262",
"0.81016177",
"0.8101401",
"0.80640364",
"0.80359054",
"0.80227053",
"0.80147207",
"0.79973376",
"0.7991117",
"0.79716605",
"0.7946429",
"0.793928",
"0.7935... | 0.8540976 | 2 |
GET /proposals/passed GET /proposals/passed.json | def passed
# the non-preliminary ones go first
@proposals = Proposal.select{ |p| p.committee.preliminary == false and p.status == 'Passed'}
@proposals += Proposal.select{ |p| p.committee.preliminary == true and p.status == 'Passed'}
respond_to do |format|
format.html # passed.html.erb
format.json { render json: @proposals }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end",
"def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json... | [
"0.68021756",
"0.6721464",
"0.6610791",
"0.63833416",
"0.61589944",
"0.6157168",
"0.6157168",
"0.615602",
"0.61308897",
"0.6048299",
"0.5965278",
"0.5956122",
"0.5862362",
"0.5791369",
"0.57696813",
"0.57696813",
"0.57696813",
"0.5732901",
"0.5709056",
"0.56706655",
"0.564084... | 0.78760844 | 0 |
GET /proposals/1 GET /proposals/1.json | def show
@proposal = Proposal.find(params[:id])
@proposal.votes.each do |v|
if v.user == current_user
@vote = v
end
end
if can? :vote, @proposal
if @vote.nil?
@vote = @proposal.votes.new
end
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @proposal }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end",
"def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json... | [
"0.783358",
"0.7670677",
"0.7426053",
"0.7383007",
"0.7237042",
"0.7237042",
"0.7177102",
"0.7021893",
"0.70093054",
"0.68766254",
"0.6743452",
"0.6633271",
"0.6588128",
"0.6507679",
"0.64621466",
"0.64602923",
"0.64602923",
"0.64602923",
"0.63885087",
"0.6378215",
"0.6314062... | 0.63843185 | 19 |
PUT /proposals/1 PUT /proposals/1.json | def update
@proposal = Proposal.find(params[:id])
respond_to do |format|
if @proposal.update_attributes(update_params)
format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @proposal.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @proposal = listing.proposals.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.h... | [
"0.7447891",
"0.7311585",
"0.7120701",
"0.70780736",
"0.70620924",
"0.7024957",
"0.700769",
"0.69558644",
"0.68180454",
"0.67874616",
"0.6773295",
"0.66783243",
"0.6647473",
"0.6558442",
"0.6558442",
"0.6558442",
"0.6558442",
"0.6558442",
"0.6558442",
"0.6558442",
"0.6483972"... | 0.72117543 | 2 |
DELETE /proposals/1 DELETE /proposals/1.json | def destroy
@proposal = Proposal.find(params[:id])
committee = @proposal.committee
@proposal.destroy
respond_to do |format|
format.html { redirect_to committee_path(committee) }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @proposal = Proposal.find(params[:id])\n @proposal.destroy\n\n respond_to do |format|\n format.html { redirect_to proposals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @proposal = Proposal.find(params[:id])\n @proposal.destroy\n\n respond_to... | [
"0.7913258",
"0.7913258",
"0.77106977",
"0.7677443",
"0.7642395",
"0.7607506",
"0.7607506",
"0.7607506",
"0.74856466",
"0.7362166",
"0.73345053",
"0.7122501",
"0.70645434",
"0.6992418",
"0.69782144",
"0.69289726",
"0.6910627",
"0.6502949",
"0.6474011",
"0.647114",
"0.6455633"... | 0.74042296 | 9 |
XXX should be in revisioncontroller? | def revision_params
params.require(:revision).permit(:rule_text, :body, :change_description, :background, :references)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_revision\n end",
"def revisions\n raise NotImplementedError\n end",
"def revision\n 99\n end",
"def revision\r\n @revision\r\n end",
"def title\n revision.title\n end",
"def revision_class #:nodoc:\n self\n end",
"def revision_class #:nodoc:\n ... | [
"0.7037463",
"0.673076",
"0.66951185",
"0.6402124",
"0.635609",
"0.6221742",
"0.6221742",
"0.61663604",
"0.61640227",
"0.61521244",
"0.61475223",
"0.6135103",
"0.60964423",
"0.6077526",
"0.6027368",
"0.5989344",
"0.5981241",
"0.59520555",
"0.5938156",
"0.5933731",
"0.5916808"... | 0.0 | -1 |
def sum(a, b) a + b end def square(a) binding.pry a 2 end def cube(a) square(a) a end | def factorial(x)
if x == 1
1
else
x * factorial(x-1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(a, b)\n p a + b\nend",
"def sum(a, b)\n p a + b\nend",
"def sum(a,b)\n p a + b\nend",
"def square x\n puts (x * x)\nend",
"def add(x, y)\n p x+y\nend",
"def multiply(a,b)\n p a*b\nend",
"def square(a)\n a * a\nend",
"def summator(x, y)\n p x + y\nend",
"def add(a,b)\n p (a + b)\nen... | [
"0.74183464",
"0.74183464",
"0.73782516",
"0.72844267",
"0.7239701",
"0.72227305",
"0.71977866",
"0.7176084",
"0.7153587",
"0.714591",
"0.7145611",
"0.71251667",
"0.71198326",
"0.7100431",
"0.7085373",
"0.70819634",
"0.70737755",
"0.70472735",
"0.70319426",
"0.70100325",
"0.7... | 0.0 | -1 |
Get parameters for lograge | def append_info_to_payload(payload)
super
payload["params"] = request.params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_params\n params[:log]\n end",
"def log_params()\n lparms = @parameters.clone if @parameters\n lparms = {} unless lparms\n lparms[:cur_host] = @host\n lparms[:cur_port] = @port\n lparms[:cur_login] = @login\n lparms[:cur_passcode] = @passcode\n lparms[:cur_ssl] = @ss... | [
"0.72568727",
"0.6974977",
"0.6796814",
"0.6654633",
"0.64986485",
"0.639651",
"0.63504136",
"0.6282042",
"0.62636644",
"0.62636644",
"0.6207054",
"0.6097402",
"0.60580355",
"0.6000372",
"0.599456",
"0.5974364",
"0.59423983",
"0.59374064",
"0.5936171",
"0.5936171",
"0.5930091... | 0.0 | -1 |
para almacenar la tarea, se debe validar si ya existe o no, se debe utililzar un match porque en la base de datos las tareas estan con el nombre mas el nombre del usuario si la tarea no existe se crea la tarea con el nombre de la tarea y el nombre del usuario, para poder luego sacar las tareas correspondientes al usuario | def almacenar(nombre)
array = Tarea.all
@@existente = false
array.each{|x| @@existente = true if /#{nombre}/.match(x["title"])}
unless @@existente
Tarea.create("#{nombre} #{@@usuario}")
end
@@existente
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obtener\narray = Tarea.all\n \n @@tareas = Array.new\n array.each{|x| @@tareas.push(x) if /#{@@usuario}/.match(x[\"title\"])}\n\n @@tareas.each do |x|\nstring = x[\"title\"].split\n string.pop\nx[\"title\"] = string.join(\" \")\n\n\n end\n #esto es para que no quede una tarea vacia al princip... | [
"0.59642744",
"0.5899846",
"0.5511915",
"0.54818285",
"0.544675",
"0.54358274",
"0.5411925",
"0.5399754",
"0.53953266",
"0.53914344",
"0.5381514",
"0.5363181",
"0.5362122",
"0.5315221",
"0.5314342",
"0.5248974",
"0.5230554",
"0.5224633",
"0.51843625",
"0.515506",
"0.51540273"... | 0.70636255 | 0 |
obtiene las tareas correspondientes a cada usuario para mostrarla en la vista, como en la base de datos el nombre de la tarea esta con el nombre mas el usuario se debe quitar el usuario para poder mostrar solo el nombre de la tarea | def obtener
array = Tarea.all
@@tareas = Array.new
array.each{|x| @@tareas.push(x) if /#{@@usuario}/.match(x["title"])}
@@tareas.each do |x|
string = x["title"].split
string.pop
x["title"] = string.join(" ")
end
#esto es para que no quede una tarea vacia al principio, la cual es la correspondiente login
@@tareas.shift
@@tareas
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alta_profesores_lista\n\t\t@profesores = []\n\t\t@tab = \"admin\"\n\t\tusuarios = User.select('id, matricula, nombre, apellido, admin, profesor').order(:matricula)\n\t\tusuarios.each do |usuario|\n\t\t\tif (usuario.matricula[0].chr == \"l\") || (usuario.matricula[0].chr == \"L\")\n\t\t\t#se checa primero que l... | [
"0.5945775",
"0.5942997",
"0.5903607",
"0.5740135",
"0.5599673",
"0.5557967",
"0.5499954",
"0.54700273",
"0.54623455",
"0.5425284",
"0.54154193",
"0.5392129",
"0.53889495",
"0.53850555",
"0.5361046",
"0.53598773",
"0.5352898",
"0.5348539",
"0.53281385",
"0.53147465",
"0.53136... | 0.66560787 | 0 |
valida si una tarea existe, si lo esta la elimina | def eliminar(id)
@@encontrada = false
array = Tarea.all
array.each{|x| @@encontrada = true if x["id"] == id.to_i}
if @@encontrada
Tarea.destroy(id)
end
@@encontrada
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n tmp_element_error = PostitTask.new\n tmp = PostitTask.find(params[:id])\n if tmp\n name = tmp.name\n unless tmp.destroy\n tmp.errors.full_messages.each do |tmp_error| \n tmp_element_error.errors.add(:base, tmp_error)\n end\n end\n end\n if tmp_elem... | [
"0.65420526",
"0.65188605",
"0.6476775",
"0.64403194",
"0.64224887",
"0.6373143",
"0.632365",
"0.62232006",
"0.6194863",
"0.6190611",
"0.6156925",
"0.6076415",
"0.60588896",
"0.5997926",
"0.59929645",
"0.59666306",
"0.5931902",
"0.59313625",
"0.5925074",
"0.5871588",
"0.58454... | 0.69417965 | 0 |
si una tarea existe y esta desactualizada la actualiza pero si existe y esta actualizada no lo hace | def actualizar(id)
@@encontrada1 = false
@@actualizada = false
array = Tarea.all
array.each do |x|
if x["id"] == id.to_i && x["done"] == true
@@encontrada1 =true
@@actualizada= true
elsif x["id"] == id.to_i && x["done"] == false
Tarea.update(id)
@@encontrada1 = true
end
end
return @@encontrada1,@@actualizada
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actualizar_extracto_de_cuenta_corriente\n if deleted?\n CuentaCorrienteExtracto.eliminar_movimiento(self.becomes(Boleta), fecha, importe_pendiente * -1)\n else\n if persona_id_changed? && !persona_id_was.nil? # si cambio de cuenta corriente\n old = get_old_boleta\n CuentaCorriente... | [
"0.64145064",
"0.624611",
"0.6233149",
"0.61522454",
"0.6043943",
"0.5963727",
"0.5861259",
"0.58606106",
"0.58526224",
"0.5843798",
"0.5835305",
"0.5811307",
"0.5772033",
"0.57637846",
"0.57327574",
"0.5695957",
"0.5693342",
"0.5688258",
"0.56590956",
"0.56460863",
"0.562102... | 0.6222373 | 3 |
Render the error message with a status of 404 and a message letting the user know the resource does not exist. | def render_404
render(
json: {
error_messages: ['Resource does not exist'],
error_code: 'NOT_FOUND'
},
status: 404
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_missing\r\n RenderError.new('404')\r\n end",
"def not_found\n render(status: :not_found, json: { errors: [{\n status: '404', code: :not_found, title: 'Not Found'\n }]})\n # render jsonapi: nil, code: 404, title: 'Invalid Path', detail: params[:path], status: :... | [
"0.8218796",
"0.81986064",
"0.8143563",
"0.8131394",
"0.8115979",
"0.8108247",
"0.8099551",
"0.8097435",
"0.80966157",
"0.80960447",
"0.8017813",
"0.7997156",
"0.79967624",
"0.7992711",
"0.7984181",
"0.7970211",
"0.7950132",
"0.7933182",
"0.7915035",
"0.7908608",
"0.78991777"... | 0.8725738 | 0 |
points are 2d with as in [x,y] example invocation: closest_pair([[2,3], [1,4], [3,5], [2,2]]) approach: brute force complexity: O(nn) | def closest_pair1(points)
min_distance = Float::MAX
best_pair = nil
(0...points.length).each do |i|
(i...points.length).each do |j|
if i != j
curr_distance = distance1(points[i], points[j])
if curr_distance < min_distance
min_distance = curr_distance
best_pair = [points[i], points[j]]
end
end
end
end
best_pair
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(points) # array with all the points\n #copy of the array by an especific cordinate\n #nlogn\n # This is a primitive, aka operations that are costless compared to the\n # total complexity we are aming for\n px = sort_by_cordinate(points, 0)\n py = sort_by_cordinate(points, 1)\n\n result = closest_pa... | [
"0.85408145",
"0.8106821",
"0.7751728",
"0.7697608",
"0.69138294",
"0.6890541",
"0.67882025",
"0.6780664",
"0.6744194",
"0.6680858",
"0.6556518",
"0.6529613",
"0.6514368",
"0.6484864",
"0.6425766",
"0.63992155",
"0.6346496",
"0.63223886",
"0.62771577",
"0.6265098",
"0.6232421... | 0.84537935 | 1 |
px > all points sorted by their x coordinates py > all points sorted by their y coordinates | def _closest_pair(px, py)
nx, ny = px.length, py.length
return [px[0], py[0]] if nx == 1 and ny == 1
return best([px[0], px[1]], [py[0], py[1]]) if nx == 2 and ny == 2
qx, rx, qy, ry = px[0...nx/2], px[nx/2...nx], py[0...ny/2], py[ny/2...ny]
qpair = _closest_pair(qx, qy)
rpair = _closest_pair(rx, ry)
min_dist = [distance(qpair[0], qpair[1]), distance(rpair[0], rpair[1])].min
split_pair = closest_split_pair(px, py, min_dist)
best(qpair, rpair, split_pair)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def points\n [top_left, top_right, bottom_left, bottom_right]\n end",
"def sorted_x\n @sorted_x ||= [start_point.x, end_point.x].sort\n end",
"def y_points\n points = []\n (0...width).each do |x|\n (0...height).reverse_each do |y|\n if (array[y][x]).nonzero? && (y + 1 >= height ||... | [
"0.6760582",
"0.6673579",
"0.6670379",
"0.6607183",
"0.66027606",
"0.6515585",
"0.6399834",
"0.63084525",
"0.6298823",
"0.62878114",
"0.62847793",
"0.6271636",
"0.62151116",
"0.6192268",
"0.6185999",
"0.61644",
"0.6112506",
"0.61103016",
"0.60958165",
"0.6049482",
"0.6034011"... | 0.54595035 | 74 |
Returns if account number is already present, else continues to generate a token | def generate_account_number
return if account_number.present?
self.account_number = generate_account_number_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_account_number_token\n loop do\n token = SecureRandom.hex(3).upcase\n break token unless User.find_by(account_number: token)\n end\n end",
"def generate_auth_token\n loop do \n token = SecureRandom.hex\n break token unless self.class.exists?(auth_token: token)\n end\... | [
"0.7797333",
"0.7063733",
"0.6776236",
"0.6755165",
"0.6741222",
"0.670835",
"0.6672453",
"0.66361755",
"0.6619657",
"0.6612816",
"0.6607426",
"0.65576863",
"0.65078455",
"0.6486288",
"0.6486288",
"0.6439464",
"0.64173603",
"0.6401108",
"0.6376855",
"0.637618",
"0.6359196",
... | 0.7640776 | 1 |
SecureRandom.hex(3) gives a 6 character long alphanumeric string which will be upcased before saving. If we want to change the length of account number, change the number here. The character length will be twice the number_of_bytes that we pass in as argument. SecureRandom.hex(3) => "2c1083" SecureRandom.hex(4) => "2bb093ed" | def generate_account_number_token
loop do
token = SecureRandom.hex(3).upcase
break token unless User.find_by(account_number: token)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_account_number\r\n acct_num = rand(10**11).to_s.rjust(11, '1')\r\n return acct_num\r\n end",
"def random_hex(len=16)\n raise NotImplementedError\n SecureRandom.hex(len)\nend",
"def new_account_number\n return rand(99999999)\n end",
"def new_account_number\n return rand(9... | [
"0.7158446",
"0.712532",
"0.7117916",
"0.7117916",
"0.7103283",
"0.70025915",
"0.6944367",
"0.6851234",
"0.68287796",
"0.68034685",
"0.67911935",
"0.6709046",
"0.66102356",
"0.66062856",
"0.66043776",
"0.66009974",
"0.65993917",
"0.6586957",
"0.6582496",
"0.6579175",
"0.65467... | 0.65648484 | 20 |
Use callbacks to share common setup or constraints between actions. | def set_movielist
@movielist = Movielist.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.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def movielist_params
params.require(:movielist).permit(:movie_id, :list_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Usr Bin Crash puzzle Kanwei Li, 2009 From memoize gem | def memoize(name)
cache = {}
(class<<self; self; end).send(:define_method, name) do |*args|
cache[args] = super unless cache.has_key?(args)
cache[args]
end
cache
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def memo; end",
"def memo\n end",
"def memo=(_arg0); end",
"def gen_washing\r\r\n end",
"def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n pr... | [
"0.6939625",
"0.6509942",
"0.5713137",
"0.5653655",
"0.5631309",
"0.5526025",
"0.5495748",
"0.54901093",
"0.5465837",
"0.54655796",
"0.54559904",
"0.5449411",
"0.5444663",
"0.54371756",
"0.54044294",
"0.53928345",
"0.5390152",
"0.53773975",
"0.5370268",
"0.5365193",
"0.535972... | 0.0 | -1 |
Store array of items as a global so we don't have to pass it around Recursive is clean but blows stack on large inputs! | def optimize(weight)
return 0 if weight <= 0
best = nil
$items.each do |item|
c = optimize(weight - item.weight) + item.cost
best = c if best.nil? || c < best
end
best
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def items; @items.clone end",
"def enqueue(items)\n @in_stack = []\n items.each { |item| @in_stack << item }\nend",
"def items\n @items ||= []\n end",
"def get_items\n\t\t@arr\n\tend",
"def all_items\r\n list = Array.new\r\n items.each{ |item| list.push(item)}\r\n list\r\n e... | [
"0.5740575",
"0.5699575",
"0.5669918",
"0.5640651",
"0.55961436",
"0.55216527",
"0.55216354",
"0.54467195",
"0.5440653",
"0.5433007",
"0.5420189",
"0.53713655",
"0.53476924",
"0.5341562",
"0.5326156",
"0.5321798",
"0.5321605",
"0.5318663",
"0.53123057",
"0.52989674",
"0.52812... | 0.0 | -1 |
Finally, something that works, somewhat ugly though =\ | def optimize3(weight, cost=0, items = $items)
return cost if weight <= 0 || items.empty?
# puts "#{weight}\t#{cost}\t#{items.collect{|i| i.weight}.join(' ')}"
same_ratio = items.find_all { |i| i.ratio == items[0].ratio }
global_best = nil
same_ratio.size.times do |x|
if weight % items[x].weight == 0
return items[x].cost * (weight / items[x].weight) + cost
end
best = (x == 0) ? items[x].cost * (weight / items[x].weight + 1) + cost : nil
(items - [items[x]]).each do |item|
if x == 0
c = optimize3(weight % items[x].weight, items[x].cost * (weight / items[x].weight) + cost, items - [items[x]])
else
c = optimize3(weight - items[x].weight, items[x].cost + cost, items)
end
best = c if (best.nil? || c < best)
end
global_best = best if best && (global_best.nil? || best < global_best)
end
global_best
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def escaper; end",
"def probers; end",
"def private; end",
"def finalize!; end",
"def final; end",
"def finalized; end",
"def schubert; end",
"def terpene; end",
"def escaper=(_); end",
"def berlioz; end",
"def rassoc(p0) end",
"def original_result; end",
"def original; end",
"def hiss; e... | [
"0.5907005",
"0.58743",
"0.57806504",
"0.5761968",
"0.5761125",
"0.57155097",
"0.56638974",
"0.5642834",
"0.56424576",
"0.5517063",
"0.5429609",
"0.5425099",
"0.539132",
"0.53842324",
"0.5383482",
"0.53655034",
"0.5355179",
"0.5343857",
"0.5343857",
"0.5343857",
"0.5343857",
... | 0.0 | -1 |
shows all posts | HTML GET REQUEST | def index
@articles = Article.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t@posts = list_posts\n end",
"def index\n # TODO: implement listing all posts\n end",
"def index\n\t\t@posts = Post.order('created_at DESC').where(status:true).page(params[:page]).per(10)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\tend\n\tend",
"def index\n\t\t@posts = Post.all\n\t\t... | [
"0.79067683",
"0.77236617",
"0.76746476",
"0.76382035",
"0.76263076",
"0.75548047",
"0.75131756",
"0.75066006",
"0.7471579",
"0.7424324",
"0.7418772",
"0.739495",
"0.7369397",
"0.73656404",
"0.73656404",
"0.73656404",
"0.73656404",
"0.7361862",
"0.7358644",
"0.7338148",
"0.73... | 0.0 | -1 |
shows the specified post | HTML GET REQUEST | def show
@article = Article.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n provides :xml, :json\n \n @post = Post[params[:id]]\n \n if content_type == :html\n render\n else\n display @post\n end\n end",
"def display_post\n begin\n # asks the user for the post id\n print \"Enter the post ID: \"\n id = STDIN.gets.chomp\n r... | [
"0.74067384",
"0.72723067",
"0.7238035",
"0.7180139",
"0.70329213",
"0.70030636",
"0.69749856",
"0.69275206",
"0.69186425",
"0.6901656",
"0.6890421",
"0.68674827",
"0.68652225",
"0.6853499",
"0.6815958",
"0.6811897",
"0.6811784",
"0.6811784",
"0.680041",
"0.6791802",
"0.67885... | 0.0 | -1 |
shows the 'new' post view | HTML GET REQUEST | def new
@article = Article.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html\n end\n end",
"def new\n\t\t@post = Post.new\n\t\trender :new\n\tend",
"def new\n @post = Post.new\n render :new\n end",
"def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # ... | [
"0.8336588",
"0.82702637",
"0.8258363",
"0.8224554",
"0.8113327",
"0.8089222",
"0.808262",
"0.8077111",
"0.8042758",
"0.8036729",
"0.8026767",
"0.8023611",
"0.80227154",
"0.80070585",
"0.8004633",
"0.79964083",
"0.79953367",
"0.79953367",
"0.79953367",
"0.79953367",
"0.799533... | 0.0 | -1 |
shows the specified post page to be edited | HTML GET REQUEST | def edit
@article = Article.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n post = Post.find_by(id: params[:id])\n redirect_to admin_preview_post_path(post)\n end",
"def edit\n \t\t@post = Post.find(params[:id])\n\tend",
"def edit # Showing edit form\n @post = Post.find(params[:id])\n end",
"def edit\n\t\t@post = Post.find(params[:id])\n\t\trender layout: \"ad... | [
"0.7095083",
"0.7075483",
"0.70543313",
"0.70260066",
"0.701512",
"0.70120955",
"0.6999625",
"0.69994766",
"0.69994766",
"0.6979481",
"0.6975455",
"0.6971174",
"0.6970981",
"0.6964401",
"0.6905543",
"0.68873066",
"0.68873066",
"0.68873066",
"0.68873066",
"0.68873066",
"0.6887... | 0.0 | -1 |
creates the new post and redirects to the new post | HTML POST REQUEST | def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @post = Post.create(post_params)\n\n # post_url comes from the prefix from our route\n redirect_to post_url(@post)\n end",
"def create\n #binding.pry\n # saving the post w/the form values into the database\n @post = Post.new(post_params) #call a new method as params - post in memo... | [
"0.7568445",
"0.7492326",
"0.747756",
"0.7451638",
"0.74442595",
"0.7400156",
"0.73955595",
"0.73916566",
"0.73732984",
"0.7320908",
"0.73159105",
"0.7314909",
"0.731061",
"0.73059666",
"0.7303393",
"0.72902817",
"0.7288135",
"0.7243147",
"0.72224844",
"0.7213529",
"0.7212501... | 0.0 | -1 |
updates the specified post and redirects to the updated post if valid, else it renders the edit page again. using 'render' rather than redirect_to allows the new params to be passed back, rather than erasing the fields HTML PATCH REQUEST | def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @post.update(post_params)\n redirect_to find_redirect(@post.page)\n else\n render :edit\n end\n end",
"def update\n\n if @post.update(post_params)\n redirect_back fallback_location: posts_url\n else\n render :edit\n end\n\n end",
"def ... | [
"0.84780616",
"0.83904874",
"0.8348372",
"0.8348372",
"0.8319848",
"0.8243668",
"0.8222979",
"0.81953883",
"0.8185828",
"0.8176769",
"0.8105336",
"0.80838174",
"0.80635417",
"0.8052036",
"0.8024737",
"0.80176914",
"0.79997677",
"0.79912806",
"0.7968001",
"0.79638594",
"0.7958... | 0.0 | -1 |
delete/destroy the specified post and redirects to the index | HTML DELETE REQUEST | def destroy
@article = Article.find(params[:id])
@article.destroy
redirect_to articles_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id]) #get the post from the id\n @post.destroy #removes the post\n\n redirect_... | [
"0.80750906",
"0.8056547",
"0.7964666",
"0.7933301",
"0.7917598",
"0.79012513",
"0.79012513",
"0.7900041",
"0.7894067",
"0.7885436",
"0.7873013",
"0.78465664",
"0.7806917",
"0.7804072",
"0.7795087",
"0.77905947",
"0.77826655",
"0.7772118",
"0.7767866",
"0.7748845",
"0.7741707... | 0.0 | -1 |
before_action :authorized helper_method :current_teller, logged_in? | def login(teller)
session[:teller_id] = @teller.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorized?\nlogged_in?\nend",
"def authorized?\n logged_in?\n end",
"def authorized?\n logged_in?\n end",
"def authorized?\n current_user.logged_in?\n end",
"def logged_in?\n authorized?\n end",
"def authorized?\n logged_in? && current_user.login == \"ej0c\"\n end",
"def logged... | [
"0.72957486",
"0.70217824",
"0.70217824",
"0.6943583",
"0.68494284",
"0.6810842",
"0.6760369",
"0.6719593",
"0.6699607",
"0.6688314",
"0.6677354",
"0.66520834",
"0.66520834",
"0.6642485",
"0.6606555",
"0.65748537",
"0.65519464",
"0.6549269",
"0.6549269",
"0.6549269",
"0.65492... | 0.0 | -1 |
This function takes in all of the smoothie ingredients, chops and mixes them up, and outputs a string of mixed characters, removing any whitespace. | def blend(smoothie_ingredients)
# retrieves only the food items and not the measurements
return smoothie_ingredients.keys.join.delete(" ").split('').shuffle!.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blend(ingredients)\n smoothie = ''\n ingredients.each do |x,y|\n smoothie += x\n end\n puts smoothie.gsub(/\\s+/, \"\").split(\"\").shuffle!.join\nend",
"def blend(smoothie_ingredients)\n mix_ingredients = smoothie_ingredients.keys.join.split(//).shuffle\n return mix_ingredients.join.delete(\" \")\n... | [
"0.68733984",
"0.6839143",
"0.6540903",
"0.61374545",
"0.5888506",
"0.58621943",
"0.5845411",
"0.5831066",
"0.5780377",
"0.5769432",
"0.57523984",
"0.5745507",
"0.5734754",
"0.572601",
"0.5702836",
"0.558994",
"0.5587249",
"0.5564574",
"0.55623424",
"0.55589384",
"0.55501854"... | 0.6229944 | 3 |
GET /meetings GET /meetings.xml | def index
@meetings = Meeting.recent
@past_meetings = Meeting.recent.past
@upcoming_meetings = Meeting.upcoming
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @meetings }
format.atom
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_meetings\n prepare\n @api.get_meetings\n end",
"def index\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json do\n out = meetings.per(500).map(&:to_json_attributes)\n out.each { |m| m[:url] = meeting_path(m[:url]) }\n r... | [
"0.73006713",
"0.7228295",
"0.7150945",
"0.71381956",
"0.70992327",
"0.70992327",
"0.70992327",
"0.70992327",
"0.70992327",
"0.70992327",
"0.7081934",
"0.70216846",
"0.7017986",
"0.69139695",
"0.68607235",
"0.678778",
"0.6680968",
"0.6652381",
"0.6564465",
"0.65491414",
"0.64... | 0.75696325 | 0 |
GET /meetings/1 GET /meetings/1.xml | def show
@meeting = Meeting.find(params[:id])
if @meeting
@attendee = @meeting.attendee_with_user(current_user) || Attendee.new
@attendees = @meeting.attendees.find_all_by_rsvp("Yes")
end
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @meeting }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @meetings = Meeting.recent\n @past_meetings = Meeting.recent.past\n @upcoming_meetings = Meeting.upcoming\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meetings }\n format.atom\n end\n end",
"def show\n @meeting = Meeting.f... | [
"0.7432931",
"0.7222755",
"0.7093803",
"0.6994988",
"0.69380337",
"0.69144934",
"0.6865746",
"0.6850136",
"0.68181527",
"0.6812334",
"0.67647654",
"0.6715466",
"0.6715466",
"0.6715466",
"0.6715466",
"0.6715466",
"0.6715466",
"0.66911983",
"0.6554662",
"0.645799",
"0.645799",
... | 0.6378646 | 22 |
GET /meetings/new GET /meetings/new.xml | def new
@meeting = Meeting.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @meeting }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @meeting = Meeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n end\n end",
"def new\n @meeting = Meeting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting }\n ... | [
"0.7177989",
"0.7177989",
"0.7177989",
"0.7172814",
"0.69502544",
"0.68651795",
"0.68575746",
"0.68321866",
"0.67510706",
"0.672825",
"0.67152536",
"0.66885686",
"0.66578853",
"0.66542256",
"0.6652893",
"0.66417617",
"0.6626984",
"0.6626984",
"0.66234565",
"0.66234565",
"0.66... | 0.7672542 | 1 |
POST /meetings POST /meetings.xml | def create
@meeting = Meeting.new(params[:meeting])
respond_to do |format|
if @meeting.save
flash[:notice] = 'Meeting was successfully created.'
format.html { redirect_to(@meeting) }
format.xml { render :xml => @meeting, :status => :created, :location => @meeting }
else
format.html { render :action => "new" }
format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @meeting = current_user.meetings.new(meeting_params)\n new_event(@meeting)\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to new_event_path, notice: 'Meeting was successfully created.' }\n else\n format.html { render :new }\n format.json { ... | [
"0.6385355",
"0.63697445",
"0.63660413",
"0.6332388",
"0.6302386",
"0.6289513",
"0.62788576",
"0.6221645",
"0.6170628",
"0.6160674",
"0.614793",
"0.61457247",
"0.60964406",
"0.6095229",
"0.60608953",
"0.606086",
"0.60464096",
"0.60216075",
"0.60052437",
"0.59765655",
"0.59733... | 0.63848025 | 1 |
PUT /meetings/1 PUT /meetings/1.xml | def update
@meeting = Meeting.find(params[:id])
respond_to do |format|
if @meeting.update_attributes(params[:meeting])
flash[:notice] = 'Meeting was successfully updated.'
format.html { redirect_to(@meeting) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @meet = Meet.find(params[:id])\n\n respond_to do |format|\n if @meet.update_attributes(params[:meet])\n format.html { redirect_to @meet, notice: 'Meet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | [
"0.6736497",
"0.67130566",
"0.6698899",
"0.6501453",
"0.64961463",
"0.64853835",
"0.64713913",
"0.6402791",
"0.6387426",
"0.6382748",
"0.6344773",
"0.63203645",
"0.62660897",
"0.62633264",
"0.6178516",
"0.61440146",
"0.6125862",
"0.61159986",
"0.61159945",
"0.6113205",
"0.608... | 0.66743153 | 3 |
DELETE /meetings/1 DELETE /meetings/1.xml | def destroy
@meeting = Meeting.find(params[:id])
@meeting.destroy
respond_to do |format|
format.html { redirect_to(meetings_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n meeting.destroy\n\n respond_to do |format|\n format.html { redirect_to( committee_meetings_url( meeting.committee ),\n flash: { success: \"Meeting destroyed.\" } ) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @meetup = Meetup.find(params[:id])\n @meetup... | [
"0.7192475",
"0.71921545",
"0.71268713",
"0.707988",
"0.7069304",
"0.7069304",
"0.7069304",
"0.7014493",
"0.7010651",
"0.7009012",
"0.6978566",
"0.6970698",
"0.69154376",
"0.69109815",
"0.690946",
"0.6866191",
"0.68227875",
"0.6816975",
"0.68023515",
"0.6794282",
"0.6767315",... | 0.7587487 | 1 |
Ignored by Nanoc 3 | def get_filter(db, fid)
filter = db[:text_filters].where("id = ?", fid).get(:name).downcase
# Multiple filters are not handled (e.g. markdown smartypants)
filter = filter.split(' ')[0]
# Prepare metadata
case filter
when 'textile' then
return ['redcloth'], 'textile'
when 'markdown' then
return ['bluecloth'], 'markdown'
when 'bbcode' then
return ['bbcode'], 'bbcode'
else
return [], 'txt'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ignores; end",
"def doc; end",
"def doc; end",
"def doc; end",
"def doc; end",
"def ignore; end",
"def pre #:doc:\n end",
"def private; end",
"def doc=(_arg0); end",
"def doc=(_arg0); end",
"def doc=(_arg0); end",
"def missing; end",
"def docs=(_arg0); end",
"def document=(_arg0); en... | [
"0.6449991",
"0.62031597",
"0.62031597",
"0.62031597",
"0.62031597",
"0.6191442",
"0.6183876",
"0.6173716",
"0.614977",
"0.614977",
"0.614977",
"0.60011095",
"0.6001013",
"0.5989082",
"0.5989082",
"0.5989082",
"0.5989082",
"0.5989082",
"0.5989082",
"0.5989082",
"0.5989082",
... | 0.0 | -1 |
Add top tweets data onto feeds GET /feeds_with_top_tweets | def feeds_with_top_tweets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feed_tweets(max_tweets = nil, latest_date = nil )\n @tweets = Tweet.joins(:user)\n .joins(\"LEFT OUTER JOIN follows ON users.id = follows.followee_id\")\n .where(\"tweets.user_id = :id OR follows.follower_id = :id\", id: self.id)\n .order(\"tweets.created_at DESC\")\n .uniq\n #debugge... | [
"0.7275259",
"0.7072762",
"0.6885682",
"0.68314815",
"0.670396",
"0.6624022",
"0.66227055",
"0.6522871",
"0.6467999",
"0.64549625",
"0.6415657",
"0.64075404",
"0.637743",
"0.6356602",
"0.63205814",
"0.6310111",
"0.6289296",
"0.62812",
"0.62709296",
"0.6202506",
"0.6184749",
... | 0.8702587 | 0 |
Symlink the dynamic linker, ld.so | def symlink_ld_so
ld_so = HOMEBREW_PREFIX/"lib/ld.so"
return if ld_so.readable?
sys_interpreter = [
"/lib64/ld-linux-x86-64.so.2",
"/lib/ld-linux.so.3",
"/lib/ld-linux.so.2",
"/lib/ld-linux-armhf.so.3",
"/lib/ld-linux-aarch64.so.1",
"/system/bin/linker",
].find do |s|
Pathname.new(s).executable?
end
raise "Unable to locate the system's ld.so" unless sys_interpreter
interpreter = begin
glibc = Formula["glibc"]
glibc.installed? ? glibc.lib/"ld-linux-x86-64.so.2" : sys_interpreter
rescue FormulaUnavailableError
sys_interpreter
end
FileUtils.mkdir_p HOMEBREW_PREFIX/"lib"
FileUtils.ln_sf interpreter, ld_so
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_link_hook(linker)\n basic_name = get_basic_name(linker)\n soname = get_soname(linker)\n symlink_lib_to basic_name\n symlink_lib_to soname\n end",
"def post_link_hook(linker, bb)\n basic_name = get_basic_name(linker, bb)\n symlink_lib_to(basic_name, bb)\n end",
"def ... | [
"0.7580968",
"0.7148825",
"0.7120533",
"0.6471518",
"0.63533896",
"0.6184087",
"0.61486834",
"0.58158135",
"0.57919675",
"0.5790475",
"0.57530034",
"0.5734655",
"0.5685838",
"0.5631665",
"0.56026757",
"0.5596154",
"0.55924875",
"0.5586103",
"0.55793375",
"0.55639243",
"0.5557... | 0.82425684 | 0 |
Symlink the host's compiler | def symlink_host_gcc
version = DevelopmentTools.non_apple_gcc_version "/usr/bin/gcc"
return if version.null?
suffix = (version < 5) ? version.to_s[/^\d+\.\d+/] : version.to_s[/^\d+/]
return if File.executable?("/usr/bin/gcc-#{suffix}") || File.executable?(HOMEBREW_PREFIX/"bin/gcc-#{suffix}")
FileUtils.mkdir_p HOMEBREW_PREFIX/"bin"
["gcc", "g++", "gfortran"].each do |tool|
source = "/usr/bin/#{tool}"
dest = HOMEBREW_PREFIX/"bin/#{tool}-#{suffix}"
next if !File.executable?(source) || File.executable?(dest)
FileUtils.ln_sf source, dest
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link(filename, outdir, platform='linux')\n f = base(filename)\n cmd, args = *case platform\n when 'darwin'\n ['gcc', '-arch i386']\n when 'linux'\n ['ld', '']\n else\n raise \"unsupported platform: #{platform}\"\n ... | [
"0.6607594",
"0.61349684",
"0.6115538",
"0.59941584",
"0.59676796",
"0.5895924",
"0.587867",
"0.5805132",
"0.577564",
"0.5770861",
"0.57555145",
"0.57321453",
"0.57066673",
"0.5703489",
"0.5626191",
"0.5576637",
"0.5545239",
"0.5505228",
"0.5503875",
"0.5474848",
"0.54355013"... | 0.7200219 | 0 |
Sjaak van den Berg | def pattern(n)
if n <= 1 # number is 1 or lower
return ''
else # number is 2 or higher
# for each number from 1 up to n, select only the even numbers
# and print that number the amount of times equal to the number
# and follow up with a new line for each unique even number
(1..n).select(&:even?).map do |x|
x.times { print "#{x}" }
print "\n"
# return output
# print "\n"
# return x
# if n > 3
# return "#{x}" * x
# else
# return "#{x}" * x + "\n"
# end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schubert; end",
"def schumann; end",
"def zuruecksetzen()\n end",
"def berlioz; end",
"def bellini; end",
"def berg; end",
"def suivre; end",
"def sichtbar_machen()\n @dach.sichtbar_machen\n @gebaedekoerpe.sichtbar_machen\n @fenster.sichtbar_machen\n @tuer.sichtbar_machen\n end",
... | [
"0.7576614",
"0.70595306",
"0.6850953",
"0.68300265",
"0.6652317",
"0.6635704",
"0.64665234",
"0.63879704",
"0.6330819",
"0.6307666",
"0.62543666",
"0.6253937",
"0.624926",
"0.6169856",
"0.61295396",
"0.6115479",
"0.6113548",
"0.6109211",
"0.6101353",
"0.60676706",
"0.6044888... | 0.0 | -1 |
collects all owner instances | def initialize(name) # takes name as input
@name = name # instance variable for person name
@species = "human" # set species to human
@@all << self # pushes each instance to @@all array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owners\n self.cars.map{|car_instance| car_instance.owner}.uniq\n end",
"def owners\n return @owners\n end",
"def objects\n @objects ||= population_group_members.collect(&:objects).flatten.uniq\n end",
"def owners\n @obj['owners']\n end",
"def instances\n Egi... | [
"0.661263",
"0.6466205",
"0.6305786",
"0.6274701",
"0.6246703",
"0.622373",
"0.6196797",
"0.6129333",
"0.6098595",
"0.6012128",
"0.60044944",
"0.5979221",
"0.59784985",
"0.5953312",
"0.5952858",
"0.59420705",
"0.59360725",
"0.5903167",
"0.5897607",
"0.58966917",
"0.58838564",... | 0.0 | -1 |
given a dropdown list, return the list items as an array of strings with symbols for header or divider | def dropdown_list_items(list)
css_select(list, "li").map do |item|
if item['class'] && item['class'].include?("divider")
:divider
elsif item['class'] && item['class'].include?("dropdown-header")
{ :header => item.text.strip }
else
item.text.strip
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_options(items)\n items.map do |item|\n if item.is_a?(Array)\n \"<option value=\\\"#{item.last}\\\">#{item.first}</option>\"\n else\n \"<option value=\\\"#{item}\\\">#{item}</option>\"\n end\n end.join(\"\\n\")\n end",
"def format_for_dr... | [
"0.6703572",
"0.6472989",
"0.6442024",
"0.6339355",
"0.625227",
"0.62237626",
"0.6216079",
"0.6163029",
"0.6160544",
"0.6160544",
"0.61278826",
"0.6117026",
"0.6082532",
"0.60705376",
"0.60685676",
"0.6016247",
"0.59884906",
"0.59873635",
"0.5909746",
"0.5871464",
"0.57388884... | 0.73770213 | 1 |
GET /inversions GET /inversions.json | def index
permission_denied and return if current_user.cannot 'read_inversion'
@inversions = Inversion.all
@new_inversion = Inversion.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def versions\n JSON.parse(RestClient.get(\"#{VERSION_URL}/.json\", self.default_headers))[\"versions\"].collect { |v| v[\"id\"] }.uniq\n end",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", arg... | [
"0.6828426",
"0.6658833",
"0.6615265",
"0.656496",
"0.6462295",
"0.6443544",
"0.634676",
"0.6336408",
"0.6273345",
"0.62544596",
"0.6249097",
"0.6248858",
"0.61608666",
"0.6144573",
"0.6137064",
"0.6088992",
"0.6064875",
"0.5995043",
"0.59650743",
"0.5959151",
"0.58936846",
... | 0.6722068 | 1 |
GET /inversions/1 GET /inversions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def versions\n JSON.parse(RestClient.get(\"#{VERSION_URL}/.json\", self.default_headers))[\"versions\"].collect { |v| v[\"id\"] }.uniq\n... | [
"0.6979076",
"0.6932634",
"0.69099915",
"0.6688635",
"0.6681855",
"0.6679537",
"0.6670666",
"0.6663171",
"0.6652113",
"0.6604293",
"0.65808433",
"0.6558361",
"0.653319",
"0.64946985",
"0.64667904",
"0.6430677",
"0.64031637",
"0.6290831",
"0.6237408",
"0.6228973",
"0.6227888",... | 0.0 | -1 |
POST /inversions POST /inversions.json | def create
permission_denied and return if current_user.cannot 'create_inversion'
@inversion = Inversion.new(inversion_params)
respond_to do |format|
if @inversion.save
format.html { redirect_to inversions_url, success: @inversion.table_name_to_show.concat( ' fue creada satisfactoriamente.') }
format.json { render :show, status: :created, location: @inversion }
else
format.html { render :new }
format.json { render json: @inversion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n permission_denied and return if current_user.cannot 'read_inversion'\n @inversions = Inversion.all\n @new_inversion = Inversion.new\n end",
"def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend",
"def create\n version_attributes = params.require(:version).permit(:... | [
"0.6122786",
"0.5995528",
"0.59828323",
"0.58740574",
"0.5815153",
"0.5805874",
"0.5504974",
"0.54876375",
"0.5440713",
"0.54056454",
"0.5298512",
"0.52474576",
"0.51993805",
"0.51987857",
"0.5129507",
"0.5112156",
"0.5097236",
"0.5069937",
"0.50551194",
"0.5051203",
"0.50483... | 0.6142687 | 0 |
PATCH/PUT /inversions/1 PATCH/PUT /inversions/1.json | def update
permission_denied and return if current_user.cannot 'update_inversion'
respond_to do |format|
if @inversion.update(inversion_params)
format.html { redirect_to inversion_url, success: @inversion.table_name_to_show.concat( ' fue actualizado satisfactoriamente.') }
format.json { render :show, status: :ok, location: @inversion }
else
format.html { render :edit }
format.json { render json: @inversion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aos... | [
"0.6500243",
"0.6379029",
"0.6197282",
"0.6197282",
"0.6197282",
"0.6192458",
"0.6028327",
"0.6007387",
"0.59853804",
"0.59819144",
"0.59643567",
"0.59149766",
"0.5907336",
"0.5897103",
"0.5831606",
"0.57979035",
"0.5796307",
"0.5796307",
"0.57659876",
"0.57554513",
"0.573842... | 0.6464035 | 1 |
DELETE /inversions/1 DELETE /inversions/1.json | def destroy
permission_denied and return if current_user.cannot 'destroy_inversion'
@inversion.destroy
respond_to do |format|
format.html { redirect_to inversions_url, success: 'Inversion fue eliminado satisfactoriamente.' }
format.json { head :no_content }
format.js { render 'layouts/destroy' }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n @instrument_version.destroy\n\n respond_to do |format|\n format.html { redirect_to(instrument_versions_url) }\n ... | [
"0.77067125",
"0.7021626",
"0.6898421",
"0.6860792",
"0.6814764",
"0.67798084",
"0.6777002",
"0.67765176",
"0.67662334",
"0.6682487",
"0.65991765",
"0.65686244",
"0.65317816",
"0.6496022",
"0.6474038",
"0.6468849",
"0.645475",
"0.64395833",
"0.64281034",
"0.64163375",
"0.6401... | 0.66536504 | 10 |
Use callbacks to share common setup or constraints between actions. | def set_inversion
@inversion = Inversion.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 inversion_params
params.require(:inversion).permit(:code, :description, :alias)
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 |
overwrites current password with its hash | def hash_password!
@password = BCrypt::Password.create(@password)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password=(new_password); end",
"def update_hash!(password)\n self.password = password\n hash_password\n save\n end",
"def hash_new_password\n self.password = BCrypt::Password.create(@new_password)\n end",
"def hash_new_password\n self.password = BCrypt::Password.create(@n... | [
"0.80666226",
"0.79818887",
"0.7891975",
"0.7841877",
"0.7795894",
"0.7795579",
"0.77386457",
"0.7709716",
"0.77044505",
"0.76443547",
"0.7610888",
"0.760723",
"0.7571119",
"0.7560734",
"0.75541925",
"0.7538848",
"0.7512936",
"0.7512936",
"0.75051266",
"0.7495999",
"0.7479781... | 0.73712903 | 31 |
checks if given password matches with the user's | def password_match? password
BCrypt::Password.new(@password) == password
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def passwords_match?\n context.user.password == context.password\n end",
"def matching_password?(pass)\n self.password_hash == encrypt_password(pass)\n end",
"def password_match?(entered_password = '')\n password == User.hash_with_salt(entered_password, salt)\n end",
"def password_match?(password... | [
"0.86199653",
"0.8453933",
"0.81589735",
"0.8134479",
"0.8134479",
"0.8130134",
"0.8130134",
"0.81194365",
"0.8072656",
"0.80581415",
"0.80513275",
"0.79164684",
"0.7905791",
"0.7898164",
"0.7897955",
"0.787927",
"0.787927",
"0.78194946",
"0.7812218",
"0.780571",
"0.78033835"... | 0.8130207 | 5 |
generates and saves an random API key | def generate_api_key!
@api_key = Digest::SHA1.hexdigest((Time.now.to_f + rand(100) * rand()).to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_api_key\n key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12345678).to_s)[1..10]\n self.api_key = self._id.to_s + key\n end",
"def generate_api_key\n key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12345678).to_s)[1..10]\n self.api_key = self._id.to_s + key\n end",
"def generate_... | [
"0.8663579",
"0.8663579",
"0.8597357",
"0.8509766",
"0.84947217",
"0.8459179",
"0.83940005",
"0.83940005",
"0.8358565",
"0.82222754",
"0.819442",
"0.81201404",
"0.8104667",
"0.8020866",
"0.80207604",
"0.79967225",
"0.79954904",
"0.7971065",
"0.7943076",
"0.7903435",
"0.790343... | 0.86330414 | 2 |
list all natural numbers below limit that are multiples of 3 or 5 collects correct multiples of natural numbers below limit | def collect_multiples(limit)
multiples = []
(1...limit).each do |num|
multiples << num if (num % 3 == 0 || num % 5 == 0)
end
return multiples
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_multiples(limit)\n multiples = []\n numbers = (1..limit.to_i-1).to_a\n numbers.each do |i|\n if i % 3 == 0 || i % 5 == 0\n multiples.push(i)\n end\n end\n multiples \nend",
"def multiples_of_3_or_5(max)\n multiples = []\n for i in 3...max #two dots are inclusive, three do... | [
"0.7995934",
"0.7860386",
"0.7824288",
"0.7802197",
"0.7740848",
"0.7726163",
"0.7702223",
"0.76687694",
"0.763893",
"0.76187193",
"0.75940394",
"0.75856316",
"0.7561259",
"0.7499732",
"0.74889857",
"0.73814625",
"0.7367339",
"0.7303635",
"0.72721547",
"0.7257886",
"0.7250479... | 0.7851614 | 2 |
returns correct sum of multiples of 10 | def sum_multiples(limit)
multiples = collect_multiples(limit)
# return multiples.sum
return multiples.inject(0){|sum,n| sum + n }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sumdig_r(n)\n\n # puts \"#{n} and n /10 is #{n/10} and n%10 is #{n%10}\"\n\n if (n<10) \n return n\n else\n return n%10 + sumdig_r(n/10)\n end\nend",
"def sumdig_r(n)\n return n if n < 10\n (n%10) + sumdig_r(n/10)\nend",
"def modulo_10_method\n if @summed_array % 10 == 0\n true\n els... | [
"0.7196691",
"0.70145065",
"0.6914927",
"0.6913369",
"0.6868571",
"0.6838614",
"0.6735893",
"0.6732372",
"0.6712404",
"0.66845804",
"0.666835",
"0.6656885",
"0.66330254",
"0.6621975",
"0.66203463",
"0.6614378",
"0.65880513",
"0.6582631",
"0.657155",
"0.6567223",
"0.65586066",... | 0.0 | -1 |
Returns my accounts as Padma::Account objects | def padma_accounts
return nil if self.accounts.nil?
self.accounts.map{|a|PadmaAccount.new(a)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accounts\n Management::Account.all(self)\n end",
"def accounts\n\t\treturn @accounts\n\tend",
"def accounts\n response = query_api(\"/rest/accounts\")\n return response[\"accounts\"].map {|account| Account.new(self, account)}\n end",
"def get_accounts\n @accounts = Account.all\n ... | [
"0.7751779",
"0.7661673",
"0.7652608",
"0.7641887",
"0.7597057",
"0.75443",
"0.754061",
"0.752987",
"0.75099534",
"0.74770606",
"0.74174017",
"0.7405429",
"0.71041197",
"0.70661867",
"0.70654166",
"0.70612395",
"0.70393413",
"0.7033915",
"0.7000612",
"0.69850373",
"0.6976003"... | 0.8455378 | 0 |
Returns me enabled accounts as Padma::Account objects | def enabled_accounts
return [] if self.accounts.nil?
self.accounts.reject{|a|!a['enabled']}.map{|a|PadmaAccount.new(a)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enabled_accounts\n self.padma.try(:enabled_accounts)\n end",
"def padma_accounts\n return nil if self.accounts.nil?\n self.accounts.map{|a|PadmaAccount.new(a)}\n end",
"def accounts\n Management::Account.all(self)\n end",
"def all\n @dealing_platform.gather 'accounts', :acco... | [
"0.7983615",
"0.75145507",
"0.7334475",
"0.7208966",
"0.70647144",
"0.7052674",
"0.7043298",
"0.70306796",
"0.70035243",
"0.6908325",
"0.6865661",
"0.68348813",
"0.68333775",
"0.6779871",
"0.6750549",
"0.67298484",
"0.6705439",
"0.6623847",
"0.66135246",
"0.65814143",
"0.6568... | 0.84496975 | 0 |
Hack for the calendar range to work | def start_time
Date.today
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range_start=( value ); @range_start = value; rationalise_dates(); end",
"def beginning_of_week; end",
"def beginning_of_week; end",
"def setup_range(date)\n diff = date.wday - self.class.windex(start_wday)\n @first = date - (diff + ((diff < 0) ? DAYS : 0))\n @last = @first + DAYS ... | [
"0.66434234",
"0.6612971",
"0.6612971",
"0.6565703",
"0.65058154",
"0.6262707",
"0.6219479",
"0.6215323",
"0.6175778",
"0.6155572",
"0.61468124",
"0.6130412",
"0.61277306",
"0.6093429",
"0.60907793",
"0.60903525",
"0.6088403",
"0.6065767",
"0.6065767",
"0.60622823",
"0.605974... | 0.0 | -1 |
Returns a +key+ from the config. | def [](key)
config[key.to_s] || config[key.to_sym]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(key)\n self.config[key]\n end",
"def get(key)\n @config_hash[key]\n end",
"def config_for_key(key)\n settings.config[key]\n end",
"def get(key)\n\t\t\treturn @config[key]\n\t\tend",
"def [](key)\n config[key]\n end",
"def [](key)\n @config[key]\n end",
"d... | [
"0.7576577",
"0.7550113",
"0.7536905",
"0.7494042",
"0.73419994",
"0.7294743",
"0.72859585",
"0.72632974",
"0.7247787",
"0.72214115",
"0.7215542",
"0.7211381",
"0.7144439",
"0.71031606",
"0.69765043",
"0.6850175",
"0.683712",
"0.682809",
"0.681057",
"0.68102217",
"0.67995393"... | 0.7156406 | 12 |
Returns the full path to the config file. | def config_file
File.join AppRoot, ConfigFile
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_path\n @config_path ||= local_config_path\n end",
"def path\n @path ||= File.dirname @config_file\n end",
"def relative_config_file\n File.join(@settings[:config_dir], @settings[:config_file])\n end",
"def app_config_path\n Pathname.new('.').join('config')\n end... | [
"0.8284185",
"0.8264604",
"0.81300884",
"0.8124038",
"0.81118363",
"0.8012646",
"0.79815865",
"0.7981453",
"0.79060876",
"0.78872585",
"0.78718936",
"0.7830699",
"0.7805095",
"0.7803831",
"0.77489644",
"0.76945806",
"0.7693582",
"0.766047",
"0.76601374",
"0.76568896",
"0.7619... | 0.82430494 | 2 |
stores all instances of Artist | def initialize(name)
@name = name
@songs = []
self.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(name) #everytime an Artist instance is created, this method is called. Everything inside the block is its properties\n @name = name\n @songs = []\n\n @@all << self\n end",
"def artists\n @artists ||= artists_raw.map {|a| @session.artist.build(:name => a) }\n end",
"def arti... | [
"0.7129824",
"0.7026427",
"0.6965256",
"0.69181377",
"0.6893632",
"0.68826574",
"0.6866629",
"0.6824401",
"0.67284346",
"0.6719518",
"0.66524994",
"0.6603969",
"0.65679646",
"0.6567308",
"0.6535202",
"0.65315396",
"0.6522757",
"0.6458142",
"0.64218014",
"0.64043945",
"0.63978... | 0.0 | -1 |
Yield self for rubystyle initialization | def configure
yield self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @colours = default_colours\n @default = \"\\033[92m\"\n\n yield self if block_given?\n end",
"def initialize name = :rdoc # :yield: self\n defaults\n\n check_names name\n\n @name = name\n\n yield self if block_given?\n\n define\n end",
"def styles=(_arg0... | [
"0.6778602",
"0.66115177",
"0.6314544",
"0.6285113",
"0.6269817",
"0.621812",
"0.6206106",
"0.6193776",
"0.6171551",
"0.6171551",
"0.6171551",
"0.6171551",
"0.6143248",
"0.6129522",
"0.61042255",
"0.6092088",
"0.6091285",
"0.60433835",
"0.60433835",
"0.60433835",
"0.60433835"... | 0.0 | -1 |
Return the current configuration options as a Hash | def options
opts = {}
VALID_CONFIG_KEYS.each_key do |k|
opts.merge!(k => send(k))
end
opts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options\n opts = {}\n self.configuration_options.each do |option|\n opts.merge!({option.name.to_sym => option.value})\n end\n opts\n end",
"def options\n Hash[ *Configuration::VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end",
"def options\n Hash[\n *Co... | [
"0.84417653",
"0.82640785",
"0.8189162",
"0.8110969",
"0.8110969",
"0.7994236",
"0.78877115",
"0.78877115",
"0.78818274",
"0.78014815",
"0.7769207",
"0.7755151",
"0.77459496",
"0.76934254",
"0.766668",
"0.76445687",
"0.76311094",
"0.76258475",
"0.7603138",
"0.7603138",
"0.759... | 0.7795012 | 10 |
Set the default configuration onto the extended class | def reset
VALID_CONFIG_KEYS.each do |k, v|
send("#{k}=", v)
end
self.server_binding_url = "#{::ENV.fetch('GRPC_SERVER_HOST',
'0.0.0.0')}:#{::ENV.fetch('GRPC_SERVER_PORT', 9_001)}"
self.interceptors = ::Gruf::Interceptors::Registry.new
self.hooks = ::Gruf::Hooks::Registry.new
self.root_path = ::Rails.root.to_s.chomp('/') if defined?(::Rails)
determine_loggers
self.ssl_crt_file = "#{root_path}config/ssl/#{environment}.crt"
self.ssl_key_file = "#{root_path}config/ssl/#{environment}.key"
cp = ::ENV.fetch('GRUF_CONTROLLERS_PATH', 'app/rpc').to_s
self.controllers_path = root_path.to_s.empty? ? cp : "#{root_path}/#{cp}"
self.backtrace_on_error = ::ENV.fetch('GRPC_BACKTRACE_ON_ERROR', 0).to_i.positive?
self.rpc_server_options = {
max_waiting_requests: ::ENV.fetch('GRPC_SERVER_MAX_WAITING_REQUESTS',
GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS).to_i,
pool_size: ::ENV.fetch('GRPC_SERVER_POOL_SIZE', GRPC::RpcServer::DEFAULT_POOL_SIZE).to_i,
pool_keep_alive: ::ENV.fetch('GRPC_SERVER_POOL_KEEP_ALIVE', GRPC::Pool::DEFAULT_KEEP_ALIVE).to_i,
poll_period: ::ENV.fetch('GRPC_SERVER_POLL_PERIOD', GRPC::RpcServer::DEFAULT_POLL_PERIOD).to_i,
connect_md_proc: nil,
server_args: {}
}
self.use_default_interceptors = ::ENV.fetch('GRUF_USE_DEFAULT_INTERCEPTORS', 1).to_i.positive?
if use_default_interceptors
interceptors.use(::Gruf::Interceptors::ActiveRecord::ConnectionReset)
interceptors.use(::Gruf::Interceptors::Instrumentation::OutputMetadataTimer)
end
self.health_check_enabled = ::ENV.fetch('GRUF_HEALTH_CHECK_ENABLED', 0).to_i.positive?
options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @config = DEFAULT_CONFIG.deep_dup\n end",
"def initialize(config = {})\n super\n original_initialize(config)\n end",
"def initialize(...)\n super()\n configure(...)\n end",
"def default_configuration=(_arg0); end",
"def initialize(*)\n super\n apply_... | [
"0.7237514",
"0.7227835",
"0.7224668",
"0.72157276",
"0.71949047",
"0.7156908",
"0.7053635",
"0.70450276",
"0.701952",
"0.701952",
"0.69846267",
"0.69537365",
"0.6899523",
"0.6878238",
"0.6873349",
"0.6869706",
"0.6849939",
"0.6810481",
"0.6799405",
"0.6799405",
"0.67744654",... | 0.0 | -1 |
Dynamically determine the appropriate logger | def determine_loggers
if defined?(::Rails) && ::Rails.logger
self.logger = ::Rails.logger
else
require 'logger'
self.logger = ::Logger.new($stdout)
log_level = ::ENV.fetch('LOG_LEVEL', 'info').to_s.upcase
begin
logger.level = ::Logger::Severity.const_get(log_level)
rescue NameError => _e
logger.level = ::Logger::Severity::INFO
end
end
self.grpc_logger = logger if grpc_logger.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __prep_logger__(name, logger = nil)\n if name.is_a?(String) && ! logger.nil?\n [name, logger.class <= Logger ? logger : Logger.new(logger)]\n elsif name.class <= Logger && logger.nil?\n [name, name]\n else\n [name, Logger.new(name)]\n end\n end",
"def logger( name ... | [
"0.7128099",
"0.6945406",
"0.675343",
"0.675343",
"0.6714733",
"0.66715235",
"0.6647845",
"0.662637",
"0.662637",
"0.6616979",
"0.658269",
"0.6558022",
"0.65439224",
"0.6517293",
"0.6517293",
"0.65078455",
"0.6467223",
"0.64628303",
"0.64309806",
"0.6424142",
"0.6407963",
"... | 0.6855611 | 2 |
go to EMR if pres has done normal buy, or if normal buy isn't possible | def must_buy_power?(entity)
@round.emergency_buy ||
(@game.must_buy_power?(entity) && entity.cash < @game.current_power_cost)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attemp_buying\n\n end",
"def must_buy_train?(entity)\n must_buy_power?(entity)\n end",
"def bought?\n # paym\n end",
"def can_buy_depot_train?(entity)\n entity.cash >= @depot.upcoming.first.price\n end",
"def require_self_enabled_cross_selling\n if @entit... | [
"0.66395116",
"0.62103873",
"0.6175484",
"0.6103558",
"0.60685664",
"0.5970868",
"0.59352213",
"0.5907364",
"0.5746278",
"0.5742828",
"0.57376546",
"0.5701373",
"0.5683558",
"0.56708395",
"0.56154895",
"0.5614428",
"0.5596291",
"0.55884534",
"0.55882615",
"0.5585243",
"0.5583... | 0.5610845 | 16 |
So I don't have to create a new IssueShares view... | def must_buy_train?(entity)
must_buy_power?(entity)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @shares = Share.all\n end",
"def index\n @shares = Share.all\n end",
"def index\n @artwork_shares = ArtworkShare.all\n end",
"def index \n @shares = Share.all if admin?\n end",
"def create\n @share = Share.new(share_params)\n @project = Project.where(:key => params[:proj... | [
"0.6073024",
"0.6073024",
"0.59635305",
"0.5926382",
"0.58802646",
"0.58801734",
"0.583196",
"0.5820496",
"0.5763268",
"0.5674401",
"0.5665418",
"0.5635664",
"0.5621745",
"0.562049",
"0.5614837",
"0.5614837",
"0.5614837",
"0.5614837",
"0.5614837",
"0.5593982",
"0.55668527",
... | 0.0 | -1 |
ebuy doesn't affect progress track, but is twice as expensive and has a different target power | def ebuy_cash_needed(corporation)
return 0 unless @game.corporation_power[corporation] < @game.min_ebuy_power
diff = @game.min_ebuy_power - @game.corporation_power[corporation]
diff * @game.class::POWER_COST[@game.phase.name] * 1.5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buy_bot(percent_increase = 0.05, chunk = 0.006, prepump_buffer = 0.5)\n market_name = @market_name\n low_24_hr, last_price, ask_price, volume = get_market_summary(market_name)\n total_spent = 0.0\n p [low_24_hr, last_price, ask_price, volume]\n if ... | [
"0.64981633",
"0.6068097",
"0.605936",
"0.60275126",
"0.5988859",
"0.5985206",
"0.59287745",
"0.5924918",
"0.58365464",
"0.5817814",
"0.5817453",
"0.58029604",
"0.5802052",
"0.5799018",
"0.57708746",
"0.57540154",
"0.5698585",
"0.5698585",
"0.5690677",
"0.5665625",
"0.5659567... | 0.5480755 | 54 |
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3digit numbers. | def solve( n = 3 )
min = 10**(n - 1)
max = (10 * min) - 1
max.downto( min ).each do |i|
# Create the next palindromic number.
p = (i.to_s + i.to_s.reverse).to_i
# Factors must be min <= f <= sqrt(p). The quotient of p and f <= max.
# Find the first number with a factor satisfying these constraints.
a = Math.sqrt( p ).to_i.downto( min ).select {|f| max >= p / f && 0 == p % f}
return p if 0 < a.length #puts "%d x %d = %d" % [a[0], p / a[0], p]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem_4\n num1 = 999\n largest_pal = 0\n\n while num1 > 99\n num2 = num1 - 1\n while num2 > 99\n product = num1 * num2\n if is_palindrome?(product) && product > largest_pal\n largest_pal = product\n end\n num2 -= 1\n end\n num1 -= 1\n end\n\n return largest_pal\nen... | [
"0.83555037",
"0.8242398",
"0.8170143",
"0.81107473",
"0.8078514",
"0.80674416",
"0.80501807",
"0.8009623",
"0.7979529",
"0.7962498",
"0.7948993",
"0.7926019",
"0.78802824",
"0.78060204",
"0.7799266",
"0.7770549",
"0.7770034",
"0.7762247",
"0.7759526",
"0.77482855",
"0.774302... | 0.0 | -1 |
Initializes the chunk instance. | def initialize(type, attributes = {})
self.type = type
attributes.each { |k, v| send("#{k}=", v) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(&chunk_callback)\n @chunk_callback = chunk_callback\n end",
"def initialize_new_test_store\n verify_store_is_blank_for_init\n add_chunk MemoryChunk.new(:max_chunk_size=>max_chunk_size,:max_index_block_size=>max_index_block_size)\n end",
"def initialize\n super()\n ... | [
"0.6877799",
"0.66815877",
"0.6561395",
"0.65548617",
"0.65327877",
"0.64942086",
"0.6483905",
"0.6476164",
"0.6476164",
"0.6468437",
"0.63970095",
"0.6391912",
"0.63868374",
"0.63474625",
"0.6336715",
"0.63355184",
"0.63331157",
"0.62786347",
"0.62786347",
"0.6259976",
"0.62... | 0.0 | -1 |
Writes the chunk to the IO stream, using the provided content. The checksum will be calculated and appended to the stream. | def write_with_crc(io, content)
io << [content.length].pack('N') << type << content
io << [Zlib.crc32(content, Zlib.crc32(type))].pack('N')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(chunk)\n chunk.read\n end",
"def write(chunk)\n @size += chunk.bytesize\n # Worth noting that size always appears larger during this check than it\n # is in reality since the size is updated prior to writing out the data to\n # ensure that the amount of data stored in RA... | [
"0.67910624",
"0.6640919",
"0.63424355",
"0.624041",
"0.6085087",
"0.6056909",
"0.59049314",
"0.5780607",
"0.5733388",
"0.56672204",
"0.564678",
"0.55954313",
"0.5552174",
"0.5544837",
"0.5508556",
"0.5494334",
"0.5463504",
"0.5450318",
"0.5449808",
"0.54348654",
"0.5350668",... | 0.6068339 | 5 |
Writes the chunk to the IO stream. It will call the +content+ method to get the content for this chunk, and will calculate and append the checksum automatically. | def write(io)
write_with_crc(io, content || '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(chunk)\n chunk.read\n end",
"def write(io)\n write_with_crc(io, content || \"\")\n end",
"def write(chunk)\n @size += chunk.bytesize\n # Worth noting that size always appears larger during this check than it\n # is in reality since the size is updated prior to w... | [
"0.6953399",
"0.6554605",
"0.6513914",
"0.62119555",
"0.6108585",
"0.6107049",
"0.5999084",
"0.59141713",
"0.57899016",
"0.5699912",
"0.5671154",
"0.5651358",
"0.56068385",
"0.559704",
"0.559704",
"0.55875796",
"0.5359926",
"0.53571254",
"0.5320443",
"0.5314533",
"0.53140837"... | 0.6640842 | 1 |
Returns the content for this chunk when it gets written to a file, by packing the image information variables into the correct format. | def content
[width, height, depth, color, compression, filtering, interlace].pack('NNC5')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content\n [keyword, ChunkyPNG::COMPRESSION_DEFAULT, Zlib::Deflate.deflate(value)].pack('Z*Ca*')\n end",
"def content\n [\n keyword,\n ChunkyPNG::COMPRESSION_DEFAULT,\n Zlib::Deflate.deflate(value),\n ].pack(\"Z*Ca*\")\n end",
"def contents\n im... | [
"0.6875797",
"0.67448545",
"0.6641725",
"0.6641725",
"0.6564766",
"0.65301347",
"0.6342224",
"0.6264146",
"0.60675406",
"0.60489434",
"0.6021899",
"0.59156084",
"0.5883282",
"0.5782732",
"0.57648164",
"0.5762235",
"0.57306427",
"0.5676782",
"0.56752455",
"0.5669904",
"0.56614... | 0.6196884 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.