query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Provides operations to manage the targetedManagedAppConfigurations property of the microsoft.graph.deviceAppManagement entity.
def targeted_managed_app_configurations() return MicrosoftGraph::DeviceAppManagement::TargetedManagedAppConfigurations::TargetedManagedAppConfigurationsRequestBuilder.new(@path_parameters, @request_adapter) end
[ "def targeted_managed_app_configurations=(value)\n @targeted_managed_app_configurations = value\n end", "def targeted_managed_app_configurations\n return @targeted_managed_app_configurations\n end", "def managed_apps=(value)\n @managed_apps = va...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Provides operations to manage the vppTokens property of the microsoft.graph.deviceAppManagement entity.
def vpp_tokens() return MicrosoftGraph::DeviceAppManagement::VppTokens::VppTokensRequestBuilder.new(@path_parameters, @request_adapter) end
[ "def vpp_tokens=(value)\n @vpp_tokens = value\n end", "def vpp_tokens\n return @vpp_tokens\n end", "def managed_app_policies()\n return MicrosoftGraph::DeviceAppManagement::ManagedAppPolicies::ManagedAppPoliciesRequestBuilder.new(@path_parameter...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Provides operations to manage the windowsInformationProtectionPolicies property of the microsoft.graph.deviceAppManagement entity.
def windows_information_protection_policies() return MicrosoftGraph::DeviceAppManagement::WindowsInformationProtectionPolicies::WindowsInformationProtectionPoliciesRequestBuilder.new(@path_parameters, @request_adapter) end
[ "def mdm_windows_information_protection_policies()\n return MicrosoftGraph::DeviceAppManagement::MdmWindowsInformationProtectionPolicies::MdmWindowsInformationProtectionPoliciesRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def windows_information_protection_policies=(va...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create custom method_missing method If the called method is not explicitly defined then it tries to find the method definition in the QUERYlike patterns. And if the method is there it builds a request based on the pattern definition.
def method_missing(method_name, *args, &block) begin invoke_query_api_pattern_method(method_name, *args, &block) rescue PatternNotFoundError super end end
[ "def method_missing method, *opt\n method.to_s =~ /^do_[A-Z]+$/ ? process_request(*opt) : super\n end", "def method_missing(method, *args)\n\t\t\t\t# To support underscores, we replace them with hyphens when calling the API\n\t\t\t\t@path_parts << method.to_s.gsub(\"_\", \"-\").downcase\n\t\t\t\t# Append ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Computes single Query API pattern parameter
def compute_query_api_pattern_param(query_api_method_name, source, params_with_defaults, used_query_params) # :nodoc: case when source.is_a?(Hash) then compute_query_api_pattern_hash_data(query_api_method_name, source, params_with_defaults, used_query_params) when source.is_a?(Array) th...
[ "def generate_query\n \n # set up for the loop\n @query_string = @base\n @query_string += @wrapped_values[:format] + @wrapped_values[:query_string] + @wrapped_values[:rank] + @wrapped_values[:api_key]\n \n end", "def fit_to_query( params )\n #This is a stub, used for indexing\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
1. sets all joinable join_requests as member/participant 2. ensure user_id has a join_request for joinable 3. sets user_id as the organizer/creator for joinable 4. create a chat_message to let people know about this new organizer/creator
def to user_id, message return yield false, USER_NOT_FOUND unless user = User.find(user_id) return yield false, INVALID_JOINABLE unless joinable_is_valid? owner_join_request = JoinRequest.where(joinable: @joinable, user_id: user_id, role: member_type).first_or_create ApplicationRecord.transact...
[ "def join!(user)\n # It loads up all the user because in the case where the chat is saved but the chat_participations have not been saved,\n # this is the only way to ensure we don't have duplicates.\n return if self.chat_participations.map(&:user_id).include?(user.id)\n self.chat_participations.create!...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read and transform a template using a map of keyvalue pairs template must refer to a relative filename (without extension ".st") that uses the syntax: $var$ (StringTemplate lib for Java)
def process_template(template_name,map) template = File.dirname(__FILE__) + "/../templates/#{template_name}.st" map['timestamp']=Time.now.httpdate File.open(template,'r') do | f | # detect words inside dollar sign pairs replaced = f.read.gsub(/(\$\w*\$)/) do | match | key = mat...
[ "def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\n end", "def template(file, temp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def Lookup the Ruby class refered to by a model name
def to_class(model_name) Kernel.const_get(model_name.to_s.camelize) end
[ "def model_class(model_name)\n class_map[model_name.to_sym] || model_name.camelize.constantize\n end", "def model(name)\n name.gsub(/\\W+/, '_').classify.constantize\n end", "def get_object(model_sym)\n object = model_sym.to_s.camelize.constantize\n end", "def dynamic_model_class_name\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new Config. The configuration is loaded from the file 'hiera.yaml' which is expected to be found in the given module_dir.
def initialize(module_dir, diagnostics) @module_dir = module_dir config_file = File.join(module_dir, 'hiera.yaml') validator = ConfigChecker.new(diagnostics) begin data = YAML.load_file(config_file) validator.validate(data, config_file) unless diagnostics.errors? ...
[ "def load_hiera\n @hiera = YAML.load_file(HIERA_CONFIG)\n end", "def create_hiera_config\n\t\t\t\ttemplate(\"node_hiera_config.yaml.erb\", \"#{name}/puppet/manifests/configuration/#{name.downcase}.#{domain.downcase}.yaml\")\n\t end", "def initialize\n @tree = YAML::parse(File.open(CONFIG_FILE))\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tunning_diagrams GET /tunning_diagrams.json GET /tunning_diagrams.xml
def index @tunning_diagrams = TunningDiagram.accessible_by(current_ability).search(params[:search]).page(params[:page]) respond_to do |format| format.html # index.html.erb format.json { render json: @tunning_diagrams } format.xml { render xml: @tunning_diagrams } end end
[ "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tunning_diagram }\n format.xml { render xml: @tunning_diagram }\n end\n end", "def index\r\n @diagrams = Diagram.all\r\n end", "def index\n @diagrams = Diagram.all\n\n respond_to do |f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tunning_diagrams/1 GET /tunning_diagrams/1.json GET /tunning_diagrams/1.xml
def show respond_to do |format| format.html # show.html.erb format.json { render json: @tunning_diagram } format.xml { render xml: @tunning_diagram } end end
[ "def index\n @tunning_diagrams = TunningDiagram.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunning_diagrams }\n format.xml { render xml: @tunning_diagrams }\n end\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tunning_diagrams/new GET /tunning_diagrams/new.json GET /tunning_diagrams/new.xml
def new respond_to do |format| format.html # new.html.erb format.json { render json: @tunning_diagram } format.xml { render xml: @tunning_diagram } end end
[ "def new\n @diagram = Diagram.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @diagram }\n end\n end", "def new\n @diagram = Diagram.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @diagram }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /tunning_diagrams/1 PUT /tunning_diagrams/1.json PUT /tunning_diagrams/1.xml
def update respond_to do |format| if @tunning_diagram.update_attributes(params[:tunning_diagram]) format.html { redirect_to @tunning_diagram, notice: I18n.t('controllers.update_success', name: @tunning_diagram.class.model_name.human) } format.json { head :no_content } format.xml { hea...
[ "def update\n @diagram = Diagram.find(params[:id])\n respond_to do |format|\n if @diagram.update_attributes(params[:diagram])\n format.html { render(:json => {:success => true}) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /tunning_diagrams/1 DELETE /tunning_diagrams/1.json DELETE /tunning_diagrams/1.xml
def destroy #@tunning_diagram = TunningDiagram.find(params[:id]) if @tunning_diagram.destroy && @tunning_diagram.destroy respond_to do |format| format.html { redirect_to tunning_diagrams_url, notice: I18n.t('controllers.destroy_success', name: @tunning_diagram.class.model_name.human) } fo...
[ "def destroy\n @diagram = Diagram.find(params[:id])\n @diagram.destroy\n\n respond_to do |format|\n format.html { redirect_to(diagrams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @diagram = Diagram.find(params[:id])\n @diagram.destroy\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Roll dices for the current round and calculates score
def roll @dice_set.clear @dice_set.roll(@available_dices) calculate_points end
[ "def score\n roll_results = @dice.map {|die| die.roll}\n points_this_turn = calculate_points(roll_results)\n add_to_total(points_this_turn)\n\n points_this_turn\n end", "def roll\n @result = dices.map(&:roll).reduce(&:+)\n @rolled_sides = dices.map(&:rolled_side)\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
send notification in french to this address
def notify_french(dest) mail(dest, FRENCH_SUBJECT, mail_content(french_model_file)) end
[ "def notify_english(dest)\n mail(dest, ENGLISH_SUBJECT, mail_content(english_model_file))\n end", "def notification(to,f)\n send_as :notification\n recipients to\n from f\n fbml \"Not\"\n end", "def notification(to,f)\n send_as :notification\n recipients t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
send notification in english to this address
def notify_english(dest) mail(dest, ENGLISH_SUBJECT, mail_content(english_model_file)) end
[ "def notify_french(dest)\n mail(dest, FRENCH_SUBJECT, mail_content(french_model_file))\n end", "def admin_broadcast(desired_locale, emails_as_string, subject, body)\n ActionMailer::Base.smtp_settings = APP_CONFIG[:admin_mail]\n set_locale( desired_locale )\n\n @content_type = \"text/html\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test that the correct sentence is chosen, given the input
def test_sentence_choice assert_equal('This is a great test', WordPlay.best_sentence(['This is a test', 'This is another test', 'This is a great test'], %w{test great this})) ...
[ "def test_sentence_choice\n assert_equal(\"This is a great sentence\", Wordplay.best_sentence([\"This is a sentence\",\n \"This is another sentence\", \"This is a great sentence\"], %w{test great this}))\n end", "def test_sentence_choice\n assert_equal('This is a great test', \n WordPlay...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test that basic pronouns are switched by switch_pronouns
def test_basic_pronouns assert_equal("i am a robot", WordPlay.switch_pronouns("you are a robot")) assert_equal("you are a person", WordPlay.switch_pronouns("i am a person")) assert_equal("i love you", WordPlay.switch_pronouns("you love me")) end
[ "def test_pronouns\n assert_equal('I am a robot', WordPlay.switch_pronouns('You are a robot'))\n assert_equal('You are a person', WordPlay.switch_pronouns('I am a person'))\n assert_equal('I love you', WordPlay.switch_pronouns('You love me'))\n assert_equal('You suck balls', WordPlay.switch_pronouns('I ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializes the bot object, loads in the external YAML data file and sets the bot's name. Raises an exception if the data loading process fails.
def initialize(options) @name = options[:name] || "Unnamed Bot" begin @data = YAML.load(File.open(options[:data_file]).read) rescue raise "Can't load bot data" end end
[ "def initialize(options)\n\t\t@name = options[:name] || \"Unnamed Bot\"\n\t\tbegin\n\t\t\t@data = YAML.load(File.read(options[:data_file]))\n\t\trescue\n\t\t\traise \"Can't load bot data\"\n\t\tend\n\tend", "def initialize(options = {})\n\t\t@name = options[:name] || \"Unnamed Bot\"\n\t\tbegin \n\t\t\t# @data = Y...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Chooses a random response phrase from the :responses hash and substitutes metadata into the phrase
def random_response(key) random_index = rand(@data[:responses][key].length) @data[:responses][key][random_index].gsub(/\[name\]/, @name) end
[ "def random_response(key)\n\t\t@data[:responses][key].sample.gsub(/\\[name\\]/, @name)\n\tend", "def random_response(key)\n\t\trandom_index = rand(@data[:responses][key].length)\n\t\t@data[:responses][key][random_index].gsub(/\\[name\\]/,@name)\n\tend", "def general_help_response\n response = AlexaRubykit::R...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Substitutes words and phrases on supplied input as dictated by the bot's :presubs data
def perform_substitutions(input) @data[:presubs].each { |s| input.gsub!(s[0], s[1]) } input end
[ "def perform_substitutions(input)\n\t\t@data[:presubs].each { |s| input.gsub!(s[0], s[1]) }\n\t\tinput\n\tend", "def translator\n # Greet your user in the language of their people.\n puts [\"SUP KID? \",\n \t \"What didja say? \",\n \t \"How ya doan? \",\n \t \"How ahrya?\",\n \t \"How 'bout them Sox? \",\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Using the single word keys from :responses, we search for the sentence that uses the most of them, as it's likely to be the 'best' sentence to parse
def best_sentence(input) hot_words = @data[:responses].keys.select do |k| k.class == String && k =~ /^\w+$/ end WordPlay.best_sentence(input.sentences, hot_words) end
[ "def possible_responses(sentence)\n responses = []\n\n # Find all patterns to try to match against\n @data[:responses].keys.each do |pattern|\n next unless pattern.is_a?(String)\n\n # For each pattern, see if the supplied sentence contains\n # a match. Remove substitution symbols (*) before checking.\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Using a supplied sentence, go through the bot's :responses data set and collect together all phrases that could be used as responses
def possible_responses(sentence) responses = [] # Find all patterns to try to match against @data[:responses].keys.each do |pattern| next unless pattern.is_a?(String) # For each pattern, see if the supplied sentence contains # a match. Remove substitution symbols (*) before checking. # Push al...
[ "def select_responses(results, query)\n sentences = results.map { |r| split_at_dot(r) }.flatten\n query_words = query.split ' '\n\n # Select the responses, only keeping the sentence that contain the search query\n selected = sentences.select do |sentence|\n query_words.all? { |w| sentence.include? ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
total number of hosts available for the specified zone. It is the same value as provided in the XQueryCount header in the list_hosts API method ==== Returns response: body 'count' 'status' 200 indicates success
def count_hosts( zone_id) request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::Zerigo::DNS::CountHosts.new, :path => "/api/1.1/zones/#{zone_id}/hosts/count.xml" ) end
[ "def count_hosts\n get(\"zones/#{id}/hosts/count.xml\").body['count'].to_i\n end", "def count_zones()\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Zerigo::DNS::CountZones.new,\n :path => \"/api/1.1/zones/count.xml\"\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ScrapsController > show_scrap_topic : Render scrap topic to browser
def show_scrap_topic render_404 and return if @scrap_topic.nil? @scraps = @scrap_topic.scraps if @scrap_topic flash[:notice] = 'This topic is empty, please add some scraps.'[:msg_empty_topic_add_scraps] if @scraps.length == 0 respond_to do |format| format.html { render :action => 'scrap_topic' an...
[ "def display_inline_scrap_topic\n respond_to do |format|\n format.html { redirect_to scrap_topic_path(@scrap.scrap_topic.slug) and return }\n format.js { @scraps = @scrap_topic.scraps if @scraps.nil?; render :partial => \"scrap\", :layout => false and return }\n format.xml { return }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ScrapsController > new_scrap_topic : Render new scrap topic form to browser
def new_scrap_topic @scrap_topic = ScrapTopic.new respond_to do |format| format.html { return } format.js { render :action => 'new_scrap_topic', :layout => false and return } format.xml { return } end end
[ "def new_topic\n frm.image(:alt=>\"New Topic\").fire_event(\"onclick\")\n frm.frame(:id, \"message___Frame\").td(:id, \"xEditingArea\").wait_until_present\n NewTopic.new(@browser)\n end", "def submit\n frm.button(:value=>\"Submit\").click\n ViewTopic.new(@browser)\n end", "def show_scrap_topic\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ScrapsController > create_scrap_topic : Create new scrap topic and render to browser
def create_scrap_topic @scrap_topic = ScrapTopic.new @scrap_topic.title = params[:scrap_topic][:title].strip @scrap_topic.user_id = current_user.id begin ScrapTopic.transaction do tag = Tag.find_or_create_by_name(params[:scrap_topic][:title].strip) @scrap_topic.save! respon...
[ "def new_scrap_topic\n @scrap_topic = ScrapTopic.new\n respond_to do |format|\n format.html { return }\n format.js { render :action => 'new_scrap_topic', :layout => false and return }\n format.xml { return }\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ScrapsController > edit_scrap_topic : Render edict scrap topic form to browser
def edit_scrap_topic if can_modify_scrap_topic? respond_to do |format| format.html { return } format.js { render :action => 'edit_scrap_topic', :layout => false and return } format.xml { return } end else render_401 and return end end
[ "def edit\n @post = @topic.posts.first\n @page_title = \"Edit Topic\"\n end", "def edit\n # @topic = @sub.topics.find(params[:id]) \n \n render component: \"TopicEdit\", props:{sub:@sub, topic:@topic}\n end", "def edit\n get_topic_for_edit(@current_id)\n end", "def edit\n frm.b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ScrapsController > update_scrap_topic : Update scrap topic and render to browser NOT IMPLEMENTED!
def update_scrap_topic # Not allowed for now render_401 and return end
[ "def edit_scrap_topic\n if can_modify_scrap_topic?\n respond_to do |format|\n format.html { return }\n format.js { render :action => 'edit_scrap_topic', :layout => false and return }\n format.xml { return }\n end\n else\n render_401 and return\n end\n end", "def updat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ScrapsController > show : Render scrap to browser, right now only used by ParallelText scraps
def show render_404 and return if @scrap.nil? respond_to do |format| format.html { redirect_to show_scrap_path(@scrap.slug) and return } format.js { render :action => "scrap", :layout => false and return } format.xml { return } end end
[ "def scrap\n target_url = CGI.unescape(params[:target_url])\n css_selector = CGI.unescape(params[:css_selector])\n @element_id = params[:ele_id]\n\n @scrapped_text = QuickScrapper.scrap(target_url, css_selector)\n first_word_index = params[:first_word_index] || 0\n last_word_index = params[:last_w...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
ScrapsController > display_inline_scrap : Renders the current scrap or scrap topic to the browser
def display_inline_scrap_topic respond_to do |format| format.html { redirect_to scrap_topic_path(@scrap.scrap_topic.slug) and return } format.js { @scraps = @scrap_topic.scraps if @scraps.nil?; render :partial => "scrap", :layout => false and return } format.xml { return } end e...
[ "def scrap\n target_url = CGI.unescape(params[:target_url])\n css_selector = CGI.unescape(params[:css_selector])\n @element_id = params[:ele_id]\n\n @scrapped_text = QuickScrapper.scrap(target_url, css_selector)\n first_word_index = params[:first_word_index] || 0\n last_word_index = params[:last_w...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(scrap_topic) init_scrap_topic : Creates a scrap topic based on the new slug
def init_scrap_topic(title, user_id) @scrap_topic = ScrapTopic.find_or_create_by_title(:title => title, :user_id => user_id, :parent_id => 0) end
[ "def setup\n return nil unless default_topic\n\n PubSubClient.upsert_topic(default_topic)\n end", "def create_topic!\n fora.post_new_topic\n end", "def create_slug\n if subject.present? && slug.blank?\n self.slug = subject.parameterize\n self.slug = truncate(slug, omission: '...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(true) autoload_scrap_data : Loads scrap / scrap_topic data into request scope
def autoload_scrap_data # # Get ScrapTopic identifier from the querystring if params[:scrap_topic_title] scrap_topic_title = params[:scrap_topic_title] elsif params[:scrap_topic_id] if params[:scrap_topic_id].class == Array scrap_topic_id = params[:scrap_topic_id][0] ...
[ "def eager_load; end", "def eager_autoload!; end", "def load_won_data\n # call loaddata\n loaddata(0)\n # redirect to auction list page\n redirect_to auctions_path\n end", "def collect_data\n #Put code to collect data here\n end", "def load_pre_requisites\n if @yaml.nil?\n @log.info...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(boolean) can_modify_scrap_topic? : Return true if current user can modify the scrap
def can_modify_scrap_topic? return (admin? or @scrap_topic.scraps.length == 0 or (logged_in? and @scrap_topic.user_id == current_user.id)) end
[ "def can_moderate_topic?(topic)\n has_bboard_permission?(topic, :can_moderate)\n end", "def permission_to_modify?\n PcpSubject.same_group?( @pcp_curr_step.acting_group_index, @pcp_viewing_group_map ) &&\n ( @pcp_subject.user_is_owner_or_deputy?( current_user, @pcp_curr_step.acting_group_index ) ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(boolean) scrap_user_logged_in? : Renders "tiddler status msg" or "tiddler msg" if not logged in
def scrap_user_logged_in?(error_in_empty_tiddler = false) if !logged_in? message = '<h3>'+'Please login first'[:error_login_first] + '</h3>' respond_to do |format| format.html { flash[:error] = message and render :action => 'create', :status => :unauthorized and return false } ...
[ "def yahoojp_logged_in_help?\n !session[:y_user_id].nil?\n end", "def check_session_status\n # @page = agent.get(\"http://www.okcupid.com/\")\n # @page_source = @page.parser.xpath(\"//html\").to_html.to_s\n\n if is_logged_in?\n \"Logged in\"\n elsif wrong_password?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run a command using 'artisan' ==== Parameters +command+ :: command to run
def artisan(command, options = {}) raise LaravelNotFoundError unless laravel_exists_in_directory?(@path) php = `which php`.strip raise RequiredLibraryMissingError, "php" unless php command = "#{php} #{@path}/artisan #{command}" output = `#{command}` puts output unless options[:quiet]...
[ "def run command\n @command_line_runner.run command\n end", "def cli_command(command)\n do_action({:action => :command, :command => command})\n end", "def run(command)\n commands << command if command != ''\n end", "def execute(command)\n invoke_command(command, nil)\n end", "def exe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the path to the local cache directory for a given Source ==== Return +string+ :: Filepath to the local cache directory
def cache_directory File.join(CacheFolder, make_md5(@source)) end
[ "def cache_directory\n end", "def source_dir\n Pathname(File.join(root, config[:source]))\n end", "def cache_path\n root.join(self[\"cache_path\"])\n end", "def cache_repository_path\n File.absolute_path(File.join(Rails.root, 'cache', cached_directory))\n end", "def cache_dir\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check whether the app directory is empty? This is useful to know if we are trying to create the new application in an empty directory or not, so that we may know if we need to create this application forcefully? ==== Return +boolean+ :: True, if the app directory is an empty one.
def create_in_empty_directory? is_empty_directory?(@path) end
[ "def empty?\n (Dir.new @path).each_child { |f| return false }\n true\n rescue Errno::ENOTDIR\n end", "def has_app?\n !!@app_dir\n end", "def in_app_root?\n # simply check if basic dirs exist\n %w{ miners lib log config config/application.rb}.each do |file|\n return f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check whether the specified source is a local directory or a URL? ==== Return +boolean+ :: True, if the source is a local directory.
def source_is_local? File.directory?(@source) end
[ "def is_local\n return @path[0,7] == \"file://\"\n end", "def valid_source?(source)\n absolute_uri?(source) ? true : ::File.exist?(source)\n end", "def local_valid_repo?\n @local_dir_path.directory?\n end", "def local_dir_exists?(full_path)\n File.directory?(full_path)\nend", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the path to a tasks file by its name ==== Parameters +name+ :: string name of the tasks file ==== Return +string+ :: path to the tasks file
def tasks_file(name) File.expand_path(File.join(@path, %w[ application tasks ], name)) end
[ "def file_name\n \"#{task_name}.rake\"\n end", "def get_task_name task_path\n task_path.match(/([^\\/]*)_task\\.rb$/)[1].to_sym\n end", "def find_task(name)\n name = name.to_sym unless name.nil?\n @tasks[name]\n end", "def find_task_by_name(name)\n tasks.find do |m|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
check if laravel framework exists in the current application's directory currently, this is performed by looking for the presence of 'artisan' file and the 'laravel' subdirectory. ==== Return +boolean+ :: true, if laravel framework exists
def has_laravel? laravel_exists_in_directory?(@path) end
[ "def laravel_exists_in_directory?(directory = nil, relative_to = nil)\n return false unless directory\n directory = File.expand_path(directory, relative_to)\n return false unless File.exists? File.join(directory, \"artisan\")\n return false unless File.directory? File.join(directory, \"laravel\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
check if the cache exists for the source specified by the current application's directory this further makes sure that the cache really has laravel framework as we would expect it to ==== Return +boolean+ :: true, if the cache exists
def has_cache? laravel_exists_in_directory?(@cache) end
[ "def cache_exist?\n File.exist?(@cache_file)\n end", "def cache_exists?\n File.exist?(cached_file)\n end", "def cache_exists_and_current\n File.exists?(cache_file)\n end", "def cached_checksum_exists?\n ::File.exists?(cached_checksum)\n end", "def caching_enabled?\n File.exist...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Depending on whether the 'force' parameter is provided, this method removes all the files in the directory specified by the application path, if the directory exists. Further, if the directory doesn't exist, it tries to create the directory specified by the application path.
def apply_force show_info "Creating application forcefully!" if @options[:force] FileUtils.rm_rf("#{@path}/.", :secure => true) if File.exists?(@path) and @options[:force] FileUtils.mkdir_p @path end
[ "def clean_app()\n wd = FileUtils.pwd()\n FileUtils.rm_f( [\n '/app/assets/*',\n '/app/components/*',\n '/app/controllers/*',\n '/app/helpers/*',\n '/app/models/*',\n '/app/views/*'\n ].collect!{|e| Dir.glob(wd + e)}.flatten.compact )\n end", "def clean_target(force = false...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method downloads or updates the local cache for the current source. If the source is a directory on this machine, it will simply not do anything since that can interfere with an offline installation, and the user must update the source manually in this case. Otherwise, it uses git to update or download the source ...
def download_or_update_local_cache # we have nothing to download if the source is a local directory return if source_is_local? # we need git for this purpose raise RequiredLibraryMissingError, "git" if `which git`.empty? # create the cache, and download or update as required FileUti...
[ "def fetch_local(new_dest, fetch_if_missing = true)\n if !File.exists? @repo.cache_path\n if fetch_if_missing\n fetch\n else\n raise \"Source cache #{@repo.cache_path} not readable.\"\n end\n end\n FileUtils.cp_r @repo.cache_path, new_dest\n end", "def fetch\n log.info(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method copies the files from the local cache to the directory of the application.
def copy_over_cache_files FileUtils.cp_r "#{@cache}/.", @path end
[ "def copy_cache\n\t @copy_cache ||= configuration[:copy_cache] == true ?\n\t File.expand_path(configuration[:application], Dir.tmpdir) :\n\t File.expand_path(configuration[:copy_cache], Dir.pwd) rescue nil\n\tend", "def copy_cache\n @copy_cache ||= configuration[:copy_cache] == true ?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method updates the permissions on the storage/ directory inside the newly created application. This method does not have a separate exposed call from the CLI. This can be skipped by passing 'noperms' flag for the 'new' command.
def update_permissions_on_storage if @options[:perms] response = system("chmod -R o+w #{File.join(@path, 'storage')}") if response say_success "Updated permissions on storage/ directory." else say_failed "Could not update permissions on storage/ directory." end ...
[ "def update_permissions\n # revoke any users that had something, but now has nothing\n revoke_user_permissions(users_to_revoke) unless users_to_revoke.empty?\n\n # set permissions for each of the permission types\n %w{full read change}.each do |perm_type|\n # set permi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Once, we are done with the intallation, and an error occurs, this method handles the clean_up routine by removing the application directory we created, as well as the local cache for the source, that may exist. Keeping the local cache does not make sense, since we anyways can not create applications based on these 'cor...
def clean_up FileUtils.rm_rf "#{@path}" unless create_in_current_directory? FileUtils.rm_rf "#{@cache}" end
[ "def cleanup\n tmpdir = File.join(OBS_BUILD_DIR,OBS_LOCAL_TMP)\n if File.exists?(tmpdir)\n FileUtils.rm_rf(tmpdir)\n end\n end", "def cleanup_app_caches(app_name, instance_name, app_name_is_dir = false)\n # TODO: this is almost-duplicat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
takes an array and splits it into left (less than) and right (greater than) by moving in from both sides, swapping values as positions move towards the midpoint
def partition_array(array, pivot) left_i = 0 right_i = (last_i = array.length - 1) # haven't crossed/met yet... while left_i < right_i while array[left_i] <= pivot && left_i < last_i left_i += 1 end while array[right_i] >= pivot && right_i > 0 right...
[ "def move_greater_to_left(array, pivot, left, right)\n\n pivot_value = array[pivot]\n #move pivot to the end\n array[pivot], array[right] = array[right], array[pivot]\n new_pivot = left\n\n for i in left..right\n\n if array[i] > pivot_value\n array[new_pivot], array[i] = array[i], array[new_pivot]\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
/Domain/EmailForward/Remove The command is intended to remove an existing Email Forwarding rule. Returned data: STATUS=SUCCESS or FAILURE TRANSACTID=Transaction ID Example return data: transactid=5c6690939950db9fad0a667eef0ebd8e status=SUCCESS
def remove_email_forward(source) validate_list([["Source", source, :email] ]) options = { "Source" => source } connection = Connection.new connection.post("Domain/EmailForward/Remove", options) end
[ "def delete_forward_email(domain,email)\n params={'domain':domain, 'email':email}\n get_request('deleteEmailForward?'+get_url_parameters(params)).body\n end", "def delete_rule!(objectID, forward_to_replicas = false, request_options = {})\n res = delete_rule(objectID, forward_to_replicas, request...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
/Domain/EmailForward/Update The command is intended to add a new Email Forwarding rule. Returned data: STATUS=SUCCESS or FAILURE TRANSACTID=Transaction ID Example return data: transactid=5c6690939950db9fad0a667eef0ebd8e status=SUCCESS
def update_email_forward(source, destination) validate_list([["Source", source, :email], ["Destination", destination, :email] ]) options = { "Source" => source, "Destination" => destination } connection = Connection.new connection.post("Domain/EmailForward/U...
[ "def updateAnsweringRuleOnRoutingExt(client, accountId, extensionId, answeringRuleId, forwardingNumberId)\n body = {\n 'enabled' => true,\n 'forwarding' => {\n 'notifyMySoftPhones' => true,\n 'softPhonesRingCount' => 5,\n 'ringingMode' => 'Sequentially',\n 'rules': [{\n 'index': 1,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
/Domain/EmailForward/List The command is intended to retrieve the list of email forwarding rules for a domain. Returned data: STATUS=SUCCESS or FAILURE RULE_[x]_SOURCE = the source for the rule [x] where [x] is a number starting with 1 and incrementing for each rule RULE_[x]_DESTINATION = the destination for rule [x] E...
def list_email_forwards(domain, range_from_optional, range_to_optional) validate_list([ ["Domain", domain, :domain_format] ]) options = { "Domain" => domain } optional_fields = [ ["rangeFrom", range_from_optional], ["rangeTo", range_to_optional] ] options = set_optional_fields(optional_fields, o...
[ "def list_email_forwards(domain)\n get_request('listEmailForwards?'+get_url_parameters({'domain':domain})).body\n end", "def list(domain, opts = {})\n call('domain.forward.list', domain.fqdn, opts).map do |forward|\n self.new(domain, forward['source'], forward)\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a collection of usersowners of apps for selection on challenge create or edit each User should be valid, i.e. to have an Org, otherwise skipped
def app_owners_for_select User.real.map { |u| [u.select_text, u.id] if u.org }.compact end
[ "def owner_choices\n choices = [[\"No change\", nil]]\n object.users.each do |u|\n choices << [\"#{u.email} - #{u.first_name} #{u.last_name}\", u.id] unless\n (u.id == object.owner.id) || (u.owns)\n end\n choices\n end", "def org_ids_that_user_is_orgUser_for\n if self.org_users == []\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /metric_sources GET /metric_sources.json
def index @metric_sources = MetricSource.all end
[ "def get_metrics_list\n\t\tjson_metrics_list \"#{@base_url}/source_list\"\n end", "def data_sources\n src.collect{|v| v['source']}\n end", "def traffic_sources\n data[:traffic_sources]\n end", "def get_sources\n response = execute_get(\"/reference/source\")\n Source.from_array(decode(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /metric_sources POST /metric_sources.json
def create @metric_source = MetricSource.new(metric_source_params) respond_to do |format| if @metric_source.save format.html { redirect_to @metric_source, notice: 'Metric source was successfully created.' } format.json { render :show, status: :created, location: @metric_source } els...
[ "def index\n @metric_sources = MetricSource.all\n end", "def get_metrics_list\n\t\tjson_metrics_list \"#{@base_url}/source_list\"\n end", "def create\n @data_source = DataSource.new(data_source_params)\n\n respond_to do |format|\n if @data_source.save\n format.html { redirect_to @da...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /metric_sources/1 PATCH/PUT /metric_sources/1.json
def update respond_to do |format| if @metric_source.update(metric_source_params) format.html { redirect_to @metric_source, notice: 'Metric source was successfully updated.' } format.json { render :show, status: :ok, location: @metric_source } else format.html { render :edit } ...
[ "def update\n @source = Source.find(params[:id])\n\n if @source.update(source_params)\n head :no_content\n else\n render json: @source.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @usage_source.update(usage_source_params)\n for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /metric_sources/1 DELETE /metric_sources/1.json
def destroy @metric_source.destroy respond_to do |format| format.html { redirect_to metric_sources_url, notice: 'Metric source was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @metadata_source = MetadataSource.find(params[:id])\n @metadata_source.destroy\n\n respond_to do |format|\n format.html { redirect_to metadata_sources_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @metric_http.destroy\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Marshals the _request_object_ to a JSON string using request_objectto_h
def marshal(request_object) JSON.pretty_generate(request_object.to_h) end
[ "def to_json(*_args)\n @request.to_json\n end", "def dump_request_object( request )\n\t\tbuf = \"-- Request -----\\n\"\n\t\tbuf << \"#{request.method} #{request.path} HTTP/#{Net::HTTP::HTTPVersion}\\n\"\n\t\trequest.each_capitalized do |k,v|\n\t\t\tbuf << \"#{k}: #{v}\\n\"\n\t\tend\n\t\tbuf << \"\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Unmarshals a JSON string into an object of type _klass_ using klass.new_from_hash
def unmarshal(json_string, klass) if json_string.nil? return nil elsif json_string.length == 0 return '' end if klass.respond_to?(:new_from_hash) klass.new_from_hash(JSON.load(json_string)) else raise NotImplementedError end e...
[ "def from_json(json:, klass:)\n hash = JSON.load(json)\n from_hash(hash: hash, klass: klass)\n end", "def deserialize(raw_data, cls)\n instance = cls.from_json_dict(JSON.parse(raw_data), nil)\n cls.from_json_dict(instance.to_json_dict(true), nil)\nend", "def make_klass(klass_hash)\n response = R...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
isMe(str) Passed a string, and returns the string as a pastel with the background depending on a randomly generated number
def isMe(str) case $prng1.rand(1..6) when 1 return $pastel.red(str) when 2 return $pastel.green(str) when 3 return $pastel.yellow(str) when 4 return $pastel.blue(str) when 5 return $pastel.magenta(str) when 6 return $pastel.cyan(str) end en...
[ "def onMe(str)\n case $prng1.rand(1..6)\n when 1\n return $pastel.on_red(str)\n when 2\n return $pastel.on_green(str)\n when 3\n return $pastel.on_yellow(str)\n when 4\n return $pastel.on_blue(str)\n when 5\n return $pastel.on_magenta(str)\n when 6\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
onMe(str) Passed a string, and returns it as a pastel string with the background changed Depending on a random number
def onMe(str) case $prng1.rand(1..6) when 1 return $pastel.on_red(str) when 2 return $pastel.on_green(str) when 3 return $pastel.on_yellow(str) when 4 return $pastel.on_blue(str) when 5 return $pastel.on_magenta(str) when 6 return $pastel.on_cy...
[ "def isMe(str)\n case $prng1.rand(1..6)\n when 1\n return $pastel.red(str)\n when 2\n return $pastel.green(str)\n when 3\n return $pastel.yellow(str)\n when 4\n return $pastel.blue(str)\n when 5\n return $pastel.magenta(str)\n when 6\n return $pastel.cy...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returnFont(str) Passed a string, and returns it as a TTYfont which always has a new line at the end, which the font is dependent on a random number
def returnFont(str) case $prng1.rand(1..5) # when 1 # $fontFont = TTY::Font.new("3d") # return $fontFont.write(str) when 2 $fontFont = TTY::Font.new(:doom) return $fontFont.write(str) when 3 $fontFont = TTY::Font.new(:standard) return $fontFont.write(str) ...
[ "def random_font_style\n if ( rand(100) > 20 )\n FontStyles[0]\n else\n FontStyles[1 + rand(FontStyles.length + 1)]\n end\n end", "def printStringRandomFont(printMe, duration)\n x = printMe.split(\", \")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
getIsMe() Returns an integer array (max 6) of user picked numbers, which corresponds to the colors that work well with the command prompt (this program has not yet been tested to work in any Linux Kernel, for reasons of lazyness) Note to self: GET THIS SHIT TO WORK, THEN MAKE EACH SELECTION REPRESENT THAT COLOR, DO THI...
def getIsMe() puts "Enter the colors you want the printed string to be" puts "1) Red\n2) Green\n3) Yellow\n4) Blue\n5) Magenta\n6) Cyan" isMeString = gets.chomp.split(", ") (0...isMeString.length()).each do |i| isMeString[i] = isMeString[i].to_i end puts "Chosen Numbers: #{isMeString}" ...
[ "def choose_colors\n 4.times do |i|\n\t\t\t@colors[i] = gets.chomp\n\t\tend\n\t\t@colors\n\tend", "def scan_for_colors; end", "def get_colors_from_player(prompt)\n\t\twhile true\n\t\t\tcolors = encode_input Mastermind.get_user_input(prompt)\n\t\t\treturn colors unless colors.nil?\n\t\t\tputs Mastermind.c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
printRandom(int duration) Passed an integer, interpreted as a duration in seconds for a while loop to run, prints out random symbols in a string array in randomly picked colors for a given duration, and then calls the menu function
def printRandom(duration) st = "q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M,1,2,3,4,5,6,7,8,9,0,!,@,#,$,%,^,&,*,(,),_,+,[,],|,{,}" x = st.split(",") currentTime = Time.now.to_i futureTime = currentTime + duration while (currentTime <= futur...
[ "def printStringRandomFont(printMe, duration)\n x = printMe.split(\", \")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime) do\n print \"#{isMe(onMe(\"\\n#{returnFont(x[$prng.rand(0...x.length())])}\\n\\n\"))}\"\n currentTime = Time.now...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
printStringS(string printMe, int duration) Passed a string and a duration, the code creates a string array split at a comma followed by a space. I know there can be some problems with this but this was the first thing that came to mind. I could use a regex but what ever. This does the same exact thing as the other prin...
def printStringS(printMe, duration) x = printMe.split(", ") currentTime = Time.now.to_i futureTime = currentTime + duration while (currentTime <= futureTime) do print "#{isMe(onMe(x[$prng.rand(0...x.length())]))}" currentTime = Time.now.to_i end menu() end
[ "def do_comma s; a = mega_pop(s); String == a.class ? s[:output] << \"#{a}\" : s[:output] << \"#{a.chr}\" end", "def parse_comma_seperated_string(s)\n list = s.split(',')\n end", "def split_timed\n scanner = StringScanner.new(text)\n tokens = []\n append = false\n will_append = false\n bracke...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
printStringFont(printMe, duration) Passed a string and a duration, the code creates an array
def printStringRandomFont(printMe, duration) x = printMe.split(", ") currentTime = Time.now.to_i futureTime = currentTime + duration while (currentTime <= futureTime) do print "#{isMe(onMe("\n#{returnFont(x[$prng.rand(0...x.length())])}\n\n"))}" currentTime = Time.now.to_i end me...
[ "def convert_time_string_to_array_font (time_string,font) \n array=[]\n for i in 0..(time_string.length-1) \n convert=convert_1_character_to_1_font(time_string[i],font)\n array.push(convert)\n end\n return array\n \nend", "def printRandomFont(duration)\n st = \"A,B,C,D,E,F,G,H,I,J,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
printRandomFont(duration) Prints random fonts in random colors. THere's a weird issue about a space at the end of the print statement and I don't like it :(
def printRandomFont(duration) st = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9" x = st.split(",") currentTime = Time.now.to_i futureTime = currentTime + duration while (currentTime <= futureTime)do print "#{isMe...
[ "def printStringRandomFont(printMe, duration)\n x = printMe.split(\", \")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime) do\n print \"#{isMe(onMe(\"\\n#{returnFont(x[$prng.rand(0...x.length())])}\\n\\n\"))}\"\n currentTime = Time.now...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Cache the first elements (if not cached already) and returns it.
def first check_corrupted cache_ele if @eles.empty? return @eles.first end
[ "def first_with_cache\n with_cache do\n first_without_cache\n end\n end", "def first(*args)\n if !defined?(yield) && args.empty?\n if o = @all.first\n _static_cache_frozen_copy(o)\n end\n else\n super\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Yields each countkey and caches element for returning it by using the []method.
def each_index(&block) enum = Enumerator.new do |yielder| begin @each_index = {} count = 0 self.each do |ele| # Remove previous element to not take up memory. count_before = count - 1 @each_index.delete(count_before) if @each_index.key?(count_before) ...
[ "def each\n kys = @cache.keys\n @db.execute(\"select id from tmud;\") do |k|\n kys << k.to_i\n end\n kys.uniq!\n kys.each {|k| yield @cache.get(k)}\n end", "def each()\n # We use delete_if to iterate the objects, and also to clear\n # any mappings for objects that have been GCed (we mig...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Caches a given amount of elements.
def cache_ele(amount = 1) begin @mutex.synchronize do while @eles.length <= amount @eles << @enum.next @length_cache += 1 end end rescue StopIteration @end = true end end
[ "def cache\n rows.each(&:cache)\n end", "def _store(*key_elements, value)\n cache.put(_key(*key_elements), value)\n end", "def cache!\n line_items.each(&:cache!)\n end", "def initialize(name, size=1000)\n @cache_list[name] = []\n @cache_list[\"#{name}_size\"] = size\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Crea los MD a partir de las ayudas de las herramientas
def create_md tool original = tool[1].split("\n") new = [] note = false # Cambia las rutas y < y > por código HTML def diple l return l.gsub('de +++YAML+++ en <http://pecas.cliteratu.re>', 'de [+++YAML+++](yaml.html)') .gsub('de JavaScript en <http://pecas.cliteratu.re>...
[ "def build_mdimages\n\n return unless options.Build_Markdown_Images\n\n puts \"#{A_CYAN}Middlemac is creating `#{options.File_Markdown_Images}`.#{A_RESET}\"\n\n files_array = []\n out_array = []\n longest_shortcut = 0\n longest_path = 0\n\n Dir.glob(\"#{app.source}/Resources/**/*.{jpg,png,gif}\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
"cache_page" alias method which effectivly forces the domain name to be prepended to the page cache path. Note that the "caches_page" method called on actions within a controller is affected by this as well
def cache_page_with_domain(content = nil, options = nil) return unless perform_caching && caching_allowed path = "/#{request.host}" path << case options when Hash url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format])) when S...
[ "def page_cache(page)\n if page\n \"/page-#{page}\"\n else\n \"\"\n end\n end", "def cache_page(content = nil, options = nil)\n return unless perform_caching && caching_allowed\n\n path = case options\n when Hash\n url_for(options.merge(:only_path => true, :sk...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If doesn't have a current appointment, was already given a dose, allow them to all changes they'd like to Otherwise check if patient can schedule (checking the conditions)
def can_update_profile? !@patient.appointments.current || # if there's no appointment, allow @patient.doses.count.positive? || # if there's already a dose, allow @patient.can_schedule? # if it's the user 1st dose and there's an appointment, check if they can still schedule end
[ "def can_cancel_and_reschedule?\n patient.doses.empty? || start < Rails.configuration.x.schedule_up_to_days.days.from_now.end_of_day\n end", "def doctor_double_booked #We check this against all of the doctors appointments \n this_start = self.start_time #Instance methods that are called on a particular do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the list of media types available for this resource to be deserialized from
def media_types Restfulie::MediaType.default_types + MediaType.medias_for(self) end
[ "def media_types\n self.class.get('/media-types', @options)\n end", "def media_types\n return @media_types\n end", "def media_types formats\n formats.map(&method(:media_type))\n end", "def supported_media_types\n Renderer.each.map{|(_,_,r)| r.mime_type}.compa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this model's custom representations. those representations were added through media_type definitions
def custom_representations @custom_representations ||= [] end
[ "def media_types\n Restfulie::MediaType.default_types + MediaType.medias_for(self)\n end", "def media_subtype; end", "def mediatype; end", "def media_type; end", "def media_models\n unescaped_json do\n {\n 'settings': {\n 'post': {\n 'id': 0 # WP auto generated cod...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Structure and Content assertions Fully assert db structure after full migration
def see_full_schema assert_schema do |s| s.table "activities" do |t| t.column "id", :integer t.column "actor_id", :integer t.column "action", :string t.column "created_at", :datetime t.column "updated_at", :datetime t.column "project_id", :integer t.colu...
[ "def test_migration\r\n ActiveRecord::Base.connection.execute(\"drop table entity_storage\")\r\n AddOldEntitiesTable.create\r\n ActiveRecord::Base.connection.execute(\"show columns from entity_storage\").each {|p| \r\n assert(p[1] == \"text\") if p[0] == \"value\" }\r\n entityStore = EntityStorage...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A simple structure to use as the content for the nodes. Create this structure for the tests ++ | ROOT | +++ | | ++ ++ CHILD1 | | ++ | | ++ ++ CHILD2 | | ++ | | ++ ++ ++ CHILD3 ++ CHILD4 | ++ ++ Some basic setup to create the nodes for the test tree.
def setup @root = Tree::TreeNode.new("ROOT", "Root Node") @child1 = Tree::TreeNode.new("Child1", "Child Node 1") @child2 = Tree::TreeNode.new("Child2", "Child Node 2") @child3 = Tree::TreeNode.new("Child3", "Child Node 3") @child4 = Tree::TreeNode.new("Child4", "Grand Child 1") @chi...
[ "def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end", "def initialize\n\t\t@root = Tree::TreeNode.new(\"ROOT\")\n\tend", "def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create the actual test tree.
def setup_test_tree @root << @child1 @root << @child2 @root << @child3 << @child4 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 root\nend", "def setup\n @root = Tree::TreeNode.new(\"ROOT\", \"Root Node\")\n\n @child1 = Tree::Tr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the equivalence of size and length methods.
def test_length_is_size setup_test_tree assert_equal(@root.size, @root.length, "Length and size methods should return the same result") end
[ "def has_size?\n return method(:size).owner != CommonTraits ||\n method(:length).owner != CommonTraits\n end", "def size(*) end", "def size?() end", "def expected_length?(length)\n expected == length\n end", "def has_size(left, right)\n _factor_predicate([:has_size, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the first_sibling method.
def test_first_sibling setup_test_tree # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings. assert_same(@root, @root.first_sibling, "Root's first sibling is itself") assert_same(@child1, @child1.first_sibling, "Child1's first sibling is itself") assert_sa...
[ "def is_first_sibling?\n first_sibling == self\n end", "def test_is_first_sibling_eh\n setup_test_tree\n\n assert(@root.is_first_sibling?, \"Root's first sibling is itself\")\n assert( @child1.is_first_sibling?, \"Child1's first sibling is itself\")\n assert(!@child2.is_first_sibling?,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the is_first_sibling? method.
def test_is_first_sibling_eh setup_test_tree assert(@root.is_first_sibling?, "Root's first sibling is itself") assert( @child1.is_first_sibling?, "Child1's first sibling is itself") assert(!@child2.is_first_sibling?, "Child2 is not the first sibling") assert(!@child3.is_first_sibling?, "C...
[ "def is_first_sibling?\n first_sibling == self\n end", "def first_child?\n sibling_index.zero?\n end", "def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"R...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the is_last_sibling? method.
def test_is_last_sibling_eh setup_test_tree assert(@root.is_last_sibling?, "Root's last sibling is itself") assert(!@child1.is_last_sibling?, "Child1 is not the last sibling") assert(!@child2.is_last_sibling?, "Child2 is not the last sibling") assert( @child3.is_last_sibling?, "Child3's l...
[ "def is_last_sibling?\n last_sibling == self\n end", "def isLastSibling?\r\n lastSibling == self\r\n end", "def last_child?\n parent && sibling_index == parent.children.length - 1\n end", "def last_sibling\n root? ? self : @_node_parent.children.last\n end", "def test_last_siblin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the last_sibling method.
def test_last_sibling setup_test_tree assert_same(@root, @root.last_sibling, "Root's last sibling is itself") assert_same(@child3, @child1.last_sibling, "Child1's last sibling should be child3") assert_same(@child3, @child2.last_sibling, "Child2's last sibling should be child3") assert_sa...
[ "def is_last_sibling?\n last_sibling == self\n end", "def last_sibling\n root? ? self : @_node_parent.children.last\n end", "def isLastSibling?\r\n lastSibling == self\r\n end", "def test_is_last_sibling_eh\n setup_test_tree\n\n assert(@root.is_last_sibling?, \"Root's last siblin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the siblings method, which is essentially an iterator.
def test_siblings setup_test_tree # Lets first collect the siblings in an array. siblings = [] @child1.siblings { |sibling| siblings << sibling} assert_equal(2, siblings.length, "Should have two siblings") assert(siblings.include?(@child2), "Should have 2nd child as sibling") ...
[ "def siblings\n SiblingsAccessor.new(self)\n end", "def next_sibling()\n #This is a stub, used for indexing\n end", "def have_sibling(...)\n Matchers::HaveSibling.new(...)\n end", "def siblings(selector = nil)\n \t invoke [\"siblings\", selector], :flatten_uniq => t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the is_only_child? method.
def test_is_only_child_eh setup_test_tree assert( @root.is_only_child? , "Root is an only child") assert(!@child1.is_only_child?, "Child1 is not the only child") assert(!@child2.is_only_child?, "Child2 is not the only child") assert(!@child3.is_only_child?, "Child3 is not the only child"...
[ "def isOnlyChild?\r\n parent.children.size == 1\r\n end", "def isOnlyChild?\n parent.children.size == 1\n end", "def is_only_child?\n return false if parent.nil? # root\n 1 == parent.children.size\n end", "def is_only_child?\n is_root? ? true : parent.children.size == 1\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the next_sibling method.
def test_next_sibling setup_test_tree assert_nil(@root.next_sibling, "Root does not have any next sibling") assert_equal(@child2, @child1.next_sibling, "Child1's next sibling is Child2") assert_equal(@child3, @child2.next_sibling, "Child2's next sibling is Child3") assert_nil(@child3.next...
[ "def next_sibling()\n #This is a stub, used for indexing\n end", "def next_sibling\r\n find(:xpath, \"following-sibling::*[1]\")\r\n end", "def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend", "def next_sibling\n return @links[:next_sibling]\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the previous_sibling method.
def test_previous_sibling setup_test_tree assert_nil(@root.previous_sibling, "Root does not have any previous sibling") assert_nil(@child1.previous_sibling, "Child1 does not have previous sibling") assert_equal(@child1, @child2.previous_sibling, "Child2's previous sibling is Child1") asse...
[ "def previous_sibling\n return @links[:previous_sibling]\n end", "def sibling_prev\n @parent.get(index - 1) unless is_first_sibling?\n end", "def prev_sibling_of(node)\n\t\treturn valid(node) ? node.previous_sibling : nil\n\tend", "def previous_sibling\n return nil if is_root?\n\n my...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the remove_from_parent! method.
def test_remove_from_parent_bang setup_test_tree assert(@root.has_children?, "Should have children") assert(!@root.is_leaf?, "Root is not a leaf here") child1 = @root[0] assert_not_nil(child1, "Child 1 should exist") assert_same(@root, child1.root, "Child 1's root should be ROOT") ...
[ "def remove_from_parent!\n @parent.remove!(self) unless root?\n end", "def remove_from_parent!\n @parent.remove!(self) unless is_root?\n end", "def removeFromParent\n @parent.remove(self) if @parent\n end", "def remove\r\n return unless parent? # No need to remove if parentless\r\n\r\n p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the first_child method.
def test_first_child setup_test_tree assert_equal(@child1, @root.first_child, "Root's first child is Child1") assert_nil(@child1.first_child, "Child1 does not have any children") assert_equal(@child4, @child3.first_child, "Child3's first child is Child4") end
[ "def test_first_sibling\n setup_test_tree\n\n # TODO: Need to fix the first_sibling method to return nil for nodes with no siblings.\n assert_same(@root, @root.first_sibling, \"Root's first sibling is itself\")\n assert_same(@child1, @child1.first_sibling, \"Child1's first sibling is itself\")\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the last_child method.
def test_last_child setup_test_tree assert_equal(@child3, @root.last_child, "Root's last child is Child3") assert_nil(@child1.last_child, "Child1 does not have any children") assert_equal(@child4, @child3.last_child, "Child3's last child is Child4") end
[ "def test_last_sibling\n setup_test_tree\n\n assert_same(@root, @root.last_sibling, \"Root's last sibling is itself\")\n assert_same(@child3, @child1.last_sibling, \"Child1's last sibling should be child3\")\n assert_same(@child3, @child2.last_sibling, \"Child2's last sibling should be child3\")...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the each_leaf method.
def test_each_leaf setup_test_tree nodes = [] @root.each_leaf { |node| nodes << node } assert_equal(3, nodes.length, "Should have THREE LEAF NODES") assert(!nodes.include?(@root), "Should not have root") assert(nodes.include?(@child1), "Should have child 1") assert(nodes.incl...
[ "def each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end", "def each_leaf(&block)\n each_leaf_node([], @root, block)\n end", "def each_leaf &block\n if block_given?\n self.each { |node| yield(node) if node.is_leaf? }\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the print_tree method.
def test_print_tree setup_test_tree #puts #@root.print_tree end
[ "def print_tree\n @tree.print_tree\n end", "def print_tree\n space = 0\n print_tree_helper(@root, space)\n end", "def print_tree\n if root.children\n puts \" - root : #{root.children.length} - \"\n root.children.each(&:print_node)\n puts ''\n end\n end", "def pri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tests the binary dumping mechanism with an Object content node
def test_marshal_dump # Setup Test Data test_root = Tree::TreeNode.new("ROOT", "Root Node") test_content = {"KEY1" => "Value1", "KEY2" => "Value2" } test_child = Tree::TreeNode.new("Child", test_content) test_content2 = ["AValue1", "AValue2", "AValue3"] test_grand_child = Tree::...
[ "def can_be_fully_dumped?(object)\n begin\n Marshal.dump(object)\n true\n rescue TypeError, IOError\n false\n end\n end", "def marshal_dump; end", "def objdump_io(io)\n ((io.respond_to? :path) && io.path) ? objdump_path(io.path) : \n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test freezing the tree
def test_freeze_tree_bang setup_test_tree @root.content = "ABC" assert_equal("ABC", @root.content, "Content should be 'ABC'") @root.freeze_tree! # Note: The error raised here depends on the Ruby version. # For Ruby > 1.9, RuntimeError is raised # For Ruby ~ 1.8, TypeError is r...
[ "def freezeTree!\r\n each {|node| node.freeze}\r\n end", "def freezeTree!\n each {|node| node.freeze}\n end", "def freeze_tree!\n each {|node| node.freeze}\n end", "def test_thread_for_recursion\n assert_nothing_thrown do\n depth = 1000 # Use a reasonably large ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run the assertions for the deprecated depth method.
def do_deprecated_depth assert_equal(1, @root.depth, "A single node's depth is 1") @root << @child1 assert_equal(2, @root.depth, "This should be of depth 2") @root << @child2 assert_equal(2, @root.depth, "This should be of depth 2") @child2 << @child3 assert_equal(3, @root.d...
[ "def verify_depth(*) end", "def verify_depth=(p0) end", "def check_depth(expected_depth)\r\n if expected_depth - self.depth != 0\r\n error \"F12: Error, Invalid control/structure nesting.\"\r\n end\r\n end", "def update_depth\n @depth = 1\n end", "def test_it_reports_accurate_dep...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the depth computation algorithm. Note that this is the correct depth computation. The original Tree::TreeNodedepth was incorrectly computing the height of the node instead of its depth.
def test_node_depth assert_equal(0, @root.node_depth, "A root node's depth is 0") setup_test_tree for child in [@child1, @child2, @child3] assert_equal(1, child.node_depth, "Node #{child.name} should have depth 1") end assert_equal(2, @child4.node_depth, "Child 4 should have dep...
[ "def test_it_reports_accurate_depth_of\n skip\n @tree.insert(61, \"Bill & Ted\")\n @tree.insert(16, \"Johnny English\")\n @tree.insert(92, \"Sharknado 3\")\n @tree.insert(50, \"Hannibal Buress: Animal Furnace\")\n\n assert_equal 1, @tree.depth_of(92)\n assert_equal 2, @tree.depth_of(50)\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the level method. Since this is an alias of node_depth, we just test for equivalence
def test_level assert_equal(0, @root.level, "A root node's level is 0") assert_equal(@root.node_depth, @root.level, "Level and depth should be the same") setup_test_tree for child in [@child1, @child2, @child3] assert_equal(1, child.level, "Node #{child.name} should have level 1") ...
[ "def test_level\n # draw new level if level has changed\n draw_level if actor.level != @level\n end", "def verify_depth(*) end", "def check_level(level) \r\n if level != @level\r\n fail XfOOrthError, \"Nesting Error: #{@level} vs #{level}\"\r\n end\r\n end", "def node_depth()\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the breadth computation algorithm
def test_breadth assert_equal(1, @root.breadth, "A single node's breadth is 1") @root << @child1 assert_equal(1, @root.breadth, "This should be of breadth 1") @root << @child2 assert_equal(2, @child1.breadth, "This should be of breadth 2") assert_equal(2, @child2.breadth, "This sho...
[ "def breadth_first\n @breadth_first = true\n end", "def test_bfs_no_path\n a = @graph.insertNode(\"A\")\n b = @graph.insertNode(\"B\")\n c = @graph.insertNode(\"C\")\n d = @graph.insertNode(\"D\")\n e = @graph.insertNode(\"E\")\n\n @graph.insertEdge(a, b)\n @graph.insertEdge(a, c)\n @g...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the breadth for each
def test_breadth_each j = Tree::TreeNode.new("j") f = Tree::TreeNode.new("f") k = Tree::TreeNode.new("k") a = Tree::TreeNode.new("a") d = Tree::TreeNode.new("d") h = Tree::TreeNode.new("h") z = Tree::TreeNode.new("z") # The expected order of response expected_array...
[ "def breadth_first\n @breadth_first = true\n end", "def test_breadth\n assert_equal(1, @root.breadth, \"A single node's breadth is 1\")\n\n @root << @child1\n assert_equal(1, @root.breadth, \"This should be of breadth 1\")\n\n @root << @child2\n assert_equal(2, @child1.breadth, \"This...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the preordered_each method.
def test_preordered_each j = Tree::TreeNode.new("j") f = Tree::TreeNode.new("f") k = Tree::TreeNode.new("k") a = Tree::TreeNode.new("a") d = Tree::TreeNode.new("d") h = Tree::TreeNode.new("h") z = Tree::TreeNode.new("z") # The expected order of response expected_ar...
[ "def preordered_each &block # :yields: node\n each(&block)\n end", "def test_40_EachWithSkip\n\t\tprintTestHeader \"Template Iterator: Each with Skip\"\n\t\trval = nil\n\n\t\tcount = 0\n\t\t@iter.iterate do |iter, item|\n\t\t\tcount += 1\n\t\t\tassert iter.skipped?, \"Iterator#skipped? was not set.\" if\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }