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 |
|---|---|---|---|---|---|---|
Displays attendance records of a workshop | def attendee
@training_records = @training.training_records
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @attendances = Attendance.all\n end",
"def index\n @title = 'Workout Records'\n @workout_records = current_user.workout_records.find(:all, :order => 'date_performed')\n end",
"def show\n # authorize @timesheet\n @shifts = @timesheet.shifts.order(time_in: :desc)\n @employee = @tim... | [
"0.6609895",
"0.6524233",
"0.6500905",
"0.6472271",
"0.64557993",
"0.6253594",
"0.6214651",
"0.62002087",
"0.62002087",
"0.62002087",
"0.62002087",
"0.61990535",
"0.61906576",
"0.6179133",
"0.61508965",
"0.6149542",
"0.6121683",
"0.6116071",
"0.6087156",
"0.6083659",
"0.60543... | 0.0 | -1 |
Custom method to mark the attendance record of a training event | def record_attendance
TrainingRecord.where(id: params[:unattended_ids]).update_all(attended: true)
redirect_to trainings_url, notice: "The attendance was successfully updated"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attend_event(event, status = :pending)\n a = Attendance.where(user_id: self.id, event_id: event.id).first_or_create\n a.status = status\n a.save\n end",
"def set_event\n @attendance = Attendance.find(params[:id])\n end",
"def certify_event_attendence\n @event = Event.find_by_id(params[... | [
"0.71377575",
"0.65374744",
"0.6376546",
"0.6375869",
"0.62864804",
"0.6283579",
"0.62629837",
"0.62422925",
"0.6220341",
"0.62051284",
"0.6196048",
"0.61597455",
"0.6122399",
"0.6092125",
"0.6073184",
"0.6018037",
"0.5998513",
"0.5910962",
"0.5872051",
"0.5844412",
"0.583568... | 0.5924925 | 17 |
Use callbacks to share common setup or constraints between actions. | def set_training
@training = Training.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def training_params
params.require(:training).permit(:title, :category, :description, :date, :time, :duration)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
creates a new mentorship relationship paramters from JSON: name, pdSupervisor, pdInstitution, pdStartYear, pdEndYear currently assumes that all parameters are not nil not sure if we should render as json | def create
Rails.logger.info(params)
if params.has_key?(:name) && params.has_key?(:pdSupervisor) && params.has_key?(:pdInstitution) && params.has_key?(:pdStartYear) && params.has_key(:pdEndYear)
# need to find the person, supervisor, and institution IDs first
name_id = Person.find_person_id(params[:name])
supervisor_id = Person.find_mentor_supervisor_id(params[:pdSupervisor], params[:pdInstitution])
instit_id = Institution.find_institution_id(params[:pdInstitution])
# check if the mentorship already exists
unless Mentorship.exists?(:person_id => name_id, :mentor_id => supervisor_id, :institution_id => instit_id, :start => params[:pdStartYear], :end => params[:pdEndYear])
@mentorship = Mentorship.new_degree(params[:name], params[:pdSupervisor], params[:pdInstitution], params[:pdStartYear], params[:pdEndYear])
if @mentorship != nil && @mentorship.save
render json: @mentorship.as_json, status: :created
return
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_relations_data(personality)\n new_relations_data = {}\n new_relations_data[:personality_id] = personality.id\n new_relations_data[:related_content_data] = personality.content\n new_relations_data\n end",
"def create \n @mentorship = Mentorship.new(params[:mentorship])\n \n # REFA... | [
"0.6167884",
"0.6143598",
"0.6023628",
"0.60101247",
"0.593652",
"0.59189564",
"0.5885262",
"0.58489144",
"0.5755231",
"0.57241064",
"0.5699846",
"0.56985736",
"0.5669499",
"0.56311494",
"0.56311494",
"0.56311494",
"0.5629569",
"0.5614089",
"0.5593516",
"0.55847037",
"0.55840... | 0.7405176 | 0 |
Deletes the least recently used item so your LRU cache is back to max size. | def eject!
#removes the first node
node = @store.first
@store.remove(node.key)
#get rid of the map's reference to the deleted node
@map.delete(node.key)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lru_delete(item)\n lru_join(item.lru_prev, item.lru_next)\n return item\n end",
"def evict_least_recently_used\n @node_counts -= 1\n @table.delete(@head.key)\n delete_front_node\n end",
"def delete_min_locator\n return nil if empty?\n use_min\n loc = mode_call(:find_min_loc)\n ... | [
"0.74968547",
"0.7480868",
"0.6879096",
"0.67489374",
"0.6608478",
"0.62962925",
"0.62877434",
"0.6272144",
"0.618621",
"0.6099631",
"0.6088332",
"0.607148",
"0.60698366",
"0.6061431",
"0.6056884",
"0.60513735",
"0.60388476",
"0.60308874",
"0.6025646",
"0.60094714",
"0.598730... | 0.0 | -1 |
Creates a new provider collection. | def initialize name, providers = {}, default = nil
@name = name
@configured_providers = providers
@configured_default = default || providers.values.first
reset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_collection\n Models::Collection.new\n end",
"def create_collections\n self.collections.each do |c|\n self.add_collection(c)\n end\n end",
"def new(*args)\n obj = super\n @provider_instances << obj\n obj\n end",
"def create_collections\n @client[URLS_COLL... | [
"0.69963115",
"0.6761887",
"0.67116195",
"0.6507936",
"0.6442271",
"0.6380323",
"0.6372822",
"0.6369834",
"0.6369523",
"0.6369523",
"0.6369523",
"0.6369523",
"0.6363703",
"0.62674165",
"0.6263163",
"0.6239566",
"0.6200413",
"0.6177408",
"0.6167212",
"0.60660404",
"0.6011751",... | 0.0 | -1 |
Adds a new provider to the provider collection. | def add extension, provider
providers[extension] = provider
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_provider(name, klass)\n @providers[name] = klass\n end",
"def add_provider!(provider, provider_info = {}, access = {})\n Api::Request.new do |request|\n request[:access] = access\n request[:method] = :POST\n request[:path] = \"/mgmt/{{client_id}}/storages/#{provider... | [
"0.6940578",
"0.66328067",
"0.64919317",
"0.6239821",
"0.61185026",
"0.607157",
"0.606617",
"0.60642457",
"0.60566235",
"0.59977895",
"0.5982376",
"0.59495604",
"0.59476715",
"0.59152204",
"0.5864147",
"0.5859157",
"0.5837305",
"0.5832999",
"0.5809659",
"0.5809659",
"0.580965... | 0.7386824 | 0 |
List of configured providers. | def providers
@providers ||= {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def providers\n @providers.keys\n end",
"def providers\n @providers ||= load_hash 'config/providers.yml'\n end",
"def providers\n driver(current_driver).providers\n end",
"def providers\n @providers_manager\n end",
"def providers\n providers = YARD::Registry.all(\"pup... | [
"0.8362594",
"0.8128595",
"0.80782074",
"0.79805493",
"0.7715629",
"0.76403266",
"0.76014507",
"0.76014507",
"0.7413273",
"0.74022377",
"0.7297735",
"0.72866434",
"0.72759145",
"0.6921644",
"0.6845834",
"0.67605525",
"0.6726786",
"0.6722341",
"0.6717966",
"0.67173785",
"0.666... | 0.8151667 | 1 |
Resets the provider collection to the initial values. | def reset
providers.clear
configured_providers.each { |k, v| self[k] = v }
self.default = configured_default
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_provider\n remove_stored_info\n set_default_as_provider\n end",
"def reset\n @collection = []\n end",
"def reset!\n # this should be overridden by concrete adapters\n end",
"def reset_initial_values\n @initial_values.clear if @initial_values\n @missing... | [
"0.7753693",
"0.7116367",
"0.6629752",
"0.6623564",
"0.66110027",
"0.66110027",
"0.6471403",
"0.6417714",
"0.6363478",
"0.63123494",
"0.63123494",
"0.62903196",
"0.624949",
"0.6244952",
"0.6232816",
"0.6227661",
"0.6222696",
"0.62199634",
"0.6205134",
"0.6171895",
"0.61715275... | 0.7555268 | 1 |
Get provider corresponding to a given format. | def formats
providers.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [] format\n providers[format]\n end",
"def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Pr... | [
"0.6890807",
"0.6637845",
"0.6144279",
"0.612312",
"0.59931195",
"0.59456164",
"0.59246707",
"0.5909754",
"0.57798964",
"0.5763829",
"0.5706053",
"0.5702132",
"0.5696122",
"0.56224453",
"0.5619345",
"0.56161296",
"0.5578824",
"0.5563391",
"0.55528134",
"0.551311",
"0.5490883"... | 0.6160864 | 2 |
Get provider corresponding to a given format. | def [] format
providers[format]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Provider.where(name: provider).first\n end\n end",
"d... | [
"0.6637845",
"0.6160864",
"0.6144279",
"0.612312",
"0.59931195",
"0.59456164",
"0.59246707",
"0.5909754",
"0.57798964",
"0.5763829",
"0.5706053",
"0.5702132",
"0.5696122",
"0.56224453",
"0.5619345",
"0.56161296",
"0.5578824",
"0.5563391",
"0.55528134",
"0.551311",
"0.5490883"... | 0.6890807 | 0 |
If any of the 'indicator properties' in the attribute hash are not nil, the boolean property is set to true in the attribute hash. Otherwise it's set to the default (or not set if default=nil). Returns the attribute hash. | def infer_boolean bool_property, indicator_properties, atts, default=nil
atts[bool_property] = default unless (atts[bool_property] or default.nil?)
indicator_properties.each do |x|
atts[bool_property] = true unless atts[x].nil?
end
return atts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boolean_attributes\n @boolean_attributes\n end",
"def copy_boolean_options_to_attributes(keys)\n keys.each do |k|\n if @opts[k] && !@attr.has_key?(k)\n @attr[k] = k\n end\n end\n end",
"def attributes_nil_hash\n @_attributes_nil_hash ||= {}.tap do |attr_hash... | [
"0.5871165",
"0.58479124",
"0.5739904",
"0.563485",
"0.5597352",
"0.5594985",
"0.55411273",
"0.5538196",
"0.552452",
"0.5505258",
"0.5490311",
"0.5428838",
"0.53585804",
"0.52806413",
"0.5279203",
"0.5273315",
"0.52719796",
"0.52068394",
"0.51994675",
"0.5199269",
"0.5197765"... | 0.7186898 | 0 |
Cleans a list of Boolean values to be either true or false | def clean_bool dirty_vals
vals = []
array = separate(dirty_vals)
array.each { |dirty_val|
val = get_b(dirty_val)
#if val.nil? and (!dirty_val.nil? and dirty_val.strip!='')
# val = dirty_val.match(/(not applicable|n\/a|not available)/i).nil?
#end
vals << val
}
if vals.empty? or vals.uniq == [nil]
return nil
elsif vals.include? true
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_falsy_values(list)\n list.select {|element| !!element}\nend",
"def remove_falsy_values list\n list.select { |item| !!item }\nend",
"def munge_boolean(value)\n case value\n when true, 'true', :true\n 'true'\n when false, 'false', :false\n 'false'\n else\n raise \"Invalid ... | [
"0.67963964",
"0.677568",
"0.66777885",
"0.664705",
"0.6532966",
"0.6388392",
"0.63500625",
"0.6339539",
"0.6331791",
"0.6289312",
"0.62826055",
"0.6270334",
"0.6262669",
"0.6237597",
"0.6234937",
"0.62102747",
"0.61962754",
"0.6169771",
"0.61552",
"0.6148134",
"0.6104385",
... | 0.7573842 | 0 |
Easy access to the current connection context. | def connection
settings.connection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection #:nodoc:\n Thread.current['connection'] ||= retrieve_connection\n Thread.current['connection']\n end",
"def context\n Context.instance\n end",
"def connection\n retrieve_connection\n end",
"def context\n @context ||= Context.new(self)\n end",
"def context... | [
"0.70869696",
"0.70253927",
"0.69178975",
"0.68982804",
"0.68723774",
"0.685649",
"0.68383914",
"0.6618575",
"0.66181654",
"0.6615057",
"0.6594858",
"0.6594858",
"0.6594858",
"0.6594858",
"0.6594585",
"0.65898645",
"0.65778315",
"0.655838",
"0.6519816",
"0.6503987",
"0.649930... | 0.6254622 | 42 |
Function for initializing the Driver instance. | def initialize()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize driver\n @driver = driver\n end",
"def initialize(driver)\n\t\tsuper\n\n\t\tself.driver = driver\n\tend",
"def initialize(driver)\r\n @@driver = driver\r\n end",
"def driver_initialize\n\t\t#Driver initialization happens here.\n\t\tdriver = Driver::new\n\t\tdriver.seed = rand(100)\n\t\t... | [
"0.8146847",
"0.80160236",
"0.7998658",
"0.7858474",
"0.731117",
"0.71061283",
"0.70538735",
"0.70538735",
"0.70538735",
"0.70538735",
"0.70538735",
"0.70538735",
"0.69862056",
"0.6961147",
"0.6790253",
"0.6639914",
"0.6595987",
"0.6524962",
"0.65206426",
"0.6503429",
"0.6492... | 0.0 | -1 |
Function for navigating to passed URL and creating browser instance. | def navigateTo(browser_instance,url)
Capybara.default_driver = :selenium
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
# $worldMap = Hash.new
$session = Capybara::Session.new(:selenium)
$session.visit 'https://staging-bbva.everfiapps-dev.net/cportal/ccdee586/login'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_page(browser_handle, url)\n browser_handle.goto(url)\nend",
"def navigate_to(url)\n self.visit url\n end",
"def navigate_to(url)\n self.visit url\n end",
"def go_to_page(url)\n Logbook.step(\"Open start page #{url} :)\")\n @browser.get url\n sleep 2\n\n @browser\... | [
"0.7511774",
"0.7470131",
"0.73721313",
"0.734198",
"0.7321395",
"0.72917706",
"0.7285907",
"0.7269727",
"0.71324486",
"0.7122379",
"0.7053053",
"0.7036144",
"0.69951206",
"0.69078857",
"0.6897082",
"0.6839892",
"0.68358505",
"0.6785373",
"0.6753554",
"0.6702242",
"0.667388",... | 0.6266028 | 45 |
Function for navigating to passed URL and creating browser instance. def navigateTo(browser_instance,url) $browser = Watir::Browser.new browser_instance $browser.cookies.clear $browser.goto(url) end Function for closing all the opened browser instances. | def close_multiple_browsers(browser_instance)
# if browser_instance == "ie"
# Sys::ProcTable.ps.each{|ps|
# if ps.name.downcase==browser_instance+"xplore.exe"
# Process.kill('KILL',ps.pid)
# end}
# end
# if browser_instance != "ie"
$browser.close
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def go_to(url)\n @browser.navigate.to url\n end",
"def goto_page(browser_handle, url)\n browser_handle.goto(url)\nend",
"def navigateTo(browser_instance,url)\n Capybara.default_driver = :selenium\n\n \n Capybara.register_driver :selenium do |app|\n Capybara::Selenium::Driver.new(app, ... | [
"0.6979972",
"0.6943354",
"0.68233675",
"0.6781023",
"0.67809355",
"0.6634658",
"0.65798134",
"0.65744716",
"0.6571664",
"0.64872974",
"0.6408356",
"0.63914335",
"0.6351872",
"0.63504416",
"0.63236266",
"0.63182306",
"0.6294872",
"0.6257424",
"0.6248659",
"0.6220599",
"0.6216... | 0.6636261 | 5 |
After the depthfirst search is done we can find any vertice connected to "node" in constant time [O(1)] and find a path to this node in linear time [O(n)]. | def path_to(node)
return unless has_path_to?(node)
path = []
current_node = node
while(current_node != @source_node) do
path.unshift(current_node)
current_node = @edge_to[current_node]
end
path.unshift(@source_node)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth_first_search(node)\n return if node.nil?\n node.visit\n node.connections.each do |conn|\n depth_first_search(conn) unless conn.visited\n end\nend",
"def path_to(node)\n return unless @visited.include?(node)\n path = []\n while(node != @node) do\n path.unshift(node) \n node = @... | [
"0.6875687",
"0.6873869",
"0.67981875",
"0.6794501",
"0.67521584",
"0.67380077",
"0.6705711",
"0.66593736",
"0.66064054",
"0.6573044",
"0.65468067",
"0.65302616",
"0.64828247",
"0.645809",
"0.6415288",
"0.63948447",
"0.63936937",
"0.6379044",
"0.63639575",
"0.6360958",
"0.635... | 0.637559 | 19 |
GET /companies GET /companies.json | def index
if request.format.to_sym == :html
@companies = Company.page(params[:page]).order("LOWER(name)")
else
@companies = Company.all
end
respond_with(@companies)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def companies\n render \"company/companies.json.jbuilder\", status: :ok\n end",
"def index\n @companies = Company.all\n if @companies\n render json: {\n companies: @companies\n }\n else\n render json: {\n status: 500,\n errors: ['No companies']\n }\n end... | [
"0.79014075",
"0.78579754",
"0.77734107",
"0.77734107",
"0.77734107",
"0.77734107",
"0.7593946",
"0.751332",
"0.7442931",
"0.74332345",
"0.7311373",
"0.72778213",
"0.72639275",
"0.7246536",
"0.72437197",
"0.7199838",
"0.715509",
"0.7150789",
"0.7148859",
"0.7133268",
"0.71272... | 0.70137346 | 37 |
GET /companies/1 GET /companies/1.json | def show
@company = Company.find(params[:id])
@company_offers = @company.offers.order(:close_date)
@company_deals = @company.deals.order(:close_date)
respond_with(@company)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @companies = Company.all\n @com_info = Company.last\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def companies\n render \"company/companies.json.jbuilder\", status: :ok\n end",
"def index\n @companie... | [
"0.78097886",
"0.76837516",
"0.7651147",
"0.7642482",
"0.7642482",
"0.7642482",
"0.7642482",
"0.75732714",
"0.7532066",
"0.7413212",
"0.7413212",
"0.7413212",
"0.7413212",
"0.7413212",
"0.7413212",
"0.73368204",
"0.73075074",
"0.7303594",
"0.7290155",
"0.72426957",
"0.7118147... | 0.0 | -1 |
GET /companies/new GET /companies/new.json | def new
@company = Company.new
respond_with(@company)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @company = Company.new(:name => 'default')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company }\n end\n end",
"def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render ... | [
"0.8215413",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.8138594",
"0.80940586",
"0.77714676",
"0.76540494",
"0.7585538",
"0.754403",
"0.7481533",
"0.7471644",
"0.7469828",
"0.7415118",
"0.7412604",
... | 0.7397445 | 23 |
POST /companies POST /companies.json | def create
# binding.pry
@company = Company.new(params[:company])
if @company.save
UpdateMailer.update_email(@company, current_user, action_name).deliver
flash[:notice] = 'Company was successfully created.'
end
respond_with(@company)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Company.create(params[\"company\"])\n end",
"def create\n if @company = Company.find(entity_id_from_params(:company))\n respond_to do |format|\n current_user.account.companies << @company\n format.html { redirect_to root_path, notice: 'Company was successfully ... | [
"0.75086176",
"0.7454409",
"0.7148216",
"0.7067736",
"0.69924504",
"0.6992177",
"0.6991816",
"0.6991816",
"0.6991816",
"0.6991816",
"0.692276",
"0.69189334",
"0.69189334",
"0.69189334",
"0.69189334",
"0.69189334",
"0.69163394",
"0.690428",
"0.6899169",
"0.68933874",
"0.684762... | 0.0 | -1 |
PUT /companies/1 PUT /companies/1.json | def update
@company = Company.find(params[:id])
if @company.update_attributes(params[:company])
UpdateMailer.update_email(@company, current_user, action_name).deliver
flash[:notice] = 'Company was successfully updated.'
end
respond_with(@company)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update\n @company = Company.find(company_params[:id])\n\n if @company.update(company_params)\n head :no_content\n else\n render json: @company.errors, status: :unprocessable_entity\n end\n end",
... | [
"0.76533496",
"0.7175312",
"0.704681",
"0.6998336",
"0.6969464",
"0.6967971",
"0.69584334",
"0.69537246",
"0.69537246",
"0.69537246",
"0.69537246",
"0.69537246",
"0.69537246",
"0.69481844",
"0.6931405",
"0.69090986",
"0.6901196",
"0.675459",
"0.6741089",
"0.6741089",
"0.67410... | 0.0 | -1 |
DELETE /companies/1 DELETE /companies/1.json | def destroy
@company = Company.find(params[:id])
@company.destroy
UpdateMailer.update_email(@company, current_user, action_name).deliver
flash[:notice] = 'Company was successfully deleted.'
respond_with(@company)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:id])\n @company.destroy\n\n respond_to do |format|\n format.... | [
"0.8018972",
"0.7861743",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7692561",
"0.7642027",
"0.76235217",
"0.76215345",
"0.76215345",
"0.76215345",
"0.7568788",
"0.7547548",
"0.75399697",
"0.74384123... | 0.0 | -1 |
private return all the other Response objects for the same Question. exclude yourself private | def sibling_responses
# exclude yourself
# load questions, then load responses
question.responses.where.not(id: id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def responses\n object.questions.map do |q|\n Embedded::ResponseSerializer.new(q.filtered_responses.first,root: false)\n end\n end",
"def sibling_responses\n question.responses.where.not(id: self.id)\n end",
"def sibling_responses\n self.question.responses.where.not(id: self.id)\n end... | [
"0.7329625",
"0.6650163",
"0.6506545",
"0.6506545",
"0.64659095",
"0.64549106",
"0.6346589",
"0.6340093",
"0.63355917",
"0.624607",
"0.6175839",
"0.6162994",
"0.6161303",
"0.6161219",
"0.6119024",
"0.60971034",
"0.6080812",
"0.6062206",
"0.60487366",
"0.6040555",
"0.6037918",... | 0.6531143 | 2 |
see if any sibling response exists with the same respondent_id | def respondent_already_answered?
sibling_responses.exists?(user_id: user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respondent_already_answered?\n sibling_responses.exists?(responder_id: self.responder_id)\n end",
"def respondent_already_answered?\n sibling_responses.where('user_id = ?', self.user_id).exists?\n end",
"def sibling_responses\n # self.question.responses.where(\"responses.id != ?\", self.id... | [
"0.76925874",
"0.7279114",
"0.6903097",
"0.6882504",
"0.6853014",
"0.6681651",
"0.6681651",
"0.66347",
"0.6610954",
"0.6606145",
"0.65704745",
"0.63962346",
"0.6159311",
"0.61430603",
"0.6081521",
"0.6046843",
"0.5690411",
"0.56268024",
"0.56240535",
"0.5583392",
"0.55649704"... | 0.730623 | 1 |
User Can't Create Multiple Responses To The Same Question | def not_duplicate_response
if respondent_already_answered?
errors[:user_id] << 'this user has already answered this question'
end
# unless sibling_responses.where(user_id: user_id).empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \n respond_to do |format|\n \n if !params[:questions].nil? \n params[:questions].each {\n |q| \n type = Question.find_by_id(q[0]).question_type\n answer = (type == 2 ? Answer.find_by_id(q[1]).correct : nil)\n Response.new( \n {\... | [
"0.71334463",
"0.71333545",
"0.694733",
"0.68908095",
"0.68387",
"0.67739964",
"0.67739964",
"0.67181784",
"0.6646776",
"0.6606174",
"0.6529411",
"0.6510068",
"0.64713866",
"0.6468316",
"0.6412771",
"0.6402794",
"0.63880986",
"0.6382566",
"0.63802475",
"0.63491833",
"0.629651... | 0.7277313 | 0 |
Author Can't Respond To Own Poll The simplest way is to use associations to traverse from a Response object back to the AnswerChoice, to the Question, and finally the Poll. You can then verify whether the poll's author is the same as the respondent_id. This may involve multiple queries, but we will later improve this. Don't spend too much time trying to refactor the method right now. Many students have gone down this deep, dark rabbit hole and you'll have time to explore it later. | def respondent_is_not_author_poll?
#
# respondend.id == author.id
if question.poll.author.id == user.id
errors[:user_id] << 'author should not answer to his/her poll'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_author?\n Response.joins(question: :poll).where(\"polls.user_id = ?\", self.user_id).exists?\n end",
"def not_author_response\n if author_respondent?\n errors[:author] << 'cannot answer their own poll'\n end\n end",
"def poll_author?\n self.answer_choice.question.poll.... | [
"0.7459119",
"0.74162626",
"0.74114394",
"0.6611128",
"0.65162957",
"0.6469948",
"0.61780465",
"0.60721993",
"0.6028036",
"0.5976189",
"0.5953859",
"0.5941682",
"0.58937144",
"0.5889886",
"0.58878314",
"0.58872795",
"0.58787656",
"0.58635414",
"0.58278686",
"0.58248705",
"0.5... | 0.771261 | 0 |
maybe change to bulk add answers, split at "comma" | def add_answers
clear
puts "Enter the answers, split by a comma for each"
answers = gets.chomp
answers = answers.gsub(/,\s/,',')
answers = answers.split(",")
answers.each do |answer|
new_answer = Answer.create({:name => answer, :question_id => @current_question.id})
end
puts "Do you want to add another question (y/n)?"
input = gets.chomp
if input == 'y'
add_question
else
admin_menu
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incorrect_answers\n object.incorrect_answers.split(\", \")\n end",
"def formatAnswerFromArray( answerString )\n answerRows = answerString.split(\"~\")\n answerArr = Array.new()\n answerRows.each { |ans|\n row = \"\"\n ansarr = ans.split(\",\")\n ansarr.each { |a|\n ... | [
"0.680871",
"0.68013906",
"0.6725226",
"0.66144794",
"0.6599786",
"0.6464852",
"0.6413902",
"0.6099468",
"0.59617704",
"0.5886474",
"0.58621216",
"0.58137965",
"0.57926846",
"0.57704324",
"0.5759983",
"0.573695",
"0.5736252",
"0.5711745",
"0.57016957",
"0.5692117",
"0.5681086... | 0.62643254 | 7 |
Getter for the +synonym_dictionaries+ class variable | def synonym_dictionaries
@@synonym_dictionaries
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def synonym_dict\n return @@synonym_dict if @@synonym_dict\n @@synonym_dict = {}\n config[\"synonyms\"].each do |syn_set|\n syn_set.each {|syn| @@synonym_dict[syn] ||= Set.new; @@synonym_dict[syn].merge syn_set }\n end\n @@synonym_dict\n end",
"def synonyms\n @synonyms ||= self.clas... | [
"0.72524345",
"0.7052447",
"0.6648062",
"0.6587201",
"0.6079081",
"0.6041376",
"0.60287887",
"0.58597106",
"0.57994384",
"0.56783175",
"0.5657994",
"0.5577216",
"0.5484738",
"0.5428246",
"0.54171556",
"0.5338815",
"0.5298998",
"0.5243255",
"0.52053016",
"0.5148142",
"0.514814... | 0.8335839 | 0 |
Checks if the given +dictionary+ symbol is a key in the +synonym_dictionaries+ class variable | def dictionary_exists? dictionary
synonym_dictionaries.key?(dictionary.capitalize)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_dictionary(dictionary)\n right = dictionary.word_present?(@word)\n return true if right\n false\n end",
"def checking_dictionary_for_word_match\n valid_word?(@prefix)\n end",
"def is_word?(word)\n Constants::DICTIONARY.key?(word.downcase)\n end",
"def tag_in_di... | [
"0.6732161",
"0.6651128",
"0.62585914",
"0.619724",
"0.61556536",
"0.6082066",
"0.5996537",
"0.5889723",
"0.5883029",
"0.5878499",
"0.5804458",
"0.5798499",
"0.5776489",
"0.5756547",
"0.5722699",
"0.57173216",
"0.56295604",
"0.5624733",
"0.55810237",
"0.55740976",
"0.5567953"... | 0.7829819 | 0 |
Output the config settings | def output_config
puts 'Using config file: ' + $CONFIG_FILE
@conf.each { |key, value| puts key + " = " + value }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_config\n self.config_to_hash.each { |k, v| puts \"#{k}: #{v}\" }\n end",
"def display_config\n # Format types and the additional options that apply to each type\n format_opts = {\n \"block\" => [\n \"entry-break\",\n \"element-break\",\n ... | [
"0.7614439",
"0.74402165",
"0.696857",
"0.69136924",
"0.6891031",
"0.6890713",
"0.6855754",
"0.6665212",
"0.66063887",
"0.65654945",
"0.6543973",
"0.6507965",
"0.6497492",
"0.6485931",
"0.647976",
"0.6419686",
"0.6391958",
"0.63871443",
"0.63694614",
"0.6325521",
"0.6306755",... | 0.8242229 | 0 |
Check if the pwd is zup enabled | def zup_dir_enabled?
if File.exist?('.zup/enabled')
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_zup_dir\n unless zup_dir_enabled?\n puts ' * Adding current directory'\n # Create .zup directory\n FileUtils.mkdir('.zup') unless File.directory?('.zup')\n # Create file to enable zup\n File.open(\".zup/enabled\", 'w') { |f| f.close }\n else\n puts ' * Directory alrea... | [
"0.69885933",
"0.68684465",
"0.6520007",
"0.6285853",
"0.60789806",
"0.599638",
"0.5930512",
"0.5908339",
"0.5835427",
"0.58321446",
"0.58160293",
"0.58053213",
"0.5750155",
"0.5736638",
"0.57259625",
"0.5686872",
"0.565659",
"0.565015",
"0.5611827",
"0.5549427",
"0.552972",
... | 0.76437134 | 0 |
Enable the pwd so it can sync with the remote host | def enable_zup_dir
unless zup_dir_enabled?
puts ' * Adding current directory'
# Create .zup directory
FileUtils.mkdir('.zup') unless File.directory?('.zup')
# Create file to enable zup
File.open(".zup/enabled", 'w') { |f| f.close }
else
puts ' * Directory already initialised'
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setpwent\n ::Etc.setpwent\n end",
"def pwd; end",
"def pwd()\n instructions = 'pwd'\n r = @ssh ? @ssh.exec!(instructions) : `#{instructions}`\n @results[:pwd] = r.chomp\n end",
"def pwd\n @local\n end",
"def cmd_pwd(param)\n send_unauthorised and return unless logge... | [
"0.6534146",
"0.63058156",
"0.62963724",
"0.62324107",
"0.5968677",
"0.59647095",
"0.59162617",
"0.5882659",
"0.5880919",
"0.5880286",
"0.5846027",
"0.5788797",
"0.5784952",
"0.5784952",
"0.57719475",
"0.5701141",
"0.56891406",
"0.56795526",
"0.5673639",
"0.56517905",
"0.5631... | 0.0 | -1 |
Disable the pwd so it nolonger syncs with the remote host | def disable_zup_dir
if zup_dir_enabled?
puts ' * Uninitialising current directory'
# TODO: Fix uninitialising a directory
# Removing .zup directory breaks syncing if it's ever re-initialised
#FileUtils.rm_rf(".zup") if File.directory?('.zup')
FileUtils.rm('.zup/enabled')
exit 0
else
puts ' * Directory not initialised'
return false
exit 0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pwd; end",
"def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end",
"def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end",
"def debian_password\n nil\n end",
"def pwd\n @local\n end",
"... | [
"0.62073046",
"0.60840744",
"0.608232",
"0.60499245",
"0.5987129",
"0.5978821",
"0.5929579",
"0.58674437",
"0.58083105",
"0.5714188",
"0.56781375",
"0.56781375",
"0.56606054",
"0.5614558",
"0.5560245",
"0.55298203",
"0.5513296",
"0.5478268",
"0.54573494",
"0.54513174",
"0.543... | 0.0 | -1 |
Run unison to sync with remote host if enabled | def sync_zup_dir
if zup_dir_enabled?
local_dir = File.basename(Dir.pwd)
# Output the full unison command if debugging enabled
puts($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \
+ @conf['server'] + '/' + @conf['remote_dir'] + '/' \
+ local_dir) if $ZUP_DEBUG
# Run unison
system($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \
+ @conf['server'] + '/' + @conf['remote_dir'] + '/' \
+ local_dir)
else
puts " * Current directory not initialised (Run 'zup init' to add it)"
exit 0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync\n # preparation\n check_remote_path_valid\n check_git_repo\n reset_remote_repo\n\n diff_text = local_diff\n apply_diff_to_remote diff_text\n\n # output = @ssh.exec! 'hostname'\n # puts output\n end",
"def remo... | [
"0.6375961",
"0.6325847",
"0.62261987",
"0.5861778",
"0.56953704",
"0.5694294",
"0.5652193",
"0.56343615",
"0.5618496",
"0.5607516",
"0.55646706",
"0.552747",
"0.5507347",
"0.54969",
"0.5482247",
"0.54487777",
"0.5443176",
"0.54225856",
"0.54140884",
"0.53845",
"0.53729093",
... | 0.66907656 | 0 |
such actions should be moved to separate service | def remove_customers
@import.customers.destroy_all
@import.update(state: :created, started_at: nil, completed_at: nil, invalid_customers: 0)
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service; end",
"def actions; end",
"def services\n\n end",
"def run_actions; end",
"def service_request(service); end",
"def services\n end",
"def action_hook; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def service; r... | [
"0.6524496",
"0.65075666",
"0.6451984",
"0.6355279",
"0.62618285",
"0.6258286",
"0.6111734",
"0.6029704",
"0.6029704",
"0.6029704",
"0.6029704",
"0.6029704",
"0.6003889",
"0.5981323",
"0.59458226",
"0.58895713",
"0.5888683",
"0.5872916",
"0.58451754",
"0.58451754",
"0.5845175... | 0.0 | -1 |
GET /roles GET /roles.xml | def index
@roles = Role.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @roles }
format.json { render :json => @roles.to_json(:only => [:id, :code, :name, :definition]) }
format.js { render (:update){ |page| page[dom_id_nested(:index)].replace :file => "admin/roles/index" } }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @roles = @client.roles\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @roles }\n end\n end",
"def index\n @roles = Role.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ro... | [
"0.765395",
"0.73884916",
"0.73800194",
"0.73537827",
"0.7349313",
"0.7307362",
"0.71644545",
"0.71563125",
"0.7147755",
"0.709412",
"0.70782536",
"0.7047145",
"0.7045595",
"0.6965548",
"0.6892383",
"0.68836725",
"0.6883257",
"0.6859065",
"0.68405116",
"0.68359077",
"0.683302... | 0.61369747 | 90 |
GET /roles/new GET /roles/new.xml | def new
@role = Role.new(:category => 0)
@possible_permissions = Permission.by_category(@role.category)
respond_to do |format|
format.xml { render :xml => @role }
format.js #new.js.rjs
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
"def new\n @role = Role.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role }\n end\n end",
... | [
"0.7652707",
"0.7652707",
"0.7652707",
"0.7652707",
"0.7645628",
"0.75188315",
"0.74036145",
"0.7401122",
"0.7392047",
"0.7352519",
"0.7314729",
"0.7287063",
"0.72534263",
"0.71865225",
"0.7153129",
"0.7117309",
"0.710744",
"0.710744",
"0.710744",
"0.7058945",
"0.70502895",
... | 0.6599124 | 38 |
POST /roles POST /roles.xml | def create
@role = Role.new(params[:role])
respond_to do |format|
if @role.save
flash[:notice] = 'Role was successfully created.'
format.xml { render :xml => @role, :status => :created, :location => @role }
format.js #create.js.rjs
else
@possible_permissions = Permission.by_category(@role.category)
format.xml { render :xml => @role.errors, :status => :unprocessable_entity }
format.js #create.js.rjs
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n chef_server_rest.post(\"roles\", self)\n self\n end",
"def post_role(role)\n role = {\n \"id\"=>nil,\n \"name\"=>nil, \n \"description\"=>\"\", \n \"sessionTimeout\"=>\"60\",\n \"roles\"=>[],\n \"privileges\"=>[]\n }.merge(role);\n post(\"#{url_bas... | [
"0.6648283",
"0.66474384",
"0.6290778",
"0.61988467",
"0.6091542",
"0.6087422",
"0.60257316",
"0.60000217",
"0.58930975",
"0.5870327",
"0.5833719",
"0.58180964",
"0.5807781",
"0.58023876",
"0.58021086",
"0.5789968",
"0.5771046",
"0.5755769",
"0.57313377",
"0.57262254",
"0.572... | 0.0 | -1 |
PUT /roles/1 PUT /roles/1.xml | def update
respond_to do |format|
if @role.update_attributes(params[:role])
flash[:notice] = 'Role was successfully updated.'
format.html { redirect_to(@role) }
format.xml { head :ok }
format.js
else
@possible_permissions = Permission.by_category(@role.category)
format.html { render :action => "edit" }
format.xml { render :xml => @role.errors, :status => :unprocessable_entity }
format.js
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @role = Role.find_by_name(params[:name])\n \n respond_to do |format|\n @role.authorities = Authority.find_by_name(params[:authority_names])\n format.html { redirect_to(my_gem_role_path(@role.name),\n :notice => 'Role was successfully updated.') }\n format.xm... | [
"0.6927021",
"0.68739194",
"0.68296283",
"0.6658158",
"0.6658158",
"0.6657796",
"0.6646289",
"0.6639587",
"0.6611606",
"0.65743977",
"0.6448827",
"0.64373785",
"0.6342125",
"0.6340391",
"0.6330269",
"0.6327314",
"0.63118714",
"0.6311083",
"0.6308927",
"0.62863934",
"0.6279235... | 0.0 | -1 |
DELETE /roles/1 DELETE /roles/1.xml | def destroy
respond_to do |format|
if @role.destroy
format.html { redirect_to(@role) }
format.js { render (:update) {|page| page[dom_id_nested(:item, @role)].remove() } }
else
flash[:notice] = 'Role was not deleted.'
format.html { redirect_to roles_path }
format.js { render (:update) { |page| page.alert("Cannot delete role #{@role.name}") }}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n chef_server_rest.delete(\"roles/#{@name}\")\n end",
"def destroy\n @role = @client.roles.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n flash[:notice] = 'Role was successfully removed.' \n format.html { redirect_to(client_roles_url(@client)) }\n ... | [
"0.73153687",
"0.71410984",
"0.70588833",
"0.70588833",
"0.70306534",
"0.69952327",
"0.69625664",
"0.69525975",
"0.6904067",
"0.68919075",
"0.6886388",
"0.6883458",
"0.67904866",
"0.67854214",
"0.6705457",
"0.66825765",
"0.6665933",
"0.66417426",
"0.6618673",
"0.6600824",
"0.... | 0.0 | -1 |
before every action check if any user is logged in | def require_login
if session[:user_id].blank?
redirect_to root_url, notice: "Login is required to perform this action!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_logged_in\n unless current_user\n redirect_to '/login'\n end\n end",
"def ensure_logged_in\n login! if @user.nil?\n end",
"def logged_in\n\t \t!current_user.nil?\n\t end",
"def logged_in\n logged_in_user != nil\n end",
"def logged_in_user\n unless logged_in?... | [
"0.7626321",
"0.7605218",
"0.75437105",
"0.7500471",
"0.74753255",
"0.74608755",
"0.74588656",
"0.7456016",
"0.74548393",
"0.7450612",
"0.7445222",
"0.74270463",
"0.7415904",
"0.7410896",
"0.73965913",
"0.7396289",
"0.73847884",
"0.7373266",
"0.7352127",
"0.73334265",
"0.7330... | 0.0 | -1 |
before every action identify the user that is logged in | def identify_user
@user = User.find_by(id: session[:user_id])
if !@user
redirect_to root_url, notice: "User not identified!"
end
if params[:book_id].blank?
redirect_to root_url, :notice => "It is not a valid action!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logged_in\r\n end",
"def declared_user\n if logged_in?\n if Protege.find_by(user_id: current_user.id.to_i).nil?\n redirect_to root_path, :alert => \"Access denied.\"\n end\n else\n redirect_to root_path, :alert => \"Access denied.\"\n end\n end",
"def logged_i... | [
"0.7620227",
"0.7241152",
"0.7203908",
"0.71483696",
"0.71065485",
"0.708104",
"0.7080451",
"0.7047475",
"0.7028963",
"0.70267695",
"0.7021245",
"0.70032275",
"0.6993246",
"0.6969713",
"0.6955776",
"0.69535804",
"0.69535804",
"0.6950243",
"0.6941458",
"0.69268006",
"0.6908687... | 0.0 | -1 |
We're only going to bother with the first 5 episodes | def sync
feed = RSS::Parser.parse(@external_program.podcast_url, false)
return false if !feed || feed.items.empty?
feed.items.first(5).select { |i| can_import?(i) }.each do |item|
episode = @external_program.external_episodes.build(
:title => item.title,
:summary => item.description,
:air_date => item.pubDate,
:external_id => item.guid.content
)
# Import Audio
enclosure = item.enclosure
audio = Audio::DirectAudio.new(
:external_url => enclosure.url,
:size => enclosure.length,
:description => episode.title,
:byline => @external_program.title,
:position => 0
)
episode.audio << audio
end
@external_program.save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_episodes(show, name, id)\n db_show = TvShows.where(:user => session[:username]).where(:name => name).first\n\n if !db_show.nil?\n last_season = TvShows.where(:user => session[:username]).where(:name => name).first.season\n last_episode = TvShows.where(:user => session[:username]).where(:name... | [
"0.65678346",
"0.6417063",
"0.6287272",
"0.62093246",
"0.62093246",
"0.62093246",
"0.62093246",
"0.6151687",
"0.6137111",
"0.6129858",
"0.61132944",
"0.6012718",
"0.5989661",
"0.5920803",
"0.59150416",
"0.5903672",
"0.58997595",
"0.58929527",
"0.5868579",
"0.57257944",
"0.570... | 0.0 | -1 |
Tacks the registry behind local_tag | def full_tag(local_tag, registry)
"#{registry}/#{local_tag}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag(tag); end",
"def tag(tag); end",
"def our_tags\n tag_map.tap do |t|\n t.each_pair { |k, v| t[k] = tags.fetch(v, nil) }\n end\n end",
"def local_tags\n @local.tags\n end",
"def tags_to_add\n local_tags.reject { |t, v| aws_tags.include?(t) and aws_tags[t] == v }... | [
"0.55408585",
"0.55408585",
"0.5540361",
"0.5477359",
"0.54692864",
"0.5456492",
"0.5453355",
"0.54405653",
"0.54222846",
"0.539707",
"0.5288271",
"0.52485037",
"0.52144533",
"0.5187233",
"0.51737446",
"0.5171082",
"0.5171082",
"0.51461905",
"0.51461905",
"0.513562",
"0.51338... | 0.70968634 | 0 |
Calculate the SHA256 of the concatenated content of the given list of files after line endings have been stripped | def sha256(files)
sha = Digest::SHA2.new
files.each do |f|
next if File.directory?(f)
content = File.binread(f)
# work around possible git checkout issues by removing CR and LF from the file
content.gsub!("\n", "")
content.gsub!("\r", "")
sha << content
end
sha.hexdigest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def digest_sha2(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::SHA2.hexdigest(File.read(file)) : nil\n }\n end",
"def digest_sha1(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::SHA1.hexdigest(File.read(file)) : nil\n }\n ... | [
"0.66718936",
"0.63775253",
"0.6148582",
"0.5974193",
"0.5872315",
"0.58635956",
"0.5860442",
"0.58485496",
"0.5744255",
"0.5714874",
"0.5702175",
"0.5652525",
"0.56464887",
"0.56072354",
"0.55387217",
"0.55273",
"0.5516689",
"0.5507359",
"0.550718",
"0.55028313",
"0.542722",... | 0.7338418 | 0 |
Returns a string to be used as an image tag | def content_version(image_sourcefiles)
"content-#{sha256(image_sourcefiles)}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_img_tag()\n \"<img src='#{self.encode}' />\"\n end",
"def image_tag(image)\n raw \"<img src=\\\"/images/\" + image + \"\\\"/>\"\n end",
"def make_img_tag(x)\n\n\"<img src='\" + x +\"'/>\"\n\nend",
"def image_tag(image, opts={})\n if is_uri?(image)\n path = image\n e... | [
"0.7878503",
"0.784707",
"0.73892283",
"0.7232643",
"0.70964324",
"0.7091647",
"0.7081505",
"0.69948363",
"0.69067574",
"0.69045",
"0.68845636",
"0.68583536",
"0.6829865",
"0.68250823",
"0.6755572",
"0.6719416",
"0.670958",
"0.6705684",
"0.67030185",
"0.66915226",
"0.66844594... | 0.0 | -1 |
Download json with a thousand ways of a certain category | def get_json_from_openstreetmaps(key,val,constrain_to_usa = true)
timeout = 20000
bounds = "#{CONTINENTAL_US[:s]},#{CONTINENTAL_US[:w]},#{CONTINENTAL_US[:n]},#{CONTINENTAL_US[:e]}"
bounds_string = constrain_to_usa ? "(#{bounds})" : ""
#This string fetches all geometry of a way including center points, but does not restrict how many ways to download
#str = "data=[out:json][timeout:#{timeout}];way[\"#{key}\"=\"#{val}\"](#{bounds_string});foreach((._;>;);out center #{NUMBER_TO_DOWNLOAD};);"
#This string fetches almost all geometry of a way except for center points. Does restrict number to download.
str = "data=[out:json][timeout:#{timeout}][maxsize:1073741824];way[\"#{key}\"=\"#{val}\"]#{bounds_string};out count;out meta geom #{NUMBER_TO_DOWNLOAD};"
print str
base_url = "http://overpass-api.de/api/interpreter?"
url = "#{base_url}#{URI.escape(str)}"
puts url
response = Typhoeus.get(url, {followlocation: true, timeout: timeout})
response.body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_categories(count = ENV['DEFAULT_CATEGORY_COUNT'].to_i)\n max_category = 18418\n uri = \"http://jservice.io/api/categories?count=#{count}&offset=#{1+rand(max_category/count.to_f)}\"\n request = HTTParty.get(uri)\n data = JSON.parse(request.body)\nend",
"def categories()\n @web.get('http://www.w... | [
"0.6801513",
"0.5988172",
"0.5903828",
"0.5830827",
"0.5759682",
"0.5666592",
"0.5636708",
"0.5636708",
"0.5636708",
"0.5636708",
"0.5621296",
"0.56193566",
"0.5569264",
"0.55605793",
"0.55453724",
"0.5523555",
"0.5501333",
"0.54920936",
"0.548831",
"0.5474963",
"0.5446883",
... | 0.0 | -1 |
Parses an HTTP header string (from the second line on) and returns a hash. | def parse_header(raw)
header = {}
field = nil
raw.each_line do |line|
case line
when /^([A-Za-z0-9!\#$%&'*+\-.^_`|~]+):\s*(.*?)\s*\z/om
field, value = $1, $2
header[field] = value
when /^\s+(.*?)\s*\z/om
value = $1
fail "bad header '#{line}'." unless field
header[field][-1] << ' ' << value
else
fail "bad header '#{line}'."
end
end
header.each do |key, value|
value.strip!
value.gsub!(/\s+/, ' ')
end
header
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_header(line)\n if (match = line.match(/^(.+?):\\s*(.+)#{@nl}$/))\n key = match[1].downcase\n set_header_special_values(key, match[2])\n parse_normal_header(line, key, match[1], match[2])\n elsif (match = line.match(/^HTTP\\/([\\d\\.]+)\\s+(\\d+)\\s+(.+)$/))\n @response.code = ma... | [
"0.77940863",
"0.7784196",
"0.74535525",
"0.73659676",
"0.7275645",
"0.7240513",
"0.7186212",
"0.6995989",
"0.69778246",
"0.69268936",
"0.68458",
"0.6817888",
"0.68014413",
"0.678655",
"0.67348224",
"0.67158926",
"0.6677246",
"0.66378576",
"0.65972626",
"0.6594826",
"0.656826... | 0.69974273 | 7 |
Decrement the integer value of a key by the given number. | def decrby(key, decrement)
send_command([:decrby, key, Integer(decrement)])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dec(key,value)\n _set(key, (_get(key) || 0) - value)\n end",
"def decr(key, value = 1)\n mon_synchronize do\n perform [\"decr\", key, value], proc: T_INT\n end\n end",
"def decr(key, value = 1)\n mon_synchronize do\n perform [\"decr\", key, value], :proc => T_INT\n end\n e... | [
"0.7788995",
"0.77010024",
"0.76765805",
"0.76502395",
"0.76502395",
"0.755122",
"0.7349987",
"0.7339793",
"0.730003",
"0.6898535",
"0.68906945",
"0.6843618",
"0.6843618",
"0.6828622",
"0.67729133",
"0.6768649",
"0.6758973",
"0.6705658",
"0.65518355",
"0.6509683",
"0.64989954... | 0.7205911 | 9 |
Increment the integer value of a key by one. | def incr(key)
send_command([:incr, key])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _inc(key,value)\n _set(key, (_get(key) || 0) + value)\n end",
"def increment(key)\n @counter[key] += 1\n end",
"def increment\n Dictionary.db.zincrby @key, 1, @value\n end",
"def incr(key); end",
"def incr(key); end",
"def incrby(key, increment); end",
"def incrby(key, i... | [
"0.8546398",
"0.8440538",
"0.83541155",
"0.81469995",
"0.81469995",
"0.81236756",
"0.81236756",
"0.80572253",
"0.80104357",
"0.79280925",
"0.79027927",
"0.7857353",
"0.77896583",
"0.76560795",
"0.75172895",
"0.75172895",
"0.7464603",
"0.7452834",
"0.739074",
"0.7318309",
"0.7... | 0.76643014 | 13 |
Increment the integer value of a key by the given integer number. | def incrby(key, increment)
send_command([:incrby, key, Integer(increment)])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _inc(key,value)\n _set(key, (_get(key) || 0) + value)\n end",
"def increment(key)\n @counter[key] += 1\n end",
"def incrby(key, increment); end",
"def incrby(key, increment); end",
"def increment\n Dictionary.db.zincrby @key, 1, @value\n end",
"def incr(key); end",
"def ... | [
"0.83145404",
"0.8208279",
"0.8077446",
"0.8077446",
"0.79672027",
"0.79084706",
"0.79084706",
"0.7875213",
"0.7846512",
"0.7824136",
"0.77706105",
"0.76563656",
"0.76446706",
"0.7642724",
"0.76345533",
"0.7325844",
"0.7325844",
"0.72343284",
"0.71754074",
"0.7137071",
"0.712... | 0.76418406 | 14 |
Increment the numeric value of a key by the given float number. | def incrbyfloat(key, increment)
send_command([:incrbyfloat, key, Float(increment)], &Floatify)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incrbyfloat(key, increment); end",
"def incrbyfloat(key, increment); end",
"def incrbyfloat(key, increment)\n node_for(key).incrbyfloat(key, increment)\n end",
"def increment(key, val)\n self[key] += _floatify(val)\n end",
"def hincrbyfloat(key, field, increment); end",
"def hincrbyfl... | [
"0.89294297",
"0.89294297",
"0.87088376",
"0.8641977",
"0.8132191",
"0.8132191",
"0.7913796",
"0.7734302",
"0.75416577",
"0.75007063",
"0.7265617",
"0.7265617",
"0.71622664",
"0.71622664",
"0.7102625",
"0.70946944",
"0.70680773",
"0.6973783",
"0.6945841",
"0.6931626",
"0.6919... | 0.8462094 | 4 |
Set the string value of a key. | def set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil)
args = [:set, key, value.to_s]
args << "EX" << Integer(ex) if ex
args << "PX" << Integer(px) if px
args << "EXAT" << Integer(exat) if exat
args << "PXAT" << Integer(pxat) if pxat
args << "NX" if nx
args << "XX" if xx
args << "KEEPTTL" if keepttl
args << "GET" if get
if nx || xx
send_command(args, &BoolifySet)
else
send_command(args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key=(value)\n raise TypeError, 'key must be a String or respond to #to_s' unless value.is_a?(String) || respond_to?(:to_s)\n \n @key = value.to_s\n end",
"def key=(value)\n @key = value.to_s\n end",
"def []=(key, value)\n setValueFo... | [
"0.83226436",
"0.77962935",
"0.77581835",
"0.7731623",
"0.76726204",
"0.7500018",
"0.7454675",
"0.74425685",
"0.7367446",
"0.7357871",
"0.7342931",
"0.7342931",
"0.73147106",
"0.7252742",
"0.7252604",
"0.7227737",
"0.7189322",
"0.71102804",
"0.70913905",
"0.7074253",
"0.70685... | 0.0 | -1 |
Set the time to live in seconds of a key. | def setex(key, ttl, value)
send_command([:setex, key, Integer(ttl), value.to_s])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_timer(key, time)\n transaction.timers[key] = time\n end",
"def expire(key, seconds, **kwargs); end",
"def ttl=(seconds)\n self.shared_max_age = age + seconds\n end",
"def expire(key, seconds)\n # no-op\n end",
"def []=(key, value)\n v = TimedObject.new(value, Time.now + t... | [
"0.7033809",
"0.6994046",
"0.6849151",
"0.68432796",
"0.68292415",
"0.6708266",
"0.6637561",
"0.6637561",
"0.66218823",
"0.66203856",
"0.66160643",
"0.66160643",
"0.66160643",
"0.65959114",
"0.6570283",
"0.6565751",
"0.65489846",
"0.6545847",
"0.65303",
"0.6516957",
"0.650524... | 0.60496616 | 42 |
Set the time to live in milliseconds of a key. | def psetex(key, ttl, value)
send_command([:psetex, key, Integer(ttl), value.to_s])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_timer(key, time)\n transaction.timers[key] = time\n end",
"def []=(key, value)\n v = TimedObject.new(value, Time.now + timeout)\n @store[key] = v\n end",
"def set(key, value, options = {})\n time = options[:time] || timeout\n \n # we can technically do away with checking against... | [
"0.7197187",
"0.70529664",
"0.70327383",
"0.68871564",
"0.675136",
"0.67206305",
"0.67123795",
"0.666408",
"0.66620487",
"0.6641866",
"0.6570745",
"0.65438426",
"0.6517914",
"0.65075564",
"0.65042424",
"0.6491647",
"0.6453056",
"0.6453056",
"0.6443655",
"0.6443655",
"0.637915... | 0.0 | -1 |
Set the value of a key, only if the key does not exist. | def setnx(key, value)
send_command([:setnx, key, value.to_s], &Boolify)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(key, value=nil)\n @data[key.to_s] = value\n end",
"def set_default key, value\n return false if has_key?(key)\n self[key] = value\n end",
"def put(key, value)\n #if key exists\n if a_hash[key] != nil\n a_hash[key] = value\n end\n end",
"de... | [
"0.7479501",
"0.7344384",
"0.72144693",
"0.71791166",
"0.7061458",
"0.7061458",
"0.7013134",
"0.7011545",
"0.70092756",
"0.7006719",
"0.6981302",
"0.69521904",
"0.69521904",
"0.693599",
"0.69106865",
"0.6896844",
"0.68796885",
"0.68794984",
"0.6877824",
"0.6877667",
"0.681679... | 0.0 | -1 |
Set one or more values. | def mset(*args)
send_command([:mset] + args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(values); end",
"def set(*args)\n # not supported\n end",
"def set(*args)\n # not supported\n end",
"def set(values: nil,\n **_kwargs)\n # subclasses will generally want to call Client.munge_to_array()\n # on values before calling super()\n Cisco::Logger.debug(\"value... | [
"0.77182424",
"0.767537",
"0.767537",
"0.7433163",
"0.7401008",
"0.73431075",
"0.7341954",
"0.7341954",
"0.72341347",
"0.71834",
"0.7044045",
"0.69730467",
"0.6967741",
"0.6938582",
"0.6851271",
"0.68064076",
"0.67670006",
"0.67586756",
"0.6704054",
"0.67040294",
"0.67040294"... | 0.0 | -1 |
Set one or more values, only if none of the keys exist. | def msetnx(*args)
send_command([:msetnx, *args], &Boolify)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_multiple(keys, values)\n @mutex.synchronize do\n raise \"Invalid size #{keys}=#{values}\" unless keys.size == values.size\n # pp keys,values\n keys.zip(values).each do |var, val|\n do_set(var,val) unless var.nil? or val.nil?\n end\n end\n end",
"def set(values); end",
... | [
"0.77332973",
"0.7168097",
"0.70538497",
"0.67479897",
"0.67458564",
"0.67458564",
"0.6615992",
"0.6613405",
"0.64248836",
"0.6272163",
"0.6233832",
"0.6233832",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733",
"0.6210733... | 0.0 | -1 |
Get the value of a key. | def get(key)
send_command([:get, key])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(key)\n self[key]\n end",
"def getValue(key)\r\n \r\n return @aHash[key]\r\n end",
"def value(key)\n @hash[key]\n end",
"def get(key)\n @hash.get(key)\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n k... | [
"0.847488",
"0.8341601",
"0.83121467",
"0.81285393",
"0.8101179",
"0.8035877",
"0.7854947",
"0.783024",
"0.76814353",
"0.76214576",
"0.7608665",
"0.7581845",
"0.75672245",
"0.75189567",
"0.746768",
"0.7452492",
"0.7426756",
"0.7412703",
"0.73887944",
"0.7380335",
"0.73132586"... | 0.0 | -1 |
Get the values of all the given keys. | def mget(*keys, &blk)
keys.flatten!(1)
send_command([:mget, *keys], &blk)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def values_at(*keys)\n values = []\n keys.each {|key| values << fetch(key) }\n values\n end",
"def values_at(*keys)\n transaction do |y|\n keys.map{|k| y[k]}\n end\n end",
"def values_at(*keys)\n keys.map { |k| lookup(k) }\n end",
"def multiget(keys)\n dat... | [
"0.7813698",
"0.78041685",
"0.7443069",
"0.73216224",
"0.7283312",
"0.72797334",
"0.7167697",
"0.7149225",
"0.7141335",
"0.70829386",
"0.7058574",
"0.70196956",
"0.70095587",
"0.6987541",
"0.6796313",
"0.6780957",
"0.6769271",
"0.67485785",
"0.6666559",
"0.662742",
"0.6623182... | 0.57133937 | 84 |
Overwrite part of a string at key starting at the specified offset. | def setrange(key, offset, value)
send_command([:setrange, key, Integer(offset), value.to_s])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_string(offset, value)\n @contents.pos = offset\n @contents << value\n end",
"def new_string_offset\n last_string_index = @data[last_string_index_offset, 4].unpack1('V')\n offset = @offset + @string_start + last_string_index\n\n u16len, o16 = ResStringPool.utf16_len(@data[offse... | [
"0.69160527",
"0.6080193",
"0.6005277",
"0.57910573",
"0.568737",
"0.5649233",
"0.5616926",
"0.5605164",
"0.5605164",
"0.5605164",
"0.5599434",
"0.5599434",
"0.55837566",
"0.5574692",
"0.55335915",
"0.55315244",
"0.55315244",
"0.543442",
"0.5410416",
"0.54051703",
"0.5392307"... | 0.534628 | 22 |
Get a substring of the string stored at a key. | def getrange(key, start, stop)
send_command([:getrange, key, Integer(start), Integer(stop)])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](key)\n if path_portion = fragment.split(\"/\").find {|i| i.include?(key.to_s)}\n return path_portion.sub(\"#{key}=\", \"\")\n end\n \n nil\n end",
"def get_string(key)\n get(key, \"Z\")\n end",
"def get(key, *si)\n raise(ArgumentError, \"Argument ... | [
"0.66220564",
"0.657902",
"0.6445188",
"0.6444402",
"0.6265102",
"0.6218933",
"0.6081815",
"0.606387",
"0.60474527",
"0.60285056",
"0.5937909",
"0.5891969",
"0.5852809",
"0.5843318",
"0.58313644",
"0.579623",
"0.579623",
"0.57638097",
"0.57410693",
"0.57177776",
"0.57171756",... | 0.0 | -1 |
Append a value to a key. | def append(key, value)
send_command([:append, key, value])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(key, value)\n perform(:append, key, value.to_s)\n end",
"def append(key, value); end",
"def append(key, value); end",
"def append(key, value)\n node_for(key).append(key, value)\n end",
"def add(key, value)\n\t\t\t\tself[key] = value\n\t\t\tend",
"def append value\n add_i... | [
"0.84017235",
"0.8304687",
"0.8304687",
"0.828599",
"0.8084607",
"0.7937106",
"0.79326266",
"0.78343666",
"0.7794228",
"0.7794228",
"0.762247",
"0.75847954",
"0.75204664",
"0.7502489",
"0.742414",
"0.739131",
"0.7365538",
"0.7352885",
"0.7317122",
"0.7270993",
"0.720927",
"... | 0.7856952 | 7 |
Set the string value of a key and return its old value. | def getset(key, value)
send_command([:getset, key, value.to_s])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key=(value)\n raise TypeError, 'key must be a String or respond to #to_s' unless value.is_a?(String) || respond_to?(:to_s)\n \n @key = value.to_s\n end",
"def []=(key, value)\n setValueForKey(key.to_s, value.to_s)\n end",
"def []=(key,value)\n r... | [
"0.7275936",
"0.7059648",
"0.7056077",
"0.70361114",
"0.6950887",
"0.69140714",
"0.6758175",
"0.6754377",
"0.6754377",
"0.67415184",
"0.6726618",
"0.66994923",
"0.66890574",
"0.6664882",
"0.6651859",
"0.6650504",
"0.6598903",
"0.6589563",
"0.65787095",
"0.65645856",
"0.654767... | 0.6317226 | 28 |
Get the value of key and delete the key. This command is similar to GET, except for the fact that it also deletes the key on success. | def getdel(key)
send_command([:getdel, key])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete key\n rv = self[key]\n self.removeField key\n return rv\n end",
"def delete(key)\n response = request(:delete, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n data[S_PREV_VALUE]\n else\n nil\n end\n end",
"def delet... | [
"0.78800714",
"0.7846711",
"0.78098875",
"0.78098875",
"0.78098875",
"0.78098875",
"0.78098875",
"0.7728809",
"0.7728809",
"0.76398957",
"0.7554374",
"0.75538796",
"0.75500077",
"0.7517569",
"0.7509904",
"0.74682623",
"0.74482524",
"0.74388283",
"0.742984",
"0.7425656",
"0.73... | 0.80624545 | 0 |
Get the value of key and optionally set its expiration. GETEX is similar to GET, but is a write command with additional options. When no options are provided, GETEX behaves like GET. | def getex(key, ex: nil, px: nil, exat: nil, pxat: nil, persist: false)
args = [:getex, key]
args << "EX" << Integer(ex) if ex
args << "PX" << Integer(px) if px
args << "EXAT" << Integer(exat) if exat
args << "PXAT" << Integer(pxat) if pxat
args << "PERSIST" if persist
send_command(args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getex(key, **options); end",
"def get(key, expires_in = 0, &block)\n\n end",
"def getex(key, **options)\n node_for(key).getex(key, **options)\n end",
"def get(key, expires_in = 0)\n k = build_key(key)\n\n value = with_client do |client|\n client.get(k)\n end\n\n if !value.nil? &... | [
"0.6949803",
"0.66357166",
"0.65973264",
"0.6281269",
"0.62269014",
"0.62249666",
"0.60985285",
"0.60868347",
"0.60264266",
"0.59986705",
"0.5956625",
"0.5946595",
"0.5924147",
"0.5887354",
"0.58578724",
"0.5819998",
"0.5744547",
"0.5744547",
"0.5744547",
"0.5744547",
"0.5723... | 0.56581837 | 31 |
Get the length of the value stored in a key. | def strlen(key)
send_command([:strlen, key])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_length\n key.unpack('b*').first.length\n end",
"def llen(key); end",
"def llen(key); end",
"def length()\n return @i_keys.get_length()\n end",
"def length()\n return self.keys.get_length()\n end",
"def xlen(key); end",
"def strlen(key)\n node_for(key).strlen(key)\n ... | [
"0.8317144",
"0.81746495",
"0.81746495",
"0.80323046",
"0.7957185",
"0.78694016",
"0.7826855",
"0.7804281",
"0.765236",
"0.765236",
"0.7640324",
"0.7622893",
"0.7585785",
"0.75668055",
"0.75172657",
"0.74686134",
"0.7430591",
"0.7389715",
"0.7381224",
"0.7343596",
"0.73418075... | 0.7114492 | 28 |
To handle $~, $1, etc | def last_match=(match)
if parent
scope = self
while scope.parent
scope = scope.parent
end
scope.last_match = match
else
@last_match = match
end
match
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preProcess(s)\n n = s.length().to_i\n if n==0\n return \"^$\"\n end\n ret = \"^\"\n (0..n-1).each do |re|\n ret += ('#' + s[re].to_s)\n end\n ret += '#$'\n return ret\nend",
"def regexp=(_arg0); end",
"def sanitize(name)\n #name.gsub(\".\", \"_\").gsub(/<.+>/, \"\")\n name.gsub(\... | [
"0.59447324",
"0.5836503",
"0.5823134",
"0.5718691",
"0.5553685",
"0.55448914",
"0.5520433",
"0.55116326",
"0.5491959",
"0.5437016",
"0.5437016",
"0.5437016",
"0.5427665",
"0.5427665",
"0.5427665",
"0.54138696",
"0.540289",
"0.5374139",
"0.53678924",
"0.5364782",
"0.5360316",... | 0.0 | -1 |
The Nth group of the last regexp match. | def nth_ref(n)
if lm = last_match()
return lm[n]
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nth_ref(n)\n if lm = @last_match\n return lm[n]\n end\n\n return nil\n end",
"def process_nth_ref(exp)\n n = exp.shift\n raise if n < 1 or n > 9\n resultify(\"(RegExp.$#{n} || #{@model.encode_nil})\")\n end",
"def retrieve_last_match_from_stderr(re, nth = 0)\n return unless $s... | [
"0.7311233",
"0.6590991",
"0.64058936",
"0.6100316",
"0.6100138",
"0.58060926",
"0.5659509",
"0.5657635",
"0.5489867",
"0.5486948",
"0.5441531",
"0.54292196",
"0.5419881",
"0.5405483",
"0.5402288",
"0.5325947",
"0.53171045",
"0.5288833",
"0.5286013",
"0.52855444",
"0.5268016"... | 0.72483605 | 1 |
One of the special globals $&, $`, $' or $+. | def back_ref(kind)
if lm = last_match()
res = case kind
when :&
lm[0]
when :"`"
lm.pre_match
when :"'"
lm.post_match
when :+
lm.captures.last
end
return res
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def globals; end",
"def globals; end",
"def global_variables() end",
"def globals; list_all :global_variables; end",
"def global_var\n $global_var \n end",
"def global?; end",
"def encode_global_variable(name)\n raise if name.to_s[0,1] != '$'\n \"$\" + @global_name_generator.get(name.to_s)\n... | [
"0.6926019",
"0.6926019",
"0.6647114",
"0.62372506",
"0.620995",
"0.61501765",
"0.6094475",
"0.60512537",
"0.6044292",
"0.5971754",
"0.5967766",
"0.59497285",
"0.5888526",
"0.5858662",
"0.58381605",
"0.57419056",
"0.5718646",
"0.5705616",
"0.5694432",
"0.56906307",
"0.56434",... | 0.0 | -1 |
GET /clubs GET /clubs.json | def index
authorize Club
@clubs = Club.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @clubs = Club.all\n render json: @clubs\n end",
"def index\n\t\t@clubs = Club.all\n\t\trender json: @clubs\n\tend",
"def show\n @club = Club.find(params[:id])\n\n render json: @club\n end",
"def index\n @clubs = Club.all\n\n respond_to do |format|\n format.html # index.ht... | [
"0.82473654",
"0.8111927",
"0.80283284",
"0.8004295",
"0.7850272",
"0.77443665",
"0.7703937",
"0.75692767",
"0.75692767",
"0.75692767",
"0.75216234",
"0.7386078",
"0.7347323",
"0.7230501",
"0.71990705",
"0.7097331",
"0.70414716",
"0.7035367",
"0.6946004",
"0.691601",
"0.68934... | 0.7183093 | 15 |
GET /clubs/1 GET /clubs/1.json | def show
@club = Club.find(params[:id])
authorize @club
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @club = Club.find(params[:id])\n\n render json: @club\n end",
"def show\n \n @club = Club.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @club }\n end\n\n \n end",
"def index\n @clubs = Club.all\n ren... | [
"0.83942306",
"0.82158464",
"0.81019014",
"0.8078959",
"0.7889925",
"0.7877483",
"0.786315",
"0.78516775",
"0.75047773",
"0.74475837",
"0.74475837",
"0.74475837",
"0.7375221",
"0.72653127",
"0.7220348",
"0.72018844",
"0.71983624",
"0.7168892",
"0.7067452",
"0.70564526",
"0.70... | 0.64701915 | 66 |
POST /clubs POST /clubs.json | def create
authorize Club
@club = Club.new(club_params)
@club.owner = current_user
@club.users << current_user
respond_to do |format|
if @club.save
format.html { redirect_to @club, notice: 'Club was successfully created.' }
format.json { render :show, status: :created, location: @club }
else
format.html { render :new }
format.json { render json: @club.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\t@club = Club.new(club_params)\n\n\t\tif @club.save\n\t\t \trender json: @c... | [
"0.8054144",
"0.7773733",
"0.7694407",
"0.7685378",
"0.7629768",
"0.7629768",
"0.7382724",
"0.737534",
"0.7166113",
"0.7161418",
"0.71364695",
"0.70934063",
"0.7001579",
"0.69559604",
"0.6933581",
"0.6887192",
"0.6851174",
"0.68438107",
"0.6837938",
"0.6834599",
"0.6810462",
... | 0.7116273 | 11 |
PATCH/PUT /clubs/1 PATCH/PUT /clubs/1.json | def update
@club = Club.find(params[:id])
authorize @club
respond_to do |format|
if @club.update(club_params)
format.html { redirect_to @club, notice: 'Club was successfully updated.' }
format.json { render :show, status: :ok, location: @club }
else
format.html { render :edit }
format.json { render json: @club.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def update\n @club = Club.find(params[:id])\n\n respond_to do |format|\n if @club.update_... | [
"0.78566873",
"0.7662503",
"0.7648432",
"0.7564167",
"0.7512484",
"0.74925065",
"0.74925065",
"0.7461075",
"0.7461075",
"0.7461075",
"0.7461075",
"0.7461075",
"0.74399173",
"0.72643304",
"0.72520417",
"0.7219107",
"0.7159269",
"0.7110806",
"0.7005018",
"0.70039654",
"0.695351... | 0.71363366 | 17 |
DELETE /clubs/1 DELETE /clubs/1.json | def destroy
@club = Club.find(params[:id])
authorize @club
@club.destroy
respond_to do |format|
format.html { redirect_to clubs_url, notice: 'Club was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.ht... | [
"0.81467396",
"0.8125921",
"0.8125921",
"0.80589193",
"0.80589193",
"0.80283463",
"0.7990399",
"0.7949108",
"0.79312074",
"0.78865546",
"0.78865546",
"0.78865546",
"0.78705937",
"0.78516614",
"0.77526957",
"0.771957",
"0.7699575",
"0.7608901",
"0.7604228",
"0.7587584",
"0.758... | 0.7623334 | 17 |
POST /clubs/1/join POST /clubs/1/join.json | def join
@club = Club.find(params[:id])
authorize @club
@club.club_memberships.create! user_id: current_user.id
redirect_to action: :show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join\n @beer_club = BeerClub.find(params[:id])\n if Membership.where(:beer_club_id => @beer_club.id, :user_id => current_user.id).exists?\n respond_to do |format|\n format.html { redirect_to :back, notice: \"You are already a member of this club!\" }\n end\n else\n... | [
"0.7300599",
"0.65574485",
"0.64909005",
"0.64552486",
"0.64253485",
"0.63883805",
"0.6370366",
"0.63585943",
"0.63530385",
"0.6340715",
"0.63233674",
"0.6319779",
"0.6173563",
"0.61190057",
"0.60923785",
"0.60726094",
"0.6056324",
"0.6054606",
"0.6047761",
"0.6042337",
"0.60... | 0.78311723 | 0 |
POST /clubs/1/leave POST /clubs/1/leave.json | def leave
@club = Club.find(params[:id])
authorize @club
@club.club_memberships.where(user_id: current_user).destroy_all
redirect_to action: :show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @leave = Leave.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leave }\n end\n end",
"def create\n @leafe = Leave.new(leafe_params)\n\n respond_to do |format|\n if @leafe.save\n format.html { redirect_to @leafe, notice: 'Le... | [
"0.6537879",
"0.6456636",
"0.64482385",
"0.63692695",
"0.636711",
"0.63562167",
"0.62911886",
"0.62337303",
"0.61901367",
"0.6177278",
"0.61333936",
"0.61333936",
"0.61333936",
"0.6106388",
"0.60843277",
"0.606639",
"0.59515834",
"0.59335065",
"0.5870352",
"0.586905",
"0.5824... | 0.6148277 | 10 |
Never trust parameters from the scary internet, only allow the white list through. | def club_params
params.require(:club).permit(
:name, :short_name, :description,
:cover_image, :remove_cover_image, :logo, :remove_logo, :recording_area
)
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.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.629... | 0.0 | -1 |
For example, if the array , , so return . Complete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer. simpleArraySum has the following parameter(s): ar: an array of integers The first line contains an integer, , denoting the size of the array. The second line contains spaceseparated integers representing the array's elements. Output Format Print the sum of the array's elements as a single integer. Sample Input 6 1 2 3 4 10 11 Sample Output 31 | def simpleArraySum(ar)
count = 0
ar.each {|x| count += x}
count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simpleArraySum(ar)\n return ar.map(&:to_i).sum\nend",
"def simpleArraySum(ar)\n ar.sum\nend",
"def simpleArraySum(ar)\n ar.sum\nend",
"def sum_array(array)\n return array.sum\n\n # sum_total_of_array = 0\n # for number in array\n # sum_total_of_array += number\n # end\n # return sum_total_... | [
"0.84559375",
"0.8279123",
"0.8244422",
"0.815086",
"0.810255",
"0.8083986",
"0.80654943",
"0.806012",
"0.7958405",
"0.794336",
"0.79200554",
"0.7916011",
"0.7913863",
"0.7900274",
"0.78907776",
"0.78897697",
"0.78890973",
"0.78884196",
"0.78776824",
"0.78756464",
"0.787426",... | 0.7952488 | 9 |
=begin saasclass.org HW 1: Ruby calisthenics by Nathan Dotz | def palindrome? ( something )
raise unless something.is_a?(String)
test_string = something.downcase.gsub(/\W/, '')
return test_string == test_string.reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alg; end",
"def schumann; end",
"def numerator() end",
"def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n\nend",
"def basic_calc\n print \"(a)dd, (s)ubtract, (m)ultiply, (d)ivide: \"\n\nend",
"def calculated; end",
"def sum; end",
"def advanced_calc\n print \"(p)ower, (s)q... | [
"0.6557689",
"0.6525326",
"0.63818663",
"0.6365048",
"0.6365048",
"0.63239104",
"0.62769127",
"0.622515",
"0.6221255",
"0.6205346",
"0.61757493",
"0.60707855",
"0.5999533",
"0.59901226",
"0.59878576",
"0.598367",
"0.5953868",
"0.5946026",
"0.5941206",
"0.5937179",
"0.5932781"... | 0.0 | -1 |
information and their logs shall be automatically made for them. author vict0rem Gets numeric input, loops until user inputs only an integer value | def getIntegerInput()
val = gets.chomp
while !/((\d)+)/.match(val) || /((\d)+\.(\d)+)/.match(val)
puts 'This input should be an integer. Please input again.'
val = gets.chomp
end
return val
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ask_for_digits\r\n puts (\"Calculator\").colorize(:white).on_green\r\n variables = []\r\n input = @@prompt.ask(\"Enter a number between 1000 and 9999 e.g. 1234:\") do |q|\r\n q.convert -> (input) { input.split(/[\\s]/) }\r\n q.convert(:integer, \"Invalid input. Try ag... | [
"0.66092736",
"0.6603989",
"0.65450525",
"0.6543666",
"0.6501524",
"0.64608026",
"0.64101535",
"0.64075357",
"0.6405119",
"0.635944",
"0.63532937",
"0.6329079",
"0.63286066",
"0.63224363",
"0.62884784",
"0.62768",
"0.6269413",
"0.6258408",
"0.62535346",
"0.624236",
"0.6240378... | 0.6152773 | 28 |
Gets numeric input, loops until user inputs a float or integer value | def getFloatInput()
val = gets.chomp
while not /((\d)+)/.match(val) || /((\d)+\.(\d)+)/.match(val)
puts 'This input should be a decimal (I.E. 1.1 or 1.2) or integer
(I.E. 1 or 2). Please input again.'
val = gets.chomp
end
return val
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_check(number)\n until (number.to_f.to_s == number || number.to_i.to_s == number) && number.to_f != nil\n print \"ERROR: Please enter a valid number (float or integer):\"\n number = gets.chomp\n end\n return number\nend",
"def verify_number(data_to_verify)\n until (Float(data_to_verify) rescu... | [
"0.77336425",
"0.77113897",
"0.76842934",
"0.76531905",
"0.7525484",
"0.75112915",
"0.74006647",
"0.73721296",
"0.7364309",
"0.72914773",
"0.7273671",
"0.7222926",
"0.71937853",
"0.70949006",
"0.7084996",
"0.7074564",
"0.698324",
"0.6965458",
"0.69071674",
"0.68944436",
"0.68... | 0.7706417 | 2 |
These defs are made to determine the amount of CP a character needs to level up and if they did level up how much CP they will need for their next level. | def CP(level)
cpNeeded = 0
if level > 0 && level <= 5
cpNeeded + 4
elsif level > 5 && level <= 20
cpNeeded + 8
else
cpNeeded + 0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cr_or_level(num_of_pcs, cr_or_level)\n if num_of_pcs <= 4\n @cr = cr_or_level\n elsif num_of_pcs == 5\n @cr = cr_or_level + (cr_or_level * 0.25)\n elsif num_of_pcs == 6\n @cr = cr_or_level + (cr_or_level * 0.5)\n elsif num_of_pcs == 7\n @cr = cr_or_level + (cr_or_level * 0.7... | [
"0.65192807",
"0.5765847",
"0.5704485",
"0.5703791",
"0.5649336",
"0.56417644",
"0.5570401",
"0.55661213",
"0.5530373",
"0.54888004",
"0.5477106",
"0.5445855",
"0.5432166",
"0.5427537",
"0.5421823",
"0.53717446",
"0.53274924",
"0.5319638",
"0.5318701",
"0.526846",
"0.5257585"... | 0.75770634 | 0 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set Complete? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def set_complete?(eqps = [])
itms = items
!itms.empty? && ((itms & eqps).size == itms.size)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_as_complete\n mark_as_complete_and_save\n end",
"def complete?; end",
"def mark_complete\n self.complete = true\n self.save\n end",
"def mark_as_complete_and_save\n self.complete = true\n save\n end",
"def complete!\n @completed = true\n @completed_at = Time.now\n end... | [
"0.7429153",
"0.6970775",
"0.6965546",
"0.6938573",
"0.6916579",
"0.6851977",
"0.6825764",
"0.67574567",
"0.66737837",
"0.6659592",
"0.6612763",
"0.65987337",
"0.65907615",
"0.6567258",
"0.65655744",
"0.65655744",
"0.65529007",
"0.65529007",
"0.65388346",
"0.6531535",
"0.6523... | 0.6527179 | 20 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate Equip Set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def maesb_generate_equip_set
@maesb_belongs_to_sets = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maesb_generate_equipment_sets\n # Generate Equipment Sets\n ($data_weapons + $data_armors).compact.each { |equip| equip.maesb_generate_equip_set }\n # Update items to refer to the set to which they belong\n set_items = $data_armors.compact.select {|armor| !armor.maesb_sets.empty? }\n set_items.e... | [
"0.68351865",
"0.60732543",
"0.60037035",
"0.5973523",
"0.5968878",
"0.5706798",
"0.5605056",
"0.55641353",
"0.55604774",
"0.55501145",
"0.5425557",
"0.5397567",
"0.5395156",
"0.53529346",
"0.53304124",
"0.5302607",
"0.5301194",
"0.52929443",
"0.5286353",
"0.5280704",
"0.5276... | 0.6679016 | 1 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate Equip Set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def maesb_generate_equip_set
super
@maesb_sets = note.scan(/\\SET\s*\[(.+?)\]/i).collect { |set_s|
MAESB_EquipmentSet.new(set_s[0]) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maesb_generate_equipment_sets\n # Generate Equipment Sets\n ($data_weapons + $data_armors).compact.each { |equip| equip.maesb_generate_equip_set }\n # Update items to refer to the set to which they belong\n set_items = $data_armors.compact.select {|armor| !armor.maesb_sets.empty? }\n set_items.e... | [
"0.68341446",
"0.6678514",
"0.6005648",
"0.5975926",
"0.5968161",
"0.57080483",
"0.56052655",
"0.55645406",
"0.55605036",
"0.555093",
"0.5427449",
"0.5399112",
"0.53962564",
"0.5353751",
"0.5332548",
"0.53034526",
"0.53031844",
"0.52937335",
"0.52871126",
"0.52815944",
"0.527... | 0.6074233 | 2 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set Complete? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def maesb_set_complete?(maesb_equips)
maesb_sets.each { |set| return true if set && set.set_complete?(maesb_equips) }
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_as_complete\n mark_as_complete_and_save\n end",
"def complete?; end",
"def mark_complete\n self.complete = true\n self.save\n end",
"def mark_as_complete_and_save\n self.complete = true\n save\n end",
"def complete!\n @completed = true\n @completed_at = Time.now\n end... | [
"0.7429153",
"0.6970775",
"0.6965546",
"0.6938573",
"0.6916579",
"0.6851977",
"0.6825764",
"0.67574567",
"0.66737837",
"0.6659592",
"0.6612763",
"0.65987337",
"0.65907615",
"0.6567258",
"0.65655744",
"0.65655744",
"0.65529007",
"0.65529007",
"0.65388346",
"0.6531535",
"0.6527... | 0.0 | -1 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate Equipment Sets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def maesb_generate_equipment_sets
# Generate Equipment Sets
($data_weapons + $data_armors).compact.each { |equip| equip.maesb_generate_equip_set }
# Update items to refer to the set to which they belong
set_items = $data_armors.compact.select {|armor| !armor.maesb_sets.empty? }
set_items.each { |set_item|
set_item.maesb_sets.collect {|set| set.items }.flatten.uniq.each { |equip|
equip.maesb_belongs_to_sets.push(set_item.id)
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maesb_generate_equip_set\n @maesb_belongs_to_sets = []\n end",
"def maesb_generate_equip_set\n super\n @maesb_sets = note.scan(/\\\\SET\\s*\\[(.+?)\\]/i).collect { |set_s| \n MAESB_EquipmentSet.new(set_s[0]) }\n end",
"def generate_demands\n\t\n\t\tcase @inputs.generation_method... | [
"0.7470944",
"0.6843264",
"0.59731007",
"0.59340966",
"0.5891488",
"0.58855706",
"0.5860812",
"0.58247143",
"0.5794167",
"0.57598925",
"0.57151693",
"0.5606726",
"0.5597033",
"0.55759776",
"0.555635",
"0.5553693",
"0.5518126",
"0.5489724",
"0.547689",
"0.54609674",
"0.5440910... | 0.8237184 | 0 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get Array of All Objects Retaining Features ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def feature_objects(*args, &block)
maesb_sets.compact + (super(*args, &block))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_features\r\n feature_objects.inject([]) {|r, obj| r + obj.features }\r\n end",
"def objects\n @objects ||= []\n end",
"def objects\n @objects ||= []\n end",
"def objects\n @objects ||= []\n end",
"def all_objects; end",
"def array\n self.allObjects\n end",
... | [
"0.72875047",
"0.7075519",
"0.7053895",
"0.70462984",
"0.6974509",
"0.69432837",
"0.68581146",
"0.68282115",
"0.6693439",
"0.66029346",
"0.65807647",
"0.65681255",
"0.652994",
"0.64497",
"0.63681597",
"0.6362593",
"0.6349647",
"0.6338608",
"0.6305448",
"0.62015057",
"0.618376... | 0.60012096 | 32 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get Added Value of Parameter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def param_plus(param_id, *args, &block)
val = super(param_id, *args, &block)
maesb_sets.compact.inject(val) {|r, item| r += item.params[param_id] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameterReturn(param)\n return param\nend",
"def param; end",
"def param; end",
"def param_plus(param_id)\r\n @param_plus[param_id]\r\n end",
"def param( value )\n @paramNum += 1\n @params[@paramNum.to_s] = value\n return \":\" + @paramNum.to_s\n end",
"def parameter_string\n\t\tend",... | [
"0.68150127",
"0.6556336",
"0.6556336",
"0.65206426",
"0.64703137",
"0.64075214",
"0.6360481",
"0.6358102",
"0.63555354",
"0.62309027",
"0.61933863",
"0.6134356",
"0.6124009",
"0.6124009",
"0.6114801",
"0.6114801",
"0.61133057",
"0.6104645",
"0.61037576",
"0.60607696",
"0.606... | 0.0 | -1 |
I used the method above because in the method below I want to find if the name of the item is in the new array. if it is, Im going to increment it one. If not, Im going to put it into the array. | def consolidate_cart(cart)
new_cart = []
counter = 0
while counter < cart.length do
new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart)
#We want to figureout if item is in our new cart
#This method checks to see if the item we're looking for is in the new cart. Takes in items name and collection or cart. :item key points to name of the item.
# This will either return the item or it will retrun nil. RETURNS THE ITEM OR RETURNS NIL
#This above code produces nil or cart[counter], per the above method. If nil is prodcued then a new hash called new_cart_item is added to the new array with a new hash called :count.
#If it already exist, the counter is incremented by one.
#My question is, what is new_cart_item
if new_cart_item
#If this has a truthy value, do whats below. New_cart_item is the item!!! It will be truthy if it is in the array. If in the array, we will just incremement count by 1. And do this every time this item comes up.
new_cart_item[:count] += 1
else new_cart_item = {
#Else is all other options. Either truthy of falsey. If new_cart_item returns nil, then we will do below. Which is creating our item. Creating a new hash, which is the same hash with :count added. So you can say, if this is not already in our array, which will produce nil, we will add :count to the array and and put it into the new array. We will give it a count of 1. Once its been built the count will be incremented by one for each time the item is in the old cart.
:item => cart[counter][:item],
:price => cart[counter][:price],
:clearance => cart[counter][:clearance],
:count => cart[counter][:count] = 1
}
new_cart<< new_cart_item
end
counter += 1
end
new_cart
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_elements(array)\n new_array = []\n\n array.each do |original_array_element|\n\n #now inside the array looking at each indv hash\n \tif new_array.empty?\n\n \t\tfirst_new_element = {name: original_array_element[:name], count: 1}\n \t\tnew_array.push(first_new_element)\n\n \telse\n name_found =... | [
"0.65487725",
"0.6353932",
"0.6237777",
"0.6213303",
"0.61805165",
"0.6168216",
"0.6113214",
"0.59783983",
"0.5969943",
"0.5910795",
"0.5903968",
"0.59027946",
"0.58798784",
"0.58712655",
"0.58654684",
"0.58600324",
"0.58470786",
"0.58024645",
"0.5781512",
"0.5776512",
"0.577... | 0.6157613 | 6 |
Returns true if a particular concern exists | def exists? concern
mapper.instance_variable_get('@concerns').include?(concern)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register?(curation_concern)\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"curation_concern=#{curation_concern.id}\",\n ... | [
"0.70485693",
"0.6434445",
"0.6415208",
"0.6409155",
"0.63483673",
"0.6341407",
"0.6309783",
"0.6258535",
"0.62329644",
"0.6208513",
"0.61902153",
"0.61816335",
"0.61488104",
"0.61488104",
"0.6148396",
"0.61426073",
"0.609767",
"0.60826993",
"0.6078935",
"0.6068534",
"0.60672... | 0.84185463 | 0 |
The abstract concern should be able to handle resources having a preferred collection/resource target. | def call(mapper, concern_options = {})
@mapper = mapper
@concern_options = concern_options
build
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_class\n raise NotImplementedError\n end",
"def reference_resource\n return super if defined?(super)\n\n raise NotImplementedError\n end",
"def resource_collection\n @resource_collection ||= @run_context.resource_collection\n end",
"def resource_collecti... | [
"0.65963537",
"0.6441069",
"0.63092786",
"0.62719566",
"0.6143603",
"0.6134698",
"0.6100378",
"0.6081047",
"0.6069944",
"0.59489024",
"0.59489024",
"0.59281707",
"0.5880016",
"0.587787",
"0.5839482",
"0.58336556",
"0.5832619",
"0.5824523",
"0.58217174",
"0.57979053",
"0.57871... | 0.0 | -1 |
Create new limitable session | def log_limitable_request!
token = generate_limitable_token
opts = session_limitable_condition unique_session_id: token,
last_accessed_at: Time.current
authenticate_limitable? && session_limitable_adapter.create!(opts) && token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_session\n raise NotImplementedError\n end",
"def new_session\n open_session do |sess|\n sess.extend(SessionMethods)\n yield sess if block_given?\n end\n end",
"def new_session(options)\n options[:source_profile] = options[:source_profile].to_sym\n options[:prof... | [
"0.7130167",
"0.671234",
"0.6645477",
"0.6577669",
"0.6480489",
"0.6466582",
"0.6436545",
"0.6414748",
"0.6414748",
"0.6373933",
"0.63496906",
"0.62867486",
"0.62320757",
"0.6224505",
"0.61803794",
"0.6170402",
"0.6124263",
"0.61147344",
"0.60747194",
"0.6072996",
"0.6066895"... | 0.65364313 | 4 |
Check if +token_or_object+ is valid | def accept_limitable_token?(token_or_object)
extract_object_from_options(token_or_object).present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?\n @token.valid?\n end",
"def token_valid?\n raise 'To be implemented in child classes'\n end",
"def check_object(obj)\n check_parse_tree ParseTree.new.parse_tree(obj)\n end",
"def valid_token?(token)\n exists?(:token => token)\n end",
"def valid?(thing); end",... | [
"0.68578213",
"0.6835685",
"0.67999315",
"0.67559093",
"0.6641336",
"0.6641336",
"0.6480503",
"0.64756775",
"0.6388875",
"0.6303368",
"0.62689465",
"0.62159526",
"0.61649215",
"0.61642873",
"0.61549205",
"0.6130855",
"0.6118404",
"0.61175054",
"0.61175054",
"0.61169726",
"0.6... | 0.6804529 | 2 |
Update the `:last_accessed_at` to current time. | def update_limitable_access_at(token_or_object)
record = extract_object_from_options(token_or_object)
record.last_accessed_at = Time.current
record.save(validate: false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_last_activity_at\n current_user.last_activity_at = Time.zone.now if current_user\n end",
"def touch\n @last_access_time = @@access_time_sequence\n @@access_time_sequence += 1\n end",
"def access!\n today = Time.now\n if last_access.nil? || last_access < today\n... | [
"0.7388707",
"0.6967271",
"0.69560385",
"0.681438",
"0.67254746",
"0.6642778",
"0.66007364",
"0.6571303",
"0.6568112",
"0.6568112",
"0.6568112",
"0.6568112",
"0.65566546",
"0.65069973",
"0.6478962",
"0.6476362",
"0.64331293",
"0.64331293",
"0.6421007",
"0.6396269",
"0.6396269... | 0.71818066 | 1 |
Expire session matching the +token_or_object+. | def expire_session_limit(token_or_object)
object = extract_object_from_options(token_or_object)
object && session_limitable_adapter.destroy(object)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire!\n token = nil\n save!\n end",
"def invalidate_session\n @sequence = 0\n @session_id = nil\n end",
"def end_session\n self.update_attributes(session_expires_in: Time.now)\n end",
"def logout!(options = {})\n session[:session_token] = session[:active_at] = nil\n end",
... | [
"0.6366113",
"0.634913",
"0.6299228",
"0.6176928",
"0.61189204",
"0.59891504",
"0.5950706",
"0.59456265",
"0.59401256",
"0.5930891",
"0.5928277",
"0.59167",
"0.58880484",
"0.58853513",
"0.5880049",
"0.58356476",
"0.58177674",
"0.57804483",
"0.5754164",
"0.5742323",
"0.5733262... | 0.78240633 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.