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 |
|---|---|---|---|---|---|---|
Update properties for a Device Group | def properties=(value)
start = Time.now
debug "Updating properties for device group: \"#{resource[:full_path]}\""
connection = self.class.get_connection(resource[:account])
update_device_group(connection,
resource[:full_path],
resource[:description],
value,
resource[:disable_alerting])
debug "Finished in #{(Time.now-start)*1000.0} ms"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if params[:device_group][:property_ids]\n params[:device_group][:property_ids].each do |property_id|\n @property = Property.find(property_id)\n @device_group.properties << @property\n end\n end\n respond_to do |format|\n if @device_group.update(device_group_pa... | [
"0.73503065",
"0.73163116",
"0.7088025",
"0.6695261",
"0.6664472",
"0.65236855",
"0.6408554",
"0.6379127",
"0.6376438",
"0.6365804",
"0.63204944",
"0.63078314",
"0.6294496",
"0.6292342",
"0.6290587",
"0.6253899",
"0.6189208",
"0.6179692",
"0.6177306",
"0.6166517",
"0.6164902"... | 0.79387367 | 0 |
Helper method for updating a Device Group via HTTP PATCH | def update_device_group(connection, fullpath, description, properties, disable_alerting)
device_group = get_device_group(connection, fullpath, 'id,parentId')
device_group_hash = build_group_json(fullpath,
description,
properties,
disable_alerting,
device_group['parentId'])
update_device_group = rest(connection,
Puppet::Provider::Logicmonitor::DEVICE_GROUP_ENDPOINT % device_group['id'],
Puppet::Provider::Logicmonitor::HTTP_PATCH,
build_query_params(nil, nil, -1, device_group_hash.keys),
device_group_hash.to_json)
valid_api_response?(update_device_group) ? debug(update_device_group) : alert(update_device_group)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @group.update_attributes(params[:group])\n respond_with(@group, only: [:id, :name, :creator_id, :admin_id])\n else\n render_error(404, request.path, 20103, \"Failed to update group info\")\n end\n end",
"def UpdateGroup params = {}\n \n APICall(path: 'groups.json... | [
"0.77909523",
"0.77025294",
"0.76624304",
"0.7630251",
"0.75740623",
"0.75375164",
"0.7534706",
"0.7524395",
"0.7502586",
"0.7485858",
"0.7409007",
"0.7395079",
"0.7375483",
"0.7366132",
"0.7364552",
"0.7339757",
"0.7339757",
"0.7339757",
"0.73317033",
"0.73300135",
"0.732171... | 0.76476216 | 3 |
Media (photos and videos) to delete photos or videos, use delete_object(object_id) note: you'll need the user_photos or user_videos permissions to actually access media after upload | def get_picture(object, args = {}, options = {})
# Gets a picture object, returning the URL (which Facebook sends as a header)
graph_call("#{object}/picture", args, "get", options.merge(:http_component => :headers)) do |result|
result["Location"]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_media\n media_category = Media.find(params[:id]).media_category_id\n Media.find(params[:id]).destroy\n\n redirect_to media_path(media_category)\n end",
"def destroy\n MediaCategory.find(params[:id]).destroy\n\n redirect_to admin_medias_path\n end",
"def remove_media\n @media = ... | [
"0.70971805",
"0.68074423",
"0.6741996",
"0.6717942",
"0.67026865",
"0.66759986",
"0.6627726",
"0.6604609",
"0.66045403",
"0.6601327",
"0.65972614",
"0.6571652",
"0.6565354",
"0.6553976",
"0.65422773",
"0.6537609",
"0.6534655",
"0.6532269",
"0.65265715",
"0.65232736",
"0.6518... | 0.0 | -1 |
Wall posts To get wall posts, use get_connections(user, "feed") To delete a wall post, just use delete_object(post_id) | def put_wall_post(message, attachment = {}, profile_id = "me", options = {})
# attachment is a hash describing the wall post
# (see X for more details)
# For instance,
#
# {"name" => "Link name"
# "link" => "http://www.example.com/",
# "caption" => "{*actor*} posted a new review",
# "description" => "This is a longer description of the attachment",
# "picture" => "http://www.example.com/thumbnail.jpg"}
self.put_object(profile_id, "feed", attachment.merge({:message => message}), options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def posts\n backend.wall_page(self).posts\n end",
"def get_posts(graph, facebook_id)\n graph.get_connections(facebook_id, \"feed\", { limit: 10 })\n end",
"def wall(url: nil, owner_id: nil, post_id: nil)\n owner_id, post_id = Utility::PostUrlParser.call(url) if url\n if post_id.nil?\n... | [
"0.6969904",
"0.636177",
"0.61998564",
"0.6193593",
"0.6185437",
"0.61118764",
"0.61118764",
"0.60961396",
"0.6036085",
"0.5957265",
"0.5956041",
"0.59383345",
"0.59217465",
"0.59200907",
"0.5912457",
"0.5890358",
"0.5878921",
"0.58526814",
"0.58435625",
"0.58228964",
"0.5760... | 0.57916296 | 20 |
Comments to delete comments, use delete_object(comment_id) to get comments, use get_connections(object, "likes") | def put_comment(object_id, message, options = {})
# Writes the given comment on the given post.
self.put_object(object_id, "comments", {:message => message}, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_comments\n end",
"def destroy\n id = @comment.micropost_id\n likes = Like.find_by_sql(['SELECT \"likes\".* FROM \"likes\" WHERE \"likes\".\"comment_id\" = ?', @comment.id])\n likes.each do |like|\n like_id = ActiveRecord::Base.sanitize(like.id)\n execute_statement(\"DELETE FROM lik... | [
"0.7735174",
"0.7133519",
"0.7115246",
"0.6976745",
"0.68903834",
"0.68854874",
"0.6883965",
"0.6844737",
"0.68358815",
"0.68180704",
"0.68180704",
"0.68142796",
"0.67961085",
"0.67961085",
"0.6794491",
"0.67932653",
"0.6763884",
"0.6755012",
"0.67180836",
"0.66879106",
"0.66... | 0.0 | -1 |
Likes to get likes, use get_connections(user, "likes") | def put_like(object_id, options = {})
# Likes the given post.
self.put_object(object_id, "likes", {}, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Like\n end",
"def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Generic\n end",
"def likes\n lik... | [
"0.80367583",
"0.79998726",
"0.73243344",
"0.7257137",
"0.72164446",
"0.71479404",
"0.7044396",
"0.70388806",
"0.698619",
"0.6977709",
"0.6969903",
"0.69543606",
"0.69101554",
"0.68826574",
"0.6868834",
"0.68577665",
"0.6851651",
"0.68404746",
"0.68315595",
"0.6821983",
"0.67... | 0.0 | -1 |
Direct access to the Facebook API see any of the above methods for example invocations | def graph_call(path, args = {}, verb = "get", options = {}, &post_processing)
result = api(path, args, verb, options) do |response|
error = check_response(response)
raise error if error
end
# now process as appropriate (get picture header, make GraphCollection, etc.)
post_processing ? post_processing.call(result) : result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def facebook\n\n end",
"def facebook\n end",
"def facebook\n handle_oauth\n end",
"def facebook\n callback\n end",
"def fbCall(path,params = {})\n params['access_token'] = self.token ? self.token['access_token'] : self.originalFriend.token['access_token']\n getJSON(\"https://graph.faceb... | [
"0.7738893",
"0.77128214",
"0.72962236",
"0.7192094",
"0.7100549",
"0.6969892",
"0.6934083",
"0.67646575",
"0.65992135",
"0.6581492",
"0.6576277",
"0.6563032",
"0.6537288",
"0.648308",
"0.6481627",
"0.64763224",
"0.6459488",
"0.64523834",
"0.6420313",
"0.6404448",
"0.63965833... | 0.0 | -1 |
Action responders must be public to receive Wisper notifications; see for relevant detail. (Needless to say that, even though these are public methods, they should never be called directly.) | def on_create_success(entity)
Responder::CreateSuccess.new(self).respond_to entity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def actions; end",
"def action_hook; end",
"def send_action(*_arg0); end",
"def run_actions; end",
"def process_action(...)\n send_action(...)\n end",
"def action_responder(name_of_action)\n action_respo... | [
"0.663267",
"0.663267",
"0.663267",
"0.6596799",
"0.65697277",
"0.6409653",
"0.6386967",
"0.6314557",
"0.63032794",
"0.6278916",
"0.6277532",
"0.6277532",
"0.6277532",
"0.6277532",
"0.6277532",
"0.6275237",
"0.62480766",
"0.6240649",
"0.6225163",
"0.6221447",
"0.6182863",
"... | 0.0 | -1 |
Actual Edit and Update failure logic is identical. | def on_edit_failure(payload)
Responder::EditFailure.new(self).respond_to payload
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit?\n update? # same as update - no access \n end",
"def test_editability(model_instance)\n return unless fee_classes.include?(model_instance.class)\n model_instance.errors.add(:base, 'uneditable_state') unless model_instance.claim.editable?\n rescue StandardError\n ... | [
"0.6398828",
"0.634274",
"0.63220274",
"0.6293285",
"0.62882596",
"0.624533",
"0.6231929",
"0.62030977",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.61782444",
"0.... | 0.682925 | 0 |
============= Explict block ============= | def hello(&block)
block.call if block_given?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704",
"0.80390704"... | 0.0 | -1 |
Looks for a logged in user in the session and loads it. If no officer found, returns nil | def current_officer
if (officer_id = session[:officer_id])
@current_officer ||= Officer.find(officer_id)
elsif (officer_id = cookies.signed[:officer_id])
officer = Officer.find(officer_id)
if officer && officer.authenticated?(cookies[:remember_token])
log_in officer
@current_officer = officer
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end",
"def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end",
"def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end",
"def... | [
"0.6956786",
"0.6956786",
"0.6956786",
"0.686571",
"0.67203736",
"0.67181337",
"0.6704728",
"0.6673909",
"0.6673909",
"0.66702896",
"0.664347",
"0.663861",
"0.66304016",
"0.66133827",
"0.661182",
"0.65681595",
"0.6561061",
"0.6559997",
"0.6506697",
"0.6502818",
"0.6502818",
... | 0.7068578 | 0 |
Redirects to login if officer is not logged in. This serves as an access security | def login_required
redirect_to new_session_path if current_officer.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_required\n redirect_to login_path unless logged_in?\n end",
"def login_required\n if !logged_in?\n redirect \"/login?#{env[\"REQUEST_PATH\"]}\"\n end\n end",
"def login_required\n redirect_to(login_url) unless logged_in? && authorized?\n end",
"def login_required\n ... | [
"0.7664395",
"0.7662895",
"0.7567415",
"0.75009376",
"0.7475761",
"0.74498796",
"0.7428888",
"0.7428888",
"0.74228156",
"0.74139184",
"0.7412023",
"0.73886734",
"0.73806614",
"0.7353687",
"0.7340208",
"0.7339743",
"0.73382807",
"0.7325659",
"0.7319789",
"0.731788",
"0.7305822... | 0.8211434 | 0 |
Sets default language if no language is transmitted in params | def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_language\n params[:lang] ||= 'en'\n Localization.use params[:lang]\n end",
"def set_language\n I18n.locale = params[:locale] || I18n.default_locale\n @lang = Wzs::Multilang::get_language(I18n.locale)\n end",
"def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.defa... | [
"0.87640315",
"0.8170733",
"0.78735316",
"0.76710534",
"0.7607171",
"0.75601506",
"0.7544727",
"0.7510447",
"0.7499547",
"0.7463825",
"0.74463946",
"0.74122393",
"0.73782843",
"0.7375852",
"0.73630977",
"0.7358266",
"0.7337584",
"0.72784275",
"0.7273415",
"0.72496027",
"0.722... | 0.70497996 | 51 |
Adds the locale for I18n to every link inside the app | def default_url_options
{ locale: I18n.locale }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_with_locale(url)\n params.to_unsafe_h.include?('locale') ? \"#{url}?locale=#{I18n.locale}\" : url\n end",
"def lang_switcher\n I18n.available_locales.each do |loc|\n locale_param = request.path == root_path ? root_path(locale: loc) : params.merge(locale: loc)\n if I18n.l... | [
"0.69857645",
"0.6824832",
"0.6811",
"0.6720647",
"0.6645329",
"0.662629",
"0.6561275",
"0.64823794",
"0.6480525",
"0.6465635",
"0.63504946",
"0.62871486",
"0.6280675",
"0.6256917",
"0.6227062",
"0.6204205",
"0.61334425",
"0.6131501",
"0.6130126",
"0.61041915",
"0.6100411",
... | 0.5832629 | 46 |
scrap les urls des sites des mairies du 92 | def get_townhall_email
array1 = []
get_townhall_urls.each do |i|
url = Nokogiri::HTML(open("http://annuaire-des-mairies.com/#{i}"))
n = url.xpath('/html/body/div/main/section[2]/div/table/tbody/tr[4]/td[2]')
array1 << n.text.to_s
end
return array1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_the_urls_of_val_doise_townhalls(page_url)\n doc = Nokogiri::HTML(open(page_url))\n urls = []\n#on recupere le css a[class=lientxt]\n get_urls = doc.css(\"a[class=lientxt]\")\n get_urls.each{|link| urls.push(\"http://annuaire-des-mairies.com\"+link['href'][1...link['href'].length])}\n url... | [
"0.75841486",
"0.75577265",
"0.75274456",
"0.74938786",
"0.74938786",
"0.73440087",
"0.731884",
"0.7153854",
"0.7124843",
"0.711707",
"0.7111645",
"0.7109259",
"0.7074819",
"0.7040674",
"0.6990799",
"0.6988434",
"0.69736946",
"0.69699204",
"0.69004107",
"0.6876272",
"0.685002... | 0.0 | -1 |
scrappe tous les noms de villes du val d'oise | def get_townhall_names
url_générale = Nokogiri::HTML(open("http://annuaire-des-mairies.com/val-d-oise.html"))
names_mairies_array = []
names_mairies = url_générale.xpath('//p/a')
names_mairies.each do |urls|
names = urls.text
names_mairies_array << names
end
return names_mairies_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def veichles\n ['Bil', 'Moped', 'Motorsykkel', 'Tungt kjøretøy', 'ATV', 'Buss', 'Sykkel']\n end",
"def names\n [\n \"Charge de travail\" , #00\n \"Travail en groupe\" , #01\n \"Maths\" , #02\n \"Codage\" , #03\n ... | [
"0.6302191",
"0.61695415",
"0.61365914",
"0.5993862",
"0.5949413",
"0.59219325",
"0.5921589",
"0.58743227",
"0.58566976",
"0.57994145",
"0.5736827",
"0.5700763",
"0.5653994",
"0.5649113",
"0.56256217",
"0.561919",
"0.561919",
"0.5558732",
"0.5555831",
"0.55493015",
"0.5545997... | 0.0 | -1 |
fusionne les deux arrays en un array de hashs au format (ville => email mairie) | def perform
final_array = []
names = get_townhall_names
email = get_townhall_email
final_hash = Hash[names.zip(email)]
save_as_json(final_hash)
save_as_spreadsheet(final_hash)
save_as_csv(final_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_fusion\r\n results = Hash[*@citys_list.zip(@citys_mail).flatten]\r\n print results.each_slice(1).map(&:to_h)\r\n \r\nend",
"def final_array_def (emails,names)\n\tfinal_array = []\n\temails.length.times do |i|\n\thash = {}\n\thash[names[i]] = emails[i]\n\tfinal_array << hash\n\tend\n\treturn fi... | [
"0.70264107",
"0.70173794",
"0.7000443",
"0.69379234",
"0.68922484",
"0.6876014",
"0.68097246",
"0.6761626",
"0.67136663",
"0.66391397",
"0.64845324",
"0.6476739",
"0.64660305",
"0.6347685",
"0.628613",
"0.6281741",
"0.6236079",
"0.61879957",
"0.6152429",
"0.61379975",
"0.602... | 0.0 | -1 |
Recursively walk terms and parameters (leaf nodes) | def walkTerm(statement, sublevel, entity = nil, parentFunction = nil, argidx = nil)
# Map subject and object when walkTerm is called non-recursively
if entity == :subject
element = "cause"
unless statement.nestedStatement
statement.currentobj = statement.obj.subject
else
statement.currentobj = statement.nestedStatement.subject
end
elsif entity == :object
element = "theme"
unless statement.nestedStatement
statement.currentobj = statement.obj.object
else
statement.currentobj = statement.nestedStatement.object
end
end
# Shorthand assignments
obj = statement.currentobj
document = statement.document
passage = statement.passage
debug = statement.debug
includeBEL = statement.includeBEL
unless statement.nestedStatement
relation = statement.relation
relationTriple = statement.relationTriple
else
relation = statement.nestedRelation
relationTriple = statement.nestedrelationTriple
end
if !obj.nil? and !statement.obj.relationship.nil?
if sublevel == 0
# Statements are relations unless they are unary
unless !obj.instance_of?(BEL::Language::Statement) and
statement.keeptogether and
obj.arguments.length == 1 and
obj.arguments[0].instance_of?(BEL::Language::Parameter)
relationTriple[element].refid = "r" + String($relationId)
else
relationTriple[element].refid = "a" + String($annotationId)
end
if includeBEL
# Substitute elements for relative original BEL string
substitutionString = relation.infons["BEL (relative)"].sub String(obj), relationTriple[element].refid
if entity == :object
#strip remaining brackets
substitutionString = substitutionString.tr('()','')
end
relation.infons["BEL (relative)"] = substitutionString
end
end
#
# Map terms
#
if obj.instance_of?(BEL::Language::Term)
mapTerms(statement, sublevel, parentFunction, argidx)
#
# Map parameters
#
elsif obj.instance_of?(BEL::Language::Parameter)
mapParameters(statement, parentFunction, argidx)
#
# Map statements
#
elsif obj.instance_of?(BEL::Language::Statement)
statement.nestedStatement = obj
statement.insideNestedStatement = true
walkStatement(statement)
end
elsif statement.obj.relationship.nil?
puts "Note: Skipping #{statement.obj}, single-term statements not (yet) supported."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursiveTreeTraversal(element)\n if StereotypesHelper.hasStereotype(element, $veStereotype)\n findRefinedParameters(element)\n end\n for child in element.getOwnedElement()\n recursiveTreeTraversal(child)\n end\nend",
"def recursiveTreeTraversal(element)\n if StereotypesHelper.ha... | [
"0.6116803",
"0.60215497",
"0.5911224",
"0.5800048",
"0.57956296",
"0.5748433",
"0.56565636",
"0.5616083",
"0.55600804",
"0.5555625",
"0.55397785",
"0.5534623",
"0.55264634",
"0.5502355",
"0.5477033",
"0.54680836",
"0.5467178",
"0.54525036",
"0.54069024",
"0.54062235",
"0.540... | 0.0 | -1 |
davids token is 6461766964626c697540676d61696c2e636f6d | def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept, Authorization, Token'
headers['Access-Control-Max-Age'] = "1728000"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rfc_2045_token; end",
"def token_uri; end",
"def cdr(token)\n token.split(DELIMITER).second.then(&Base64.method(:decode64))\n end",
"def segmentation_anonymous_id_cookie\n \"sanmid\"\n end",
"def car(token)\n token.split(DELIMITER).first.then(&Base64.method(:decode64))\n end",
"de... | [
"0.5868119",
"0.58402586",
"0.5652484",
"0.5499712",
"0.5450319",
"0.5412386",
"0.54016435",
"0.5383668",
"0.5383668",
"0.5383668",
"0.5329039",
"0.5329039",
"0.5329039",
"0.5329039",
"0.53263116",
"0.52567434",
"0.5247727",
"0.52104074",
"0.52011883",
"0.5192306",
"0.5159153... | 0.0 | -1 |
main users based on last 10000 clicks | def main_users
@main_users = ParseGoLink.main_users
render json: @main_users
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_users\n @get_users = Rails.cache.fetch(\"get_aside_users\", :expires_in => 1.hours) do\n if @current_user.present?\n Core::User.active.where(\"verified = 1 AND id != #{@current_user.id}\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n else\n Core::User.active.wh... | [
"0.6103421",
"0.5991539",
"0.5965249",
"0.5948182",
"0.5870699",
"0.58474016",
"0.58361214",
"0.57954884",
"0.5776195",
"0.5744218",
"0.5740562",
"0.572575",
"0.57246447",
"0.57131743",
"0.56965244",
"0.5663211",
"0.5655865",
"0.56164676",
"0.56138456",
"0.560787",
"0.5579076... | 0.0 | -1 |
GQL updates assign values using the array syntax See gql_expression.rb | def []=(attr_name, value)
writer_method = "#{attr_name}="
send(writer_method, value) if respond_to?(writer_method)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update()\ndb = PG connect( {dbname: 'bounty_hunter',\n host: 'localhost'\n })\nsql = \"UPDATE bounty_hunters\nSET (name,\n species,\n homeworld,\n favourite_weapon\n )=(\n $1, $2, $3, $4\n )\n WHERE id = $5\n \"\n\nvalues = [@name, @species, @homeworld, @fa... | [
"0.61298466",
"0.593655",
"0.5844621",
"0.5781451",
"0.57772154",
"0.5749875",
"0.5727808",
"0.568228",
"0.5679099",
"0.56617135",
"0.56531876",
"0.5637537",
"0.5637537",
"0.5619162",
"0.55932915",
"0.5591016",
"0.5575658",
"0.55086315",
"0.55009204",
"0.54883045",
"0.5477683... | 0.0 | -1 |
need to add model test | def pet_count
pets.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(model_class); end",
"def setup(model_class); end",
"def make_and_model; end",
"def set_test_model\n @test_model = TestModel.find(params[:id])\n end",
"def set_test_model\n @test_model = TestModel.find(params[:id])\n end",
"def test_model\n assert_raise(ArgumentError){@test_car.mo... | [
"0.68206626",
"0.68206626",
"0.6769266",
"0.6736159",
"0.67325836",
"0.67102265",
"0.667959",
"0.6659984",
"0.6659984",
"0.6613454",
"0.6529699",
"0.65260917",
"0.64172745",
"0.63526446",
"0.6314491",
"0.6305458",
"0.62906384",
"0.6284235",
"0.62495846",
"0.6245142",
"0.62263... | 0.0 | -1 |
Yes, it's called package because module is a reserved word | def package
@package ||= path.split('/lib/')[0].split('/').last.split('.js').last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def packages; end",
"def k_package!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n\n\n\n type = K_PACKAGE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at l... | [
"0.67353594",
"0.6665122",
"0.6556278",
"0.6536218",
"0.6508328",
"0.6426168",
"0.6362813",
"0.6327646",
"0.62823504",
"0.6250995",
"0.62251645",
"0.62251645",
"0.62251645",
"0.62143946",
"0.61981213",
"0.61981213",
"0.61562824",
"0.6152726",
"0.6152726",
"0.6152726",
"0.6152... | 0.60383797 | 32 |
I want to return an array that doubles each element of the input array | def double_array(arr)
doubled_arr = arr.map do | element|
element *2
end
doubled_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_to_double(source_array)\n \n i = 0\n new_array = []\n \n while i < source_array.length do\n new_array_value = source_array[i] * 2\n new_array << new_array_value\n \n i += 1\n end\n \n new_array\nend",
"def map_to_double(source_array)\n array = []\n index = 0 \n \n while index < so... | [
"0.8113166",
"0.8093475",
"0.78498197",
"0.7824536",
"0.76009935",
"0.75924516",
"0.757723",
"0.75660414",
"0.73971635",
"0.7390382",
"0.73832947",
"0.73761904",
"0.73294103",
"0.72993433",
"0.7280207",
"0.7257046",
"0.72050697",
"0.7188062",
"0.7178201",
"0.70868623",
"0.700... | 0.7410474 | 8 |
GET /customized_concepts GET /customized_concepts.json | def index
@customized_concepts = CustomizedConcept.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @course = Course.find(params[:course_id])\n @customized_concept = @course.customized_concepts.find(params[:id])\n end",
"def set_customized_concept\n @customized_concept = CustomizedConcept.find(params[:id])\n end",
"def create\n @course = Course.find(params[:course_id])\n @cust... | [
"0.68541723",
"0.68018615",
"0.6728507",
"0.62837774",
"0.6267942",
"0.60885704",
"0.60455537",
"0.6031294",
"0.5994282",
"0.5994282",
"0.59654725",
"0.58847564",
"0.58569443",
"0.58115816",
"0.5737045",
"0.5665238",
"0.5556035",
"0.5491585",
"0.54797035",
"0.54778033",
"0.53... | 0.78086793 | 0 |
GET /customized_concepts/1 GET /customized_concepts/1.json | def show
@course = Course.find(params[:course_id])
@customized_concept = @course.customized_concepts.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @customized_concepts = CustomizedConcept.all\n end",
"def set_customized_concept\n @customized_concept = CustomizedConcept.find(params[:id])\n end",
"def create\n @course = Course.find(params[:course_id])\n @customized_concept = @course.customized_concepts.new(customized_concept_p... | [
"0.7831783",
"0.6775864",
"0.66508",
"0.66340804",
"0.6481487",
"0.62545395",
"0.62069273",
"0.61926204",
"0.6136589",
"0.6037333",
"0.6037333",
"0.6014648",
"0.5907674",
"0.5893592",
"0.58694124",
"0.5839345",
"0.58303535",
"0.5772579",
"0.5735444",
"0.5725731",
"0.5708238",... | 0.7014512 | 1 |
POST /customized_concepts POST /customized_concepts.json | def create
@course = Course.find(params[:course_id])
@customized_concept = @course.customized_concepts.new(customized_concept_params)
respond_to do |format|
if @customized_concept.save
format.html { redirect_to @course, notice: 'Customized concept was successfully created.' }
format.json { render :show, status: :created, location: @customized_concept }
else
format.html { render :new }
format.json { render json: @customized_concept.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @customized_concepts = CustomizedConcept.all\n end",
"def set_customized_concept\n @customized_concept = CustomizedConcept.find(params[:id])\n end",
"def customized_concept_params\n params.require(:customized_concept).permit(:course_id, :title, :description, :video, :lecture)\n ... | [
"0.6761858",
"0.66796887",
"0.64662015",
"0.6328216",
"0.61436796",
"0.59552485",
"0.5952309",
"0.59016407",
"0.5662458",
"0.56600857",
"0.5626573",
"0.5467005",
"0.54021335",
"0.5401365",
"0.5382899",
"0.5310986",
"0.52510834",
"0.52383316",
"0.5234013",
"0.52316713",
"0.522... | 0.733524 | 0 |
PATCH/PUT /customized_concepts/1 PATCH/PUT /customized_concepts/1.json | def update
respond_to do |format|
if @customized_concept.update(customized_concept_params)
format.html { redirect_to @customized_concept, notice: 'Customized concept was successfully updated.' }
format.json { render :show, status: :ok, location: @customized_concept }
else
format.html { render :edit }
format.json { render json: @customized_concept.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_customized_concept\n @customized_concept = CustomizedConcept.find(params[:id])\n end",
"def update\n @orderable_concept = OrderableConcept.find(params[:id])\n\n respond_to do |format|\n if @orderable_concept.update_attributes(params[:orderable_concept])\n format.html { redirect_... | [
"0.65403557",
"0.65271056",
"0.6336022",
"0.63072926",
"0.63072926",
"0.60435414",
"0.5915217",
"0.5841427",
"0.5825572",
"0.5803414",
"0.57943493",
"0.5770371",
"0.5721804",
"0.5683588",
"0.55955327",
"0.5583532",
"0.55675054",
"0.5534411",
"0.5534411",
"0.55102235",
"0.5485... | 0.73499787 | 0 |
DELETE /customized_concepts/1 DELETE /customized_concepts/1.json | def destroy
@customized_concept.destroy
respond_to do |format|
format.html { redirect_to customized_concepts_url, notice: 'Customized concept was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @orderable_concept = OrderableConcept.find(params[:id])\n @orderable_concept.destroy\n\n respond_to do |format|\n format.html { redirect_to orderable_concepts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @concept = Concept.find(params[:id])\n @c... | [
"0.72778064",
"0.7265202",
"0.7265202",
"0.710455",
"0.66949916",
"0.65777224",
"0.6565862",
"0.65384096",
"0.65101707",
"0.64560324",
"0.64560324",
"0.6449879",
"0.64449114",
"0.64107627",
"0.6386794",
"0.6385608",
"0.63815707",
"0.63799417",
"0.6369514",
"0.6353753",
"0.633... | 0.78199947 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_customized_concept
@customized_concept = CustomizedConcept.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 customized_concept_params
params.require(:customized_concept).permit(:course_id, :title, :description, :video, :lecture)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /pets GET /pets.json | def index
if user_signed_in?
@user = current_user
@pets = current_user.pets.reverse
else
redirect_to root_path
return
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @pets }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pets = Pet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pets }\n end\n end",
"def show\n @pet = Pet.find_by(id: params[:id])\n if @pet\n render json: @pet\n else\n render json: {}, status: 404\n end\n end",
"... | [
"0.7532408",
"0.7481141",
"0.7442882",
"0.7442882",
"0.7365796",
"0.7232409",
"0.7110083",
"0.6978937",
"0.6939604",
"0.6848388",
"0.683465",
"0.6797097",
"0.6695568",
"0.6684484",
"0.6653209",
"0.6653209",
"0.6602785",
"0.65907687",
"0.6585763",
"0.6477046",
"0.64590454",
... | 0.6523989 | 19 |
GET /pets/1 GET /pets/1.json | def show
@pet = Pet.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @pet }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @pet = Pet.find_by(id: params[:id])\n if @pet\n render json: @pet\n else\n render json: {}, status: 404\n end\n end",
"def index\n @pets = Pet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pets }\n end\n end",
"... | [
"0.75733095",
"0.73931026",
"0.7245301",
"0.70816267",
"0.7062426",
"0.7058671",
"0.6981802",
"0.6895421",
"0.6866418",
"0.6858466",
"0.6762347",
"0.66688824",
"0.6666302",
"0.64767885",
"0.6471701",
"0.6471701",
"0.64502436",
"0.6442229",
"0.6401544",
"0.6370456",
"0.6365462... | 0.7517837 | 2 |
GET /pets/new GET /pets/new.json | def new
@user = current_user
@pet = @user.pets.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @pet }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lost_pet = LostPet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost_pet }\n end\n end",
"def new\n @pet = Pet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pet }\n end\n ... | [
"0.75966233",
"0.723062",
"0.7222331",
"0.7056523",
"0.7056523",
"0.7009805",
"0.70057005",
"0.70012003",
"0.69963574",
"0.69676054",
"0.69582736",
"0.695148",
"0.69497854",
"0.69350594",
"0.6931725",
"0.69169813",
"0.69073385",
"0.6881428",
"0.68494684",
"0.68481183",
"0.684... | 0.74882567 | 1 |
POST /pets POST /pets.json | def create
@user = current_user
@pet = @user.pets.new(params[:pet])
binding.pry
if humane_society_ips.include?(request.remote_ip)
@pet.at_humane_society = true
end
respond_to do |format|
if @pet.save
format.html { redirect_to root_path, notice: 'Pet was successfully created.' }
format.json { render json: @pet, status: :created, location: @pet }
else
format.html { render action: "new" }
format.json { render json: @pet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @pet = @person.pets.build(pet_params)\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to person_path(@person), notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @person }\n else\n format.html { re... | [
"0.7303997",
"0.7081908",
"0.7000595",
"0.6952367",
"0.68931097",
"0.6804849",
"0.6789769",
"0.6748069",
"0.6664846",
"0.66344166",
"0.6613724",
"0.65952945",
"0.6573272",
"0.6449908",
"0.64429986",
"0.64418715",
"0.6437518",
"0.64174235",
"0.6417186",
"0.6385124",
"0.6381243... | 0.6113706 | 47 |
PUT /pets/1 PUT /pets/1.json | def update
@pet = Pet.find(params[:id])
respond_to do |format|
if @pet.update_attributes(params[:pet])
format.html { redirect_to root_path, notice: 'Pet was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @pet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n if @pet.update_attributes(params[:pet])\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n ... | [
"0.66811895",
"0.66649413",
"0.6663732",
"0.66373914",
"0.66149145",
"0.6559485",
"0.6559485",
"0.6559485",
"0.6559485",
"0.6559485",
"0.6559485",
"0.65266526",
"0.65131277",
"0.63891435",
"0.63477635",
"0.6334447",
"0.6322319",
"0.6314258",
"0.6288815",
"0.62430245",
"0.6216... | 0.6643125 | 3 |
DELETE /pets/1 DELETE /pets/1.json | def destroy
@pet = Pet.find(params[:id])
@pet.destroy
respond_to do |format|
format.html { redirect_to pets_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n pet = @user.pets.find(params[:id])\n pet.destroy\n render json: pet\n end",
"def pet_delete(pet)\n @db.delete(\"pets\", pet[\"id\"])\n end",
"def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: I18n.t(\"pet... | [
"0.76552933",
"0.76330024",
"0.7302086",
"0.7267687",
"0.7248253",
"0.72239506",
"0.721972",
"0.72023845",
"0.72023845",
"0.72023845",
"0.72023845",
"0.72023845",
"0.71824735",
"0.7175317",
"0.7128093",
"0.7128093",
"0.7124565",
"0.7117816",
"0.7114961",
"0.70514756",
"0.7045... | 0.750838 | 3 |
validates :name, presence: true | def index
@patrons = Patron.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_is_valid\n errors.add(:name,'Invalid empty string for name.') unless name_is_valid?\n end",
"def name_present\n if name.blank?\n errors.add(:name, \"Can't be empty\")\n end\n end",
"def name_is_valid\n errors.add(:name,\"Invalid string for name.\") unless name_is_valid?\n end",
"... | [
"0.85423356",
"0.85312206",
"0.8309702",
"0.80220187",
"0.79651934",
"0.79651934",
"0.79517025",
"0.78527737",
"0.7687741",
"0.76870894",
"0.7671357",
"0.7638802",
"0.7638802",
"0.7638802",
"0.76169115",
"0.75806874",
"0.75749415",
"0.749427",
"0.7447472",
"0.74231964",
"0.73... | 0.0 | -1 |
Generate a friendly string randomly to be used as token. By default, length is 20 characters. | def friendly_token(length = 20)
# To calculate real characters, we must perform this operation.
# See SecureRandom.urlsafe_base64
rlength = (length * 3) / 4
SecureRandom.urlsafe_base64(rlength).tr('lIO0', 'sxyz')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_token\n 32.times.map{ rand(36).to_s(36) }.join # 32 alphanumeric characters\n end",
"def generate_token\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n token = (0...50).map { o[rand(o.length)] }.join\n return token\n end",
"def rand_token length=36\r\n\ttoken =... | [
"0.8341831",
"0.8303068",
"0.82232136",
"0.8050449",
"0.8020398",
"0.80009365",
"0.797985",
"0.79169524",
"0.78613895",
"0.78367186",
"0.775581",
"0.77160907",
"0.76943225",
"0.76943225",
"0.76943225",
"0.76943225",
"0.7681546",
"0.76418835",
"0.7629756",
"0.75901985",
"0.758... | 0.83982605 | 0 |
find all of the employees for the location instance | def employees
Employee.all.select do |emp|
emp.location == self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def employees\n employee_array = []\n locations.each do |location|\n location.employees.each do |employee|\n employee_array << employee\n end\n end\n employee_array\n end",
"def all_employees\n self.workplace.employees\n end",
"def all_employees\n ServiceProvider.all(... | [
"0.7776603",
"0.7423415",
"0.67937756",
"0.67202336",
"0.6630696",
"0.6623034",
"0.64878774",
"0.6389549",
"0.6299226",
"0.6144151",
"0.6106964",
"0.6096123",
"0.6096123",
"0.60584205",
"0.6013435",
"0.6008707",
"0.5984021",
"0.5969415",
"0.5963448",
"0.5938073",
"0.58840406"... | 0.74121946 | 2 |
Returns the single root for the class (or just the first root, if there are several). Deprecation note: the original acts_as_nested_set allowed roots to have parent_id = 0, so we currently do the same. This silliness will not be tolerated in future versions, however. | def root
acts_as_nested_set_options[:class].find(:first, :conditions => "(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root\n if self.dotted_ids\n self.class.find(self.dotted_ids.split('.').first)\n else\n node = self\n node = node.parent while node.parent\n node\n end\n end",
"def root\n nested_set_class.find_with_nested_set_scope(:first, :conditions => ... | [
"0.7639601",
"0.7573074",
"0.73372406",
"0.7283091",
"0.7256298",
"0.72382885",
"0.7212995",
"0.72067875",
"0.71194696",
"0.71082735",
"0.70686173",
"0.70459086",
"0.7044596",
"0.7016398",
"0.6982343",
"0.6969877",
"0.6969877",
"0.69552547",
"0.69273543",
"0.69190854",
"0.690... | 0.72842383 | 3 |
Returns the roots and/or virtual roots of all trees. See the explanation of virtual roots in the README. | def roots
acts_as_nested_set_options[:class].find(:all, :conditions => "(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)", :order => "#{acts_as_nested_set_options[:left_column]}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roots\n nodes.select{ |n| n.root? }\n end",
"def roots\n self.ontology_classes(force_reload=true).select{|c| c.isroot?}\n end",
"def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n ... | [
"0.7494112",
"0.7006442",
"0.6990156",
"0.6775148",
"0.6615451",
"0.6530727",
"0.6464751",
"0.63990253",
"0.63784933",
"0.6316445",
"0.63004977",
"0.62469256",
"0.62237465",
"0.6211025",
"0.61942333",
"0.61899465",
"0.6174147",
"0.61655897",
"0.61340314",
"0.6131425",
"0.6114... | 0.6628554 | 4 |
Recalculate the left/right values of all nodes. Can be used to convert ordinary trees into nested sets. | def renumber_all
scopes = []
# only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems)
roots.each do |r|
r.renumber_full_tree unless scopes.include?(r.scope_condition)
scopes << r.scope_condition
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:l... | [
"0.7184487",
"0.7098187",
"0.65608287",
"0.64842767",
"0.6427803",
"0.63191175",
"0.62815183",
"0.62173057",
"0.6019624",
"0.59977704",
"0.5987223",
"0.59181285",
"0.5853808",
"0.5853663",
"0.58239204",
"0.5711054",
"0.57010436",
"0.5676017",
"0.56590146",
"0.5627154",
"0.561... | 0.0 | -1 |
On creation, automatically add the new node to the right of all existing nodes in this tree. | def before_create # already protected by a transaction
maxright = base_set_class.maximum(right_col_name, :conditions => scope_condition) || 0
self[left_col_name] = maxright+1
self[right_col_name] = maxright+2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_create\n maxright = self.class.maximum(acts_as_nested_set_options[:right_column], :conditions => acts_as_nested_set_options[:scope]) || 0\n # adds the new node to the right of all existing nodes\n self[acts_as_nested_set_options[:left_column]] = maxright+1\n self[acts... | [
"0.73110974",
"0.66116565",
"0.6545355",
"0.65242076",
"0.6497894",
"0.6453593",
"0.635631",
"0.6343747",
"0.627902",
"0.6275489",
"0.62203336",
"0.6182126",
"0.61652964",
"0.6160576",
"0.6140413",
"0.6065717",
"0.6057033",
"0.60449076",
"0.60440564",
"0.6031852",
"0.6010775"... | 0.0 | -1 |
On destruction, delete all children and shift the lft/rgt values back to the left so the counts still work. | def before_destroy # already protected by a transaction
return if self[right_col_name].nil? || self[left_col_name].nil?
self.reload # in case a concurrent move has altered the indexes
dif = self[right_col_name] - self[left_col_name] + 1
base_set_class.delete_all( "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})" )
base_set_class.update_all("#{left_col_name} = CASE \
WHEN #{left_col_name} > #{self[right_col_name]} THEN (#{left_col_name} - #{dif}) \
ELSE #{left_col_name} END, \
#{right_col_name} = CASE \
WHEN #{right_col_name} > #{self[right_col_name]} THEN (#{right_col_name} - #{dif} ) \
ELSE #{right_col_name} END",
scope_condition)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teardown\n @root.remove!(@left_child1)\n @root.remove!(@right_child1)\n @root = nil\n end",
"def destroy_tree_from_leaves\n self.subdirectories.each do |subdirectory|\n subdirectory.destroy_tree_from_leaves\n end\n self.subdirectories.reload\n self.cfs_files.each do |cfs_fi... | [
"0.66812104",
"0.64786756",
"0.6347992",
"0.6293292",
"0.6208786",
"0.618475",
"0.61661756",
"0.61547375",
"0.6106653",
"0.6055133",
"0.6049484",
"0.6042418",
"0.59881234",
"0.59858346",
"0.58628696",
"0.5859962",
"0.58414835",
"0.58174384",
"0.581299",
"0.5811586",
"0.577390... | 0.0 | -1 |
By default, records are compared and sorted using the left column. | def <=>(x)
self[left_col_name] <=> x[left_col_name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmp (left_element, right_element)\n #puts left_element\n #puts right_element\n if @order == \"ASC\"\n if left_element[@order_column] < right_element[@order_column]\n return true\n else\n return false\n end\n else\n ... | [
"0.6703479",
"0.66438",
"0.6443174",
"0.6358814",
"0.6303578",
"0.6174257",
"0.616655",
"0.61394936",
"0.61229604",
"0.60936207",
"0.60879433",
"0.60340875",
"0.60009676",
"0.59609056",
"0.59419787",
"0.5916788",
"0.59127635",
"0.58945715",
"0.5874114",
"0.5871756",
"0.584381... | 0.6554659 | 3 |
Deprecated. Returns true if this is a root node. | def root?
parent_id = self[parent_col_name]
(parent_id == 0 || parent_id.nil?) && self[right_col_name] && self[left_col_name] && (self[right_col_name] > self[left_col_name])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_root_node?\n @nodes.size == 1\n end",
"def root?\n root\n end",
"def root?\n !has_parent?\n end",
"def root?\n @type == ROOT\n end",
"def root?\n true\n end",
"def root?\n root == self\n end",
"def root?\n false\n end",
"def root... | [
"0.81766397",
"0.80926067",
"0.80271626",
"0.80203354",
"0.79955834",
"0.7992824",
"0.7992352",
"0.7940613",
"0.7914862",
"0.7914862",
"0.7881153",
"0.78369236",
"0.7809944",
"0.7802172",
"0.7782715",
"0.7733866",
"0.7585806",
"0.7537625",
"0.7537625",
"0.7537625",
"0.7537625... | 0.0 | -1 |
Deprecated. Returns true if this is a child node | def child?
parent_id = self[parent_col_name]
!(parent_id == 0 || parent_id.nil?) && (self[left_col_name] > 1) && (self[right_col_name] > self[left_col_name])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_child_nodes()\n if @child_nodes.first_child.nil? then\n return false\n else\n return true\n end\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def child?\n !root?\n end",
"def child?\n !... | [
"0.79603773",
"0.7814983",
"0.7814983",
"0.7786256",
"0.7737336",
"0.76288193",
"0.7578937",
"0.7540097",
"0.7527541",
"0.73899573",
"0.73824453",
"0.7351262",
"0.7334665",
"0.7334231",
"0.73064137",
"0.7286926",
"0.7278749",
"0.7270024",
"0.726623",
"0.72097003",
"0.72097003... | 0.6638566 | 90 |
Deprecated. Returns true if we have no idea what this is | def unknown?
!root? && !child?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legacy?\n false\n end",
"def deprecated?\n false\n end",
"def completely_deprecated?\n @deprecated == :completely\n end",
"def deprecated?\n superseded_by.present?\n end",
"def ordinary?\n raise \"Not implemented yet\"\n end",
"def deprecated?\n ... | [
"0.766861",
"0.7548163",
"0.74961597",
"0.74371773",
"0.7401675",
"0.7229891",
"0.71265566",
"0.7114632",
"0.71074533",
"0.71001107",
"0.70476544",
"0.70336086",
"0.6980551",
"0.69424057",
"0.6933448",
"0.6933448",
"0.6929677",
"0.6925631",
"0.68161255",
"0.67866397",
"0.6772... | 0.0 | -1 |
Returns this record's root ancestor. | def root
# the BETWEEN clause is needed to ensure we get the right virtual root, if using those
base_set_class.find(:first, :conditions => "#{scope_condition} \
AND (#{parent_col_name} IS NULL OR #{parent_col_name} = 0) AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name})")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_ancestor\n has_parent? ? parent.root_ancestor : self\n end",
"def root\n ancestors.first || self\n end",
"def root\n return self if root?\n (root_relation_enabled? && root_ancestor) || ancestors.first\n end",
"def root\n self_and_ancestors.first\n end... | [
"0.83231187",
"0.80980664",
"0.79259104",
"0.7638012",
"0.74833167",
"0.73352784",
"0.72664464",
"0.72638637",
"0.7249485",
"0.7242637",
"0.7212541",
"0.7176655",
"0.7155322",
"0.7155322",
"0.7134192",
"0.71137166",
"0.7070988",
"0.7007501",
"0.6996722",
"0.6957024",
"0.69304... | 0.615257 | 74 |
Returns the root or virtual roots of this record's tree (a tree cannot have more than one real root). See the explanation of virtual roots in the README. | def roots
base_set_class.find(:all, :conditions => "#{scope_condition} AND (#{parent_col_name} IS NULL OR #{parent_col_name} = 0)", :order => "#{left_col_name}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roots\n nodes.select{ |n| n.root? }\n end",
"def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n end",
"def roots\n acts_as_nested_set_options[:class].find(:all, :conditions... | [
"0.7079386",
"0.7046463",
"0.6888999",
"0.6759608",
"0.6606695",
"0.65630203",
"0.65467656",
"0.6501717",
"0.632362",
"0.6297851",
"0.6291363",
"0.61610913",
"0.61275357",
"0.6116486",
"0.6111284",
"0.609791",
"0.6067172",
"0.6067172",
"0.60617656",
"0.604975",
"0.6027195",
... | 0.6163727 | 11 |
Returns this record's parent. | def parent
base_set_class.find(self[parent_col_name]) if self[parent_col_name]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent\n if parent_id.blank? then nil else unscoped_find(parent_id) end\n end",
"def parent\n return @parent\n end",
"def parent\n\n h.parent_id ?\n Ruote::Exp::FlowExpression.fetch(@context, h.parent_id) :\n nil\n end",
"def parent\n tree.pare... | [
"0.84784544",
"0.83824444",
"0.8354035",
"0.830168",
"0.82071406",
"0.82053274",
"0.8205208",
"0.819517",
"0.81944245",
"0.8117471",
"0.8117471",
"0.8117471",
"0.8117471",
"0.80889726",
"0.8035122",
"0.79576796",
"0.7908726",
"0.7894084",
"0.78788114",
"0.7874622",
"0.7869753... | 0.7128962 | 82 |
Returns an array of all parents, starting with the root. | def ancestors
self_and_ancestors - [self]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ancestors\n parents = []\n\n this_parent = self.parent\n\n while this_parent != nil\n parents << this_parent\n this_parent = this_parent.parent\n end\n parents\n end",
"def parents\n unless @parents\n @parents = []\n object = ... | [
"0.8063405",
"0.7997283",
"0.77717274",
"0.7750851",
"0.7635208",
"0.7568248",
"0.751398",
"0.74752855",
"0.7475203",
"0.745758",
"0.74157244",
"0.74121433",
"0.74039507",
"0.73833936",
"0.7382528",
"0.73592144",
"0.7347399",
"0.7326278",
"0.7285764",
"0.7271115",
"0.7200792"... | 0.0 | -1 |
Returns an array of all parents plus self, starting with the root. | def self_and_ancestors
base_set_class.find(:all, :conditions => "#{scope_condition} AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name})", :order => left_col_name )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end",
"def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n... | [
"0.8120564",
"0.81204414",
"0.80846035",
"0.80822563",
"0.799836",
"0.7768516",
"0.7661956",
"0.76125795",
"0.76058424",
"0.7586401",
"0.7563383",
"0.7562111",
"0.7486465",
"0.74743366",
"0.7452375",
"0.7411038",
"0.73923314",
"0.72901964",
"0.7288449",
"0.7263943",
"0.725350... | 0.0 | -1 |
Returns all the children of this node's parent, except self. | def siblings
self_and_siblings - [self]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def siblings\n return [] unless parent\n parent.children.reject { |p| p == self }\n end",
"def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end",
"def children\n dataset.nested.filter(self.class.quali... | [
"0.72534496",
"0.6916118",
"0.6714133",
"0.6709741",
"0.66709584",
"0.6619373",
"0.6498624",
"0.64912295",
"0.64912295",
"0.64787",
"0.6464504",
"0.6463161",
"0.6460375",
"0.64581126",
"0.6452195",
"0.64503527",
"0.6448903",
"0.6419546",
"0.6403517",
"0.6384796",
"0.6384796",... | 0.0 | -1 |
Returns all the children of this node's parent, including self. | def self_and_siblings
if self[parent_col_name].nil? || self[parent_col_name].zero?
[self]
else
base_set_class.find(:all, :conditions => "#{scope_condition} AND #{parent_col_name} = #{self[parent_col_name]}", :order => left_col_name)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end",
"def children\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"#{nested_set_parent} = #{self.id}\", :order => nested_set_left)\n end",
"def chi... | [
"0.7634356",
"0.7259016",
"0.7202455",
"0.719435",
"0.7178175",
"0.7161041",
"0.7087561",
"0.69796944",
"0.69543666",
"0.6890178",
"0.68715376",
"0.68399674",
"0.6838534",
"0.6824851",
"0.6803588",
"0.6788061",
"0.6763411",
"0.6750177",
"0.6750177",
"0.67488354",
"0.67442113"... | 0.0 | -1 |
Returns the level of this object in the tree, root level being 0. | def level
return 0 if self[parent_col_name].nil?
base_set_class.count(:conditions => "#{scope_condition} AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name})") - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level\n return 0 if root?\n\n @parent.level + 1\n end",
"def level\n parent_id.nil? ? 0 : compute_level\n end",
"def level\n if parent.nil?\n 0\n else\n parent.level + 1;\n end\n end",
"def level\n root? ? 0 : ancestors.count\n en... | [
"0.8281878",
"0.81978035",
"0.7918772",
"0.778641",
"0.7766266",
"0.7766266",
"0.76997364",
"0.75247705",
"0.7508308",
"0.7508308",
"0.7395063",
"0.7395063",
"0.7258708",
"0.72070634",
"0.7155497",
"0.7098564",
"0.7096889",
"0.6991486",
"0.69806343",
"0.6958423",
"0.68818164"... | 0.6271305 | 35 |
Returns the number of nested children of this object. | def all_children_count
return (self[right_col_name] - self[left_col_name] - 1)/2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_children\n @children.size\n end",
"def num_children\n @children.size\n end",
"def num_children\n count = 0\n self.children.each do |child|\n count = count + child.num_children\n end\n\n return self.children.size + count\n end",
"def count_children\n ... | [
"0.8398504",
"0.8378222",
"0.83523947",
"0.8122807",
"0.8009751",
"0.79829365",
"0.7730541",
"0.7683608",
"0.7582975",
"0.7526048",
"0.7504786",
"0.7484354",
"0.73339397",
"0.7274246",
"0.721356",
"0.7212441",
"0.71243304",
"0.7067528",
"0.70630413",
"0.7061069",
"0.7051977",... | 0.6513029 | 40 |
Returns itself and all nested children. Pass :exclude => item, or id, or [items or id] to exclude one or more items and all of their descendants. | def full_set(special=nil)
if special && special[:exclude]
exclude_str = " AND NOT (#{base_set_class.sql_for(special[:exclude])}) "
elsif new_record? || self[right_col_name] - self[left_col_name] == 1
return [self]
end
base_set_class.find(:all, :conditions => "#{scope_condition} #{exclude_str} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})", :order => left_col_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_children(options = {})\n conditions = \"(#{nested_set_left} > #{self[nested_set_left]}) and (#{nested_set_right} < #{self[nested_set_right]})\"\n if options[:exclude]\n transaction do\n # exclude some items and all their children\n options[:exclude] = ... | [
"0.6893128",
"0.6810607",
"0.64480454",
"0.62908393",
"0.6191619",
"0.6076562",
"0.59581566",
"0.5936782",
"0.5933396",
"0.5921334",
"0.59110093",
"0.5899419",
"0.5893955",
"0.5873582",
"0.58590585",
"0.5819769",
"0.579713",
"0.5791045",
"0.5767786",
"0.57394755",
"0.5689808"... | 0.0 | -1 |
Returns all children and nested children. Pass :exclude => item, or id, or [items or id] to exclude one or more items and all of their descendants. | def all_children(special=nil)
full_set(special) - [self]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_children(options = {})\n conditions = \"(#{nested_set_left} > #{self[nested_set_left]}) and (#{nested_set_right} < #{self[nested_set_right]})\"\n if options[:exclude]\n transaction do\n # exclude some items and all their children\n options[:exclude] = ... | [
"0.74371666",
"0.70197344",
"0.6592408",
"0.63761985",
"0.6288133",
"0.62532914",
"0.62080973",
"0.6190531",
"0.61816496",
"0.61080414",
"0.6103033",
"0.6084506",
"0.6062308",
"0.60235035",
"0.6003771",
"0.596848",
"0.59574425",
"0.592502",
"0.59181404",
"0.59181404",
"0.5910... | 0.53822553 | 87 |
Returns this record's immediate children. | def children
base_set_class.find(:all, :conditions => "#{scope_condition} AND #{parent_col_name} = #{self.id}", :order => left_col_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_children\n return children\n end",
"def children\n _children\n end",
"def children\n entries\n end",
"def get_children\n return @children\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n ... | [
"0.79561377",
"0.7917964",
"0.78821695",
"0.78709346",
"0.77638066",
"0.77638066",
"0.77529913",
"0.76823556",
"0.76823556",
"0.76823556",
"0.7682236",
"0.76585543",
"0.76379603",
"0.7629049",
"0.7611802",
"0.76102257",
"0.7590137",
"0.7582787",
"0.753093",
"0.752095",
"0.752... | 0.72143537 | 44 |
Returns this record's terminal children (nodes without children). | def leaves
base_set_class.find(:all, :conditions => "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]}) AND #{left_col_name} + 1 = #{right_col_name}", :order => left_col_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n\t\treturn children_of @current_node\n\tend",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def children\n []\n end",
"def get_children\n return @children\n end",
"def ... | [
"0.7485976",
"0.7482659",
"0.7482659",
"0.74710757",
"0.74710757",
"0.74710757",
"0.74622446",
"0.745783",
"0.74518925",
"0.7441958",
"0.7397935",
"0.7368642",
"0.734426",
"0.7332586",
"0.7332586",
"0.73195386",
"0.7237186",
"0.7208795",
"0.7179286",
"0.71649426",
"0.7156215"... | 0.0 | -1 |
Returns the count of this record's terminal children (nodes without children). | def leaves_count
base_set_class.count(:conditions => "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]}) AND #{left_col_name} + 1 = #{right_col_name}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_children\n @children.size\n end",
"def count_children\n count = children.count\n if count\n children.each { |child| count += child.count_children }\n end\n count\n end",
"def num_children\n @children.size\n end",
"def num_children\n count = 0\n se... | [
"0.79330945",
"0.7913664",
"0.78799975",
"0.7837773",
"0.77757674",
"0.7772748",
"0.76224947",
"0.7556294",
"0.7451842",
"0.73071563",
"0.72903603",
"0.72588015",
"0.7095993",
"0.69766325",
"0.69315207",
"0.6885031",
"0.68847525",
"0.687455",
"0.6806833",
"0.6794341",
"0.6794... | 0.0 | -1 |
Recalculate the left/right values of all nodes in this record's tree. Can be used to convert an ordinary tree into a nested set. | def renumber_full_tree
indexes = []
n = 1
transaction do
for r in roots # because we may have virtual roots
n = r.calc_numbers(n, indexes)
end
for i in indexes
base_set_class.update_all("#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}", "#{self.class.primary_key} = #{i[:id]}")
end
end
## reload?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = 1 + r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{... | [
"0.72770286",
"0.68205845",
"0.6439447",
"0.6390184",
"0.6345537",
"0.6257305",
"0.6247141",
"0.62443066",
"0.59245634",
"0.58968276",
"0.5881247",
"0.58579767",
"0.5830209",
"0.5822079",
"0.574823",
"0.57463944",
"0.56827253",
"0.56699955",
"0.5663866",
"0.5661947",
"0.56296... | 0.736635 | 0 |
Deprecated. Adds a child to this object in the tree. If this object hasn't been initialized, it gets set up as a root node. This method exists only for compatibility and will be removed in future versions. | def add_child(child)
transaction do
self.reload; child.reload # for compatibility with old version
# the old version allows records with nil values for lft and rgt
unless self[left_col_name] && self[right_col_name]
if child[left_col_name] || child[right_col_name]
raise ActiveRecord::ActiveRecordError, "If parent lft or rgt are nil, you can't add a child with non-nil lft or rgt"
end
base_set_class.update_all("#{left_col_name} = CASE \
WHEN id = #{self.id} \
THEN 1 \
WHEN id = #{child.id} \
THEN 3 \
ELSE #{left_col_name} END, \
#{right_col_name} = CASE \
WHEN id = #{self.id} \
THEN 2 \
WHEN id = #{child.id} \
THEN 4 \
ELSE #{right_col_name} END",
scope_condition)
self.reload; child.reload
end
unless child[left_col_name] && child[right_col_name]
maxright = base_set_class.maximum(right_col_name, :conditions => scope_condition) || 0
base_set_class.update_all("#{left_col_name} = CASE \
WHEN id = #{child.id} \
THEN #{maxright + 1} \
ELSE #{left_col_name} END, \
#{right_col_name} = CASE \
WHEN id = #{child.id} \
THEN #{maxright + 2} \
ELSE #{right_col_name} END",
scope_condition)
child.reload
end
child.move_to_child_of(self)
# self.reload ## even though move_to calls target.reload, at least one object in the tests was not reloading (near the end of test_common_usage)
end
# self.reload
# child.reload
#
# if child.root?
# raise ActiveRecord::ActiveRecordError, "Adding sub-tree isn\'t currently supported"
# else
# if ( (self[left_col_name] == nil) || (self[right_col_name] == nil) )
# # Looks like we're now the root node! Woo
# self[left_col_name] = 1
# self[right_col_name] = 4
#
# # What do to do about validation?
# return nil unless self.save
#
# child[parent_col_name] = self.id
# child[left_col_name] = 2
# child[right_col_name]= 3
# return child.save
# else
# # OK, we need to add and shift everything else to the right
# child[parent_col_name] = self.id
# right_bound = self[right_col_name]
# child[left_col_name] = right_bound
# child[right_col_name] = right_bound + 1
# self[right_col_name] += 2
# self.class.transaction {
# self.class.update_all( "#{left_col_name} = (#{left_col_name} + 2)", "#{scope_condition} AND #{left_col_name} >= #{right_bound}" )
# self.class.update_all( "#{right_col_name} = (#{right_col_name} + 2)", "#{scope_condition} AND #{right_col_name} >= #{right_bound}" )
# self.save
# child.save
# }
# end
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_child child\n @children << child\n self\n end",
"def add_child(root, child)\n raise NotImplementedError\n end",
"def add_child child\n @children << child\n end",
"def add_child(child)\n if self.root?\n child.root_node = self\n else\n child.root_nod... | [
"0.73784715",
"0.73500526",
"0.7319901",
"0.7218514",
"0.71272326",
"0.7121041",
"0.7118899",
"0.70876366",
"0.7050175",
"0.7044651",
"0.7044651",
"0.70296794",
"0.7014869",
"0.7009511",
"0.6986167",
"0.6976314",
"0.69511896",
"0.6943807",
"0.6875062",
"0.6828618",
"0.6799633... | 0.5703409 | 87 |
used by the renumbering methods | def calc_numbers(n, indexes) #:nodoc:
my_lft = n
# performance improvements (3X or more for tables with lots of columns) by using :select to load just id, lft and rgt
## i don't use the scope condition here, because it shouldn't be needed
my_children = base_set_class.find(:all, :conditions => "#{parent_col_name} = #{self.id}",
:order => left_col_name, :select => "#{self.class.primary_key}, #{left_col_name}, #{right_col_name}")
if my_children.empty?
my_rgt = (n += 1)
else
for c in (my_children)
n = c.calc_numbers(n + 1, indexes)
end
my_rgt = (n += 1)
end
indexes << {:id => self.id, :lft => my_lft, :rgt => my_rgt} unless self[left_col_name] == my_lft && self[right_col_name] == my_rgt
return n
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numid=(_); end",
"def renumber_lists\n lists.order(\"upper(name) asc\").each_with_index do |list, ndx|\n list.update(number: ndx+1)\n end\n end",
"def resequence\n if @numbers\n (0...@list_size).each do |j|\n target = @item[j]\n\n source = \"%4d. %s... | [
"0.64506245",
"0.6259851",
"0.61269253",
"0.60911477",
"0.60832113",
"0.59726375",
"0.59273875",
"0.5914938",
"0.5913037",
"0.58983225",
"0.5850089",
"0.5767538",
"0.5757154",
"0.5742305",
"0.5712332",
"0.5637966",
"0.5628454",
"0.5626515",
"0.56183654",
"0.5614109",
"0.56126... | 0.0 | -1 |
override ActiveRecord to prevent lft/rgt values from being saved (can corrupt indexes under concurrent usage) | def update #:nodoc:
connection.update(
"UPDATE #{self.class.table_name} " +
"SET #{quoted_comma_pair_list(connection, special_attributes_with_quotes(false))} " +
"WHERE #{self.class.primary_key} = #{quote_value(id)}",
"#{self.class.name} Update"
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prevent_double_save_bug\n false if self.persisted?\n end",
"def before_update\n lock_column_instance_filter\n super\n end",
"def _before_validation\n if new? && (set = self[model.sti_key])\n exp = model.sti_key_chooser.call(self)\n if set != exp\n... | [
"0.5821733",
"0.56324697",
"0.5543295",
"0.55406123",
"0.55342853",
"0.5472985",
"0.5472146",
"0.5430446",
"0.53787434",
"0.5355364",
"0.5355364",
"0.53139305",
"0.5279822",
"0.5268506",
"0.52679384",
"0.52679384",
"0.52655506",
"0.5263125",
"0.5247419",
"0.52450705",
"0.5241... | 0.0 | -1 |
exclude the lft/rgt columns from update statements | def special_attributes_with_quotes(include_primary_key = true) #:nodoc:
attributes.inject({}) do |quoted, (name, value)|
if column = column_for_attribute(name)
quoted[name] = quote_value(value, column) unless (!include_primary_key && column.primary) || [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]].include?(column.name)
end
quoted
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_without_checking(columns)\n _update_dataset.update(columns)\n end",
"def _update_without_checking(columns)\n _update_dataset.update(columns)\n end",
"def _update_without_checking(columns)\n ds = _update_dataset\n lc = model.lock_column\n rows = ds.... | [
"0.6621375",
"0.6621375",
"0.65491235",
"0.63984334",
"0.63360035",
"0.6259769",
"0.61639607",
"0.6115827",
"0.61111766",
"0.60705787",
"0.6058055",
"0.6058055",
"0.6052958",
"0.60441005",
"0.60441005",
"0.59847116",
"0.59847116",
"0.5975056",
"0.5965982",
"0.5922187",
"0.591... | 0.0 | -1 |
i couldn't figure out how to call attributes_with_quotes without cutting and pasting this private method in. :( Quote strings appropriately for SQL statements. | def quote_value(value, column = nil) #:nodoc:
self.class.connection.quote(value, column)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes_with_quotes\n columns_hash = self.class.columns_hash\n @attributes.inject({}) do |attrs_quoted, pair| \n attrs_quoted[pair.first] = quote(pair.last, columns_hash[pair.first])\n attrs_quoted\n end\n end",
"def attributes_with_quotes(include_primary_key = ... | [
"0.81485236",
"0.73893154",
"0.72634214",
"0.7245756",
"0.696161",
"0.69066954",
"0.6872065",
"0.6829774",
"0.66489375",
"0.66341776",
"0.662026",
"0.6598165",
"0.65825623",
"0.6531401",
"0.65191674",
"0.6447311",
"0.6447311",
"0.6447311",
"0.6447311",
"0.6447311",
"0.6447311... | 0.0 | -1 |
grid = ["11110","11010","11000","00000"] p num_islands(grid) | def license_key_formatting(s, k)
s = s.upcase.delete('-')
i = s.length - 1
until i < 0
k.times do
i-= 1
end
s[i] += '-' if i >= 0
end
s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_islands(grid)\n return 0 if grid.empty?\n\n count = 0\n\n grid.each_with_index do |row, i|\n row.each_with_index do |_col, j|\n if grid[i][j] == '1'\n dfs(i, j, grid)\n count += 1\n end\n end\n end\n count\nend",
"def count_islands(matrix)\n rows = matrix.length\n col... | [
"0.8001825",
"0.7288801",
"0.6291966",
"0.62090176",
"0.61961794",
"0.6189297",
"0.61665344",
"0.6012099",
"0.59810567",
"0.5941646",
"0.5941072",
"0.59189516",
"0.58787864",
"0.5809819",
"0.5801855",
"0.5797561",
"0.57455504",
"0.5732031",
"0.56944484",
"0.5689263",
"0.56878... | 0.0 | -1 |
I worked on this challenge [by myself, with: ]. shortest_string is a method that takes an array of strings as its input and returns the shortest string +list_of_words+ is an array of strings shortest_string(array) should return the shortest string in the +list_of_words+ If +list_of_words+ is empty the method should return nil Your Solution Below def shortest_string(list_of_words) arrlen = list_of_words.length 1 if arrlen 0 if list_of_words[arrlen1].length < shortest_len shortest_str = list_of_words[arrlen1] shortest_len = shortest_str.length end arrlen = 1 end return shortest_str end | def shortest_string(list_of_words)
if list_of_words.length == 0
return nil
end
list_of_words.sort_by! {|i| i.length}
return list_of_words[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortest_string(list_of_words)\n # PSEUDOCODE\n # return nil if list has no strings in it\n # I'm assuming the .length method is okay here, otherwise this problem would be a lot more tedious\n # Initialize initial shortest word as first word in array\n # Initialize initial shortest length as length of t... | [
"0.89361185",
"0.8881807",
"0.88110244",
"0.8796344",
"0.87886435",
"0.8780531",
"0.8778372",
"0.87461585",
"0.87158734",
"0.87056077",
"0.87036514",
"0.8697932",
"0.8696524",
"0.86935776",
"0.86565083",
"0.86020035",
"0.8592066",
"0.85364354",
"0.85133046",
"0.8489889",
"0.8... | 0.8359429 | 25 |
Create a new proxy connection to the given proxy host and port. Optionally, a :user key may be given to identify the username with which to authenticate. | def initialize(proxy_host, proxy_port = 1080, options = {})
@proxy_host = proxy_host
@proxy_port = proxy_port
@options = options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_proxy(address, port, user = T.unsafe(nil), password = T.unsafe(nil)); end",
"def http_proxy addr, opts={}\n return Net::HTTP unless addr\n\n host, port = addr.split \":\"\n port ||= opts[:port] || 8080\n\n user = opts[:username]\n pass = opts[:password]\n\n Kronk::Cmd.verbos... | [
"0.69448906",
"0.676763",
"0.67436266",
"0.6698953",
"0.6698953",
"0.6698953",
"0.6698953",
"0.6698953",
"0.6698953",
"0.6698953",
"0.6677544",
"0.66153663",
"0.6614841",
"0.6578097",
"0.6505692",
"0.6496108",
"0.64199877",
"0.64193255",
"0.639969",
"0.6374131",
"0.6208548",
... | 0.6005994 | 25 |
Return a new socket connected to the given host and port via the proxy that was requested when the socket factory was instantiated. | def open(host, port, connection_options)
socket = Socket.tcp(proxy_host, proxy_port, nil, nil,
connect_timeout: connection_options[:timeout])
ip_addr = IPAddr.new(Resolv.getaddress(host))
packet = [VERSION, CONNECT, port.to_i, ip_addr.to_i, options[:user]].pack("CCnNZ*")
socket.send packet, 0
version, status, port, ip = socket.recv(8).unpack("CCnN")
if status != GRANTED
socket.close
raise ConnectError, "error connecting to proxy (#{status})"
end
return socket
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proxified_socket(host, port)\n proxy = ENV[\"https_proxy\"] || ENV[\"http_proxy\"] || false\n\n if proxy && !fuzzy_hostname_match_any?(host, ENV[\"no_proxy\"])\n Proxifier.Proxy(proxy).open(host, port)\n else\n TCPSocket.new(host, port)\n end\n end",
"def op... | [
"0.76001567",
"0.71789515",
"0.692484",
"0.685941",
"0.6842947",
"0.6760849",
"0.6757075",
"0.6723374",
"0.6599654",
"0.6573526",
"0.65724576",
"0.6567157",
"0.6548365",
"0.6541595",
"0.65214294",
"0.65103066",
"0.64605594",
"0.6395141",
"0.63469183",
"0.63281417",
"0.6324139... | 0.70843345 | 2 |
System messages (user left, got invited, room renamed, etc) | def system_messages
data['sysMes']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def system_msg\n msg=[]\n if (AppConfig.read_only_flag=='y' and !AppConfig.read_only_msg.blank?)\n msg << \"<p>#{h AppConfig.read_only_msg}</p>\"\n end\n \n if (AppConfig.ooc_read_only_flag=='y' and !AppConfig.ooc_read_only_msg.blank?)\n msg << \"<p>#{h AppConfig.ooc_read_only_msg}</p>\"\n... | [
"0.6722214",
"0.62676734",
"0.62676734",
"0.6247814",
"0.6187957",
"0.61807066",
"0.6149143",
"0.6096753",
"0.6096753",
"0.6080909",
"0.60201865",
"0.6013793",
"0.6005453",
"0.59911287",
"0.59911287",
"0.59911287",
"0.59792495",
"0.59792495",
"0.596086",
"0.5928538",
"0.58972... | 0.63648367 | 1 |
CMS SETTINGS CONFIGS API Settings | def locationURNInput
return @driver.find_element(:xpath, "//input[@placeholder='location_urn']")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settings\n request(Resources::RESOURCE_SETTINGS, HTTP_METHOD_POST)\n end",
"def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end",
"def get_settings\n reques... | [
"0.7421613",
"0.739472",
"0.73901784",
"0.73901784",
"0.7383403",
"0.7376206",
"0.72974193",
"0.7289265",
"0.72891897",
"0.7277101",
"0.7239867",
"0.72119343",
"0.72119343",
"0.72087824",
"0.72087824",
"0.7184922",
"0.7155484",
"0.7155484",
"0.7155365",
"0.7123577",
"0.711776... | 0.0 | -1 |
Sets playback rate of CSS animations. | def playback_rate=(value)
command("Animation.setPlaybackRate", playbackRate: value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_frame_rate(rate)\n @cue_list.frame_rate = rate\n end",
"def frame_rate=(rate)\n @list.each { |c| c.change_frame_rate(@fps, rate) }\n @fps = rate\n end",
"def animationSpeed=(animationSpeed)\n @animationSpeed = animationSpeed.to_f/1000 * 60\n end",
"def frames_per_second=(a); ... | [
"0.7158706",
"0.707443",
"0.69102335",
"0.6275587",
"0.62502605",
"0.6159518",
"0.6121623",
"0.6069054",
"0.6041771",
"0.5938782",
"0.58216393",
"0.5720135",
"0.57045597",
"0.5663251",
"0.5663251",
"0.56567955",
"0.56222117",
"0.5576935",
"0.5575593",
"0.5573351",
"0.55466235... | 0.77307385 | 0 |
Complete the makeAnagram function below. | def makeAnagram(a, b)
dict = Hash.new{0}
cnt = 0
a.chars.each {|n| dict[n] += 1}
b.chars.each {|n| dict[n] -= 1}
dict.values.each {|v| cnt += v.abs}
cnt
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_anagram(text)\n\nend",
"def combine_anagrams_method2(words)\n\ttemp1 = Array.new\n\ttemp1 = words.clone\t# making a deep copy of the input \n\tanagram = Array.new\t\n\ti = 0\n\twhile i < temp1.length\t\t\t\n\t\tcount = 0 # count the number of anagrams of a particular string say \"cars\"\n\t\tfor j in... | [
"0.8007",
"0.7566226",
"0.7470645",
"0.7432831",
"0.7404339",
"0.7392311",
"0.73076415",
"0.72849494",
"0.728457",
"0.72840166",
"0.7270021",
"0.72607476",
"0.7258781",
"0.725877",
"0.7246425",
"0.72407764",
"0.72151047",
"0.72024703",
"0.718429",
"0.7177312",
"0.7133882",
... | 0.70296323 | 29 |
Complete the alternatingCharacters function below. | def alternatingCharacters(s)
previous_char = ""
cnt = 0
s.chars do |c|
if c == previous_char
cnt += 1
end
previous_char = c
end
cnt
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alternating_char string\n arr = string.chars\n count = 0\n arr.each_with_index do |x,xi|\n if xi > 0\n if arr[xi-1] == 'A'\n count +=1 unless x == 'B'\n else\n count +=1 unless x == 'A'\n end\n end\n end\n count\nend",
"def alternatingCharacters(s)\n del_count = 0\n ... | [
"0.663255",
"0.64897543",
"0.6408977",
"0.6312761",
"0.63033795",
"0.6279413",
"0.62460554",
"0.61642134",
"0.6131965",
"0.6115898",
"0.6087037",
"0.605124",
"0.6016919",
"0.5997678",
"0.5996773",
"0.5988759",
"0.5985937",
"0.59777147",
"0.5973668",
"0.59669346",
"0.5952255",... | 0.71197784 | 0 |
Afficher si c'est gagner ou perdu | def demande_de_grille #definir une methode demande de grille
puts "choisir 5 nombres de 1 à 45"
grid = gets
return grid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peutRetourAvant?()\n return @indiceCoup < @tabCoup.size\n end",
"def debo_ir_a_carcel\n if (super)\n return !pagar_fianza\n else\n return true \n # Lo hemos hecho así, porque pensamos que si tiene carta y llama a \n # pagar fianza y tiene el saldo suficiente, se rest... | [
"0.6883653",
"0.6611924",
"0.66074383",
"0.6571171",
"0.63197565",
"0.6265348",
"0.6262407",
"0.6214913",
"0.6211352",
"0.62064666",
"0.619145",
"0.6086819",
"0.60700464",
"0.60642225",
"0.6007804",
"0.6006101",
"0.5997971",
"0.5987469",
"0.59809446",
"0.59657764",
"0.5954715... | 0.0 | -1 |
comaparaison de la grille et le tirage | def show_result sorted_grid, sorted_draw
# comparons la grille et le tirage
winner = (sorted_grid == sorted_draw)
if winner
puts "Vous avez gagne"
else
puts "Vous avez perdu"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def porc_grasa\n\t\t(1.2 * self.indice_masa_corporal + 0.23 * edad - 10.8 * sexo - 5.4).round(1)\n\tend",
"def grasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * ( sexo ? 1 : 0) - 5.4\n\tend",
"def porcentaje_graso\n (1.2*calcular_imc)+(0.23*@edad)-(10.8*@sexo)-5.4\n end",
"def candidatGrille()\n\n\tend"... | [
"0.7751134",
"0.7530691",
"0.73430467",
"0.7241775",
"0.7128314",
"0.7124336",
"0.71112186",
"0.6979215",
"0.68545216",
"0.6790285",
"0.6613468",
"0.6575124",
"0.656638",
"0.6491464",
"0.6481334",
"0.6475752",
"0.646888",
"0.6457517",
"0.6438405",
"0.64339834",
"0.6332017",
... | 0.0 | -1 |
enregistrer une grille pour le loto courant | def validate_grid grid
# verifier que le tirage n'a pas encore eu lieu
@saved_grids ||=[]
# TODO check draw isnot yet done
return @saved_grids if draw_done?
@saved_grids.push grid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sauvegarderJeu()\n\t\t# création de la sauvegarde\n\t\t@sauvegarde = Sauvegarde.creer( self.joueur,self.carte,self.nbTour )\n\n @sauvegardeYaml = SauvegardeYAML.creer(self.joueur.nom)\n @sauvegardeYaml.enregistrement( self.sauvegarde)\n\n\tend",
"def sauvegarder(nomFichier)\n\t\n\t\t# Ouverture du fich... | [
"0.59939194",
"0.5798812",
"0.5716627",
"0.5670351",
"0.55467117",
"0.54689956",
"0.53533775",
"0.53275794",
"0.53203315",
"0.53117484",
"0.52975065",
"0.52975065",
"0.52827907",
"0.5265971",
"0.526555",
"0.5250033",
"0.5236853",
"0.5216669",
"0.5205916",
"0.52012175",
"0.520... | 0.0 | -1 |
Handles Format for Auth Methods | def redirect_auth(url)
respond_to do |format|
format.html do
flash[:error] = "You do not have permission to view or modify this resource."
redirect_to url
end
format.json do
head :unauthorized
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_methods; end",
"def auth\n end",
"def auth\n end",
"def auth(value); end",
"def authenticate\n end",
"def auth_param; end",
"def auth(args)\r\n auth_method = args.fetch(:type, :standard)\r\n standard_auth(args) if auth_method == :standard\r\n end",
"def authenticate_user\... | [
"0.7273745",
"0.7179859",
"0.7179859",
"0.71093464",
"0.6862402",
"0.68124276",
"0.6776702",
"0.67414236",
"0.67325646",
"0.6680244",
"0.66417253",
"0.66407377",
"0.6520645",
"0.64852357",
"0.6469268",
"0.6446972",
"0.64343417",
"0.64183044",
"0.64117193",
"0.6409074",
"0.639... | 0.0 | -1 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
key_for_min=nil
lowest_value=nil
name_hash.each do |key,value|
if lowest_value==nil || value<lowest_value
lowest_value=value
key_for_min=key
end
end
key_for_min
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585... | 0.0 | -1 |
Checks the response status of the linked_url and stores it on the ok or broken collections | def check_status(linked_url, from_url)
if @broken.keys.include?(linked_url)
# This was already known to be broken, we add another origin
@broken[linked_url] << from_url
else
if !@ok.include?(linked_url)
# We still don't know about this link status, so we check it now
if reachable?(linked_url)
@ok << linked_url
else
@broken[linked_url] = [from_url]
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def urls_failed\n\t\t\t@urls.select{|u| not u.success}\n\t\tend",
"def checkError\n status = Array.new\n if params[:offset]\n if params[:limit] != \"\"\n urlMasters = Urlmaster.limit(params[:limit].to_i).offset(params[:offset].to_i)\n else\n urlMasters = Urlmaster.offset(params[:off... | [
"0.63393325",
"0.622879",
"0.6131479",
"0.6090742",
"0.6090742",
"0.6089222",
"0.60618484",
"0.59566075",
"0.5912328",
"0.5910831",
"0.58864087",
"0.58178145",
"0.5809795",
"0.580053",
"0.5790382",
"0.5782917",
"0.5739215",
"0.5716895",
"0.5703633",
"0.5685282",
"0.5676209",
... | 0.7361032 | 0 |
A page is reachable if its response status is less than 400 In the case of exceptions, like timeouts or server connection errors, we consider it unreachable | def reachable?(url)
page = MetaInspector.new(url)
if page.response.status < 400
true
else
false
end
rescue
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reachable?\n return true if (page_ref && (page_ref.good? || (page_ref.http_status == 200))) || (gleaning && gleaning.good?)\n return false if (page_ref && @@BadResponseCodes.include?(page_ref.http_status)) &&\n (gleaning && @@BadResponseCodes.include?(gleaning.http_status))\n end",
"def page_st... | [
"0.6861654",
"0.6764447",
"0.6672075",
"0.6623096",
"0.65873194",
"0.65186507",
"0.6506967",
"0.6459085",
"0.6456401",
"0.64426",
"0.6436165",
"0.64096296",
"0.6357562",
"0.6351178",
"0.6307416",
"0.6292868",
"0.6282211",
"0.6273107",
"0.62696683",
"0.62693334",
"0.6259066",
... | 0.76856244 | 0 |
overridden Devise method that checks the soft delete timestamp on authentication | def active_for_authentication?
super && !deactivated_at
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active_for_authentication? \n super && !deleted_at \n end",
"def active_for_authentication? \n super && !deleted_at \n end",
"def active_for_authentication?\n super && !deleted_at\n end",
"def active_for_authentication?\n super && !deleted_at\n end",
"def active_for_authenti... | [
"0.7788317",
"0.7788317",
"0.76786214",
"0.76735294",
"0.7646309",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
"0.75502956",
... | 0.6381246 | 56 |
method that adds an interest to interest_db database | def add_interest(db, interest)
db.execute("INSERT INTO interests (interest) VALUES (?)", [interest])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_interest(id)\n SocietyInterest.create(society_id: self.id, interest_id: id)\n end",
"def add_friend_interest(db, friend_id, interest_id)\n db.execute(\"INSERT INTO friends_interests (friend_id, interest_id) VALUES (?, ?)\", [friend_id, interest_id])\nend",
"def create \n @interest = Interest.... | [
"0.7968279",
"0.77632064",
"0.68672884",
"0.6721698",
"0.65774286",
"0.65774286",
"0.65774286",
"0.65774286",
"0.65774286",
"0.6483784",
"0.63011116",
"0.6286764",
"0.6194512",
"0.61882764",
"0.6170924",
"0.61625606",
"0.61574566",
"0.6108701",
"0.6105049",
"0.6079302",
"0.60... | 0.8421365 | 0 |
method that adds a friend to friend_db database | def add_friend(db, friend_name, age, birth_month, birth_day, likes_birthdays)
db.execute("INSERT INTO friends (friend_name, age, birth_month, birth_day, likes_birthdays) VALUES (?, ?, ?, ?, ?)", [friend_name, age, birth_month, birth_day, likes_birthdays])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_friend(friend)\n raise ArgumentError unless friend\n raise ArgumentError.new(\"Already friended\") if friends.include? friend\n\n f = Friendship.new :user_id => self.id, :friend_id => friend.id\n return f.save\n end",
"def add_friend\n # check if this friend isnt't to our list friend\n ... | [
"0.7863094",
"0.76336265",
"0.75564027",
"0.74632585",
"0.74216974",
"0.7373835",
"0.7326069",
"0.72926813",
"0.72406733",
"0.7234682",
"0.7154937",
"0.7137835",
"0.707263",
"0.7064795",
"0.7009636",
"0.7008091",
"0.6961659",
"0.69246745",
"0.6908144",
"0.6812475",
"0.6747190... | 0.82042044 | 0 |
method that joins a friend to their interest in the join table | def add_friend_interest(db, friend_id, interest_id)
db.execute("INSERT INTO friends_interests (friend_id, interest_id) VALUES (?, ?)", [friend_id, interest_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_interests_array(db, friend_name)\n friend_interests = db.execute(\"SELECT interests.interest FROM friends join friends_interests on friends.id=friends_interests.friend_id join interests on interests.id=friends_interests.interest_id where friend_name='#{friend_name}'\")\nend",
"def relation_method\n ... | [
"0.62735987",
"0.6204703",
"0.6159128",
"0.5939733",
"0.5919285",
"0.5893872",
"0.5893872",
"0.5858603",
"0.5826177",
"0.58008754",
"0.5729356",
"0.5694167",
"0.56681126",
"0.56304824",
"0.56233764",
"0.56207585",
"0.56186277",
"0.5594803",
"0.55798703",
"0.55626386",
"0.5559... | 0.52686244 | 55 |
method that returns the id of the name specied from the friends table | def find_friend_id(db, friend_name)
friend_id = db.execute("SELECT friends.id FROM friends WHERE friend_name='#{friend_name}'")
friend_id[0][0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id(name)\n @users.each do |user|\n return user[:id] if user[:name] == name\n end\n nil\n end",
"def get_friendship_id(user)\n \tFriendship.where(\"user_id = ? AND friend_id = ?\", current_user.id, user.id).first.id\n end",
"def get_friend_id \n uri ... | [
"0.6791384",
"0.6568132",
"0.6549109",
"0.6315099",
"0.6296776",
"0.62645805",
"0.61871487",
"0.61871487",
"0.6115304",
"0.6078169",
"0.6065757",
"0.6062285",
"0.60531163",
"0.6005002",
"0.6005002",
"0.5979276",
"0.596438",
"0.59635335",
"0.5898441",
"0.58923906",
"0.5856448"... | 0.7842519 | 0 |
method that returns the id of the interest specied from the interests table | def find_interest_id(db, interest_name)
interest_id = db.execute("SELECT interests.id FROM interests WHERE interest='#{interest_name}'")
interest_id[0][0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_interestID\n if current_user == nil\n @current_interestID = nil\n elsif UserInterestMapping.where(userID: current_user[:id]) == []\n @current_interestID = nil\n else\n @current_interestID = UserInterestMapping.where(userID: current_user[:id])[0][:interestID]\n end\n @curre... | [
"0.7075682",
"0.6963178",
"0.6963178",
"0.6963178",
"0.6963178",
"0.6963178",
"0.69167006",
"0.679399",
"0.66481733",
"0.6397777",
"0.62641895",
"0.62553436",
"0.60541075",
"0.6051885",
"0.60421365",
"0.59422874",
"0.59422874",
"0.5873735",
"0.5846951",
"0.58388776",
"0.57914... | 0.7844811 | 0 |
method that returns an array of all the interests of a friend | def find_interests_array(db, friend_name)
friend_interests = db.execute("SELECT interests.interest FROM friends join friends_interests on friends.id=friends_interests.friend_id join interests on interests.id=friends_interests.interest_id where friend_name='#{friend_name}'")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_friends_with_interest(name)\n self.friends(:f).relatives.interests.where(name: name).pluck(:f)\n end",
"def friends\n @friends_arr = []\n current_user = User.where(id: self.id)\n friends = current_user[0].friendships\n friends.each do |f|\n @friends_arr.push(f.friendee)\n end\n ... | [
"0.7380466",
"0.71147174",
"0.6999954",
"0.6964164",
"0.6944664",
"0.693833",
"0.6826695",
"0.6818718",
"0.6716332",
"0.6712336",
"0.668627",
"0.6600203",
"0.65822005",
"0.658095",
"0.655361",
"0.6532074",
"0.650395",
"0.64952224",
"0.64528954",
"0.64249176",
"0.6411293",
"... | 0.6811051 | 8 |
Time complexity O(1) Space complexity O(1) | def add_first(data)
new_node = Node.new(data, nextNode = @head)
@head = new_node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\... | [
"0.65076977",
"0.6224968",
"0.59870076",
"0.59614",
"0.592963",
"0.5878061",
"0.5871787",
"0.58503795",
"0.58141303",
"0.5810536",
"0.5783606",
"0.5758984",
"0.5741224",
"0.57400525",
"0.5717067",
"0.5695446",
"0.56916237",
"0.5682769",
"0.56791544",
"0.56744385",
"0.56462455... | 0.0 | -1 |
Time complexity O(1) Space complexity O(1) | def get_first
return @head.data if @head
return @head
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\... | [
"0.65076977",
"0.6224968",
"0.59870076",
"0.59614",
"0.592963",
"0.5878061",
"0.5871787",
"0.58503795",
"0.58141303",
"0.5810536",
"0.5783606",
"0.5758984",
"0.5741224",
"0.57400525",
"0.5717067",
"0.5695446",
"0.56916237",
"0.5682769",
"0.56791544",
"0.56744385",
"0.56462455... | 0.0 | -1 |
Time complexity O(n) Space complexity O(1) | def length
current_node = @head
return 0 unless current_node
list_length = 0
until current_node.nil?
list_length += 1
current_node = current_node.next
end
return list_length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\... | [
"0.6839633",
"0.67023456",
"0.6287286",
"0.6151161",
"0.61348873",
"0.61199117",
"0.61065507",
"0.6105198",
"0.60804695",
"0.605704",
"0.6049214",
"0.60462457",
"0.6014997",
"0.6008531",
"0.60057807",
"0.5989388",
"0.598355",
"0.59711045",
"0.5970589",
"0.5946939",
"0.5941710... | 0.0 | -1 |
Time complexity O(n); O(n) to get to last element, O(1) to insert Space complexity O(1) | def add_last(data)
last_node = Node.new(data)
unless head
@head = last_node
else
current_node = @head
until current_node.next.nil?
current_node = current_node.next
end
current_node.next = last_node
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_last(element)\n if @first_node == nil\n insert_first(element)\n else\n old_last_node = find_last_node\n old_last_node.insert_after(element)\n @size += 1\n end\n end",
"def add element\n add_last(element)\n end",
"def add element\n add_last(element)\n end",
"de... | [
"0.7669553",
"0.6946828",
"0.6946828",
"0.69161916",
"0.67929345",
"0.67547405",
"0.6697564",
"0.66869307",
"0.66809857",
"0.66217834",
"0.66061",
"0.65817434",
"0.65147287",
"0.65055215",
"0.65011406",
"0.6495936",
"0.6484156",
"0.64506924",
"0.6449935",
"0.64331686",
"0.641... | 0.0 | -1 |
Time complexity O(n) to access last element Space complexity O(1) | def get_last
return @head if @head.nil?
current_node = @head
until current_node.next.nil?
current_node = current_node.next
end
return current_node.data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_item(arr)\n\treturn arr[-1]\nend",
"def last_element(array)\n array[-1]\nend",
"def lastElement(arr)\n return arr[arr.length - 1]\nend",
"def last_of(arr)\n output = arr[-1]\n return output\nend",
"def using_last(array)\n last_element=array.last\nend",
"def last_of(arr)\n retu... | [
"0.78702563",
"0.78004694",
"0.77573615",
"0.77408516",
"0.77365685",
"0.76760715",
"0.7659408",
"0.76469725",
"0.7639697",
"0.7616225",
"0.7592484",
"0.7575984",
"0.7517216",
"0.7498584",
"0.74696684",
"0.74521315",
"0.7447629",
"0.74475944",
"0.74475944",
"0.7411757",
"0.74... | 0.0 | -1 |
Time complexity O(n) Space complexity O(1) | def get_at_index(index)
current_index = 0
current_node = @head
until current_index == index
return nil if current_node.nil?
current_node = current_node.next
current_index += 1
end
return current_node.data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\... | [
"0.68383443",
"0.67022353",
"0.6287102",
"0.6151411",
"0.61351335",
"0.6119561",
"0.6107089",
"0.61056364",
"0.6081318",
"0.6057649",
"0.604912",
"0.60464",
"0.6015387",
"0.6008364",
"0.6006688",
"0.59890276",
"0.59838516",
"0.5971524",
"0.59703755",
"0.59473056",
"0.5940865"... | 0.0 | -1 |
GET /observations GET /observations.json | def index
@cruise = Cruise.find(params[:cruise_id])
@observations = @cruise.observations.order(observed_at: :desc).accessible_by(current_ability)
respond_to do |format|
format.csv { send_data build_csv, filename: "observations-#{@cruise.id}.csv"}
format.json { send_data build_json, filename: "observations-#{@cruise.id}.json"}
format.geojson { send_data build_geojson, filename: "observations-#{@cruise.id}.geojson"}
format.sigrid3
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_observations # :nologin:\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end",
"def list_observations\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end",
"def index\n @observations = Observation.... | [
"0.724541",
"0.72072977",
"0.7196251",
"0.7101862",
"0.7024558",
"0.68346304",
"0.68106896",
"0.6502588",
"0.64973384",
"0.64839226",
"0.6398919",
"0.63950795",
"0.6359676",
"0.63107514",
"0.6275471",
"0.62149364",
"0.6155672",
"0.6131335",
"0.6126413",
"0.60933864",
"0.60868... | 0.6090778 | 20 |
GET /observations/1 GET /observations/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @observations = Observation.all()\n end",
"def extract_observations(url)\n\n JSON.load(open(url))\n\n end",
"def show\n @observation = Observation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\... | [
"0.67711335",
"0.67475224",
"0.6717042",
"0.65535736",
"0.65496236",
"0.6516681",
"0.64280385",
"0.63851666",
"0.63757455",
"0.61541724",
"0.61337066",
"0.6056076",
"0.60321456",
"0.5999285",
"0.5979333",
"0.59619814",
"0.595239",
"0.595239",
"0.5942247",
"0.5939914",
"0.5832... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.