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 |
|---|---|---|---|---|---|---|
Called when a message is received, receiving ReceiverHandlercount messages | def on_message(delivery, message)
# Print received message
if @log_msgs == "body"
Formatters::BasicFormatter.new(message).print
elsif @log_msgs == "dict"
Formatters::DictFormatter.new(message).print
end
# If process reply to
if @process_reply_to and !message.reply_to.nil?
self.do_process_reply_to(message)
end
# Increase number of received messages
@received = @received + 1
# If all messages are received
if @received == @count
# Close receiver
delivery.receiver.close
# Close connection
delivery.receiver.connection.close
end # if
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_received(message)\n @message_handlers.each do |block|\n block.call(message)\n end\n end",
"def on_receive(message)\n end",
"def received\n end",
"def receive_msg msg\n # stub, overwrite this in your handler\n end",
"def receives_messages\n Messenger.... | [
"0.6887329",
"0.6765397",
"0.6757999",
"0.6747996",
"0.66874695",
"0.665105",
"0.665105",
"0.65329725",
"0.6487146",
"0.64148605",
"0.6400146",
"0.6390028",
"0.6385803",
"0.63106287",
"0.63036394",
"0.6216118",
"0.6165126",
"0.61249256",
"0.61115146",
"0.60898244",
"0.6086603... | 0.6549731 | 7 |
default value is nil | def value
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default\n nil\n end",
"def default\n nil\n end",
"def set_default\n end",
"def default; end",
"def default; end",
"def default=(_); end",
"def default\n end",
"def default=(value); end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end... | [
"0.80734533",
"0.80734533",
"0.78648186",
"0.78594214",
"0.78594214",
"0.7794627",
"0.7660349",
"0.7625772",
"0.7573737",
"0.7573737",
"0.7573737",
"0.7573737",
"0.7573737",
"0.7573737",
"0.7573737",
"0.7573737",
"0.7573737",
"0.7573737",
"0.7526293",
"0.7526293",
"0.7503683"... | 0.6708905 | 84 |
convenience for collecting lists for example a list of things might be specified by the rule first:thing rest:(delimiter item:thing) this returns a list of those things, provided first, rest, and item are so defined | def items
(rest.elements || []).inject([first]) { |list, el| list << el.item }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_list; end",
"def parse_list; end",
"def saw_begin_list(list); end",
"def parse_lists_from_subject(subject)\n # extract part between '[...]'\n subject.to_s.match(/\\[(.*)\\]/)\n if $1\n # and create array by valid separators: \\s , |\n subject_array = $1.split(/[\\s,|]/)\n else... | [
"0.5873925",
"0.5873925",
"0.567244",
"0.55718756",
"0.5546085",
"0.5470776",
"0.5439933",
"0.5363642",
"0.5322854",
"0.52626806",
"0.5224208",
"0.52098763",
"0.5199561",
"0.5199561",
"0.5199561",
"0.5196001",
"0.51937634",
"0.51921177",
"0.5191041",
"0.5183084",
"0.51798224"... | 0.5606278 | 3 |
returns the ABCNodes that are immediate descendants of this node (immediate descendant meaning there may be intervening SyntaxNodes, but they are not ABCNodes) or select from among these children by passing subclasses of ABCNode | def children(*types)
if types.count > 0
children.select { |el| el.is_one_of? *types }
else
next_descendants(ABCNode)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ascendants(*of_type, &block)\n if root?\n []\n else\n __filter_node_list([parent] + parent.ascendants, *of_type, &block)\n end\n end",
"def descendants(*args, &blk)\n res = []\n each{|c|\n res += c.descendants(*args, &blk) if c.is_a? XML\n }\n ... | [
"0.6157988",
"0.609773",
"0.597885",
"0.5921023",
"0.59028864",
"0.58992827",
"0.5869371",
"0.5858752",
"0.5817827",
"0.5807498",
"0.57820797",
"0.57800174",
"0.5725877",
"0.5652421",
"0.56303775",
"0.56216675",
"0.55670446",
"0.5550273",
"0.5541383",
"0.553973",
"0.55339015"... | 0.7292915 | 0 |
returns the first child (of type, optionally) or nil if no children | def child(type=nil)
c = children(type)[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_child!(children)\n children[1] || children\n end",
"def first\n @children[0]\n end",
"def first_child\n child 0\n end",
"def child\n children[0]\n end",
"def first_child\n children.min_by { |x| x.position}\n end",
"def name\n return ... | [
"0.7283955",
"0.7242061",
"0.7073357",
"0.6911435",
"0.6763153",
"0.6690597",
"0.66373146",
"0.6504628",
"0.64523125",
"0.6451528",
"0.64393693",
"0.6392268",
"0.6280359",
"0.6269426",
"0.62675345",
"0.6226695",
"0.62112206",
"0.61193734",
"0.61129856",
"0.6089946",
"0.599471... | 0.8050874 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_advertisement
@advertisement = current_user.company.advertisements.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 advertisement_params
params.require(:advertisement).permit(:advertisement_id, :title, :body, :image1, :delivery_date)
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.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
GET /recipes GET /recipes.json | def index
@recipes = Recipe.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def index\n info = Aws.get_recipes_from_db\n render... | [
"0.8315941",
"0.76739687",
"0.76456314",
"0.75547504",
"0.7492078",
"0.7476003",
"0.74459517",
"0.7393438",
"0.7300475",
"0.7273354",
"0.72657275",
"0.7214473",
"0.7162102",
"0.71540695",
"0.7122386",
"0.71124816",
"0.7101849",
"0.70503086",
"0.69963014",
"0.6985436",
"0.6985... | 0.7057095 | 30 |
GET /recipes/1 GET /recipes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def show(id) \n response = request(:get, \"/recipes/#{id}.json\")\n response.first[1]\n end",
"def show\n resp... | [
"0.79414284",
"0.790214",
"0.75844485",
"0.756833",
"0.7435937",
"0.7432573",
"0.7403042",
"0.7356558",
"0.7325271",
"0.7305129",
"0.72860897",
"0.726182",
"0.723712",
"0.71111596",
"0.70902306",
"0.7004932",
"0.70041907",
"0.69779086",
"0.69637275",
"0.6949757",
"0.6949757",... | 0.0 | -1 |
POST /recipes POST /recipes.json | def create
@recipe = Recipe.new(recipe_params)
respond_to do |format|
if @recipe.save
format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }
format.json { render :show, status: :created, location: @recipe }
else
format.html { render :new }
format.json { render json: @recipe.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n recipe = Recipe.create(recipe_params)\n render json: recipe\n end",
"def create\n user = current_user\n if params[:id]\n @recipe = Recipe.new(name: params[:name],\n description: params[:description],\n ingredients: params[:indredients],\n instructions... | [
"0.7513961",
"0.7252413",
"0.71854967",
"0.7043643",
"0.69464684",
"0.69280976",
"0.69280976",
"0.6921548",
"0.6838844",
"0.6824818",
"0.68215215",
"0.681211",
"0.6806326",
"0.680137",
"0.67922544",
"0.67922544",
"0.6773201",
"0.677275",
"0.6763137",
"0.6756849",
"0.67557687"... | 0.6830795 | 13 |
PATCH/PUT /recipes/1 PATCH/PUT /recipes/1.json | def update
respond_to do |format|
if @recipe.update(recipe_params)
format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }
format.json { render :show, status: :ok, location: @recipe }
else
format.html { render :edit }
format.json { render json: @recipe.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n recipe.update(recipe_params)\n render json: recipe\n end",
"def update\n begin\n recipe = Recipe.find(params[:id])\n\n if recipe.update_attributes(recipe_params)\n render json: { status: 'SUCCESS', message: ... | [
"0.7412457",
"0.7212625",
"0.7132887",
"0.7110579",
"0.707984",
"0.70403636",
"0.6898505",
"0.6888944",
"0.6888944",
"0.6888944",
"0.6888944",
"0.6887258",
"0.6844805",
"0.6808558",
"0.6766614",
"0.67402714",
"0.6716237",
"0.66892487",
"0.66645557",
"0.66595244",
"0.66223663"... | 0.6611246 | 30 |
DELETE /recipes/1 DELETE /recipes/1.json | def destroy
@recipe.destroy
respond_to do |format|
format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def recipe_delete # /v1/user/:id/recipes/:recipe_id (DELETE)\n params[:recipes] = params[:recipe_id]\n recipes_delete\n end",
"def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ingredient... | [
"0.82631564",
"0.8203384",
"0.7745981",
"0.7638722",
"0.76314753",
"0.76168",
"0.7602991",
"0.7566857",
"0.75504524",
"0.75504524",
"0.75504524",
"0.75504524",
"0.75504524",
"0.7474456",
"0.74714565",
"0.7446406",
"0.74406594",
"0.74406594",
"0.74406594",
"0.74406594",
"0.744... | 0.7137432 | 51 |
Use callbacks to share common setup or constraints between actions. | def set_recipe
@recipe = Recipe.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 recipe_params
params.require(:recipe).permit(:content, :quantity_upstairs, :quantity_downstairs, :food_type, :ann_safe, :checkbox_value, :id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
has_one :codeml_result, dependent: :destroy has_one :fast_result, dependent: :destroy after_create :execute_pipeline | def execute_pipeline
PipelineJob.perform_async(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_convert_stock_one_on_one( employee, quantity) \n source = self.one_to_one_source \n source_item = source.item \n \n new_convert_stock = ConvertStock.new \n new_convert_stock.source_quantity = quantity \n new_convert_stock.creator_id = employee.id \n new_convert_stock.stock_convers... | [
"0.5544524",
"0.53742033",
"0.5256601",
"0.51525205",
"0.50925136",
"0.5025746",
"0.5025746",
"0.50197214",
"0.50197214",
"0.50178915",
"0.5017191",
"0.4990979",
"0.49557236",
"0.49461472",
"0.48944542",
"0.4881921",
"0.48762062",
"0.4873938",
"0.4871976",
"0.48446843",
"0.48... | 0.0 | -1 |
get every test to pass before coding runner below | def runner
welcome()
currentsum = initial_round()
currentsum = hit?(currentsum)
while currentsum < 22
currentsum = hit?(currentsum)
end
end_game(currentsum)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if no... | [
"0.7274132",
"0.7200911",
"0.71905994",
"0.7134598",
"0.7127439",
"0.70358455",
"0.6860759",
"0.68229115",
"0.68049264",
"0.6790065",
"0.6790065",
"0.6768047",
"0.65728307",
"0.65551996",
"0.65487796",
"0.65460235",
"0.65293026",
"0.64595217",
"0.6447049",
"0.6447049",
"0.644... | 0.0 | -1 |
Command to pass to shell_out. | def command
if new_resource.command.is_a?(Array)
[new_resource.python] + new_resource.command
else
"#{new_resource.python} #{new_resource.command}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shell_out_command(cmd, msg)\n cmd_local = \"#{cmd}\" + \" -c #{knife_config}\" + \"#{grep_cmd}\"\n shell_out = Mixlib::ShellOut.new(\"#{cmd_local}\", :timeout => timeout)\n puts \"#{msg}\"\n puts \"#{cmd_local}\"\n @op = shell_out.tap(&:run_command).stdout\n puts \"#{c... | [
"0.7550706",
"0.69870144",
"0.69238216",
"0.6903258",
"0.68766254",
"0.6657787",
"0.6609094",
"0.64676195",
"0.64654976",
"0.6357223",
"0.6346813",
"0.6346813",
"0.6336614",
"0.63284785",
"0.631996",
"0.6314063",
"0.6297181",
"0.6275871",
"0.6267741",
"0.6235331",
"0.6219414"... | 0.0 | -1 |
Environment variables to pass to shell_out. | def environment
if new_resource.parent_python
environment = new_resource.parent_python.python_environment
if new_resource.environment
environment = environment.merge(new_resource.environment)
end
environment
else
new_resource.environment
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def msys_apps_envvars_for_cmd\n vars = with_msys_install_hint{ msys_apps_envvars }\n vars.map do |key, val|\n \"#{key}=#{val}\"\n end.join(\"\\n\")\n end",
"def cmd_getenv(*args)\n vars = client.sys.config.getenvs(*args)\n\n if vars.length == 0\n print_error(\"None of the spec... | [
"0.6823074",
"0.680961",
"0.6693461",
"0.66444445",
"0.6540566",
"0.6395838",
"0.63755846",
"0.63488823",
"0.6346558",
"0.63415444",
"0.6338589",
"0.62040025",
"0.6192248",
"0.6190188",
"0.6178436",
"0.61660635",
"0.6165813",
"0.61602134",
"0.61581105",
"0.61447906",
"0.61312... | 0.0 | -1 |
before_action :load_flats, only: [:conversations_by_user] | def index
# p 'in users, BookingsController'
@conversations = Conversation.where(user_id: @user.id)
# p @conversations
if @conversations
conversations_serializer = parse_json @conversations
json_response "Indexed user's conversations successfully", true, {conversations: conversations_serializer}, :ok
else
json_response "Cannot find conversations for user", false, {}, :not_found
end
# @flat = Flat.order(created_at: :desc)
# @flat = policy_scope(Flat).order(created_at: :desc)
# authorize @cars
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @user_conversations = UserConversation.all\n end",
"def index\n # @conversations = Conversation.all\n @conversations = current_user.conversations\n end",
"def index\n #find the current user object\n @user = User.find(session[:user_id])\n #get the id of current user\n user_id ... | [
"0.6640121",
"0.65178794",
"0.63903695",
"0.63703316",
"0.63354474",
"0.6295956",
"0.6285403",
"0.6263965",
"0.62322944",
"0.6191548",
"0.61489576",
"0.6141955",
"0.61242044",
"0.6079881",
"0.60319126",
"0.5969224",
"0.5966668",
"0.58922404",
"0.586439",
"0.5860623",
"0.58539... | 0.62607527 | 8 |
reference for passing array in params | def conversation_params
params.require(:conversation).permit(:flat_id, flat_id_array: [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getArray _args\n \"getArray _args;\" \n end",
"def rewrite_param_values(array_params); end",
"def params_array_from(raw_params); end",
"def params=(_arg0); end",
"def params=(_arg0); end",
"def initialize(*args)\n params_init # paramable\n array_init(*args)\n end",
"def splat_mth(*mu... | [
"0.656562",
"0.6534699",
"0.6503011",
"0.65019804",
"0.65019804",
"0.64515084",
"0.6325931",
"0.631942",
"0.62071174",
"0.61715233",
"0.6159177",
"0.61419606",
"0.61369824",
"0.6123749",
"0.6123749",
"0.6123749",
"0.6123749",
"0.6123749",
"0.6123749",
"0.6123749",
"0.6123749"... | 0.0 | -1 |
To prevent users from using something insecure like "Password" we make sure that the secret they've provided is at least 30 characters in length. | def ensure_secret_secure(secret)
if secret.blank?
raise ArgumentError, "A secret is required to generate an " +
"integrity hash for cookie session data. Use " +
"config.secret_token = \"some secret phrase of at " +
"least #{SECRET_MIN_LENGTH} characters\"" +
"in config/initializers/secret_token.rb"
end
if secret.length < SECRET_MIN_LENGTH
raise ArgumentError, "Secret should be something secure, " +
"like \"#{SecureRandom.hex(16)}\". The value you " +
"provided, \"#{secret}\", is shorter than the minimum length " +
"of #{SECRET_MIN_LENGTH} characters"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secret_length\n @secret_length ||= 32\n end",
"def friendly_secret\n self.class.friendly_secret(length)\n end",
"def validate_secret(opt) # parse the title for the secret\n unless @secret.nil?\n (key, @secret) = @secret.split(/:\\s?/)\n @secret.strip!\n end\n ... | [
"0.7520606",
"0.7257533",
"0.70026004",
"0.6868733",
"0.6802432",
"0.678343",
"0.67611235",
"0.6724692",
"0.66394",
"0.6613152",
"0.6591436",
"0.6514654",
"0.6506961",
"0.6505508",
"0.6470401",
"0.6457895",
"0.6428709",
"0.6428709",
"0.6411107",
"0.6401201",
"0.6398188",
"0... | 0.72543395 | 2 |
Build an unbalanced tree from unsorted data | def build_tree_from_unsorted(arr)
return nil if arr.empty?
@root = Node.new(arr.shift)
until arr.empty?
child_node = Node.new(arr.shift)
assign_children(@root, child_node)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end",
"def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end",
"def build_tree(data_array)\n root = nil\n \n data_array.each ... | [
"0.78237903",
"0.7754102",
"0.761129",
"0.7323377",
"0.7283544",
"0.7247971",
"0.72393286",
"0.7217896",
"0.71982557",
"0.7164551",
"0.71630865",
"0.7153899",
"0.71277064",
"0.70789814",
"0.70767045",
"0.70371664",
"0.6996168",
"0.6983732",
"0.69540966",
"0.69359505",
"0.6928... | 0.7492917 | 3 |
Build a tree from sorted data, setting the median as the root | def build_tree_from_sorted(arr)
return nil if arr.empty?
left, right, middle = get_left_right_middle(arr)
@root = Node.new(middle)
make_children(@root, left)
make_children(@root, right)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end",
"def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end",
"def build_tree(data_array)\n root = nil\n \n data_array.each ... | [
"0.6558561",
"0.64382875",
"0.63553596",
"0.6242733",
"0.6241094",
"0.6067161",
"0.6034394",
"0.5961088",
"0.5960198",
"0.59091127",
"0.5840622",
"0.5820964",
"0.5820257",
"0.5804957",
"0.5770254",
"0.5727567",
"0.5711552",
"0.5703989",
"0.569803",
"0.56913126",
"0.56734544",... | 0.65351343 | 1 |
Build a meaningless tree and waste your time | def build_tree_arbitrary(arr)
node = Node.new(arr[0])
queue = [node]
@root = node
i = 0
until queue.empty?
node = queue.shift
children = node_children(node, i, arr)
queue.concat(children)
i += 2
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def produce_tree(ary); end",
"def build_tree(arr)\n\tend",
"def tree\n @tree ||= build_tree\n end",
"def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n ... | [
"0.7332564",
"0.7331433",
"0.71261656",
"0.7088093",
"0.7037673",
"0.69999087",
"0.69929796",
"0.69334954",
"0.6877431",
"0.6811008",
"0.6750986",
"0.6740798",
"0.6737556",
"0.6732581",
"0.6728313",
"0.6715232",
"0.67077535",
"0.6706999",
"0.66814226",
"0.66759896",
"0.664951... | 0.67709553 | 10 |
Some students should be enrolled in multiple courses to make the test effective. | def populate_students
CoursesUsers.create(courses_users)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_multiple_courses\n \n end",
"def enrolled_service_learning_courses(quarter = Quarter.current_quarter, unit = Unit.find_by_abbreviation(\"carlson\"), options = {:enrolled_courses_options => {}})\n quarter = [quarter] unless quarter.is_a?(Array)\n @enrolled_service_learning_courses = []\n ... | [
"0.79511976",
"0.6674152",
"0.6667313",
"0.6646607",
"0.66097176",
"0.6595312",
"0.6595312",
"0.6581144",
"0.65519035",
"0.65425944",
"0.6537532",
"0.6486666",
"0.64061815",
"0.63582504",
"0.6350201",
"0.63409674",
"0.6333139",
"0.6328302",
"0.63206834",
"0.6315694",
"0.63060... | 0.0 | -1 |
Return the 'true' (i.e. most specialized) classname of this object When return_id is true, the 'specialized' database id is also returned | def type(return_id = false)
query, levels = self.class.cti_outer_join_sql(id)
result = self.class.connection.execute(query).first
# replace returned ids with the levels corresponding to their classes
result_levels = result.inject({}) do |hash, (k,v)|
hash[k] = levels[k] unless v.nil?
hash
end
# find class with maximum level value
foreign_key = result_levels.max_by { |k,v| v }.first
class_name = DBViewCTI::Names.table_to_class_name(foreign_key[0..-4])
if return_id
id_ = result[foreign_key].to_i
[class_name, id_]
else
class_name
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type(return_id = false)\n query, levels = self.class.cti_outer_join_sql(id)\n result = self.class.connection.execute(query).first\n # replace returned ids with the levels corresponding to their classes\n result_levels = result.inject({}) do |hash, (k,v)|\n hash[k]... | [
"0.71521866",
"0.63399816",
"0.60104936",
"0.5906077",
"0.57766384",
"0.57685393",
"0.5752798",
"0.5685372",
"0.56263345",
"0.5620079",
"0.56127894",
"0.56062007",
"0.55897456",
"0.556686",
"0.55571985",
"0.5555988",
"0.55535656",
"0.5545961",
"0.5529576",
"0.55188483",
"0.55... | 0.7205548 | 0 |
registers a derived class and its descendants in the current class class_name: name of derived class (the one calling cti_register_descendants on this class) descendants: the descendants of the derived class | def cti_register_descendants(class_name, descendants = {})
@cti_descendants ||= {}
@cti_descendants[class_name] = descendants
if cti_derived_class?
# call up the chain. This will also cause the register_ascendants callbacks
self.superclass.cti_register_descendants(self.name, @cti_descendants)
end
# call back to calling class
@cti_ascendants ||= []
class_name.constantize.cti_register_ascendants(@cti_ascendants + [ self.name ])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cti_register_ascendants(ascendants)\n @cti_ascendants = ascendants\n end",
"def register_derived_type(name_prefix, options={})\n options = {\n :also_matches => [],\n :entity_class => @entity_class\n }.merge!(options)\n options[:also_matches].push(*self.matches_names)\n n... | [
"0.6021408",
"0.5671427",
"0.5635377",
"0.5635377",
"0.55555415",
"0.54864746",
"0.54864746",
"0.5434053",
"0.5428377",
"0.535379",
"0.5239922",
"0.5221086",
"0.52199346",
"0.5209481",
"0.51835346",
"0.51779824",
"0.5171605",
"0.51612014",
"0.5150061",
"0.5140055",
"0.5140055... | 0.83949983 | 0 |
registers the ascendants of the current class. Called on this class by the parent class. ascendants: array of ascendants. The first element is the highest level class, derived classes follow, the last element is the parent of this class. | def cti_register_ascendants(ascendants)
@cti_ascendants = ascendants
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cti_register_descendants(class_name, descendants = {})\n @cti_descendants ||= {}\n @cti_descendants[class_name] = descendants\n if cti_derived_class?\n # call up the chain. This will also cause the register_ascendants callbacks\n self.superclass.cti_register_des... | [
"0.75792086",
"0.6220952",
"0.6211236",
"0.59619945",
"0.5942822",
"0.59396935",
"0.5916648",
"0.58827436",
"0.58755416",
"0.5776554",
"0.57473123",
"0.5700165",
"0.56992865",
"0.56892216",
"0.5669219",
"0.56331426",
"0.5626764",
"0.5602407",
"0.55936044",
"0.55617607",
"0.55... | 0.7134154 | 1 |
returns a list of all descendants | def cti_all_descendants
result = []
block = Proc.new do |klass, descendants|
result << klass
descendants.each(&block)
end
@cti_descendants ||= {}
@cti_descendants.each(&block)
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def descendants\n children + children.map(&:descendants).flatten\n end",
"def descendants\n _descendants.flatten.uniq\n end",
"def descendants\n children + children.map(&:children).flatten\n end",
"def descendants\n list = []\n children.each do |child|\n list << child\n ... | [
"0.86860335",
"0.86547303",
"0.86041355",
"0.85932326",
"0.85932326",
"0.8562172",
"0.8545913",
"0.8516754",
"0.84689844",
"0.83004344",
"0.8266972",
"0.8158597",
"0.81469303",
"0.81283695",
"0.81117445",
"0.80980814",
"0.80784917",
"0.80660635",
"0.80194086",
"0.7998634",
"0... | 0.7454846 | 31 |
this method is only used in testing. It returns the number of rows present in the real database table, not the number of rows present in the view (as returned by count) | def cti_table_count
result = connection.execute("SELECT COUNT(*) FROM #{DBViewCTI::Names.table_name(self)};")
result[0]['count'].to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row_count \r\n assert_exists\r\n return rows.length\r\n end",
"def count\n @rows.count\n end",
"def rows_count\n @rows.size\n end",
"def row_count\n @rows.length;\n end",
"def numberOfRowsInTableView(view)\n # Return the number of items.\n @entries ? @entr... | [
"0.7950203",
"0.784802",
"0.75352746",
"0.75290674",
"0.73810005",
"0.7303065",
"0.7288592",
"0.7246807",
"0.71132594",
"0.70948905",
"0.70739824",
"0.70682526",
"0.7064147",
"0.7055987",
"0.7055987",
"0.7052614",
"0.70374",
"0.70149523",
"0.7009896",
"0.69776714",
"0.6977671... | 0.6769851 | 32 |
Verify if has a virtual machine topic associated with this class. | def has_topic
!@topic.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_topic?\n ! (topic.nil? || topic_name.nil?)\n end",
"def has_vm?(vm_cid)\n @telemetry_manager.monitor('initialize') do\n _init_azure\n end\n with_thread_name(\"has_vm?(#{vm_cid})\") do\n @telemetry_manager.monitor('has_vm?', id: vm_cid) do\n vm = @vm_manager.find(... | [
"0.6546054",
"0.6461766",
"0.6359832",
"0.62185943",
"0.60365605",
"0.5915271",
"0.58648807",
"0.58195835",
"0.57955754",
"0.5719867",
"0.5719867",
"0.55917275",
"0.55597305",
"0.549184",
"0.549184",
"0.549184",
"0.5355411",
"0.532926",
"0.5327082",
"0.5322511",
"0.5300242",
... | 0.6783201 | 1 |
Associate the topic reference when the subscription is received from OmfEc::FlowVisor::FlowVisor::create | def associate_topic(topic)
@topic = topic
self.__log_messages
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe!(topic)\n subscriptions.create!( :topic_id => topic.id )\n end",
"def create_topic!\n fora.post_new_topic\n end",
"def associate_topic(topic)\n self.synchronize do\n @topic = topic\n end\n end",
"def subscribe(_topic, **)\n raise 'not implemented'\n end",... | [
"0.69654727",
"0.693385",
"0.6924505",
"0.672404",
"0.6632238",
"0.6606716",
"0.64954007",
"0.6471134",
"0.6466183",
"0.64106846",
"0.6328354",
"0.6328129",
"0.6328129",
"0.63221544",
"0.6273144",
"0.62435305",
"0.6236382",
"0.6221248",
"0.6206416",
"0.61934483",
"0.61639106"... | 0.68802303 | 3 |
helper method to avoid hitting the API more than necessary when checking whether there are any messages | def check_for_new_messages
messages = twitter.direct_messages(:since_id => last_message_retrieved)
@num_messages = messages.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_message?\n has_message\n # && messages.count > 0\n end",
"def has_messages?\n\t\t\treturn !(messages.empty?)\n\t\tend",
"def check_for_messages\n @message_unviewed = Message.all(:recipient_id => current_user.id, :viewed => false, :opportunity => Opportunity.all(:active => true))\n if @... | [
"0.73932064",
"0.71648556",
"0.68863493",
"0.6635649",
"0.6629527",
"0.6470104",
"0.6430322",
"0.64266336",
"0.6348264",
"0.6348264",
"0.63257617",
"0.6306825",
"0.6305746",
"0.63001496",
"0.6268742",
"0.6239971",
"0.6135803",
"0.6118827",
"0.6095308",
"0.6074208",
"0.6067157... | 0.5970666 | 29 |
the sum from 1 to n (inclusive of n). | def sum_to(num)
if num == 0
return num
elsif num < -1
return nil
end
num + sum_to(num - 1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_to(n)\n (1..n).reduce(0) do |sum, value|\n sum + value\n end\nend",
"def sum(n)\n end",
"def sum(n)\n result = 0\n n.each do |number|\n result = result + number\n end\n return result\n end",
"def sum_to(n)\n n > 1 ? n + sum_to(n - 1) : n < 1 ? [].first : 1\n end",
"def sum... | [
"0.8519351",
"0.8480083",
"0.8300971",
"0.8294192",
"0.82304156",
"0.8198482",
"0.8193413",
"0.8165357",
"0.81279874",
"0.8060312",
"0.8057663",
"0.80410767",
"0.79839236",
"0.7944503",
"0.78839034",
"0.7855229",
"0.7763933",
"0.7757589",
"0.7756247",
"0.775055",
"0.7749765",... | 0.0 | -1 |
=> returns nil Write a function add_numbers(nums_array) that takes in an array of Fixnums and returns the sum of those numbers. Write this method recursively. | def add_numbers(arr)
if arr == []
return nil
elsif arr[0] == arr[-1]
return arr[0]
end
arr[-1] + add_numbers(arr[0...-1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_numbers(nums_array)\n\treturn nil if nums_array.length == 0\n\n\treturn nums_array.first if nums_array.length == 1\n\n\treturn nums_array.shift + add_numbers(nums_array)\nend",
"def add_numbers(num_array)\n return num_array[0] if num_array.length <= 1\n sum = num_array[0]\n sum += add_numbers(num_arra... | [
"0.8548478",
"0.838794",
"0.8363098",
"0.8339928",
"0.8326567",
"0.82845324",
"0.8196909",
"0.8178786",
"0.8177713",
"0.81563497",
"0.812071",
"0.80956376",
"0.80920756",
"0.8082502",
"0.8068438",
"0.8059388",
"0.805778",
"0.8055099",
"0.8045769",
"0.7996468",
"0.7970453",
... | 0.7525197 | 43 |
=> returns 5040 Write a function ice_cream_shop(flavors, favorite) that takes in an array of ice cream flavors available at the ice cream shop, as well as the user's favorite ice cream flavor. Recursively find out whether or not the shop offers their favorite flavor. | def ice_cream_shop(flavors, favorite)
return true if flavors[-1] == favorite
return false if flavors.empty?
ice_cream_shop(flavors[0...-1], favorite)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ice_cream_shop(flavors, favorite)\n # Base step\n return false if flavors.empty?\n return true if flavors[0] == favorite\n # Recursive Step\n ice_cream_shop(flavors[1..-1], favorite)\nend",
"def ice_cream_shop(flavors, favorite)\n return false if flavors == []\n return true if flavors[0] == favorite\n... | [
"0.8590992",
"0.82558006",
"0.8204239",
"0.81666",
"0.8161897",
"0.81279457",
"0.81017435",
"0.8100349",
"0.8088837",
"0.8081926",
"0.8078285",
"0.8051026",
"0.80349296",
"0.80231917",
"0.7986425",
"0.7960098",
"0.7949755",
"0.79437864",
"0.79287195",
"0.79047245",
"0.7856340... | 0.81376135 | 5 |
=> returns false Write a function reverse(string) that takes in a string and returns it reversed. | def reverse(str)
return "" if str.empty?
reverse(str[1..-1]) + str[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_string(string)\n answer = string.reverse\n return answer\nend",
"def reverse_string(string)\n reverse = string.reverse\n return reverse\nend",
"def reverse(string)\nend",
"def reverse_string(s)\n s.reverse!\nend",
"def reverse(str)\n return str.reverse()\nend",
"def reverse(str)\n ... | [
"0.8409786",
"0.83785653",
"0.8348028",
"0.83357584",
"0.83330935",
"0.83155483",
"0.8312992",
"0.8283091",
"0.82512075",
"0.82512075",
"0.82512075",
"0.8230912",
"0.8202319",
"0.8174118",
"0.81730527",
"0.8156594",
"0.8156594",
"0.8092266",
"0.807489",
"0.80622864",
"0.80581... | 0.0 | -1 |
Call 2 other functions and pass them instance variables | def virus_effects
puts "#{@state} will lose #{predicted_deaths} people in this outbreak and will spread across the state in #{speed_of_spread} months.\n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calls; end",
"def calls; end",
"def call() end",
"def call(*args)\n __call__( args )\n end",
"def two_method(x,y,z)\n\t\tx + y + z\nend",
"def call1\n call2\n call3\nend",
"def call(*) end",
"def call(*) end",
"def call(*args); end",
"def duas1(action)\n action.call\n acti... | [
"0.6464437",
"0.6464437",
"0.6199258",
"0.61759865",
"0.61726093",
"0.61211383",
"0.61062574",
"0.61062574",
"0.6030778",
"0.6011732",
"0.5990138",
"0.5990138",
"0.5990138",
"0.5990138",
"0.5990138",
"0.5990138",
"0.5990138",
"0.5990138",
"0.58861405",
"0.5882044",
"0.5877706... | 0.0 | -1 |
Depending on the Population density, we calulate the number of predicted deaths | def predicted_deaths
case @population_density
when 0..50 then (@population * 0.05).floor
when 51..100 then (@population * 0.1).floor
when 101..150 then (@population * 0.2).floor
when 151..200 then (@population * 0.3).floor
else (@population * 0.4).floor
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicted_deaths\n # predicted deaths is solely based on population density\n if @population_density >= 200\n rate = 0.4\n elsif @population_density >= 150\n rate = 0.3\n elsif @population_density >= 100\n rate = 0.2\n elsif @population_density >= 50\n rate = 0.1\n else\n ... | [
"0.87548697",
"0.87026584",
"0.8673577",
"0.86581117",
"0.86520076",
"0.8647558",
"0.8605097",
"0.859665",
"0.8595221",
"0.85898817",
"0.8535275",
"0.8535275",
"0.8486009",
"0.84841055",
"0.8457516",
"0.844626",
"0.84384036",
"0.8395974",
"0.8314984",
"0.8262793",
"0.82552826... | 0.0 | -1 |
Calculate how long the virus will take to spread based on pop density | def speed_of_spread #in months
# We are still perfecting our formula here. The speed is also affected
# by additional factors we haven't added into this functionality.
case @population_density
when 0..50 then 2.5
when 51..100 then 2
when 101..150 then 1.5
when 151..200 then 1
else 0.5
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def speed_of_spread(population_density) #in months\n # We are still perfecting our formula here. The speed is also affected\n # by additional factors we haven't added into this functionality.\n\n if @population_density >= 200\n speed = 0.5\n elsif @population_density >= 150\n speed = 1\n e... | [
"0.73655224",
"0.7360035",
"0.73489755",
"0.72912955",
"0.7284357",
"0.72813475",
"0.72813475",
"0.7150867",
"0.71429205",
"0.7132044",
"0.7114529",
"0.7097571",
"0.7092514",
"0.70803714",
"0.7067229",
"0.7067229",
"0.7067229",
"0.7066761",
"0.7059718",
"0.7051508",
"0.704674... | 0.6885476 | 31 |
adapted from SICP section 1.2 | def square(n)
n * n
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alg; end",
"def if_ins(i,spl); end",
"def strauss; end",
"def ein; end",
"def cops; end",
"def cops; end",
"def cops; end",
"def ri(p,i,n,a,s)\n j = 0\n v = nil\n h = nil\n k = nil\n while i > 0\n k = n-j-1\n h = b(k)\n v = b(j) * h\n i -= v\n j += 1\n e... | [
"0.61594343",
"0.5719489",
"0.56951886",
"0.5690199",
"0.56839776",
"0.56839776",
"0.56839776",
"0.5676464",
"0.56716794",
"0.5665984",
"0.5606352",
"0.55877817",
"0.5523351",
"0.5517822",
"0.5509652",
"0.54813147",
"0.54780513",
"0.5471747",
"0.5448934",
"0.54439324",
"0.544... | 0.0 | -1 |
Creates and initializes a new instance of the AdaptiveNetworkHardenings class. | def initialize(client)
@client = client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize( config={} )\n\t\t\t# Node Metadata\n\t\t\t@uuid = config[:uuid] || nil\n\t\t\t# Network Variables\n\t\t\t@host = config[:host] || '127.0.0.1'\n\t\t\t@port = config[:port] || '3333'\n\t\t\t@name = config[:name] || config[:host]\n\t\t\t@description = config[:description] || @name\n\n\t\t\t@socket =... | [
"0.5390672",
"0.5237181",
"0.52342117",
"0.5217499",
"0.52062607",
"0.5202826",
"0.51960665",
"0.5141007",
"0.51036406",
"0.5103318",
"0.5100264",
"0.50961",
"0.5092059",
"0.50877416",
"0.5074276",
"0.5055973",
"0.5028126",
"0.5013355",
"0.500928",
"0.50073916",
"0.49975556",... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def record_params
params.require(:record).permit()
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.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
View your website's performance. Returns time series data website performance data for the given domain and/or path. | def get_page(opts = {})
data, _status_code, _headers = get_page_with_http_info(opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end",
"def index\n @htscdts = Htscdt.all\n end",
"def performance\n authenticated_post(\"auth/r/stats/perf:1D/hist\")\n end",
"def response_time_... | [
"0.5932286",
"0.5590722",
"0.55699956",
"0.532639",
"0.5315538",
"0.52507335",
"0.51862407",
"0.5181839",
"0.5178521",
"0.5126185",
"0.5098839",
"0.5089095",
"0.5041706",
"0.50406563",
"0.50225323",
"0.5006034",
"0.5003582",
"0.49872133",
"0.4968375",
"0.49580324",
"0.4957406... | 0.0 | -1 |
View your website&39;s performance. Returns time series data website performance data for the given domain and/or path. | def get_page_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: PublicPerformanceApi.get_page ...'
end
# resource path
local_var_path = '/cms/v3/performance/'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'domain'] = opts[:'domain'] if !opts[:'domain'].nil?
query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil?
query_params[:'pad'] = opts[:'pad'] if !opts[:'pad'].nil?
query_params[:'sum'] = opts[:'sum'] if !opts[:'sum'].nil?
query_params[:'period'] = opts[:'period'] if !opts[:'period'].nil?
query_params[:'interval'] = opts[:'interval'] if !opts[:'interval'].nil?
query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?
query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'PublicPerformanceResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"PublicPerformanceApi.get_page",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PublicPerformanceApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end",
"def performance\n authenticated_post(\"auth/r/stats/perf:1D/hist\")\n end",
"def index\n @htscdts = Htscdt.all\n end",
"def response_time_... | [
"0.5912807",
"0.5645461",
"0.55971444",
"0.5320732",
"0.531637",
"0.52234256",
"0.52157116",
"0.5162989",
"0.5144299",
"0.5132467",
"0.510403",
"0.50984967",
"0.5074786",
"0.5072108",
"0.50115335",
"0.5004517",
"0.500131",
"0.49921793",
"0.4983865",
"0.4972901",
"0.49705002",... | 0.0 | -1 |
View your website's uptime. Returns uptime time series website performance data for the given domain. | def get_uptime(opts = {})
data, _status_code, _headers = get_uptime_with_http_info(opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end",
"def index\n @uptimes = Uptime.all\n end",
"def uptime\n Sys::Uptime.uptime\n end",
"def uptime\n File.foreach('/proc/uptime').eac... | [
"0.59840435",
"0.59541285",
"0.5913996",
"0.5909636",
"0.5870591",
"0.5833133",
"0.56943285",
"0.5674373",
"0.56328094",
"0.5619118",
"0.5614052",
"0.5568906",
"0.5560233",
"0.5453109",
"0.543448",
"0.54063976",
"0.53922963",
"0.5389871",
"0.5372886",
"0.5336553",
"0.53162605... | 0.52688736 | 22 |
View your website&39;s uptime. Returns uptime time series website performance data for the given domain. | def get_uptime_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: PublicPerformanceApi.get_uptime ...'
end
# resource path
local_var_path = '/cms/v3/performance/uptime'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'domain'] = opts[:'domain'] if !opts[:'domain'].nil?
query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil?
query_params[:'pad'] = opts[:'pad'] if !opts[:'pad'].nil?
query_params[:'sum'] = opts[:'sum'] if !opts[:'sum'].nil?
query_params[:'period'] = opts[:'period'] if !opts[:'period'].nil?
query_params[:'interval'] = opts[:'interval'] if !opts[:'interval'].nil?
query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil?
query_params[:'end'] = opts[:'_end'] if !opts[:'_end'].nil?
# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'PublicPerformanceResponse'
# auth_names
auth_names = opts[:debug_auth_names] || ['oauth2']
new_options = opts.merge(
:operation => :"PublicPerformanceApi.get_uptime",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PublicPerformanceApi#get_uptime\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data\n if @url\n @page = fetch_url(@url)\n @parse_time = parse_dailydev_page\n @page = nil\n self.total_time\n end\n end",
"def uptime\n Sys::Uptime.uptime\n end",
"def index\n @uptimes = Uptime.all\n end",
"def uptime\n File.foreach('/proc/uptime').eac... | [
"0.5890123",
"0.5829894",
"0.58046395",
"0.5786207",
"0.5763098",
"0.5751149",
"0.55887675",
"0.55694354",
"0.55650866",
"0.5526869",
"0.55214053",
"0.54959536",
"0.5471349",
"0.5429178",
"0.53740954",
"0.5347858",
"0.53419024",
"0.5337803",
"0.52921784",
"0.52817947",
"0.527... | 0.51053953 | 29 |
Inputs: 1. a list of anything, 2. an item for us to count in the list Returns: The number of times our item is contained in the input list Prints: Nothing For example, count_in_list([1,2,3], 1) == 1 count_in_list([1,2,3], 1) == 0 count_in_list([1,1,1], 1) == 3 NOTE Ruby has a builtin method to do this, but the purpose of this kata is to write it yourself. See: | def count_in_list(list, item_to_count)
running_total_of_number = 0 #the running total is 0
list.each do |item| #go through the list. example, the first element of 1 is the placeholder.
if item == item_to_count #if this #1 is equal to 1
running_total_of_number += 1 #then the the running total increases by 1
# do it with the second number. the .each acts like a coda.
end
# You'll need three things:
# 1. A running total of the number of times you've seen the item
# 2. A way to loop/iterate through the list
# 3. A way to add to the running total as you see the item
end
return running_total_of_number #return the # of times item_to_count has appeared
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(list)\n list.length\nend",
"def count(list, number)\n c = 0\n list.each do |n|\n if n == number\n c += 1\n end\n end\n return c\nend",
"def count_occurrences(list)\n occurrences = {}\n\n list.each do |item|\n occurrences.has_key?(item) ? occurrences[item] +=... | [
"0.7423645",
"0.73730606",
"0.734652",
"0.7207684",
"0.70814794",
"0.6837607",
"0.6833629",
"0.67698073",
"0.6732527",
"0.6675238",
"0.66296077",
"0.6615636",
"0.6614344",
"0.64636356",
"0.6451111",
"0.64439",
"0.64232343",
"0.6388172",
"0.6385334",
"0.638335",
"0.6320419",
... | 0.8222036 | 0 |
Get a list of all players, sorted by player name Response serialized array of players | def index
@players = Player.order 'lower(name)'
render json: @players, serializer: V1::ApplicationArraySerializer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_all_players\n json_output = Player.all.map do |player|\n {\n id: player.id,\n name: player.name,\n image_url: player.image_url,\n }\n end\n\n render :json => json_output\n end",
"def index\n collection = if request.query_parameters.present?\n Player.where... | [
"0.74102443",
"0.70372635",
"0.69200486",
"0.6894624",
"0.68930185",
"0.68434656",
"0.6838308",
"0.68346655",
"0.68102396",
"0.6808408",
"0.67811495",
"0.677879",
"0.6767976",
"0.6753625",
"0.67436063",
"0.6736968",
"0.6733307",
"0.67102844",
"0.67102844",
"0.67046654",
"0.66... | 0.7316249 | 1 |
Get a particular player Params +:id+ player id Response serialized Player | def show
render json: @player
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player(player_id)\n get_request(shard_endpoint_uri(\"players/#{player_id}\"))\n end",
"def get_player(id)\n\t\treturn @players[id]\n\tend",
"def player_by_id id\n @players.select {|p| p.id == id}.first\n end",
"def player(player_id)\n path = ['shards', @region, 'players', player_id].jo... | [
"0.76298755",
"0.75942206",
"0.7440805",
"0.7428888",
"0.73004556",
"0.7293837",
"0.72263086",
"0.71434593",
"0.7091214",
"0.7069652",
"0.70436805",
"0.703818",
"0.703818",
"0.703818",
"0.703818",
"0.703818",
"0.7032797",
"0.7025037",
"0.6984716",
"0.6973886",
"0.6902457",
... | 0.63388366 | 94 |
Create a player Request +:name+ player name Response serialized Player or HTTP error | def create
@player = Player.new(player_params)
if @player.save
render json: @player, status: :created, location: @player
else
render json: {errors: @player.errors}, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_player(name)\n {\n \"id\" => @player_class.create(:player_name => name).id\n }\n end",
"def create\n player = Player.new(player_params)\n if player.save\n render json: player, status: 201, location: [:api, player]\n else\n failed_to_create(player, \"player\")\n end\n ... | [
"0.77265984",
"0.7640089",
"0.7458238",
"0.7439472",
"0.7416362",
"0.73777866",
"0.73393756",
"0.733539",
"0.73177534",
"0.73177534",
"0.73177534",
"0.73177534",
"0.72944343",
"0.7254512",
"0.72503686",
"0.72357446",
"0.7228008",
"0.71955377",
"0.7194835",
"0.7194835",
"0.719... | 0.73067874 | 12 |
Update a player Params +:id+ player id Request +:name+ different player name Response serialized Player or HTTP error | def update
if @player.update(player_params)
render json: @player, status: :ok
else
render json: {errors: @player.errors}, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n player = Player.find(params[:id])\n if player.update(player_params)\n render json: player, status: 200, location: [:api, player]\n else\n failed_to_update(player, \"player\")\n end\n end",
"def update\n @player = Player.find(params[:id])\n \n if @player.save\n re... | [
"0.81990284",
"0.81164795",
"0.78854823",
"0.7877426",
"0.7876997",
"0.7876997",
"0.7876997",
"0.7876997",
"0.7876997",
"0.7876997",
"0.78732723",
"0.7862343",
"0.78346187",
"0.7802089",
"0.77845657",
"0.77845657",
"0.77845657",
"0.77845657",
"0.77671754",
"0.77671754",
"0.77... | 0.79548746 | 2 |
Delete a player A player in a match or on a team may not be deleted. Params +:id+ player id Response +:no_content+ or HTTP error | def destroy
if @player.destroy
head :no_content
else
render json: {errors: @player.errors}, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n player = Player.find(params[:id])\n player.destroy\n head 204\n end",
"def destroy\n @team = Team.find(params[:team_id])\n @player = @team.players.find(params[:id])\n @player.destroy\n\n respond_to do |format|\n format.html { redirect_to team_players_url(@team) }\n f... | [
"0.76531553",
"0.7625851",
"0.7534544",
"0.75273216",
"0.75202805",
"0.75202805",
"0.75153",
"0.75153",
"0.75153",
"0.75153",
"0.75153",
"0.75153",
"0.75153",
"0.75153",
"0.7481308",
"0.74725527",
"0.7442496",
"0.7440227",
"0.74254096",
"0.7410926",
"0.73559475",
"0.7321974... | 0.69646364 | 62 |
returns a CRUD menu returns a Menu | def crud_menu(class_name)
class_string = class_name.to_s.underscore.downcase
m = Menu.new("What would you like to do with #{class_string.humanize.downcase.pluralize}?")
m.add_menu_item(user_message: ["Create a new #{class_string.humanize.downcase}."], method_name: "#{class_string}/create")
m.add_menu_item(user_message: ["Show all #{class_string.humanize.downcase.pluralize}."], method_name: "#{class_string}/show")
m.add_menu_item(user_message: ["Update a #{class_string.humanize.downcase}."], method_name: "#{class_string}/update")
m.add_menu_item(user_message: ["Delete a #{class_string.humanize.downcase}."], method_name: "#{class_string}/delete")
m
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource\n @menu ||= params[:id].present? ? Transit::Menu.find(params[:id]) : Transit::Menu.new\n end",
"def show\n if(Admin.first.nil?)\n createAdmin\n end\n\n menu=Menu.new(menu_params)\n # if the menu is saved successfully than respond with json data and status code 201\n if me... | [
"0.7293648",
"0.7074873",
"0.6942919",
"0.67682034",
"0.67682034",
"0.67682034",
"0.67682034",
"0.67682034",
"0.67682034",
"0.6735522",
"0.6734754",
"0.6717449",
"0.6693078",
"0.66853017",
"0.66700715",
"0.6652952",
"0.6652952",
"0.6652952",
"0.6627485",
"0.660715",
"0.659714... | 0.74049234 | 0 |
returns a Menu of all the class's objects returns a Menu | def object_menu(class_name, action)
class_string = class_name.to_s.underscore.downcase
create_menu = Menu.new(menu_title_hash_by_action(class_string.humanize.downcase)[action])
all = class_name.all
all.each_with_index do |object, x|
create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: "#{class_string}/#{action}/#{object.id}"})
end
create_menu
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def menu\n @menu ||= Menu.new\n end",
"def menu\n @menu ||= Interface::Menu.new(self)\n end",
"def crud_menu(class_name)\n class_string = class_name.to_s.underscore.downcase\n m = Menu.new(\"What would you like to do with #{class_string.humanize.downcase.pluralize}?\")\n m.add_menu_ite... | [
"0.75239736",
"0.7251913",
"0.7152285",
"0.7067058",
"0.6993228",
"0.69154716",
"0.69154716",
"0.68096507",
"0.6669297",
"0.665324",
"0.6645677",
"0.66043955",
"0.6604207",
"0.65116745",
"0.6510946",
"0.648266",
"0.6466476",
"0.6440695",
"0.6434809",
"0.6434809",
"0.6434809",... | 0.7957775 | 0 |
returns a Menu of all the class's objects returns a Menu | def create_menu_from_object_list(array_of_objects, action)
create_menu = Menu.new("")
array_of_objects.each_with_index do |object, x|
create_menu.add_menu_item({user_message: get_object_display_message(object), method_name: "#{object.class}/#{action}/#{object.id}"})
end
create_menu
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_menu(class_name, action)\n class_string = class_name.to_s.underscore.downcase\n create_menu = Menu.new(menu_title_hash_by_action(class_string.humanize.downcase)[action])\n all = class_name.all\n all.each_with_index do |object, x|\n create_menu.add_menu_item({user_message: get_object_dis... | [
"0.79575884",
"0.75230646",
"0.72508806",
"0.7150978",
"0.7065246",
"0.69913936",
"0.69137925",
"0.69137925",
"0.6808621",
"0.6669307",
"0.66523826",
"0.66448665",
"0.66033614",
"0.6601939",
"0.6510299",
"0.65098864",
"0.6481154",
"0.64653426",
"0.6440507",
"0.6434226",
"0.64... | 0.6134044 | 44 |
returns object's display_fields values returns an Array of values | def get_object_display_message(object)
values = []
object.display_fields.each do |field|
values << object.send(field)
end
values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_fields\n self.class.fields.values.select { |field| field.show }\n end",
"def display_all_fields\n @@all_fields\n end",
"def display_fields\n database_field_names\n end",
"def fields\n displayed_fields = @display_fields.select { |display_field| @document.key?(display_field)... | [
"0.7486903",
"0.7280955",
"0.72705674",
"0.7188775",
"0.710983",
"0.7091536",
"0.7091536",
"0.7091536",
"0.7080267",
"0.7077025",
"0.7077025",
"0.7073988",
"0.6992585",
"0.697879",
"0.69406545",
"0.69092053",
"0.6907166",
"0.6900813",
"0.68896186",
"0.6759189",
"0.6722766",
... | 0.7910833 | 0 |
LookUp Hash for the menu item to the class name Hash | def menu_to_class_name
{"user" => User, "collaborator" => Collaborator, "assignment" => Assignment, "link" => Link}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def menu_title_hash_by_action(class_string)\n {\"show\" => \"Here are all the #{class_string.pluralize}.\", \"update\" => \"Which #{class_string} do you want to update?\", \"delete\" => \"Which #{class_string} do you want to delete?\", \"create\" => \"Enter the variables to create a new #{class_string}.\"}\n e... | [
"0.66190386",
"0.6362807",
"0.6255457",
"0.600285",
"0.5979732",
"0.5927564",
"0.58665866",
"0.57631284",
"0.5714907",
"0.56765085",
"0.5644437",
"0.5602703",
"0.5592349",
"0.55862653",
"0.55572945",
"0.5556307",
"0.5542953",
"0.5542759",
"0.5541755",
"0.5540217",
"0.5513372"... | 0.70370597 | 0 |
LookUp Hash to get the menu title, based on the class and action returns a String | def menu_title_hash_by_action(class_string)
{"show" => "Here are all the #{class_string.pluralize}.", "update" => "Which #{class_string} do you want to update?", "delete" => "Which #{class_string} do you want to delete?", "create" => "Enter the variables to create a new #{class_string}."}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def menu_title\n to_s\n end",
"def menu title, h\n case h\n when Hash\n ; # okay\n when Array\n # convert array to a hash using letters for key\n x = \"a\"\n hash = Hash.new\n h.each do |e|\n hash[x] = e\n x.succ!\n end\n h = hash\n end\n return unless h\n\n kmax_leng... | [
"0.68279886",
"0.682061",
"0.6679982",
"0.65504414",
"0.64915067",
"0.63043845",
"0.6280424",
"0.62593436",
"0.62585306",
"0.624361",
"0.6151397",
"0.60514504",
"0.60326844",
"0.6006423",
"0.59765506",
"0.5954675",
"0.5940533",
"0.5923494",
"0.591497",
"0.5913613",
"0.5910242... | 0.82719135 | 0 |
Grade book Complete the function so that it finds the mean of the three scores passed to it and returns the letter value associated with that grade. Numerical ScoreLetter Grade 90 <= score <= 100'A' 80 <= score < 90'B' 70 <= score < 80'C' 60 <= score < 70'D' 0 <= score < 60'F' Tested values are all between 0 and 100. Theres is no need to check for negative values or values greater than 100. | def get_grade(s1, s2, s3)
case avg = (s1.to_f + s2.to_f + s3.to_f)/3.0
when 90..100
"A"
when 80..90
"B"
when 70..80
"C"
when 60..70
"D"
else
"F"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_grade(scores)\n score_total = 0\n\n scores.each { |x| score_total = x + score_total }\n\n average = score_total / (scores.length)\n\n case\n when average >= 90\n letter = 'A'\n when average >= 80\n letter = 'B'\n when average >= 70\n letter = 'C'\n when average ... | [
"0.8182248",
"0.80405277",
"0.79010636",
"0.78174675",
"0.7817419",
"0.7803895",
"0.7782828",
"0.77770746",
"0.7733853",
"0.7733799",
"0.77295953",
"0.7724674",
"0.77172685",
"0.7707596",
"0.7692923",
"0.7688372",
"0.76881355",
"0.76875144",
"0.7668115",
"0.7638944",
"0.76327... | 0.0 | -1 |
Add more helper methods to be used by all tests here... | def sign_in(test_user = :user_1)
visit new_user_session_path
fill_in 'Email', with: users(test_user).email
fill_in 'Password', with: 'password'
click_on 'Log in'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end",
"def helpers; end",
"def... | [
"0.7330966",
"0.701972",
"0.701972",
"0.701972",
"0.6772961",
"0.6679903",
"0.6679903",
"0.6583205",
"0.65507036",
"0.6377433",
"0.63762784",
"0.632961",
"0.6280821",
"0.6280821",
"0.6249786",
"0.6142927",
"0.6137607",
"0.6121912",
"0.6108209",
"0.60972595",
"0.60949636",
"... | 0.0 | -1 |
GET /institutes/1 GET /institutes/1.xml | def show
@institute = Institute.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @institute }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @institucion = Institucion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @institucion }\n end\n end",
"def index\n @institutos = Instituto.all\n\n respond_to do |format|\n format.html # index.html.erb\n for... | [
"0.622178",
"0.602342",
"0.5913585",
"0.586259",
"0.58473563",
"0.58129275",
"0.5792022",
"0.5777551",
"0.5719514",
"0.569494",
"0.5681596",
"0.56767726",
"0.56626225",
"0.56564885",
"0.56233954",
"0.5603082",
"0.55932164",
"0.5583041",
"0.5572815",
"0.5571242",
"0.55709",
... | 0.62872934 | 0 |
GET /institutes/new GET /institutes/new.xml | def new
@institute = Institute.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @institute }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n @institucion = Institucion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @institucion }\n end\n end"... | [
"0.71660495",
"0.7034771",
"0.700963",
"0.6757138",
"0.67484707",
"0.6699236",
"0.6659012",
"0.66344064",
"0.66130537",
"0.66082895",
"0.6607794",
"0.65890986",
"0.6562933",
"0.6562933",
"0.6549678",
"0.65486044",
"0.6546098",
"0.6542282",
"0.65261036",
"0.6525611",
"0.652004... | 0.690252 | 3 |
POST /institutes POST /institutes.xml | def create
@institute = Institute.new(params[:institute])
respond_to do |format|
if @institute.save
format.html { redirect_to(@institute, :notice => 'Institute was successfully created.') }
format.xml { render :xml => @institute, :status => :created, :location => @institute }
else
format.html { render :action => "new" }
format.xml { render :xml => @institute.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @institucion = Institucion.new(params[:institucion])\n\n respond_to do |format|\n if @institucion.save\n flash[:notice] = 'Institucion se ha creado con exito.'\n format.html { redirect_to(admin_institucions_url) }\n format.xml { render :xml => @institucion, :status => ... | [
"0.5904447",
"0.5739754",
"0.5708926",
"0.5508922",
"0.5499313",
"0.54909134",
"0.546466",
"0.5407724",
"0.53888965",
"0.5382299",
"0.5378612",
"0.5374767",
"0.53741145",
"0.5371149",
"0.5353511",
"0.5351774",
"0.53458303",
"0.5327217",
"0.5323071",
"0.5309987",
"0.52673495",... | 0.5931114 | 0 |
PUT /institutes/1 PUT /institutes/1.xml | def update
@institute = Institute.find(params[:id])
respond_to do |format|
if @institute.update_attributes(params[:institute])
format.html { redirect_to(@institute, :notice => 'Institute was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @institute.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n respond_to do |format|\n if @instituto.update_attributes(params[:instituto])\n format.html { redirect_to(@instituto, :notice => 'Instituto fue modifica... | [
"0.62186044",
"0.60334325",
"0.5942457",
"0.59328145",
"0.5881143",
"0.58764386",
"0.58001167",
"0.5798618",
"0.57519615",
"0.5719442",
"0.57074666",
"0.56916845",
"0.5681528",
"0.5664657",
"0.56450707",
"0.56340957",
"0.5612977",
"0.5590952",
"0.5580108",
"0.55780095",
"0.55... | 0.6310584 | 0 |
DELETE /institutes/1 DELETE /institutes/1.xml | def destroy
@institute = Institute.find(params[:id])
@institute.destroy
respond_to do |format|
format.html { redirect_to(institutes_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @institucion = Institucion.find(params[:id])\n @institucion.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_institucions_url) }\n format.xml { head :ok }\n end\... | [
"0.6857661",
"0.6640354",
"0.64919686",
"0.63881564",
"0.6309334",
"0.63089013",
"0.62841195",
"0.6250412",
"0.62290096",
"0.619762",
"0.6173301",
"0.6164449",
"0.6137363",
"0.61278",
"0.61073124",
"0.60938275",
"0.6090669",
"0.60899746",
"0.6085073",
"0.6079349",
"0.605632",... | 0.6538294 | 2 |
I worked on this challenge by myself. I spent 1 hour on this challenge. error "Screw you guys " + "I'm going home." = cartmans_phrase This error was analyzed in the README file. error | def cartman_hates(thing)
while true
puts "What's there to hate about #{thing}?"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend",
"def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend",
"def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend",
"def cartmans_phrase\n puts \"I'm not fat; I'm big-boned!\"\nend",
"def cartmans_phrase\n puts \"I'm n... | [
"0.65459126",
"0.65459126",
"0.65459126",
"0.65459126",
"0.65459126",
"0.65459126",
"0.65459126",
"0.6540971",
"0.6426929",
"0.6386028",
"0.6254576",
"0.62112474",
"0.61543894",
"0.60208774",
"0.5929343",
"0.57584554",
"0.5740522",
"0.5724816",
"0.568445",
"0.5679173",
"0.565... | 0.0 | -1 |
FileSets can include any metadata listed in BasicMetadata file | def file_record(work_attributes)
file_set = FileSet.new
file_attributes = Hash.new
# Singularize non-enumerable attributes
work_attributes.each do |k,v|
if file_set.attributes.keys.member?(k.to_s)
if !file_set.attributes[k.to_s].respond_to?(:each) && work_attributes[k].respond_to?(:each)
file_attributes[k] = v.first
else
file_attributes[k] = v
end
end
end
file_attributes[:visibility] = work_attributes['visibility']
unless work_attributes['embargo_release_date'].blank?
file_attributes[:embargo_release_date] = work_attributes['embargo_release_date']
file_attributes[:visibility_during_embargo] = work_attributes['visibility_during_embargo']
file_attributes[:visibility_after_embargo] = work_attributes['visibility_after_embargo']
end
file_attributes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metadata_file; end",
"def metadata_file; end",
"def load_workset( filename )\n\n md_filename = ''\n asset_files = []\n File.open( filename, 'r').each do |line|\n if /^metadata : /.match( line )\n md_filename = /^metadata : (.*)$/.match( line ).captures[ 0 ]\n end\n\n i... | [
"0.71350425",
"0.71350425",
"0.67456824",
"0.66652495",
"0.6634314",
"0.649845",
"0.6472493",
"0.62322074",
"0.62176937",
"0.6192708",
"0.6182669",
"0.6163496",
"0.6144549",
"0.6090247",
"0.60851675",
"0.6083046",
"0.6083046",
"0.6083046",
"0.6083046",
"0.6083046",
"0.6083046... | 0.0 | -1 |
Below Generates the slug based on title | def slug_candidates
[
:title,
[:title, self.admin.last_name],
[:title, self.admin.last_name, :id]
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_slug_from_title\n self.slug = self.title.downcase.gsub(' ','-')\n end",
"def generate_slug\n self.slug = title.parameterize if title\n end",
"def generate_slug\n self.slug = self.title[0..47].parameterize\n end",
"def generate_slug\n self.slug = self.title[0..47].parameterize\... | [
"0.8957013",
"0.89245903",
"0.8814883",
"0.8814883",
"0.85977376",
"0.8552337",
"0.8552337",
"0.8481273",
"0.83908814",
"0.8326465",
"0.8307926",
"0.8290855",
"0.82050955",
"0.81547534",
"0.81383514",
"0.81037927",
"0.80989844",
"0.80925226",
"0.79604113",
"0.79604113",
"0.79... | 0.0 | -1 |
Below Determines if there's a blank or new Record to assign a slug to. | def should_generate_new_friendly_id?
new_record? || slug.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_generate_new_friendly_id?\n new_record? || self[:slug].blank?\n end",
"def should_generate_new_friendly_id?\n slug.blank?\n end",
"def should_generate_new_friendly_id?\n\t new_record? || slug.blank?\n\tend",
"def should_generate_new_friendly_id?\n\t new_record? || slug.blank?... | [
"0.75662917",
"0.7549237",
"0.74837685",
"0.74837685",
"0.74618816",
"0.74618816",
"0.74618816",
"0.74618816",
"0.74598545",
"0.7449375",
"0.7445815",
"0.73239946",
"0.73239946",
"0.72741103",
"0.7230869",
"0.7101277",
"0.708868",
"0.69013137",
"0.6858813",
"0.67569935",
"0.6... | 0.7426962 | 17 |
End ASSOCIATIONS: Many/Belongs To/One Relations. Begin METHODS: Custom Methods and model calls. End METHODS: Custom Methods and model calls. Begin CUSTOM CALLBACKS: Before_save, after_commit, & Callbacks. Below Allows Mentions inside Library Uploads to send a notification to shared admins. | def mentions
@mentions ||= begin
regex = /@([\w]+\s[\w]+)/
tags.scan(regex).flatten
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_and_share_admins\n mentioned_admins.each do |mentioned|\n # Here put email \n entry = self.library_entries.create(sender_id: self.admin.id, receiver_id: mentioned.id, admin_library_id: mentioned.library.id, shared: true)\n if entry.valid?\n Notification.create(recipient: mention... | [
"0.6289245",
"0.550039",
"0.53623027",
"0.5308498",
"0.5289884",
"0.5282263",
"0.52443576",
"0.5240714",
"0.52076924",
"0.5151897",
"0.5144538",
"0.5134809",
"0.5107841",
"0.50734717",
"0.5060941",
"0.50588334",
"0.5025179",
"0.5022611",
"0.50220287",
"0.5010111",
"0.50022745... | 0.0 | -1 |
Below Checks if the resource has been shared or not using tags inside creation. | def is_shared?
if self.library_entries.where(shared: true).empty?
return false
else
return true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shared?\n sharing != 'none'\n end",
"def shared?\n sharing != 'none'\n end",
"def shared?\n @roomer_scope == :shared\n end",
"def create\n @post =Post.find(params[:post_id])\n @tag = @post.tags.build(tag_params)\n @tag.sharer =current_user.id.to_s\n respond... | [
"0.6124779",
"0.6015607",
"0.6000117",
"0.5983364",
"0.59217644",
"0.5871944",
"0.5824583",
"0.5800974",
"0.5755824",
"0.5740492",
"0.57334346",
"0.5717369",
"0.5702758",
"0.5688727",
"0.56761956",
"0.5666828",
"0.56554675",
"0.5634675",
"0.56060755",
"0.55830944",
"0.5572881... | 0.59244835 | 4 |
Below Sends a notification to reciepient of tags in creation of resource, also adds a library entry to their archive. | def notify_and_share_admins
mentioned_admins.each do |mentioned|
# Here put email
entry = self.library_entries.create(sender_id: self.admin.id, receiver_id: mentioned.id, admin_library_id: mentioned.library.id, shared: true)
if entry.valid?
Notification.create(recipient: mentioned, actor: self.admin, action: "shared", notifiable: self)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end",
"def create_notification; end",
"def notify_resource_added(resource, request)\n email = OrderMailer.create_resource_added(resource, request)\n Thread.new(email) do |e|\n OrderMail... | [
"0.56392974",
"0.55547184",
"0.55182064",
"0.5336845",
"0.52876914",
"0.52383935",
"0.5194981",
"0.51937073",
"0.51870763",
"0.5153625",
"0.5153625",
"0.51319426",
"0.5128382",
"0.5125124",
"0.51175123",
"0.51127535",
"0.50938576",
"0.50897944",
"0.50681025",
"0.50607336",
"0... | 0.0 | -1 |
Get similarity from hamming_distance | def averagehash_similarity(hash_a, hash_b)
1 - averagehash_distance(hash_a, hash_b) / 64.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_similarity(hash_a, hash_b)\n 1 - image_hamming_distance(hash_a, hash_b) / 64.0\n end",
"def hamming_distance(other)\n self_array = self.to_a\n other_array = other.to_a\n self_array.zip(other_array).reduce(0) do |hamming, symbols|\n hamming += symbols[0] == symbols[1] ? 0 :... | [
"0.7249526",
"0.68237704",
"0.6807329",
"0.6580053",
"0.65625024",
"0.65555805",
"0.6479773",
"0.647514",
"0.6463074",
"0.645051",
"0.6417677",
"0.6417677",
"0.6414233",
"0.63889927",
"0.6383619",
"0.6331813",
"0.6316473",
"0.6313823",
"0.6295776",
"0.6278993",
"0.62774575",
... | 0.6478651 | 7 |
Use callbacks to share common setup or constraints between actions. | def set_participation
@participation = Participation.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
list of numbers, and returns a new Array that contains the product of each pair of numbers from the arguments that have the same index. You may assume that the arguments contain the same number of elements. | def multiply_list(arr1, arr2)
new_array = []
index = 0
while index < arr1.size
new_array << arr1[index] * arr2[index]
index += 1
end
new_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pair_product(arr, num) \n\nend",
"def multiply_all_pairs(arr_1, arr_2)\n arr_1.product(arr_2).map { |arr| arr.reduce(&:*) }.sort\nend",
"def multiply_list(numbers1, numbers2)\n products = []\n numbers1.each_with_index do |num, ind|\n products << num * numbers2[ind]\n end\n products\nend",
"def mu... | [
"0.7583335",
"0.72570467",
"0.720952",
"0.7183639",
"0.7179565",
"0.7179565",
"0.7179565",
"0.7179565",
"0.71789443",
"0.71599126",
"0.71469074",
"0.7145325",
"0.7145325",
"0.71430737",
"0.7142083",
"0.7137819",
"0.70929086",
"0.70840955",
"0.70671356",
"0.7058998",
"0.704895... | 0.65666217 | 99 |
Strips all HTML tags out of the given string. | def strip_html(string)
# FIXME will need something more sophisticated than this, because it sucks
string.gsub(/<[^>]*(>+|\s*\z)/m, '').strip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_tags(str)\n str.gsub(/\\</, \"<\").gsub(/\\>/, \">\").gsub(/\\&/, \"&\")\n end",
"def strip_html(string=\"\")\n begin\n string = strip_tags(string)\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace with a space\n ... | [
"0.8111277",
"0.80916935",
"0.78479964",
"0.78479964",
"0.78479964",
"0.7809479",
"0.78033006",
"0.78033006",
"0.77888924",
"0.7759668",
"0.7759273",
"0.7709444",
"0.76937675",
"0.76937675",
"0.76315415",
"0.75587356",
"0.75368816",
"0.74897814",
"0.748955",
"0.74626416",
"0.... | 0.8014589 | 2 |
This test ensures that check_args will fail, given that the user passes in no parameters into the program. | def test_nil_args
refute check_args(nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_args_invalid2\n args = CheckArgs.new\n assert_equal false, args.check_args([1, 2])\n end",
"def test_check_args_false\n c = Checker.new\n assert_equal false, c.check_args([1, 1, 1, 1])\n assert_equal false, c.check_args([1,1])\n assert_equal false, c.check_args(['something', 111... | [
"0.8553085",
"0.83903754",
"0.8330345",
"0.82804996",
"0.8194575",
"0.8193247",
"0.817947",
"0.81570274",
"0.8156736",
"0.8154093",
"0.8090222",
"0.80836034",
"0.8063563",
"0.8061744",
"0.804967",
"0.80055535",
"0.79884136",
"0.79606944",
"0.79516125",
"0.7902074",
"0.7893587... | 0.78706366 | 21 |
This test checks to make sure that check_args passes, given that the user sends exactly two parameters, with the first being an integer, and the second a nonnegative integer. | def test_two_proper_args
assert check_args([1, 1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_two_ints\n args = Arguments.new\n assert_equal false, args.check_args([1, 2])\n end",
"def test_check_num_args_valid2\n args = CheckNumArgs.new\n args.check_args([1,1,1])\n assert_kind_of Integer, 1\n end",
"def test_one_ints\n args = Arguments.new\n assert_equal false, args.che... | [
"0.87442356",
"0.85890675",
"0.8543306",
"0.8303799",
"0.8285439",
"0.8243621",
"0.81646657",
"0.81568164",
"0.80655825",
"0.8044522",
"0.7974889",
"0.7962927",
"0.79463613",
"0.7940352",
"0.79275155",
"0.7923058",
"0.7868439",
"0.7772626",
"0.76505864",
"0.76136786",
"0.7508... | 0.8391691 | 3 |
This test checks to make sure that check_args will fail, given that the user sends a negative integer into the prospectors parameter | def test_neg_prospectors
refute check_args([1, -1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_arg_check_prospectors_negative\n def exit(x); 1; end\n ret = arg_check_prospectors '-1'\n assert_equal ret, -3\n end",
"def test_zero_prospectors\n\t\tassert check_args([1, 0])\n\tend",
"def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end... | [
"0.82463735",
"0.82371026",
"0.82313204",
"0.7844593",
"0.7760241",
"0.77132714",
"0.7702076",
"0.7564594",
"0.75642926",
"0.75500464",
"0.7549203",
"0.7542663",
"0.7521135",
"0.74918616",
"0.7389225",
"0.7334671",
"0.7329245",
"0.73220724",
"0.72621655",
"0.7236182",
"0.7224... | 0.83980465 | 0 |
This test checks to make sure that check_args still passes, given that the user sends zero into the prospectors parameter EDGE CASE | def test_zero_prospectors
assert check_args([1, 0])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_neg_prospectors\n\t\trefute check_args([1, -1])\n\tend",
"def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end",
"def test_args_check_less\n\t\targs_checker = ArgsChecker::new\n\t\tarr = []\n\t\tassert_raises(\"I need one number bud, try again\") { ... | [
"0.7834248",
"0.744875",
"0.7168305",
"0.7045851",
"0.7036272",
"0.7018964",
"0.69827515",
"0.69250745",
"0.69118404",
"0.68903834",
"0.68785965",
"0.67459553",
"0.6724565",
"0.6702082",
"0.6691073",
"0.6641137",
"0.6612126",
"0.658975",
"0.6554192",
"0.6510438",
"0.64931476"... | 0.8048007 | 0 |
GET /litters/1 GET /litters/1.xml | def show
#not using
#@litter = Litter.find(params[:id])
#respond_to do |format|
# format.html # show.html.erb
# format.xml { render :xml => @litter }
#end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end",
"def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { rend... | [
"0.63912684",
"0.63912684",
"0.61387765",
"0.61214346",
"0.61113304",
"0.61082613",
"0.59447324",
"0.59383154",
"0.5912425",
"0.5904268",
"0.5895175",
"0.5830907",
"0.58266836",
"0.5791102",
"0.5783864",
"0.57419795",
"0.56926167",
"0.56793976",
"0.56711996",
"0.56511086",
"0... | 0.63987803 | 0 |
GET /litters/new GET /litters/new.xml | def new
@litter = Litter.new
@sires = Sire.find(:all,:order=>"name")
@dames = Dame.find(:all,:order=>"name")
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @litter }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lyric = Lyric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lyric }\n end\n end",
"def new\n @slitting = Slitting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slitting }\n ... | [
"0.69403857",
"0.6917806",
"0.69017977",
"0.6810246",
"0.67802703",
"0.6756856",
"0.66992843",
"0.66913545",
"0.6688937",
"0.66363126",
"0.66139746",
"0.65635985",
"0.6557131",
"0.6554281",
"0.6514636",
"0.64975435",
"0.6496912",
"0.648578",
"0.6465575",
"0.6420901",
"0.63938... | 0.68690044 | 3 |
POST /litters POST /litters.xml | def create
@litter = Litter.new(params[:litter])
@sires = Sire.find(:all,:order=>"name")
@dames = Dame.find(:all,:order=>"name")
respond_to do |format|
if @litter.save
format.html { redirect_to(litters_path, :notice => 'Litter was successfully created.') }
format.xml { render :xml => @litter, :status => :created, :location => @litter }
else
format.html { render :action => "new" }
format.xml { render :xml => @litter.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @kennel_litter = KennelLitter.new(params[:kennel_litter])\n\n respond_to do |format|\n if @kennel_litter.save\n format.html { redirect_to @kennel_litter, notice: 'Kennel litter was successfully created.' }\n format.json { render json: @kennel_litter, status: :created, location... | [
"0.58933794",
"0.5871854",
"0.5768389",
"0.5711532",
"0.5554142",
"0.5550719",
"0.5523534",
"0.5460405",
"0.5421551",
"0.5379116",
"0.5370069",
"0.53374654",
"0.53227514",
"0.5320137",
"0.53036284",
"0.52864105",
"0.5275796",
"0.5270278",
"0.52615225",
"0.525776",
"0.5226336"... | 0.58717823 | 2 |
PUT /litters/1 PUT /litters/1.xml | def update
@litter = Litter.find(params[:id])
@sires = Sire.find(:all,:order=>"name")
@dames = Dame.find(:all,:order=>"name")
respond_to do |format|
if @litter.update_attributes(params[:litter])
format.html { redirect_to(litters_path, :notice => 'Litter was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @litter.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @litter = Litter.find(params[:id])\n\n respond_to do |format|\n if @litter.update_attributes(params[:litter])\n format.html { redirect_to @litter, notice: 'Litter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | [
"0.63708353",
"0.59842366",
"0.5973589",
"0.591118",
"0.5889541",
"0.58868515",
"0.5852491",
"0.58411384",
"0.58282727",
"0.580237",
"0.57161844",
"0.5715342",
"0.57120943",
"0.56999475",
"0.5675926",
"0.5674598",
"0.56395155",
"0.56371707",
"0.56246245",
"0.5606287",
"0.5558... | 0.6212464 | 1 |
DELETE /litters/1 DELETE /litters/1.xml | def destroy
@litter = Litter.find(params[:id])
@litter.destroy
respond_to do |format|
format.html { redirect_to(litters_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @lek = Lek.find(params[:id])\n @lek.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(leks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete!\n R... | [
"0.6557725",
"0.6421214",
"0.6326835",
"0.6298232",
"0.6298232",
"0.6179706",
"0.6138767",
"0.61158025",
"0.61097425",
"0.61097425",
"0.6107589",
"0.6107589",
"0.60609365",
"0.6059919",
"0.6053293",
"0.6046545",
"0.60423905",
"0.6034084",
"0.602292",
"0.6008023",
"0.59898084"... | 0.6564121 | 0 |
Provides us with a constant time lookup of the given facet's neighbours | def find_neighbours(face)
if not @faces.member? face
# There is no point doing anything if the face is not in the model
return nil
end
neighbours = []
face.edges.each_value do |edge|
if @edges.member? edge
# this will match a pair of faces one of them will be this face
matches = @edges[edge]
matches.each do |matched_face|
if matched_face != face
neighbours.push(matched_face)
end
end
end
end
return neighbours
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def live_neighbours_around_cell(cell)\n live_neighbours = []\n\n #check top cell\n if cell.x_axis > 0\n # puts \"Cell dimen1: #{cell.x_axis}:#{cell.y_axis}\"\n candidate = self.cell_grid[cell.x_axis - 1][cell.y_axis]\n # puts \"Candidate #{candidate.inspect}\"\n live_neighbours << cand... | [
"0.6210027",
"0.6119444",
"0.59218603",
"0.58929336",
"0.5863465",
"0.5861616",
"0.58512187",
"0.5848211",
"0.58444685",
"0.58275366",
"0.5812767",
"0.57992756",
"0.57685834",
"0.5745865",
"0.5680776",
"0.56559867",
"0.56407666",
"0.5609087",
"0.55898356",
"0.55898356",
"0.55... | 0.5832027 | 9 |
Returns a titleized version of the filename my_file.pdf returns My File | def title
resource_title.presence || CGI.unescape(file_name.to_s).gsub(/\.\w+$/, '').titleize
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title\n CGI::unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n end",
"def title\n CGI::unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n end",
"def title\n CGI::unescape(self.file_name).gsub(/\\.\\w+$/, '').titleize\n end",
"def discover_file_title(page = current_page)\n... | [
"0.78236794",
"0.78226596",
"0.77352",
"0.77024174",
"0.7669881",
"0.7618735",
"0.7618735",
"0.7448031",
"0.74270076",
"0.7380212",
"0.7324282",
"0.72479856",
"0.72242177",
"0.72040194",
"0.71369725",
"0.71276784",
"0.7101518",
"0.7097445",
"0.70804125",
"0.7001001",
"0.69753... | 0.7514949 | 7 |
puts "Happy Mother's Day, Mom!" end | def mothers_day(name)
"Happy Mother's Day, #{name}!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hail_the_king\n\tputs \"hail king mark\"\nend",
"def hail_the_king\n\tputs \"hail king mark\"\nend",
"def greetings\n\tputs \"Greetings friend!\"\nend",
"def exiter\n puts \"\"\n puts \"*****************************************************************************\"\n puts \"I can't believe you're leav... | [
"0.8188794",
"0.8188794",
"0.7960303",
"0.7948425",
"0.7938684",
"0.787992",
"0.78758764",
"0.7859918",
"0.7748546",
"0.77404517",
"0.76921546",
"0.76326466",
"0.76160777",
"0.76115644",
"0.76111144",
"0.7604432",
"0.7591334",
"0.7581989",
"0.7578423",
"0.7572359",
"0.7571666... | 0.0 | -1 |
the block must return a Cps | def test_with_mercury_cps(sources, queues, **kws, &block)
em do
seql do
let(:m) { Mercury::Monadic.open(**kws) }
and_then { delete_sources_and_queues_cps(sources, queues) }
and_then { block.call(m) }
and_then { delete_sources_and_queues_cps(sources, queues) }
and_then { m.close }
and_lift { done }
end.run
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804",
"0.65260804"... | 0.0 | -1 |
of the correct number of each fruit. | def buy_fruit(list)
list.map { |fruit, quantity| [fruit] * quantity }.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buy_fruit(fruits_wih_quantity)\n fruits = []\n \n fruits_wih_quantity.each do |fruit, quantity|\n quantity.times do\n fruits << fruit\n end\n end\n\n fruits\nend",
"def buy_fruit(fruit_list)\n fruit_array = []\n fruit_list.each do |fruit, quantity|\n quantity.times { fruit_array << fruit... | [
"0.7027516",
"0.6904498",
"0.6857692",
"0.68079233",
"0.67924154",
"0.67397386",
"0.66914696",
"0.6690356",
"0.66797477",
"0.66751146",
"0.6659053",
"0.6655904",
"0.6583897",
"0.6581272",
"0.65171206",
"0.64914966",
"0.64782274",
"0.6432688",
"0.6427226",
"0.64071953",
"0.637... | 0.6528751 | 15 |
=begin take list and transform each fruit and quantity to fruit quantity and flatten the array =end | def buy_fruit(types)
fruits = []
types.each do |subarray|
subarray[1].times do |time|
fruits << subarray[0]
end
end
fruits
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buy_fruit_2(arr)\n arr.map { |fruit, quantity| [fruit] * quantity }.flatten # => [\"apples\", \"apples\", \"apples\", \"orange\", \"bananas\", \"bananas\"]\nend",
"def buy_fruit2(arr)\n arr.map { |fruit, quantity| [fruit] * quantity }.flatten\nend",
"def buy_fruit(ary)\n ary.map { |fruit, quantity| [fr... | [
"0.73612505",
"0.73401815",
"0.72806686",
"0.7242852",
"0.7242852",
"0.7242852",
"0.72266173",
"0.7210359",
"0.71545136",
"0.70066273",
"0.69635695",
"0.6954689",
"0.69305956",
"0.691524",
"0.68855387",
"0.67886496",
"0.67487717",
"0.6726757",
"0.6676413",
"0.6631249",
"0.654... | 0.5761109 | 54 |
["apples", "apples", "apples", "orange", "bananas","bananas"] =begin Input:array of subarrays that each have string and number create empty array iterate through types and for each subarray call times method on number (subarray[1]) and for each time take the item (subarray[0]) and append to fruits array return fruits array Output: one array with the strings the number of times that was given in the original array =end | def buy_fruit(array)
fruits = []
array.each do |subarray|
subarray[1].times do
fruits << subarray[0]
end
end
fruits
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buy_fruit(types)\n fruits = []\n\n types.each do |subarray|\n subarray[1].times do |time|\n fruits << subarray[0]\n end\n end\n fruits\nend",
"def buy_fruit3(array)\n #array.each_with_object([]) {|obj, result| obj.last.times {result<< obj.first}}\n array.each_with_object([]) {|(fruit, coun... | [
"0.7587965",
"0.71324956",
"0.70461273",
"0.6976981",
"0.6890353",
"0.68251824",
"0.6657469",
"0.66036433",
"0.6483378",
"0.643137",
"0.6420295",
"0.6403345",
"0.6367472",
"0.63482946",
"0.6333552",
"0.6330763",
"0.6317521",
"0.625491",
"0.62327856",
"0.6191003",
"0.61901855"... | 0.70899475 | 2 |
associated with the PUT action so when we hit this url with a PUT request, this will run | def update
# find our post
id = params[:id]
@post = Post.find(id)
# increment the number of votes
if params[:tweet] == "true"
@post.votes = @post.votes + 1
@post.save
elsif params[:flagged] == "true"
@post.flagged = @post.flagged + 1
@post.save
end
# TODO: ask Tom what this does again
render :json => @post
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put!\n request! :put\n end",
"def put(request)\n request.method = :put\n request.call\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def upda... | [
"0.73253626",
"0.6931096",
"0.6782932",
"0.6775214",
"0.67483354",
"0.660166",
"0.6557152",
"0.654198",
"0.65378946",
"0.65378946",
"0.65154064",
"0.64241236",
"0.6372714",
"0.63434434",
"0.63321036",
"0.6321409",
"0.6302976",
"0.6284745",
"0.6266784",
"0.62501836",
"0.624673... | 0.0 | -1 |
Creates a new MList::Message and delivers it to the subscribers of this list. | def post(email_or_attributes)
email = email_or_attributes
email = MList::EmailPost.new(email_or_attributes) unless email.is_a?(MList::EmailPost)
process_message messages.build(
:parent => email.reply_to_message,
:parent_identifier => email.parent_identifier,
:mail_list => self,
:subscriber => email.subscriber,
:recipients => list.recipients(email.subscriber),
:email => MList::Email.new(:source => email.to_s)
), :search_parent => false, :copy_sender => email.copy_sender
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @message = Mailboxer::Message.new\n p User.get_recipient_list(@user.id)\n p 'hola world'\n @recipients = User.get_recipient_list(@user.id)\n end",
"def message_create(originator, recipients, body, params={})\n # Convert an array of recipients to a comma-separated string.\n recipi... | [
"0.6398173",
"0.62860376",
"0.62821066",
"0.6262946",
"0.6243486",
"0.6243401",
"0.6191331",
"0.61237687",
"0.61068827",
"0.60916877",
"0.6033017",
"0.6032903",
"0.60327256",
"0.59819627",
"0.59638673",
"0.59467804",
"0.5908018",
"0.5872774",
"0.5853226",
"0.58456683",
"0.583... | 0.0 | -1 |
Processes the email received by the MList::Server. | def process_email(email, subscriber)
recipients = list.recipients(subscriber)
process_message messages.build(
:mail_list => self,
:subscriber => subscriber,
:recipients => recipients,
:email => email
), :copy_sender => list.copy_sender?(subscriber)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_mail(mail, config)\n end",
"def receive_inbound_email_from_mail(**kwargs, &block); end",
"def process_mail(mail, config)\n end",
"def process\n parsed = {}\n parsed[:contents] = \"#{@email.subject} ::: #{@email.body}\"\n parsed[:from] = \"#{@email.from[:email]}\"\n #[:to] is an ar... | [
"0.67105305",
"0.6704208",
"0.6631321",
"0.62802464",
"0.6206252",
"0.61915076",
"0.61255157",
"0.61229783",
"0.6115969",
"0.6062662",
"0.60546124",
"0.60490656",
"0.6038545",
"0.6026178",
"0.60095584",
"0.5999877",
"0.5971041",
"0.5955457",
"0.59428436",
"0.5917347",
"0.5914... | 0.6466807 | 3 |
Answers the provided subject with superfluous 're:' and this list's labels removed. clean_subject('[List Label] Re: The new Chrome Browser from Google') => 'Re: The new Chrome Browser from Google' clean_subject('Re: [List Label] Re: The new Chrome Browser from Google') => 'Re: The new Chrome Browser from Google' | def clean_subject(string)
without_label = string.gsub(subject_prefix_regex, '')
if without_label =~ REGARD_RE
"Re: #{remove_regard(without_label)}"
else
without_label
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject_clean(subject)\n return '' if subject.blank?\n\n ticket_hook = SygiopsSupport::Setting.get('ticket_hook')\n ticket_hook_divider = SygiopsSupport::Setting.get('ticket_hook_divider')\n ticket_subject_size = SygiopsSupport::Setting.get('ticket_subject_size')\n\n # remove all possibl... | [
"0.7135233",
"0.66608185",
"0.6257178",
"0.6223467",
"0.58771783",
"0.5775358",
"0.5763737",
"0.57335246",
"0.5665581",
"0.5626435",
"0.55718213",
"0.5447046",
"0.5358902",
"0.5334072",
"0.53285927",
"0.532299",
"0.5317979",
"0.5314128",
"0.5236104",
"0.5221052",
"0.51900154"... | 0.7636132 | 0 |
The MList::List instance of the list manager. | def list
@list ||= manager_list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n @list_helper ||= ListWrapper.new(self)\n end",
"def list\n @list.nil? ? List.new : @list\n end",
"def new\n @list = List.new\n end",
"def define_list(&block)\n @list = List::Base.new(model, &block)\n end",
"def new\n @list = List.new\n end",
"def list\n ... | [
"0.77844584",
"0.7516809",
"0.7247719",
"0.710566",
"0.6937961",
"0.6919102",
"0.6906006",
"0.6654938",
"0.66280895",
"0.6599661",
"0.65787715",
"0.65721375",
"0.65721375",
"0.65430504",
"0.65415287",
"0.65198594",
"0.6518074",
"0.65118045",
"0.6510626",
"0.64977205",
"0.6415... | 0.7316944 | 2 |
Answer headers values which should be stripped from outgoing email. | def strip_headers
%w(return-receipt-to domainkey-signature dkim-signature)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrub_headers(headers)\n headers.select {|h| UserMailer.legal_headers.include? h}\n end",
"def headers\n @headers ||= begin\n @mail.header.fields.inject({}) do |memo, field|\n name = field.name.downcase.to_s\n next memo if self.class.skipped_headers.include?(name)\n\n ... | [
"0.74925417",
"0.69806767",
"0.6820429",
"0.6765788",
"0.6558968",
"0.6534521",
"0.6496803",
"0.64682406",
"0.6442433",
"0.6368016",
"0.6357242",
"0.6352929",
"0.63377213",
"0.62453717",
"0.6227568",
"0.61822546",
"0.61822546",
"0.61698854",
"0.61617815",
"0.61376923",
"0.612... | 0.7680087 | 0 |
Finalize the instance variables based on the fetched items | def finalize(fetched)
fetched == 0 && @page > 1 and raise(OverflowError.new(self), "page #{@page} got no items")
@pages = @last = (fetched > @items ? @page + 1 : @page) # set the @pages and @last
@items = fetched if fetched < @items && fetched > 0 # adjust items for last non-empty page
@from = fetched == 0 ? 0 : @offset+1 - @outset # page begins from item
@to = fetched == 0 ? 0 : @offset + @items - @outset # page ends to item
@prev = (@page-1 unless @page == 1) # nil if no prev page
@next = @page == @last ? (1 if @vars[:cycle]) : @page+1 # nil if no next page, 1 if :cycle
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finalize\n @list.each do |bp|\n bp.related_bp.each { |bp| bp.remove! }\n bp.remove!\n end\n clear\n end",
"def finalize\n @entities.clear\n end",
"def finalize!\n @_values.freeze\n end",
"def initialize()\n @items = nil\n end",
"def initialize()\n\t\t... | [
"0.62318605",
"0.6145475",
"0.611263",
"0.605794",
"0.6038065",
"0.59955746",
"0.59418404",
"0.59045935",
"0.5856873",
"0.5852319",
"0.58349836",
"0.58221203",
"0.58221203",
"0.58221203",
"0.58221203",
"0.58221203",
"0.58221203",
"0.58221203",
"0.58192694",
"0.57981336",
"0.5... | 0.61566955 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.