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 |
|---|---|---|---|---|---|---|
Deletes all Visions and Goals, then redirects back to root. Meant as restart | def delete
Vision.destroy_all
Goal.destroy_all
render 'welcome/index'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\t\tlog_out\n\t\tredirect_to homepage_path\n\tend",
"def destroy\n @visit.destroy\n\n head :no_content\n end",
"def destroy\n\t\treset_session\n\t\tredirect_to \"/\"\n\tend",
"def destroy\n log_out\n redirected_to root_url\n end",
"def destroy\n log_out if logged_in? #FIXES SUBTLE ... | [
"0.64651513",
"0.6440043",
"0.630643",
"0.62915355",
"0.62548304",
"0.6253997",
"0.6219702",
"0.6217204",
"0.61919326",
"0.61655146",
"0.61529815",
"0.61494863",
"0.61371464",
"0.60995644",
"0.6093674",
"0.6088591",
"0.60883",
"0.60883",
"0.6067022",
"0.6046186",
"0.6035464",... | 0.6440863 | 1 |
Your Names 1) Jeremy Wong 2) Allison Reilly This is the file you should end up editing. Input number of people and the dessert output how many desserts needed for amount of people | def bakery_num(num_of_people, fav_food)
my_list = {"pie" => 8, "cake" => 6, "cookie" => 1} # create hash
pie_qty = 0
cake_qty = 0
cookie_qty = 0
raise ArgumentError.new("You can't make that food") unless my_list.has_key?(fav_food)
fav_food_qty = my_list.values_at(fav_food)[0] #create variable and set ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_names_ages(filename)\n output_file = File.open('names-ages.txt' , 'w')\nFile.read(filename).each_line do |line|\n person = line.split(',')\n name = person [0].strip\n age = person [1]. strip\noutput_file.puts(\"#{name} #{age}\")\nend\n output_file.close\nend",
"def take_a_number(katz_deli, name)\n ... | [
"0.5931212",
"0.5741322",
"0.5681348",
"0.5532772",
"0.5527515",
"0.5456546",
"0.5431254",
"0.5403563",
"0.5392616",
"0.53628933",
"0.5343393",
"0.53403986",
"0.5316894",
"0.53070885",
"0.52824277",
"0.52818125",
"0.5281448",
"0.52780503",
"0.5264604",
"0.5261536",
"0.5261515... | 0.5073057 | 42 |
TODO: convert to 8bit | def initialize(r,g,b,a = "FFFF", name = nil)
@red = r.length == 2 ? r : r[0..1]
@green = g.length == 2 ? g : g[0..1]
@blue = b.length == 2 ? b : b[0..1]
@alpha = a.length == 2 ? a : a[0..1]
@rgba = [@red,@green,@blue,@alpha]
@xyz = rgb_to_xyz
@lab = xyz_to_lab
@name = name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ms_byte; self >> 8; end",
"def convert_binary\n end",
"def in_binary\n Bases.val(self).in_binary\n end",
"def cp_d8\n end",
"def s8\n return self[:s8]\n end",
"def s8\n return self[:s8]\n end",
"def s8\n return self[:s8]\n end",
"def s8\n return self[:s8]\n ... | [
"0.7118094",
"0.69127846",
"0.66679716",
"0.66449624",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
"0.6635401",
... | 0.0 | -1 |
Zip all given files into a zip and send it with `send_data` | def send_zip(active_storages, filename: 'my.zip', resize_to_limit: nil)
require 'zip'
files = SendZipHelper.save_files_on_server active_storages, resize_to_limit: resize_to_limit
zip_data = SendZipHelper.create_temporary_zip_file files
send_data(zip_data, type: 'application/zip', filename: file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_files(name, files)\n if @request.env[\"HTTP_MOD_ZIP_ENABLED\"]\n filenames = []\n files.each do |file|\n path = ::File.expand_path(file.path)\n filename = file.name\n while filenames.include? filename\n extname = ::File.extname(filename)\n ... | [
"0.78642637",
"0.69310737",
"0.6895867",
"0.6849107",
"0.6807397",
"0.67758715",
"0.6721919",
"0.66629946",
"0.66545266",
"0.66545266",
"0.66285855",
"0.66189075",
"0.66147614",
"0.65439355",
"0.6492723",
"0.6468848",
"0.6332339",
"0.63242817",
"0.6313827",
"0.63052875",
"0.6... | 0.70008403 | 1 |
this function enables human friendly URLs for the model | def to_param
"#{id}-#{title}".downcase.gsub(/\W+/, "-").gsub(/^[-]+|[-]$/,"").strip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n if model.processable?\n model.absolute_url\n else\n super\n end\n end",
"def generate_url\n\t\tself.url ||= name.parameterize\n\tend",
"def model_slug\n slug\n end",
"def url_to\n h.url_for [model.category, model]\n end",
"def url_template; end",
"def url... | [
"0.6551211",
"0.65203166",
"0.645242",
"0.64442426",
"0.6370148",
"0.6370148",
"0.62949765",
"0.62915206",
"0.62697",
"0.62629485",
"0.6246661",
"0.6246661",
"0.623365",
"0.6227041",
"0.61970013",
"0.6190456",
"0.6178115",
"0.6178115",
"0.6178115",
"0.6178115",
"0.6178115",
... | 0.0 | -1 |
before_action :require_correct_user, only: [:create, :destroy] | def create
@secret = Secret.find(params[:id])
if @secret.likes.count == 0
@like = Like.new(user_id: current_user.id, secret_id: params[:id] )
if @like.save
redirect_to "/secrets"
end
else
redirect_to "/secrets"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n if !is_correct_user\n redirect_to incorrect_user_path_for\n end\n end",
"def correct_user\n# user = User.find_by_id(params[:id])\n# redirect_to(root_url) unless user && current_user?(user)\n end",
"def correct_user\n #to define the correct user and omit it when... | [
"0.6837842",
"0.67011493",
"0.6653445",
"0.6629872",
"0.6617393",
"0.6597039",
"0.65849966",
"0.6572707",
"0.6555551",
"0.65449506",
"0.6542222",
"0.6542222",
"0.6538116",
"0.6525768",
"0.65193546",
"0.6510664",
"0.64932454",
"0.6491622",
"0.6462471",
"0.6441166",
"0.6440779"... | 0.0 | -1 |
This class method is used in `lib/tasks/daily_tasks.rake` | def run
self.report_type = :daily_tasks
self.failures = []
EmailSubmission.where(
created_at: Date.yesterday...Date.current
).joins(:c100_application).find_each(batch_size: 25) do |record|
reference_code = record.c100_application.reference_code
find_failur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cron_tasks\n end",
"def jeweler_tasks; end",
"def rake_tasks(&block); end",
"def rake_tasks(&block); end",
"def configure_tasks\n end",
"def load_tasks\n end",
"def task\n end",
"def initialize\n @which = @@last_day_num\n @@last_day_num += 1\n @tasks = []\n end",
"... | [
"0.7170122",
"0.6818793",
"0.67889816",
"0.67889816",
"0.66818637",
"0.65569",
"0.6434752",
"0.64344454",
"0.6434191",
"0.6286948",
"0.62859946",
"0.61935806",
"0.61779153",
"0.61564136",
"0.61271155",
"0.610136",
"0.60902303",
"0.5997303",
"0.5990327",
"0.59535664",
"0.59242... | 0.0 | -1 |
Delete a task, need admin rights if not one you own | def delete_task id
request :delete, "tasks/#{id}"
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\t @task = Task.find(params[:id]) \n\t @task.destroy \n\t @tasks = Task.accessible_by(current_ability) \n\tend",
"def destroy\n @task = Task.find(params[:id])\n @task.destroy\n\tredirect_to admin_session_path\n end",
"def delete()\n\n client.delete(\"/tasks/#{gid}\") && true\n ... | [
"0.7894869",
"0.7713746",
"0.7708997",
"0.75706714",
"0.75143576",
"0.75118077",
"0.75092673",
"0.748056",
"0.74746364",
"0.7461524",
"0.73994195",
"0.7351891",
"0.7342248",
"0.7268489",
"0.72626126",
"0.72451824",
"0.7241018",
"0.7220889",
"0.7220889",
"0.7177565",
"0.717546... | 0.7769233 | 1 |
Get a task, need admin rights if not one you own | def task id
Task.new(self, JSON.parse(request :get, "tasks/#{id}"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_task\n @task = @current_user.tasks.find(params[:id])\n head 404 and return unless @task\n end",
"def get_task(options, task)\n options[:method] = 'Get'\n options[:endpoint] = '/kapacitor/v1/tasks/' + task[:id]\n\n task = _do_request(options)\n\n return if task['error'] == 'no t... | [
"0.7863194",
"0.740233",
"0.720406",
"0.70508397",
"0.70366",
"0.702073",
"0.7010409",
"0.69966507",
"0.69623834",
"0.6955968",
"0.69062674",
"0.68672484",
"0.6856685",
"0.67914313",
"0.6789284",
"0.6715419",
"0.6617086",
"0.6617086",
"0.6573383",
"0.6542842",
"0.65011936",
... | 0.61541367 | 66 |
List the tasks for a user, need admin rights if not yourself user_id/ the user id, nil mean current user order can specify the order, default to id.desc | def tasks user_id = nil, order = nil
if user_id
PaginatedEnum.new self, "tasks/user/#{user_id}", Task, order
else
PaginatedEnum.new self, 'tasks', Task, order
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend",
"def index\n @tasks = current_user.tasks.order('updated_at DESC')\n end",
"def index\n @tasks = @current_user.tasks\n end",
"def index\n authenticate_user!\n @tasks = current_user.tasks\n end",
"def index\n @tasks... | [
"0.78511447",
"0.73788047",
"0.73429596",
"0.72322965",
"0.72177106",
"0.71570253",
"0.71532696",
"0.69676805",
"0.69479555",
"0.6947006",
"0.68896604",
"0.6867951",
"0.6855479",
"0.68429685",
"0.6827704",
"0.68061477",
"0.6793166",
"0.6780531",
"0.6776762",
"0.67709166",
"0.... | 0.7913052 | 0 |
print values in a list | def print_values(list_node)
if list_node
print "#{list_node.value} --> "
print_values(list_node.next_node)
else
print "nil\n"
return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_values(list)\n if !list\n print \"nil\\n\"\n else\n print \"#{list.value} -> \"\n print_values(list.next_node)\n end\n end",
"def print_list(list)\n\tlist.each do |item, qty|\n\t\tputs \"#{item} = #{qty}\"\n\tend\nend",
"def print_list(list)\n\tlist.each do |x,y|\n\t\tputs x ... | [
"0.80934095",
"0.79318166",
"0.78729886",
"0.78729886",
"0.7674685",
"0.7674685",
"0.7632757",
"0.7602444",
"0.75995386",
"0.75592273",
"0.75334185",
"0.75275445",
"0.7526418",
"0.7522672",
"0.7497447",
"0.74913913",
"0.7476731",
"0.74291325",
"0.7403451",
"0.73918146",
"0.73... | 0.0 | -1 |
Push a value onto the stack | def push(value)
# IMPLEMENT ME!
@top = LinkedListNode.new(value, @top)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(value)\n return \"Stack is full\" if is_full\n\n @stack.push(value)\n @current_size += 1\n end",
"def add(value)\n @stack.push(value)\n end",
"def push(x)\n @stack << x \n end",
"def push(x)\n @stack << x\n end",
"def push(x)\n @stack.push(x)\n end",
"def push(val... | [
"0.8563555",
"0.8531257",
"0.8298897",
"0.82781947",
"0.8205244",
"0.81969625",
"0.8174969",
"0.8150769",
"0.81474",
"0.81396604",
"0.80902964",
"0.80648404",
"0.795523",
"0.79373324",
"0.79243076",
"0.79227865",
"0.79042894",
"0.78440315",
"0.78257644",
"0.7730317",
"0.77155... | 0.733289 | 38 |
Pop an item off the stack. Remove the last item that was pushed onto the stack and return the value to the user | def pop
# I RETURN A VALUE
return nil if @top.nil?
original_top = @top.value
@top = @top.next_node
original_top
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop()\n return \"Stack is empty\" if is_empty\n\n temp = @stack[-1]\n @stack.delete_at(-1)\n @current_size -= 1\n\n return temp\n end",
"def pop()\n @stack.pop\n end",
"def pop()\n\t\t@stack.pop\n\tend",
"def pop()\n # if the stack is empty, return nil\n # (it would also b... | [
"0.8282747",
"0.8272159",
"0.82568437",
"0.82367283",
"0.82284796",
"0.8221389",
"0.82085025",
"0.81877303",
"0.8171228",
"0.816917",
"0.81609",
"0.81609",
"0.81484824",
"0.81295305",
"0.8104188",
"0.8102843",
"0.8102843",
"0.8092002",
"0.80843943",
"0.80676633",
"0.80604583"... | 0.72876036 | 77 |
Reverse a given list | def reverse_list(list)
# ADD CODE HERE
reversed = Stack.new
while list
# ADD CODE HERE
reversed.push(list.value) unless list == nil
list = list.next_node
end
# ADD CODE HERE
reversed.top
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse!(list)\n list.reverse!\n end",
"def reverse_list list\n\tlist.reverse\nend",
"def reverse(list)\n list.reverse\nend",
"def reverse!(list)\n reverse_list = Array.new(list)\n (reverse_list.size - 1).downto(0).each { |index| list[index] = reverse_list[index]}\n list\nend",
"def reverse... | [
"0.8805875",
"0.8619469",
"0.82553095",
"0.80916655",
"0.8011288",
"0.7967859",
"0.7884684",
"0.7847206",
"0.78044987",
"0.7803224",
"0.76677364",
"0.7637786",
"0.76033884",
"0.7515472",
"0.7513251",
"0.7504812",
"0.7497704",
"0.7477073",
"0.74556744",
"0.745402",
"0.74010235... | 0.65758204 | 69 |
This method generates an array of all moves that can be made after the current move. | def children
result = []
positions = []
board.rows.each_with_index do |row, i|
row.each_with_index do |square, j|
if square.nil?
dup = board.rows.deep_dup
dup[i][j] = @next_mover_mark
result << dup
positions << [i, j]
end
end
end
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_possible_moves\n positions_array = []\n x = @position[0]\n y = @position[1]\n next_position = [x+1,y+2]\n positions_array << next_position if position_check(next_position)\n next_position = [x+1,y-2]\n positions_array << next_position if position_check(next_position)\n next_positio... | [
"0.74542904",
"0.7448149",
"0.74069035",
"0.7375318",
"0.72373027",
"0.7234965",
"0.7215259",
"0.72118765",
"0.72038615",
"0.71801317",
"0.71401936",
"0.71162206",
"0.70881444",
"0.7080469",
"0.70726323",
"0.70608085",
"0.7033311",
"0.70258737",
"0.6983692",
"0.69750845",
"0.... | 0.0 | -1 |
def create_layout template 'layout.html.erb', 'app/views/layouts/admin_bits/layout.html.erb' template 'stylesheets.css.scss', 'app/assets/stylesheets/admin_bits.css.scss' template 'javascripts.js', 'app/assets/javascripts/admin_bits.js' end | def create_index
template 'index.html.erb', "app/views/#{namespace}/#{resource}/index.html.erb"
template 'filters.html.erb', "app/views/#{namespace}/#{resource}/_filters.html.erb"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_layout\n if options.sass?\n directory 'app'\n gem 'compass', '>=0.10.5'\n gem 'compass-960-plugin', '>=0.10.0'\n directory 'config'\n else\n copy_file \"stylesheet.css\", \"public/stylesheets/#{file_name}.css\" if options.stylesheet?\n copy_file \"handheld.css\", \"... | [
"0.76408494",
"0.7043951",
"0.6911749",
"0.6911749",
"0.6794268",
"0.67376137",
"0.6595517",
"0.6537519",
"0.6505718",
"0.649571",
"0.64821106",
"0.6433385",
"0.6417673",
"0.640451",
"0.638857",
"0.638315",
"0.63765085",
"0.63535804",
"0.6344291",
"0.63396156",
"0.6315206",
... | 0.5763204 | 84 |
Use callbacks to share common setup or constraints between actions. | def set_item
@item = Item.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def item_params
params.require(:item).permit(:name, :price, :available, :description, :quantity, category_ids: [])
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 |
initialize sets up the database from the config file, initializes the list of models, checks for dependencies, and then registers the component with the Manager | def initialize(config)
@registered = false;
@logger = Service.get_logger
@name = config['name']
@dependencies = config['dependencies']
config['api_modules'] << API::Base
@keys = Keys.new
@served_key = @keys.gen
@responses = {}
@served_object = Ser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(config)\n run_hook(:before_initialize, config)\n\n @config = config\n raise ::SORM::NotConfigured, \"You should configure database path\" unless has_config?\n\n @db = SDBM.open config[:database]\n\n run_hook(:after_initialize, db)\n end",
"def initialize\n super\n\... | [
"0.6483393",
"0.63809437",
"0.63765085",
"0.6325461",
"0.6309367",
"0.6304332",
"0.62291884",
"0.6212353",
"0.6074174",
"0.60311115",
"0.59956026",
"0.5913431",
"0.58508205",
"0.58245665",
"0.5805527",
"0.5764378",
"0.5685111",
"0.56744945",
"0.5668256",
"0.5663666",
"0.55785... | 0.5329551 | 45 |
daemonize joins the DRb server thread to the main thread | def daemonize
Service.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def daemon\n user_thread.daemon\n end",
"def run_server_thread; end",
"def main_loop\n Thread.start(@protocol.accept) do |client|\n @grp.add Thread.current\n Thread.current['DRb'] = { 'client' => client ,\n 'server' => self }\n DRb.mutex.synchroniz... | [
"0.7548499",
"0.73314697",
"0.68567324",
"0.6812608",
"0.6802602",
"0.653109",
"0.65007526",
"0.6483671",
"0.6442721",
"0.640275",
"0.63517064",
"0.6263128",
"0.6245092",
"0.623801",
"0.6237226",
"0.62158763",
"0.62022084",
"0.61896205",
"0.6185328",
"0.6157724",
"0.6138957",... | 0.7096984 | 2 |
routes returns the list of routes this component will handle. The default (defined here) is simply the downcased name of the component | def routes
[@name.downcase]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n ... | [
"0.72251946",
"0.72251946",
"0.71573424",
"0.7058933",
"0.7058933",
"0.6992252",
"0.67778283",
"0.67355454",
"0.66467905",
"0.6603152",
"0.660275",
"0.6599081",
"0.65669143",
"0.65559924",
"0.65405995",
"0.6453154",
"0.6444249",
"0.643421",
"0.6401453",
"0.6318908",
"0.628409... | 0.70328933 | 5 |
TODO here and interface | def allowed?(key, id)
key = @manager.check_key(key)
key == :private
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def implementation; end",
"def implementation; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def probers; end",
"def operations; end",
"def operations; end",
"def wrapper; end",
"def refutal()\n end",
"def cu... | [
"0.77880156",
"0.6824925",
"0.6824925",
"0.6770964",
"0.6770964",
"0.6770964",
"0.6770964",
"0.64948875",
"0.64880747",
"0.6410521",
"0.6410521",
"0.6314105",
"0.62899333",
"0.6278313",
"0.6278313",
"0.625596",
"0.625596",
"0.62367994",
"0.62207407",
"0.6204421",
"0.6190094",... | 0.0 | -1 |
call handles the request. It sets up the environment, and calls the appropriate method on the controller. The method it calls defaults to next_path, but if a value is passed in for path_position it grabs that part of the path as the method name. | def call(env, path_position=nil)
setup_env(env)
method = path_position ? path(path_position) : next_path
if method
@controller.send(method)
else
@controller.send(:index)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(env)\n Rango::Router.set_rack_env(env) # See rango/router/adapters/*\n request = Rango::Request.new(env)\n options = env[\"rango.router.params\"] || raise(\"rango.router.params property has to be setup at least to empty hash\")\n method = env[\"rango.controller.action\"].to_sym... | [
"0.6487211",
"0.6355407",
"0.6211799",
"0.5975601",
"0.5934717",
"0.5909527",
"0.58894384",
"0.5870954",
"0.58650565",
"0.58496547",
"0.5847219",
"0.5843022",
"0.58306426",
"0.5826171",
"0.571336",
"0.56997687",
"0.56982905",
"0.56821084",
"0.56691056",
"0.56406534",
"0.56306... | 0.7536566 | 0 |
Takes an item link name like '/' or '/developer/' and returns the matching item | def item_of(id)
if id == '/'
id = '/index'
end
if %r{^/.+/$}.match(id)
id = id.chop
end
return @items.find { |i| i.identifier.without_ext == id }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_item_link(item)\n subcategory = item[\"subcategory\"].downcase\n\n if subcategory == \"audio\"\n id = item[\"identifier\"].split(\".\").last\n path = audio_item_path(id: id)\n\n elsif subcategory == \"correspondence & papers\"\n path = correspondence_item_path(id: item[\"identifi... | [
"0.72734123",
"0.71389264",
"0.6696327",
"0.65488845",
"0.65488845",
"0.6521679",
"0.64943516",
"0.6487767",
"0.6472525",
"0.63667935",
"0.632634",
"0.63009894",
"0.62553453",
"0.6246068",
"0.6151201",
"0.6126559",
"0.6093965",
"0.6080176",
"0.60300773",
"0.600883",
"0.600765... | 0.6367027 | 9 |
This program shows how the performance of Fiber.transfer degrades as the fiber count increases | def run(num_threads)
count = 0
GC.start
GC.disable
threads = []
t0 = Time.now
limit = 10_000_000 / num_threads
num_threads.times do
threads << Thread.new do
individual_count = 0
loop do
individual_count += 1
count += 1
break if individual_count == limit
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(num_fibers)\n count = 0\n\n GC.start\n GC.disable\n\n fibers = []\n num_fibers.times do\n fibers << Fiber.new { loop { Fiber.yield } }\n end\n\n t0 = Time.now\n\n while count < 1000000\n fibers.each do |f|\n count += 1\n f.resume\n end\n end\n\n elapsed = Time.now - t0\n\n put... | [
"0.6405272",
"0.58965045",
"0.5892419",
"0.5892419",
"0.54413205",
"0.5426673",
"0.53223795",
"0.53223795",
"0.52837616",
"0.5238559",
"0.5175435",
"0.5124036",
"0.5117929",
"0.510243",
"0.50992155",
"0.5077968",
"0.5075734",
"0.5075734",
"0.5065452",
"0.5065452",
"0.5064447"... | 0.4994789 | 31 |
TODO: refactor progress and download code into a mixin? | def update_download_status size, length
@current_byte ||= 0
@previous_print ||= 0
@current_byte += size
if length
pct = @current_byte * 100 / length
pct = (pct / 5) * 5
if pct != @previous_print
@previous_print = pct
status pct.to_s + '% '
end
else
# s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def progress; end",
"def progress; end",
"def progress; end",
"def progress; end",
"def progress; end",
"def progressable; end",
"def get_download\n\tend",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def perform\n ... | [
"0.7128539",
"0.7128539",
"0.7128539",
"0.7128539",
"0.7128539",
"0.7118431",
"0.6752482",
"0.672726",
"0.672726",
"0.672726",
"0.672726",
"0.641593",
"0.63472974",
"0.6312473",
"0.6307695",
"0.6287817",
"0.6233144",
"0.6218807",
"0.6182344",
"0.6151132",
"0.6115558",
"0.61... | 0.0 | -1 |
a bit of debugging code to print all nonmatched country codes. should be deleted one day. The Countries gem doesn't know about these country codes from the csv: CS FX UK YU TP and blank | def check_country_codes(countries, row)
@known_codes ||= countries.reduce(Set.new) { |a,(_,v)| a.merge v; a }
unless @known_codes.include?(row[2])
puts "#{row[2]}: #{row[0]}..#{row[1]}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country_codes\n raise_invalid_data_source('country_codes')\n end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def countries\n document[\"nationality\"].collect {|nation| ... | [
"0.6447641",
"0.6381642",
"0.6381642",
"0.6381642",
"0.6381642",
"0.6381642",
"0.6381642",
"0.6282045",
"0.62212366",
"0.61030734",
"0.60007",
"0.59946966",
"0.5978242",
"0.5931739",
"0.59154356",
"0.59085816",
"0.5908043",
"0.5882103",
"0.58413434",
"0.58318114",
"0.58298695... | 0.72985053 | 0 |
def make_groups(array) groups=Hash.new counter = 1 while array.length > 3 groups[counter] = [] selection = array.sample(4) groups[counter] = selection for x in selection array.delete(x) end counter += 1 end counter = 1 while array.length != 0 groups[counter] << array.pop counter +=1 end puts groups end make_groups(stud... | def make_groups(array)
groups=Hash.new
counter = 1
while array.length > 3
selection = array.sample(4)
groups[counter] = selection
selection.each {|x| array.delete(x)}
counter += 1
end
while array.length != 0
counter -= 1
groups[counter] << array.pop
end
groups
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accountability_groups(students)\n\nthrowaway = []\nunit = []\ngroups = []\n\n3.times do\n\tthrowaway = students.dup\n\ti = 0\n\n\twhile(throwaway.size > 0) do\n\n\t\tunit << throwaway.sample(4) if throwaway.size % 4 == 0 \n\t\tunit << throwaway.sample(5) if throwaway.size % 4 != 0\n\t\tunit[i].each { |student|... | [
"0.8072771",
"0.79583836",
"0.77233255",
"0.7627183",
"0.76248544",
"0.7517036",
"0.7516172",
"0.74800867",
"0.7453781",
"0.74338406",
"0.7397667",
"0.73343194",
"0.73324525",
"0.7226208",
"0.71791244",
"0.7141806",
"0.7137442",
"0.71175164",
"0.709859",
"0.70919526",
"0.7049... | 0.8230317 | 0 |
Query Functions Returns whether or not a TA is assigned to mark this Grouping | def has_ta_for_marking?
ta_memberships.count > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stacked_grouping_query?\n @summary.query_group.group_count == 2\n end",
"def marking_started?\n Result.joins(:marks, submission: :grouping)\n .where(groupings: { assessment_id: id },\n submissions: { submission_version_used: true })\n .where.not(marks: { mark: nil... | [
"0.61851007",
"0.60822237",
"0.5995543",
"0.58179605",
"0.5622311",
"0.55684066",
"0.54995966",
"0.5498941",
"0.5453928",
"0.5431333",
"0.54084533",
"0.53748363",
"0.53705883",
"0.53534704",
"0.53534704",
"0.5333985",
"0.5325557",
"0.5322326",
"0.5286617",
"0.52817607",
"0.52... | 0.6576205 | 0 |
Returns true if this user has a pending status for this group; false otherwise, or if user is not in this group. | def pending?(user)
membership_status(user) == StudentMembership::STATUSES[:pending]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pending?\n (status == ConfigCenter::User::PENDING)\n end",
"def pending?\n return true if self.status == 'Pending'\n return false\n end",
"def pending?\n return true if self.status == 'Pending'\n return false\n end",
"def pending?\n status == PENDING_STATE\n... | [
"0.7839128",
"0.7439822",
"0.7439822",
"0.7377409",
"0.7353522",
"0.7353522",
"0.7353522",
"0.73035944",
"0.7219306",
"0.72020346",
"0.71682155",
"0.7119906",
"0.70583606",
"0.7057556",
"0.6997404",
"0.69824755",
"0.6934822",
"0.6880668",
"0.6871664",
"0.6861234",
"0.6856054"... | 0.80595773 | 0 |
returns whether the user is the inviter of this group or not. | def is_inviter?(user)
membership_status(user) == StudentMembership::STATUSES[:inviter]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inviter?(user)\n return user.id == inviter_user_id\n end",
"def invited? user\n users.include?(user)\n end",
"def invited?(user)\n self.friend_ids.include?(user.id) or self.pending_friend_ids.include?(user.id)\n end",
"def invited_by?(user)\n user.friend_ids.include?(self.id) or user... | [
"0.8549959",
"0.79400146",
"0.7870661",
"0.78474134",
"0.7759169",
"0.7693591",
"0.76674545",
"0.76647097",
"0.7586416",
"0.7479197",
"0.7374877",
"0.73261267",
"0.7193553",
"0.7111457",
"0.7105341",
"0.7091612",
"0.70786524",
"0.7075021",
"0.7027676",
"0.7002717",
"0.6934250... | 0.8401602 | 1 |
invites each user in 'members' by its user name, to this group If the method is invoked by an instructor, checks on whether the students can be part of the group are skipped. | def invite(members,
set_membership_status = StudentMembership::STATUSES[:pending],
invoked_by_instructor: false)
# overloading invite() to accept members arg as both a string and a array
members = [members] unless members.instance_of?(Array) # put a string in an array
all_errors = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invitable_users\n @title = \"Invitar usuario\"\n @invitable_users = GetInvitableUsers.call(@previa_group)\n end",
"def set_members\n members_ids = params[:contest][:members].reject(&:empty?)\n @contest.members.destroy_all if params[:action] == \"update\"\n members_ids.each do |members_i... | [
"0.6532887",
"0.630558",
"0.63031226",
"0.6026474",
"0.60221744",
"0.5975585",
"0.59645295",
"0.5904586",
"0.58867246",
"0.58862656",
"0.5873108",
"0.5835226",
"0.5799368",
"0.5763724",
"0.57535267",
"0.5744515",
"0.5742229",
"0.5692222",
"0.56781065",
"0.5677965",
"0.5658908... | 0.7635289 | 0 |
Add a new member to base | def add_member(role, set_membership_status = StudentMembership::STATUSES[:accepted])
if role.has_accepted_grouping_for?(self.assessment_id) || role.hidden
nil
else
member = StudentMembership.new(role: role, membership_status:
set_membership_status, grouping: self)
member.save
# re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_member(opts)\n opts = check_params(opts,[:members])\n super(opts)\n end",
"def add_member( member )\n @members[member] = Person.new ( member )\n @members\n end",
"def add_member(member_name, klass, options = T.unsafe(nil)); end",
"def add_member path\n rewrite_members membe... | [
"0.7543399",
"0.7278957",
"0.7231127",
"0.7183323",
"0.7052021",
"0.7010978",
"0.68084556",
"0.6807409",
"0.67276573",
"0.66816294",
"0.66760147",
"0.663691",
"0.663691",
"0.6607687",
"0.6583554",
"0.65331566",
"0.6512895",
"0.6509228",
"0.65009177",
"0.6485375",
"0.6465768",... | 0.0 | -1 |
define whether user can be invited in this grouping | def can_invite?(role)
if self.inviter == role
raise I18n.t('groups.invite_member.errors.inviting_self')
elsif !extension.nil?
raise I18n.t('groups.invite_member.errors.extension_exists')
elsif self.student_membership_number >= self.assignment.group_max
raise I18n.t('groups.invite_member.er... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invited?\r\n key.guest && user.id == key.created_by\r\n end",
"def invite?\r\n admin? or (user.id != user_record.id and streamer?)\r\n end",
"def is_inviter?(user)\n membership_status(user) == StudentMembership::STATUSES[:inviter]\n end",
"def is_require_accepting_user_to_match_invited_us... | [
"0.7305575",
"0.72549146",
"0.7122871",
"0.7099155",
"0.70764613",
"0.70429254",
"0.70266134",
"0.6982089",
"0.6863986",
"0.6853284",
"0.6842251",
"0.6786957",
"0.673597",
"0.6717261",
"0.6669731",
"0.66516125",
"0.6627246",
"0.66229635",
"0.66223",
"0.6575841",
"0.6562118",
... | 0.6772749 | 12 |
Returns the status of this user, or nil if user is not a member | def membership_status(role)
member = student_memberships.where(role_id: role.id).first
member&.membership_status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_status(user_id)\n\t\treturn nil if not party_list[user_id]\n\t\treturn party_list[user_id][:status]\n\tend",
"def status_getuser!()\n @status = TAC_PLUS_AUTHEN_STATUS_GETUSER\n end",
"def user_status(user)\n return \"Admin\" if user.admin?\n return \"Exception\" if user.override_ac... | [
"0.71984524",
"0.65857005",
"0.6495159",
"0.64794654",
"0.6310134",
"0.6294212",
"0.62802345",
"0.62775064",
"0.62193656",
"0.6146619",
"0.6142882",
"0.60987276",
"0.605893",
"0.60255533",
"0.59891",
"0.59769475",
"0.59769124",
"0.59769124",
"0.59769124",
"0.59769124",
"0.597... | 0.6204021 | 9 |
returns the numbers of memberships, all includ (inviter, pending, accepted | def student_membership_number
accepted_students.size + pending_students.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unseen_memberships_count\n messages.watchable.unseen.group_by(&:membership_id).length\n end",
"def total_friends\n self.invited(false).count + self.invited_by(false).count\n end",
"def pending_acceptance\n inverse_friendships.map(&:user_id) - friendships.map(&:friend_id)\n end",
"def coun... | [
"0.70393705",
"0.6763444",
"0.65955",
"0.65282315",
"0.6437775",
"0.6433798",
"0.6296839",
"0.6293516",
"0.62865824",
"0.62762785",
"0.6178965",
"0.61291885",
"0.61012566",
"0.6050574",
"0.6033931",
"0.6021625",
"0.59988165",
"0.5973278",
"0.59601396",
"0.59440607",
"0.594035... | 0.7354792 | 0 |
Returns true if either this Grouping has met the assignment group size minimum, OR has been approved by an instructor | def is_valid?
instructor_approved || (non_rejected_student_memberships.size >= assignment.group_min)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_assignment?\n invalid_override || group_max > 1\n end",
"def full?\n return false if self.parent_id.nil? # course team, does not max_team_size\n max_team_members = Assignment.find(self.parent_id).max_team_size\n curr_team_size = Team.size(self.id)\n (curr_team_size >= max_team_members)\... | [
"0.6431266",
"0.61577666",
"0.60477805",
"0.59198064",
"0.59074086",
"0.58775485",
"0.5861151",
"0.5835962",
"0.5767066",
"0.5754761",
"0.56135523",
"0.5611492",
"0.5579978",
"0.5561939",
"0.55389035",
"0.5527153",
"0.5484808",
"0.54802674",
"0.5475728",
"0.54339015",
"0.5412... | 0.7756259 | 0 |
The grace credits deducted (of one student) for this specific submission in the grouping | def grace_period_deduction_single
single = 0
# Since for an instance of a grouping all members of the group will get
# deducted the same amount (for a specific assignment), it is safe to pick
# any deduction
if !grace_period_deductions.nil? && !grace_period_deductions.first.nil?
single = grace... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpaid_grace_period_amount\n total_grace_period_amount - paid_grace_period_amount\n end",
"def calculate_liability\n calculate_gross\n end",
"def prepaid_liabilities_total\n voucher_groups.inject(Money.new(0)) { |sum, vg| sum + ( vg.cogs * vg.quantity ) }\n end",
"def depreciation_costs_ccs\n... | [
"0.6084208",
"0.5903739",
"0.58836967",
"0.5863407",
"0.58421296",
"0.5783",
"0.5778953",
"0.57777286",
"0.57620984",
"0.57337224",
"0.5729332",
"0.57272416",
"0.5687587",
"0.568175",
"0.56788445",
"0.5648741",
"0.56307805",
"0.5625523",
"0.56171566",
"0.56128836",
"0.5595662... | 0.601737 | 1 |
remove all deductions for this assignment for a particular member | def remove_grace_period_deduction(membership)
deductions = membership.role.grace_period_deductions
deductions.each do |deduction|
if deduction.membership.grouping.assignment.id == assignment.id
membership.grace_period_deductions.delete(deduction)
deduction.destroy
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove\n instance_variables.map{|v| instance_variable_get(v) }\n .keep_if{|v| v.respond_to? :remove }\n .each(&:remove)\n end",
"def remove_all_members\n super\n end",
"def remove_all_members\n super\n end",
"def remove_member(... | [
"0.5732221",
"0.5705839",
"0.5705839",
"0.56870145",
"0.56541675",
"0.55794317",
"0.55770004",
"0.55371624",
"0.54460526",
"0.54159874",
"0.54052955",
"0.5394883",
"0.5391206",
"0.5358602",
"0.5341169",
"0.53353214",
"0.53336364",
"0.5319029",
"0.5301187",
"0.52753204",
"0.52... | 0.5863881 | 0 |
EDIT METHODS Removes the member by its membership id | def remove_member(mbr_id)
member = student_memberships.find(mbr_id)
if member
# Remove repository permissions first
member.destroy
if member.membership_status == StudentMembership::STATUSES[:inviter] &&
(member.grouping.accepted_student_memberships.length > 0)
membership = me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_member(id)\n @m = Member.find_by_society_id_and_user_id(self.id, id) #not using .where method as just 1 record is expected to be found\n if @m != nil and !@m.admin\n @m.destroy\n\t\t\tadd_post(id, \"Left the society\")\n end\n end",
"def del_member(_user_id)\n update!(del_members: [_... | [
"0.72532004",
"0.7070319",
"0.6960676",
"0.69517094",
"0.6852457",
"0.673755",
"0.66918325",
"0.6673812",
"0.6662625",
"0.6628942",
"0.6577729",
"0.65659523",
"0.65475506",
"0.6533471",
"0.65318227",
"0.6489439",
"0.64872617",
"0.64594305",
"0.6449679",
"0.64208317",
"0.64044... | 0.7562015 | 0 |
Removes the member rejected by its membership id Used as safeguard when student deletes the record | def remove_rejected(mbr_id)
member = memberships.find(mbr_id)
member.destroy if member && member.membership_status == StudentMembership::STATUSES[:rejected]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_rejected\n @assignment = Assignment.find(params[:id])\n membership = StudentMembership.find(params[:membership])\n grouping = membership.grouping\n if current_user != grouping.inviter\n raise I18n.t('invite_student.fail.only_inviter')\n end\n membership.delete\n membership.save... | [
"0.7969604",
"0.75976384",
"0.74604785",
"0.7243283",
"0.7178924",
"0.674936",
"0.65934503",
"0.6551604",
"0.6522543",
"0.6461488",
"0.6387938",
"0.6376657",
"0.6372149",
"0.634705",
"0.630121",
"0.62143266",
"0.6202082",
"0.61769843",
"0.6173324",
"0.6165349",
"0.61486715",
... | 0.8268125 | 0 |
If a group is invalid OR valid and the user is the inviter of the group and she is the _only_ member of this grouping it should be deletable by this user. Additionally, the grace period for the assignment should not have passed. | def deletable_by?(user)
return false unless self.inviter == user
!self.is_valid? || (self.is_valid? &&
accepted_students.size == 1 &&
self.assignment.group_assignment? &&
!assignment.past_collection_date?(self.section))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def may_destroy_group?(group)\n\t\t\tmay_administrate?\n\t\tend",
"def deny(reason)\n user = self.adult_sponsor\n if self.destroy && reason.is_a?(Hash)\n user.group = nil\n user.save\n GroupMailer.send_denied_notice(user, self, reason['email_text']).deliver\n true\n else\n false... | [
"0.69666994",
"0.67882526",
"0.6688189",
"0.66153115",
"0.65909183",
"0.6565198",
"0.63655555",
"0.635583",
"0.6342133",
"0.63208073",
"0.6314281",
"0.62874347",
"0.62821424",
"0.6279597",
"0.6270633",
"0.6240027",
"0.6238591",
"0.6228476",
"0.61985433",
"0.61893266",
"0.6185... | 0.70594615 | 0 |
Returns a list of missing assignment (required) files. A repo revision can be passed directly if the caller already opened the repo. | def missing_assignment_files(revision = nil)
get_missing_assignment_files = ->(open_revision) do
assignment.assignment_files.reject do |assignment_file|
open_revision.path_exists?(File.join(assignment.repository_folder, assignment_file.filename))
end
end
if revision.nil?
access_rep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uncommitted_files\n files = nil\n p4 (['change','-o']).each do |line|\n files << line.strip if files\n files = [] if line.start_with?('Files:')\n end\n files ||= []\n end",
"def uncommitted_files\n `hg status`.scan(/^(A|M|R|!|\\?) (\\S.*)$/).map{ |match| match.last.s... | [
"0.6141438",
"0.6077705",
"0.60733694",
"0.5986417",
"0.5986417",
"0.5975338",
"0.5940491",
"0.585904",
"0.5732854",
"0.5730738",
"0.5728041",
"0.556634",
"0.548268",
"0.54320306",
"0.54187137",
"0.54157853",
"0.54036146",
"0.5396999",
"0.53140825",
"0.5305012",
"0.5292388",
... | 0.822858 | 0 |
Return the due date for this grouping. If this grouping has an extension, the time_delta of the extension is added to the due date. If the assignment is a timed assignment and the student has started working, the due date is this grouping's start time plus the duration plus any extension. | def due_date
if assignment.section_due_dates_type
a_due_date = assignment.assessment_section_properties
.find_by(section_id: inviter&.section)&.due_date || assignment.due_date
else
a_due_date = assignment.due_date
end
extension_time = (extension&.time_delta || 0)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def due_at\n apply_extension(assessment.due_at, extension)\n end",
"def duration_with_work_days\n if self.start_date && self.due_date\n RedmineBetterGanttChart::Calendar.workdays_between(self.start_date, self.due_date)\n else\n 0\n end\n end",
"def calculate_grou... | [
"0.6472416",
"0.64272285",
"0.63417673",
"0.6247419",
"0.6168179",
"0.6168179",
"0.6142111",
"0.60969096",
"0.60724235",
"0.59797204",
"0.59715104",
"0.58250123",
"0.57629454",
"0.5730169",
"0.5711361",
"0.56925786",
"0.5685943",
"0.5674863",
"0.56650746",
"0.5658413",
"0.562... | 0.8234549 | 0 |
Returns whether the last submission for this grouping is after the grouping's collection date. Takes into account assignment late penalties, sections, and extensions. | def submitted_after_collection_date?
grouping_due_date = collection_date
revision = nil
access_repo do |repo|
# get the last revision that changed the assignment repo folder after the due date; some repos may not be able to
# optimize by due_date (returning nil), so a check with revision.server_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def past_collection_date?(section = nil)\n Time.current > submission_rule.calculate_collection_time(section)\n end",
"def only_last_submission?\n @options[:only_last_submission].present?\n end",
"def grouping_past_due_date?(grouping)\n return past_all_due_dates? if grouping.nil?\n\n date = gr... | [
"0.7383258",
"0.64656544",
"0.6214193",
"0.6037694",
"0.60258657",
"0.59449655",
"0.59449655",
"0.5939173",
"0.58341557",
"0.58139634",
"0.58056605",
"0.5792364",
"0.5707514",
"0.5618509",
"0.55923104",
"0.55899316",
"0.5570869",
"0.55649674",
"0.55467206",
"0.5546554",
"0.55... | 0.7644536 | 0 |
Return the duration of this grouping's assignment plus any extensions | def duration
assignment.duration + (extension&.time_delta || 0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjusted_duration\n duration + assignment.submission_rule.periods.pluck(:hours).sum.hours\n end",
"def duration\n @duration\n end",
"def duration\n return @duration\n end",
"def duration\n return @duration\n end",
"def duration; end",
"d... | [
"0.6914697",
"0.69044805",
"0.68419826",
"0.68419826",
"0.6813704",
"0.6813704",
"0.6813704",
"0.6813704",
"0.6813704",
"0.6797678",
"0.670733",
"0.6691812",
"0.6673626",
"0.6615428",
"0.65671456",
"0.65671456",
"0.65671456",
"0.6550629",
"0.6439138",
"0.6417837",
"0.64102757... | 0.8462653 | 0 |
Checks whether a student test using tokens is currently being enqueued for execution (with buffer time in case of unhandled errors that prevented test results to be stored) | def student_test_run_in_progress?
buffer_time = Settings.autotest.student_test_buffer_minutes.minutes
last_student_run = test_runs.where(role: self.accepted_students).first
if last_student_run.nil? || # first test
(last_student_run.created_at + buffer_time) < Time.current || # buffer time expired (for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cpu_attempt\n (0..6).each do |c|\n token_placed = board_place_token(c)\n if game_result != NO_RESULT_YET # full send\n @state[:result] = game_result\n update_game_phase(GAME_OVER)\n return true\n elsif token_placed # make sure token was placed before force delete\n ... | [
"0.59550047",
"0.5770089",
"0.57021135",
"0.56436455",
"0.55864555",
"0.5499806",
"0.5480577",
"0.5473013",
"0.54670525",
"0.54421765",
"0.5434861",
"0.5431516",
"0.54282546",
"0.5384804",
"0.5360037",
"0.53492326",
"0.53284097",
"0.53157395",
"0.5305775",
"0.52994686",
"0.52... | 0.75347704 | 0 |
Takes in a collection of results specified by +results+, and filters them using +filter_data+. Assumes +filter_data+ is not nil. +filter_data['annotationText']+ is a string specifying some annotation text to filter by. +filter_data['section']+ is a string specifying the name of the section to filter by. +filter_data['m... | def filter_results(current_role, results, filter_data)
if filter_data['annotationText'].present?
results = results.joins(annotations: :annotation_text)
.where('lower(annotation_texts.content) LIKE ?',
"%#{AnnotationText.sanitize_sql_like(filter_data['annota... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_filters(results:)\n return results unless filter_params.present?\n\n if filter_params[:organization_id].present? && !filter_params[:funder_id].present?\n return DataManagementPlan.find_by_organization(\n organization_id: filter_params[:organization_id]\n )\n end\n\n if filter... | [
"0.6530831",
"0.5727766",
"0.568565",
"0.5635043",
"0.5580024",
"0.5472577",
"0.5431211",
"0.5426375",
"0.53954303",
"0.53350157",
"0.5216785",
"0.5159506",
"0.51481503",
"0.5088385",
"0.50835925",
"0.5033315",
"0.5009398",
"0.49669984",
"0.49669376",
"0.49659142",
"0.4955628... | 0.719734 | 0 |
Orders the results, specified as +results+ by using +filter_data+ and returns the next grouping using +reversed+. +reversed+ is a boolean value, true to return the next grouping and false to return the previous one. +filter_data['orderBy']+ specifies how the results should be ordered, with valid values being "group_nam... | def order_and_get_next_grouping(results, filter_data, reversed)
asc_temp = filter_data['ascending'].nil? || filter_data['ascending'] == 'true' ? 'ASC' : 'DESC'
ascending = (asc_temp == 'ASC' && !reversed) || (asc_temp == 'DESC' && reversed) ? true : false
case filter_data['orderBy']
when 'submission_dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results\n @results ||= begin\n _dataset = filtered_dataset.limit(per_page).offset(start)\n\n if sort_by\n options = self.class.sortable_attribute_options(sort_by.to_s)\n order =\n if sort_order == \"DESC\"\n Sequel.desc(sort_by.to_sym, ... | [
"0.5482281",
"0.5391764",
"0.53644156",
"0.5037515",
"0.4988881",
"0.49387723",
"0.48920935",
"0.48838472",
"0.4856285",
"0.47981262",
"0.47870076",
"0.47591543",
"0.4703807",
"0.46615225",
"0.46598408",
"0.461621",
"0.46073496",
"0.45814428",
"0.45787856",
"0.4569988",
"0.45... | 0.7089478 | 0 |
Gets the next grouping by first ordering +results+ by group name in either ascending (+ascending+ = true) or descending (+ascending+ = false) order and then extracting the next grouping. If there is no next grouping, nil is returned. | def next_grouping_ordered_group_name(results, ascending)
results = results.group([:id, 'groups.group_name']).order('groups.group_name ASC')
if ascending
next_result = results.where('groups.group_name > ?', self.group.group_name).first
else
next_result = results.where('groups.group_name < ?', sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_and_get_next_grouping(results, filter_data, reversed)\n asc_temp = filter_data['ascending'].nil? || filter_data['ascending'] == 'true' ? 'ASC' : 'DESC'\n ascending = (asc_temp == 'ASC' && !reversed) || (asc_temp == 'DESC' && reversed) ? true : false\n case filter_data['orderBy']\n when 'submi... | [
"0.8173804",
"0.76222044",
"0.7115338",
"0.61269516",
"0.55499506",
"0.5337158",
"0.52929807",
"0.5224838",
"0.51791936",
"0.49568492",
"0.48856807",
"0.48761573",
"0.48757404",
"0.4871035",
"0.48680076",
"0.48576608",
"0.48346063",
"0.4812141",
"0.4805603",
"0.47821152",
"0.... | 0.8191095 | 0 |
Gets the next grouping by first ordering +results+ by submission date and then by group name in either ascending (+ascending+ = true) or descending (+ascending+ = false) order and then extracting the next grouping. If there is no next grouping, nil is returned. | def next_grouping_ordered_submission_date(results, ascending)
results = results.joins(:submission).group([:id, 'groups.group_name', 'submissions.revision_timestamp'])
.order('submissions.revision_timestamp ASC',
'groups.group_name ASC')
if ascending
next_re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_and_get_next_grouping(results, filter_data, reversed)\n asc_temp = filter_data['ascending'].nil? || filter_data['ascending'] == 'true' ? 'ASC' : 'DESC'\n ascending = (asc_temp == 'ASC' && !reversed) || (asc_temp == 'DESC' && reversed) ? true : false\n case filter_data['orderBy']\n when 'submi... | [
"0.83154196",
"0.77171713",
"0.6752178",
"0.56151885",
"0.5464826",
"0.5157542",
"0.51078063",
"0.49746108",
"0.4956601",
"0.49524838",
"0.48803657",
"0.48517925",
"0.4849098",
"0.48081347",
"0.48046133",
"0.47259864",
"0.4725944",
"0.4716159",
"0.47156116",
"0.4684492",
"0.4... | 0.84136486 | 0 |
Gets the next grouping by first ordering +results+ by total mark in either ascending (+ascending+ = true) or descending (+ascending+ = false) order and then extracting the next grouping. If there is no next grouping, nil is returned. | def next_grouping_ordered_total_mark(results, ascending)
# if the current result isn't present in results, add it for future processing
results = results.or(Result.where('results.id': self.current_result.id))
result_data = results.pluck('results.id', 'groups.group_name').uniq { |id, _| id }
total_marks ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_and_get_next_grouping(results, filter_data, reversed)\n asc_temp = filter_data['ascending'].nil? || filter_data['ascending'] == 'true' ? 'ASC' : 'DESC'\n ascending = (asc_temp == 'ASC' && !reversed) || (asc_temp == 'DESC' && reversed) ? true : false\n case filter_data['orderBy']\n when 'submi... | [
"0.79528385",
"0.73401713",
"0.73115253",
"0.55426437",
"0.5313785",
"0.527532",
"0.52234614",
"0.5193274",
"0.5178762",
"0.4890716",
"0.4855586",
"0.4852827",
"0.48238024",
"0.4799576",
"0.4785387",
"0.4785317",
"0.477673",
"0.47644687",
"0.47633007",
"0.4761827",
"0.4733249... | 0.78932875 | 1 |
GET /organization_profiles GET /organization_profiles.json | def index
@organization_profiles = policy_scope(OrganizationProfile).all
authorize User
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization_profile }\n end\n end",
"def index\n authorize Profile\n @profiles = ProfilePolicy::Scope.new(current_user, @user.... | [
"0.73042595",
"0.68673337",
"0.68144375",
"0.66857034",
"0.66797835",
"0.6649772",
"0.66434497",
"0.6572073",
"0.65656084",
"0.6546947",
"0.652167",
"0.652167",
"0.6507024",
"0.6473759",
"0.64170706",
"0.63670874",
"0.63658017",
"0.6344504",
"0.63387233",
"0.63140047",
"0.629... | 0.64682907 | 14 |
GET /organization_profiles/1 GET /organization_profiles/1.json | def show
authorize @organization_profile
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization_profile }\n end\n end",
"def set_organization_profile\n @organization_profile = OrganizationProfile.find(params[:id... | [
"0.746774",
"0.68327224",
"0.68099236",
"0.68066764",
"0.6784098",
"0.677852",
"0.6699004",
"0.6654429",
"0.6628842",
"0.6619762",
"0.65803087",
"0.6569723",
"0.656938",
"0.6554343",
"0.6554343",
"0.65542203",
"0.6549385",
"0.6506501",
"0.6471858",
"0.6465465",
"0.6429571",
... | 0.6056036 | 60 |
POST /organization_profiles POST /organization_profiles.json | def create
@organization_profile = OrganizationProfile.new(organization_profile_params)
current_user.organization_account.organization_profiles << @organization_profile
authorize @organization_profile
respond_to do |format|
if @organization_profile.save
format.html { redirect_to @organiza... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @organization_profile = OrganizationProfile.new(params[:organization_profile])\n\n respond_to do |format|\n if @organization_profile.save\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully created.' }\n format.json { render json: ... | [
"0.7465807",
"0.6789013",
"0.66489124",
"0.65621537",
"0.6526766",
"0.65158916",
"0.64273405",
"0.64054155",
"0.63321465",
"0.6290832",
"0.6242187",
"0.62083226",
"0.6202682",
"0.61964494",
"0.6173854",
"0.61607957",
"0.6156357",
"0.6152742",
"0.61472946",
"0.6136739",
"0.613... | 0.75832933 | 0 |
PATCH/PUT /organization_profiles/1 PATCH/PUT /organization_profiles/1.json | def update
respond_to do |format|
if @organization_profile.update(organization_profile_params)
authorize @organization_profile
format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully updated.' }
format.json { render :show, status: :ok, location: ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n if @organization_profile.update_attributes(params[:organization_profile])\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully updated.' }\n ... | [
"0.7551324",
"0.6867223",
"0.6783453",
"0.6763656",
"0.6709473",
"0.6634286",
"0.66146153",
"0.6613889",
"0.6583962",
"0.6562653",
"0.6556013",
"0.65405184",
"0.65216017",
"0.6510843",
"0.64875984",
"0.6477153",
"0.64752334",
"0.6469373",
"0.6429841",
"0.63984483",
"0.6388868... | 0.72032195 | 1 |
DELETE /organization_profiles/1 DELETE /organization_profiles/1.json | def destroy
authorize @organization_profile
@organization_profile.destroy
respond_to do |format|
format.html { redirect_to organization_profiles_url, notice: 'Organization profile was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @organization_profile = OrganizationProfile.find(params[:id])\n @organization_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to organization_profiles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @profile.destroy\n\n respond_... | [
"0.79218733",
"0.7186178",
"0.7168767",
"0.7168156",
"0.7168156",
"0.7158815",
"0.71166736",
"0.71148187",
"0.7112062",
"0.7103416",
"0.7097558",
"0.7097558",
"0.7097558",
"0.70733017",
"0.70733017",
"0.70733017",
"0.70733017",
"0.70733017",
"0.70733017",
"0.70733017",
"0.707... | 0.7497917 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_organization_profile
@organization_profile = OrganizationProfile.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def organization_profile_params
params.require(:organization_profile).permit(:inn,
:address_value,
:kpp,
:management_name,
:management_post,
:name_full_with_opf, #Полное наименование с ОПФ
:name_short_with_opf, #Краткое наименование с ОПФ
:name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Create POST /orders Request body contains JSON data with the itemId and email of customer | def create
# Create the order
@order = Order.new
@email = params[:email]
# Invoke the customer service to retrieve the customer id using the customers
customerCode, customer = Customer_Service.getCustomerByEmail(@email)
# Check to make sure the customer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n\t @order = Order.new\n\t code, customer = Customer.getCustomer(params[:email])\n\t \n\t if code != 200\n\t\t render json: { error: \"Customer email not found. #{params[:email]}\" }, status: 400\n\t\t return\n\t end\n\t \n\t code, item = Item.getItemById(params[:itemId])\n\t ... | [
"0.75999653",
"0.6919009",
"0.69098324",
"0.68824756",
"0.6873122",
"0.68068737",
"0.6725688",
"0.6672093",
"0.6658413",
"0.66366744",
"0.6627184",
"0.66141206",
"0.6605766",
"0.6603643",
"0.65432465",
"0.6541778",
"0.65358365",
"0.65265954",
"0.6511814",
"0.6506228",
"0.6492... | 0.7715528 | 0 |
Sets $VERBOSE to +true+ for the duration of the block and back to its original value afterwards. | def enable_warnings
with_warnings(true) { yield }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verbose(&block)\n with_verbose(true, &block)\n end",
"def verbose(&block)\n with_verbose(true, &block)\n end",
"def silently\n old_verbose, $VERBOSE = $VERBOSE, nil\n yield\n ensure\n $VERBOSE = old_verbose\n end",
"def verbose!\n @actor << 'VERBOSE'\n @actor.wait\n end",
... | [
"0.778494",
"0.778494",
"0.72003216",
"0.6943882",
"0.6921402",
"0.6824021",
"0.6657295",
"0.65264255",
"0.64645505",
"0.6439015",
"0.6432575",
"0.6428592",
"0.6427624",
"0.63904184",
"0.63842535",
"0.63787675",
"0.63787675",
"0.63168037",
"0.6303824",
"0.6303824",
"0.6279195... | 0.0 | -1 |
Sets $VERBOSE for the duration of the block and back to its original value afterwards. | def with_warnings(flag)
old_verbose, $VERBOSE = $VERBOSE, flag
yield
ensure
$VERBOSE = old_verbose
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verbose(&block)\n with_verbose(true, &block)\n end",
"def verbose(&block)\n with_verbose(true, &block)\n end",
"def silently\n old_verbose, $VERBOSE = $VERBOSE, nil\n yield\n ensure\n $VERBOSE = old_verbose\n end",
"def verbose!\n @actor << 'VERBOSE'\n @actor.wait\n end",
... | [
"0.74914247",
"0.74914247",
"0.69491214",
"0.6762342",
"0.67534006",
"0.6695884",
"0.64858663",
"0.64719605",
"0.6454302",
"0.62981147",
"0.62950945",
"0.62600404",
"0.6255863",
"0.62044144",
"0.6198035",
"0.61819035",
"0.61819035",
"0.6181494",
"0.6144884",
"0.6144884",
"0.6... | 0.61119 | 21 |
Deprecated : this method is not thread safe Silences any stream for the duration of the block. silence_stream(STDOUT) do puts 'This will never be seen' end puts 'But this will' This method is not threadsafe. | def silence_stream(stream)
old_stream = stream.dup
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
stream.sync = true
yield
ensure
stream.reopen(old_stream)
old_stream.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def silence_stream(stream)\n old_stream = stream.dup\n begin\n stream.reopen(SILENT_STREAM_NULL_DEVICE, 'a+')\n rescue Exception => e\n stream.puts \"[SilentStream] Unable to silence. #{e.class}: #{e.message}\"\n end\n stream.sync = true\n yield\n ensure\n stream... | [
"0.795731",
"0.79571784",
"0.7936868",
"0.7809484",
"0.77490646",
"0.7718379",
"0.7676741",
"0.75297666",
"0.7525811",
"0.7428885",
"0.73781765",
"0.7294101",
"0.7122831",
"0.7073359",
"0.70195484",
"0.6989758",
"0.6872747",
"0.6843099",
"0.67519885",
"0.67495984",
"0.6702942... | 0.7803864 | 4 |
Ensure valid credentials, either by restoring from the saved credentials files or intitiating an OAuth2 authorization. If authorization is required, the user's default browser will be launched to approve the request. | def authorize
client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)
token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)
authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)
user_id = 'default'
credentials = authorizer.get_credentials(user_id)
if credenti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials use... | [
"0.6930629",
"0.67212385",
"0.6657661",
"0.6650509",
"0.65547365",
"0.6524074",
"0.6497184",
"0.64922947",
"0.64709055",
"0.6462507",
"0.645454",
"0.6453208",
"0.64509076",
"0.6448872",
"0.6447342",
"0.64390767",
"0.64362293",
"0.640714",
"0.63986945",
"0.63936526",
"0.639223... | 0.6296429 | 58 |
CMGTODO: should only return genpop appeals. rubocop:disable Lint/UnusedMethodArgument | def age_of_n_oldest_priority_appeals(num)
[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aliens\n self.populations.map do |pop|\n pop.alien\n end\n end",
"def subgenres; end",
"def genres\n # look for a local variable called songs\n # look for a method on self. called songs => self.songs\n # looks up the parent chain\n self.songs.map do |song|\n song.genre\n end... | [
"0.5965399",
"0.58671534",
"0.5584397",
"0.545068",
"0.5449642",
"0.5317746",
"0.5315453",
"0.5295663",
"0.517311",
"0.5102765",
"0.5086717",
"0.50795496",
"0.50785",
"0.50640315",
"0.50640315",
"0.5063903",
"0.50571924",
"0.50569516",
"0.50514376",
"0.5015602",
"0.50127876",... | 0.0 | -1 |
Called as a before_filter in controllers that have some https:// actions | def ensure_proper_protocol
if !request.ssl? && USE_SSL && ssl_required?
redirect_to :protocol => 'https://', :action => action_name
return false
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_https\n if request.protocol == \"http://\" && request.host == 'HOSTNAME'\n redirect_to('https://' + request.host_with_port + request.fullpath, status: :moved_permanently)\n end\n end",
"def filter_redirect; end",
"def filter_redirect; end",
"def enforce_ssl\n redi... | [
"0.6782942",
"0.6529509",
"0.6529509",
"0.6403016",
"0.6352358",
"0.6306597",
"0.62676346",
"0.6261104",
"0.62462735",
"0.6226467",
"0.61748016",
"0.61740315",
"0.6134633",
"0.6130521",
"0.6122367",
"0.60861415",
"0.6084564",
"0.6017575",
"0.6010411",
"0.59902954",
"0.5971264... | 0.6226337 | 10 |
Called when URLs are generated | def default_url_options(options)
defaults = {}
my_controller = (options[:controller] || controller_name).to_sym
my_action = (options[:action] || action_name).to_sym
secure = ActionController::Base::SECURE
if USE_SSL
options[:override_only_path] ? options[:only_path] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generated_url; end",
"def url_template; end",
"def url_template; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
... | [
"0.7143798",
"0.67319053",
"0.67319053",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",
"0.66461104",... | 0.0 | -1 |
GET /stories GET /stories.json | def index
@stories = Story.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @stories = Story.all\n render json: @stories, root: false\n end",
"def index\n @stories = Story.order(\"created_at DESC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @stories }\n end\n end",
"def get_stories\n api_url ... | [
"0.7912268",
"0.7652356",
"0.7617811",
"0.749546",
"0.7423067",
"0.74189985",
"0.74189985",
"0.73998713",
"0.73920465",
"0.7388038",
"0.7382927",
"0.73384607",
"0.73384607",
"0.73078996",
"0.7301916",
"0.72920823",
"0.7265824",
"0.72652596",
"0.72652596",
"0.7179861",
"0.7174... | 0.74498045 | 9 |
GET /stories/1 GET /stories/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n story = Story.find(params[:id])\n render json: story\n end",
"def index\n @stories = Story.all\n render json: @stories, root: false\n end",
"def show\n @story = Story.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:... | [
"0.77520823",
"0.77079576",
"0.75249684",
"0.7514401",
"0.7487105",
"0.7486681",
"0.7486681",
"0.74650335",
"0.7456779",
"0.7456779",
"0.7367344",
"0.7367344",
"0.7367344",
"0.7367344",
"0.7367344",
"0.7367344",
"0.7366021",
"0.7325977",
"0.7306961",
"0.7269259",
"0.72025424"... | 0.0 | -1 |
POST /stories POST /stories.json | def create
@story = Story.new(story_params)
respond_to do |format|
if @story.save
format.html { redirect_to @story, notice: 'Story was successfully created.' }
format.json { render action: 'show', status: :created, location: @story }
else
format.html { render action: 'new' }... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @story = Story.new(story_params)\n if @story.save\n render json: @story, status: :ok\n else\n render json: @story.errors, status: :unprocessable_entity\n end\n end",
"def create\n @story = Story.new(params[:story])\n\n respond_to do |format|\n if @story.save\n ... | [
"0.772964",
"0.76415455",
"0.7610398",
"0.7505145",
"0.74521095",
"0.7439946",
"0.7439946",
"0.73842067",
"0.73842067",
"0.73842067",
"0.7328209",
"0.7206045",
"0.69638777",
"0.6957411",
"0.692288",
"0.6892234",
"0.68875116",
"0.6872017",
"0.6849194",
"0.6840574",
"0.6811445"... | 0.7292121 | 11 |
PATCH/PUT /stories/1 PATCH/PUT /stories/1.json | def update
respond_to do |format|
if @story.update(story_params)
format.html { redirect_to @story, notice: 'Story was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @story.errors, status: :un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @story.update(story_params)\n format.json { render json: @story, root: false, status: :ok, location: @story }\n else\n format.json { render json: @story.errors, root: false, status: :unprocessable_entity }\n end\n end\n end",
"def upda... | [
"0.7267746",
"0.7099299",
"0.7072093",
"0.7072093",
"0.706577",
"0.70631224",
"0.7057944",
"0.7057944",
"0.69516414",
"0.69078785",
"0.68319225",
"0.68319225",
"0.68319225",
"0.68319225",
"0.68319225",
"0.6823768",
"0.67423356",
"0.6701193",
"0.6686298",
"0.6641912",
"0.66327... | 0.6916157 | 11 |
DELETE /stories/1 DELETE /stories/1.json | def destroy
@story.destroy
respond_to do |format|
format.html { redirect_to stories_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_story(id)\n @client.raw('delete', \"/content/stories/#{id}\")\n end",
"def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @story = S... | [
"0.80220026",
"0.79391855",
"0.79391855",
"0.7931967",
"0.7931967",
"0.7931967",
"0.7931967",
"0.793163",
"0.79274935",
"0.77652484",
"0.7757014",
"0.7712508",
"0.7712508",
"0.7712508",
"0.7620175",
"0.7600035",
"0.7600035",
"0.7600035",
"0.7600035",
"0.75994986",
"0.756033",... | 0.78733784 | 11 |
Use callbacks to share common setup or constraints between actions. | def set_story
@story = Story.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def story_params
params.require(:story).permit(:title, :author)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
n specifies the number of cards to deal | def get_card(deck, n)
new_card = deck.cards.pop(n)
cards << new_card
cards.flatten!
new_card
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal5cards (n)",
"def take(n)\n if n > self.count \n raise 'not enough cards'\n end \n ncards = [] \n n.times do \n ncards << cards.shift\n end \n return ncards\n end",
"def take(n)\n raise Exception.new \"not enough cards\" if n > count\n first_cards = @deck[0...n]\n ... | [
"0.81756145",
"0.7828146",
"0.77284133",
"0.7569974",
"0.7455496",
"0.74463916",
"0.7434375",
"0.7420036",
"0.73145026",
"0.70790225",
"0.70762944",
"0.70429456",
"0.70341134",
"0.70245975",
"0.7000187",
"0.6626207",
"0.6573678",
"0.64870816",
"0.6486214",
"0.6443675",
"0.626... | 0.7107995 | 9 |
returns nil if card total >= 21 else returns a string | def bust_or_win?
if player.total == BLACKJACK
puts "#{player.name} hit backjack!! #{player.name} lost, dealer lost."
play_again?
elsif player.total > BLACKJACK
puts "#{player.name} busted! #{player.name} lost, dealer won."
play_again?
elsif dealer.total == BLACKJACK
puts "Deale... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_card_total(player_hand, dealer_hand, dealer_turn)\n\tplayer_total = get_player_total(player_hand).to_s\n\tdealer_total = get_dealer_total(dealer_hand,dealer_turn).to_s\n\t\n\tputs\n\tputs \"Total\" + (\" \" * (8 - player_total.length)) + player_total + (\" \" * (17 - dealer_total.length)) + dealer_tota... | [
"0.7175592",
"0.68555415",
"0.68480647",
"0.6784457",
"0.67476165",
"0.66354746",
"0.6598533",
"0.65936977",
"0.6589578",
"0.6583236",
"0.65319765",
"0.6516437",
"0.65063906",
"0.6486192",
"0.6476739",
"0.6459776",
"0.6426303",
"0.63778466",
"0.6371237",
"0.6370691",
"0.63187... | 0.0 | -1 |
2 2, nil, "Joe", "four", nil 3 | def multiply(num1, num2)
number_out = num1 * num2
p(number_out)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_count(array)\n counter = 0\n array.each do |elem|\n if elem != nil\n counter += 1\n end\n end\n counter\nend",
"def more_than_one\n\treturn 1, 2, 3\nend",
"def _reduce_444(val, _values, result)\n result = s(:nil) \n result\nend",
"def _reduce_444(val, _values, result)\n result ... | [
"0.55291533",
"0.54888976",
"0.5430695",
"0.5430695",
"0.530061",
"0.52634645",
"0.52634645",
"0.52634645",
"0.52634645",
"0.52634645",
"0.525552",
"0.525552",
"0.525552",
"0.52460843",
"0.5240384",
"0.5232431",
"0.52184933",
"0.5215783",
"0.52006376",
"0.517678",
"0.517678",... | 0.0 | -1 |
4 it wont print anything because 'return' comes before the 'puts' statement. 5 | def scream(words)
words = words + "!!!!"
puts words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cube(num)\n return num * num * num #this is an official return statement\n # after return, it will break and jump out from the method\n # nothing after it wiil be executed\n 8\n puts \"print this line\"\nend",
"def printResult(result)\r\n puts\r\n puts \" Least number of times you can copy... | [
"0.6765758",
"0.67628056",
"0.6695285",
"0.66773295",
"0.6636741",
"0.65623647",
"0.65358603",
"0.64970183",
"0.64807546",
"0.6470832",
"0.64388275",
"0.6413651",
"0.6398892",
"0.6376742",
"0.63471293",
"0.6318155",
"0.63091075",
"0.63091075",
"0.63091075",
"0.63091075",
"0.6... | 0.0 | -1 |
sends message to socket | def send_msg(msg)
s = ''
case msg
when Const::MSG_PAUSE
s = "#{Const::MSG_PAUSE}"
when Const::MSG_GAME_OVER
s = "#{Const::MSG_GAME_OVER}"
when Const::MSG_BOARD
s = "#{Const::MSG_BOARD}:#{@game.get_board_s}"
when Const::MSG_GARBAGE
s = "#{Const::MSG_GAR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(message)\n socket.send(message, 0, address, port)\n end",
"def send_message(message)\n @socket.send(message << \"\\n\", 0, nil, @client)\n end",
"def send(msg)\n @socket.puts msg\n puts '<< ' << msg\n end",
"def send_message(message)\n @socket.write(message)\n @socket.write(... | [
"0.84073883",
"0.82689315",
"0.8053334",
"0.80015033",
"0.8001391",
"0.7893094",
"0.78792435",
"0.78764415",
"0.7711474",
"0.7693879",
"0.76916623",
"0.7583205",
"0.75735825",
"0.7507177",
"0.74803555",
"0.7457349",
"0.7408943",
"0.7362014",
"0.73146755",
"0.7281928",
"0.7280... | 0.0 | -1 |
blocking recv for cnt of bytes | def recv_block(cnt)
block = nil
begin
block = @socket.recv(cnt, Socket::MSG_WAITALL)
rescue
# problem s pripojenim -- game over
@socket.close
@window.state = MenuState.new(@window)
end
block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recvn(num_bytes, timeout: nil)\n @timer.countdown(timeout) do\n fillbuffer while @timer.active? && @buffer.size < num_bytes\n @buffer.size >= num_bytes ? @buffer.get(num_bytes) : ''\n end\n end",
"def recv(n)\n until(buffer.length >= n)\n read_stream\n... | [
"0.7453278",
"0.730119",
"0.71434385",
"0.70666796",
"0.68275005",
"0.6630105",
"0.6630105",
"0.66238046",
"0.6544469",
"0.6479219",
"0.6444829",
"0.6441062",
"0.63032687",
"0.62783575",
"0.62624294",
"0.6226237",
"0.6196298",
"0.61871797",
"0.6150328",
"0.61220306",
"0.61084... | 0.6730483 | 5 |
recieves and manages game updates | def recv_msg(id)
case id
when Const::MSG_PAUSE
@game.pause!
when Const::MSG_GAME_OVER
@winner = Const::GAME_WON
when Const::MSG_BOARD
recv_block(1)
board = recv_block(Const::PNR_HOR * Const::PNR_VER)
@o_board.from_s!(board) unless board.nil?
when Con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_game\n\t\tself.game_is_started = true\n send_update\n end",
"def update\n if @winner == Const::GAME_ON\n until (m = check_msg) == Const::GOT_NO_MESSAGE\n recv_msg(m)\n end\n unless @game.paused\n @game.update\n send_msg(Const::MSG_BOARD)\n ... | [
"0.7384027",
"0.73764116",
"0.7272552",
"0.7260509",
"0.72484213",
"0.71439016",
"0.7062397",
"0.70193595",
"0.7013186",
"0.699641",
"0.6980188",
"0.69362146",
"0.69302684",
"0.6859179",
"0.6847595",
"0.68441457",
"0.67705494",
"0.6757918",
"0.6734739",
"0.6720431",
"0.669344... | 0.0 | -1 |
checks if there is incomming message returns a string with message id, or GOT_NO_MESSAGE | def check_msg
begin
s = @socket.recv_nonblock(1)
return s
rescue Errno::EAGAIN
# zadna zprava, hrajeme dal
rescue
# problem s pripojenim -- game over
@socket.close
@window.state = MenuState.new(@window)
rescue
end
Const::GOT_NO_MESSAGE
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_message_id?\n header.has_message_id?\n end",
"def has_message_id?\n !fields.select { |f| f.responsible_for?('Message-ID') }.empty?\n end",
"def message_id; @message_impl.getMessageId; end",
"def message_id\n\t\tmessage_id = self.headers[\"Message-ID\"]\n\t\tmessage_id.nil? || message_... | [
"0.682204",
"0.6660991",
"0.6469001",
"0.6461851",
"0.636607",
"0.62397766",
"0.61477506",
"0.6115264",
"0.60926217",
"0.6092111",
"0.6016177",
"0.6003347",
"0.59940535",
"0.59740305",
"0.59589154",
"0.5947897",
"0.5943419",
"0.58969647",
"0.5895829",
"0.587609",
"0.5871146",... | 0.6376828 | 4 |
updates net game state | def update
if @winner == Const::GAME_ON
until (m = check_msg) == Const::GOT_NO_MESSAGE
recv_msg(m)
end
unless @game.paused
@game.update
send_msg(Const::MSG_BOARD)
if @game.game_over
send_msg(Const::MSG_GAME_OVER)
@winner = Con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(state_manager, game)\n\n end",
"def update\n if @state == :game\n @player.update\n @level.update\n end\n end",
"def state_on_netgame\n @log.debug(\"Net_state: change to state state_on_netgame\")\n @network_state = :state_on_netgame\n make_state_change_ntfy(:ntfy_state_on... | [
"0.7751142",
"0.7575008",
"0.7553077",
"0.7472529",
"0.71075904",
"0.6969862",
"0.69561297",
"0.68388426",
"0.6706374",
"0.66841227",
"0.6680788",
"0.6659723",
"0.65829194",
"0.6571129",
"0.6550758",
"0.6515195",
"0.6498292",
"0.64717424",
"0.64702517",
"0.64326715",
"0.63955... | 0.6835794 | 8 |
draws net game window (contains normal game + opponents board) | def draw
if @winner == Const::GAME_ON
@game.draw
@o_board.draw
elsif @winner == Const::GAME_LOST
@font.draw(Const::GAME_LOST_CAPTION,
@window.width / 2 - 170, @window.height / 2 - 30, 0)
else
@font.draw(Const::GAME_WON_CAPTION,
@win... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw\n @headers[@game_state_model::players[@game_state_model.player_turn_state]::player_color].draw(@x, @y, 35)\n\n if @game_state_model.player_turn_state == 0\n @ico_one.draw(@x + 143, @y + 20, 35)\n elsif @game_state_model::players[@game_state_model.player_turn_state]::ai == nil\n ... | [
"0.7029272",
"0.70189303",
"0.7007952",
"0.6939513",
"0.691877",
"0.68849766",
"0.68786836",
"0.6825442",
"0.68182707",
"0.6805775",
"0.6798681",
"0.6775754",
"0.6721545",
"0.6678827",
"0.662319",
"0.66192555",
"0.65833265",
"0.6581982",
"0.65556747",
"0.65481335",
"0.6522817... | 0.74432266 | 0 |
hides default system cursor | def needs_cursor?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hide_cursor!\n Vedeu.bind(:_hide_cursor_) do |name|\n Vedeu::Cursors::Cursor.hide_cursor(name)\n end\n\n Vedeu.bind_alias(:_cursor_hide_, :_hide_cursor_)\n end",
"def hide_cursor(&blk)\n out = esc_code(\"?25l\")\n out << (yield + show_cursor) if block_given?\n ... | [
"0.82553726",
"0.79152197",
"0.7499856",
"0.74924767",
"0.73249096",
"0.7045033",
"0.7045033",
"0.70309925",
"0.6932412",
"0.68456775",
"0.67578375",
"0.6727076",
"0.6701484",
"0.66966593",
"0.66183573",
"0.65336466",
"0.65171",
"0.65032864",
"0.6401382",
"0.63242954",
"0.631... | 0.0 | -1 |
Return a specific result sets | def [] name
if index = @searches.names.index(name)
@collection[ index ]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resultset; end",
"def result_set\n klass.requestor.get(nil, { query: to_s })\n end",
"def result_set\n\t @result_set ||= plan.query_result_set(self)\n\tend",
"def resultset\n @resultset ||= parse_resultset(stored_data)\n end",
"def pg_gem_result_sets__from psql_db, db_queries, ba... | [
"0.72817147",
"0.7054087",
"0.6911646",
"0.6771356",
"0.65673417",
"0.6555196",
"0.6517362",
"0.65173566",
"0.6456426",
"0.6330997",
"0.6330997",
"0.62922317",
"0.6268661",
"0.62422574",
"0.62422574",
"0.62415284",
"0.60924923",
"0.60890216",
"0.6084478",
"0.6082882",
"0.6068... | 0.0 | -1 |
Returns the multisearch result sets as a Hash with the search name as key and the results as value. | def to_hash
result = {}
each_pair { |name,results| result[name] = results }
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_result_sets_for(searches)\n new_result_sets = Hash.new\n searches.each do |s|\n new_result_sets[s] = s.new_results if s.new_results.count > 0 \n end\n return new_result_sets\n end",
"def embiggen_grouped_results(values)\n embiggened_results = []\n values.each do |resultset|\... | [
"0.7318454",
"0.6300639",
"0.6269924",
"0.61106336",
"0.6085285",
"0.6082623",
"0.6034518",
"0.59556025",
"0.5930189",
"0.5924156",
"0.5916102",
"0.5908993",
"0.5898146",
"0.58820134",
"0.5864411",
"0.57802194",
"0.5754203",
"0.57223344",
"0.57035094",
"0.56449753",
"0.559776... | 0.60020316 | 7 |
Add a search definition to the multisearch request. The usual search options such as `search_type`, `routing`, etc. can be passed as a Hash, and the search definition itself should be passed as a block using the Tire DSL. | def search(*args, &block)
name_or_options = args.pop
if name_or_options.is_a?(Hash)
options = name_or_options
name = args.pop
else
name = name_or_options
end
name ||= @searches.size
options ||= {}
indice... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_definition(options={})\n options = options.reverse_merge(decay: true).with_indifferent_access\n query = options[:query]\n\n # Prefill and set the filters (top-level `filter` and `facet_filter` elements)\n #\n __set_filters = lambda do |key, f|\n @search_definition[:filter... | [
"0.6453409",
"0.633137",
"0.6173166",
"0.61022526",
"0.5995612",
"0.59920275",
"0.5880821",
"0.5864228",
"0.5853676",
"0.5847173",
"0.57844514",
"0.57625765",
"0.5743545",
"0.5737092",
"0.5732849",
"0.5726073",
"0.5714307",
"0.5702698",
"0.5695394",
"0.5684147",
"0.56604755",... | 0.67317134 | 0 |
Without argument, returns the collection of search definitions. With argument, returns a search definition by name or order. | def searches(name=nil)
name ? @searches[ name ] : @searches
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_definition(options={})\n options = options.reverse_merge(decay: true).with_indifferent_access\n query = options[:query]\n\n # Prefill and set the filters (top-level `filter` and `facet_filter` elements)\n #\n __set_filters = lambda do |key, f|\n @search_definition[:filter... | [
"0.6139591",
"0.5769594",
"0.57628167",
"0.57420284",
"0.5718285",
"0.5697043",
"0.5688811",
"0.5672215",
"0.56430596",
"0.5641426",
"0.56209713",
"0.5548476",
"0.5508076",
"0.54932904",
"0.5483046",
"0.54810685",
"0.54768145",
"0.5469912",
"0.54645425",
"0.5459377",
"0.54582... | 0.6133266 | 1 |
Returns and array of search definition names | def names
@searches.names
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_keys \n return search_field_definitions.keys\n end",
"def semantic_search_keys \n semantic_search_map.keys\n end",
"def search_objects\n @searches.keys.map { |k| @search_objects[k] }\n end",
"def search_field_list(lens = nil)\n blacklight_config(lens)... | [
"0.7569592",
"0.6362151",
"0.62876767",
"0.6242458",
"0.622808",
"0.6184982",
"0.61720884",
"0.6164763",
"0.6158254",
"0.6117472",
"0.6101357",
"0.6076999",
"0.6059627",
"0.6042162",
"0.6011567",
"0.6008246",
"0.59868693",
"0.5979858",
"0.5950001",
"0.5950001",
"0.5935085",
... | 0.74666613 | 1 |
Serializes the search definitions as an array of JSON definitions | def to_array
@searches.map do |search|
header = {}
header.update(:index => search.indices.join(',')) unless search.indices.empty?
header.update(:type => search.types.join(',')) unless search.types.empty?
header.update(:search_type => search.options[:search_ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\n @definitions = Definition.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @definitions.to_xml(:request => request) }\n format.json { render :json => @definitions.to_json(:request => request) }\n end\n end",
"def toJson()\n ... | [
"0.6052187",
"0.5932985",
"0.5916006",
"0.58659005",
"0.5854285",
"0.58165693",
"0.5814075",
"0.5770242",
"0.56583965",
"0.56276",
"0.561198",
"0.55861765",
"0.5571679",
"0.55568737",
"0.5541313",
"0.5512843",
"0.5497145",
"0.54958254",
"0.54844844",
"0.54842484",
"0.54793566... | 0.60618824 | 0 |
Serializes the search definitions as a multiline string payload | def to_payload
to_array.map { |line| MultiJson.encode(line) }.join("\n") + "\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize\n {'Version' => VERSION, 'Statement' => @rules}.to_json\n end",
"def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n writer.write_collection_of_object_values(\"hitsContainers\", @hits_containers)\n writer.wri... | [
"0.5455235",
"0.5432392",
"0.53917205",
"0.5334292",
"0.52633876",
"0.5205878",
"0.51488566",
"0.51316667",
"0.5129686",
"0.5128291",
"0.5125314",
"0.5122754",
"0.5101645",
"0.5088538",
"0.5048235",
"0.50481695",
"0.5039642",
"0.5031364",
"0.50041384",
"0.49763876",
"0.497638... | 0.50399673 | 16 |
Returns the request URL | def url
[ Configuration.url, @path ].join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n @parser.request_url\n end",
"def request_uri\n calculate_uri(@http_request.url)\n end",
"def request_url\n query_builder.request_string\n end",
"def request_uri\n @request.uri\n end",
"def request_url\n @attributes[:request_url]\n end",
"def reque... | [
"0.8529157",
"0.84094834",
"0.8337552",
"0.801917",
"0.79197115",
"0.7823424",
"0.78093505",
"0.77315",
"0.7619093",
"0.76047885",
"0.76038176",
"0.7569995",
"0.7561666",
"0.75440663",
"0.75409776",
"0.7491346",
"0.7450973",
"0.7446123",
"0.7446123",
"0.7446123",
"0.7446123",... | 0.6799046 | 77 |
Serializes the request URL parameters | def params
options = @options.dup
options.empty? ? '' : '?' + options.to_param
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __to_params__\n map { |k,v| \"#{k.to_s}=#{URI.escape(v.to_s)}\" }.join('&')\n end",
"def params() request.params end",
"def query_parameters\n request.GET\n end",
"def request_params; end",
"def query_params\n URI.encode_www_form(\n {\n affiliate:,\n access_k... | [
"0.7104221",
"0.6927097",
"0.67517847",
"0.67192847",
"0.6701796",
"0.669467",
"0.665626",
"0.66488564",
"0.6644294",
"0.661107",
"0.6609199",
"0.6608514",
"0.6596855",
"0.6596855",
"0.6521734",
"0.6519783",
"0.64803797",
"0.64768213",
"0.64663714",
"0.64637244",
"0.6455926",... | 0.63530123 | 26 |
Returns the HTTP response | def response
@response || perform and @response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def http_response\n return @http_response\n end",
"def response\n get_header_and_body\n end",
"def response\n @response ||= Net::HTTP.new(uri.host).request(request)\n end",
"def get\n @response = Net::HTTP.get_response(URI(@url))\n end",
"def response; return @response end",
"def ... | [
"0.8131731",
"0.80026424",
"0.7973088",
"0.7786846",
"0.7733341",
"0.7691123",
"0.74754435",
"0.74334055",
"0.7286256",
"0.72763306",
"0.72763",
"0.72710764",
"0.72383213",
"0.721011",
"0.7196399",
"0.71910566",
"0.71566343",
"0.71532035",
"0.71390355",
"0.71214586",
"0.71207... | 0.0 | -1 |
Returns the raw JSON as a Hash | def json
@json || perform and @json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_for_json(*)\n to_h\n end",
"def for_json\n to_hash\n end",
"def json\n @hash ||= ::JSON.parse(data)\n end",
"def to_h\n JSON.parse(body)\n end",
"def to_hash( json )\n JSON.parse( json )\n end",
"def to_hash\n @to_hash ||= JSON.parse(body)\n ... | [
"0.78176916",
"0.774702",
"0.7681215",
"0.76345295",
"0.76108444",
"0.7580031",
"0.7570658",
"0.7348793",
"0.7316217",
"0.7277015",
"0.7191677",
"0.7168008",
"0.697425",
"0.69666165",
"0.6885832",
"0.679754",
"0.67271423",
"0.6673097",
"0.6634207",
"0.6633834",
"0.6633698",
... | 0.0 | -1 |
GET /certificateinfos GET /certificateinfos.json | def index
@member = Member.find(params[:member_id])
@certificateinfos = @member.certificateinfo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def certificate_details\n data[:certificate_details]\n end",
"def show\n @certificate = Certificate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @certificate }\n end\n end",
"def cert_chain\n service = Service.find(para... | [
"0.6957346",
"0.6275125",
"0.6256646",
"0.6252026",
"0.6245596",
"0.61068153",
"0.60829747",
"0.60829747",
"0.60801727",
"0.6028435",
"0.599934",
"0.5969497",
"0.59564704",
"0.5955245",
"0.5949053",
"0.58803123",
"0.58428305",
"0.58125955",
"0.5805192",
"0.58001935",
"0.57995... | 0.65669733 | 1 |
GET /certificateinfos/1 GET /certificateinfos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def certificate_details\n data[:certificate_details]\n end",
"def index\n @member = Member.find(params[:member_id])\n @certificateinfos = @member.certificateinfo\n end",
"def show\n @certificate = Certificate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n... | [
"0.66430867",
"0.66007954",
"0.65996236",
"0.6504314",
"0.63919544",
"0.63808906",
"0.63143027",
"0.61660653",
"0.6151653",
"0.6151653",
"0.60935163",
"0.6079571",
"0.6029052",
"0.6010991",
"0.5943868",
"0.5911527",
"0.58889866",
"0.58395594",
"0.58165365",
"0.58116376",
"0.5... | 0.0 | -1 |
POST /certificateinfos POST /certificateinfos.json | def create
@member = Member.find(params[:member_id])
@certificateinfo = @member.build_certificateinfo(certificateinfo_params)
respond_to do |format|
if @certificateinfo.save
format.html { redirect_to new_member_serviceinfo_path(@certificateinfo.member.id), notice: 'Certificateinfo was success... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @certificate = Certificate.new(certificate_params)\n respond_to do |format|\n if @certificate.save\n format.html { redirect_to root_path, notice: 'Certificate was successfully created.' }\n format.json { render :show, status: :created, location: @certificate }\n else\n ... | [
"0.6971275",
"0.6705045",
"0.6647485",
"0.65588343",
"0.64638567",
"0.64591056",
"0.6369841",
"0.632964",
"0.6279787",
"0.6277623",
"0.62760496",
"0.6275929",
"0.6266546",
"0.6238117",
"0.62103754",
"0.6150843",
"0.6136386",
"0.6136327",
"0.6122952",
"0.60888016",
"0.6067988"... | 0.698815 | 0 |
PATCH/PUT /certificateinfos/1 PATCH/PUT /certificateinfos/1.json | def update
respond_to do |format|
if @certificateinfo.update(certificateinfo_params)
format.html { redirect_to @certificateinfo, notice: 'Certificateinfo was successfully updated.' }
format.json { render :show, status: :ok, location: @certificateinfo }
else
format.html { render :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @certificate.update(certificate_params)\n format.html { redirect_to root_path, notice: 'Certificate was successfully updated.' }\n format.json { render root_path, status: :ok, location: @certificate }\n else\n format.html { render :edit }\n... | [
"0.7061409",
"0.7027216",
"0.69652826",
"0.6951505",
"0.66454166",
"0.6516593",
"0.65008193",
"0.64837116",
"0.6445084",
"0.64199793",
"0.64199793",
"0.6364885",
"0.6283377",
"0.6184716",
"0.6159774",
"0.61471164",
"0.61245877",
"0.6112727",
"0.6087408",
"0.60605854",
"0.6054... | 0.7238684 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.