query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
The answer value for a provided question. Use the user answer when available, otherwise return the default
def answer_for(options, q, default = nil) options[:answers][q] ? options[:answers][q] : default end
[ "def answer_for(options, q, default = nil)\n answer = DEFAULT_ANSWERS[q]\n # check to see if there is a value for this in the provided options\n if options[:answers] && options[:answers][q]\n answer = options[:answers][q]\n end\n # use the default if we don't have anything\n if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the javascript include tag for the specified javascript from the Google Libraries API. Javascript filenames have the format ., for instance: chromeframe.1.0.2 jquery.1.6.2
def google_javascript(input) return nil if input.blank? type,version = input.split('.', 2) filename = TYPE_FILENAME_MAPPING[type] return nil if filename.blank? # We weren't able to identify the type uri = "https://ajax.googleapis.com/ajax/libs/#{type}/#{version}/#{filename}" "<script type=\"t...
[ "def g_javascript_include_tag( *sources )\n g = Guilded::Guilder.instance\n defaults = nil\n if sources.include?( :defaults )\n defaults = ActionView::Helpers::AssetTagHelper::JAVASCRIPT_DEFAULT_SOURCES\n sources.delete( :defaults )\n end\n if sources.include?( :...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Asserts that _data_value_ is of valid type. Will yield to obtain origin of value in case an error is produced
def validate_data_value(value, &block) # The DataProvider.value_type is self recursive so further recursive check of collections is needed here unless value_is_validated? || DataProvider.value_type.instance?(value) actual_type = Types::TypeCalculator.singleton.infer(value) raise Types::TypeAssertion...
[ "def verify_type(value, name, type)\n if value == nil\n raise \"Field \\\"#{name}\\\" must have a non-null value.\"\n end\n raise TypeError.new(\"Invalid data type #{value.class} for JSON field \\\"#{name}\\\": #{type} expected\") unless value.class <= type\n end", "def validate_data_vali...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create an empty file and the enclosing directory, if needed
def cf(file) FileUtils.mkdir_p(Pathname.new(file).dirname) File.open(file, "w+").close end
[ "def write\n make_parent_directory\n generate_file\n end", "def create_empty_file(file)\n path = \"#{@location}/#{file}\"\n FileUtils.touch(path)\n end", "def create_file(filename, directory)\n directory = normalize(directory)\n dir_path = \"./#{directory}/\"\n file_path = \"#...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is used to delete an email from the edit page
def delete_email check_delete_email_params Email.delete(params[:email_id]) redirect_to user_path(id: params[:user_id]) end
[ "def destroy\n @email.destroy\n respond_to do |format|\n format.html { redirect_to(contact_info_admin_emails_url) }\n format.xml { head :ok }\n end\n add_log(user: current_user, action: \"Deleted email: #{@email.email}\")\n end", "def destroy\n @email = Email.destroy(params[:id])\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is used to delete a contact from user's contacts
def delete_contact contact_delate_check(params[:user_id], params[:to_delete_id]) Contact.delete(Contact.where(from_user: params[:user_id], to_user: params[:to_delete_id])) redirect_to contacts_page_path(id: params[:user_id]) end
[ "def delete(contact)\n @contacts.delete(contact)\n end", "def delete\n @@contacts.delete(self) #I'm honestly just making an educated guess with this one. Or just a regular guess.\n end", "def delete_contact\n contact = retrieve_contact_by_email\n if contact\n if @rolodex.delete(contact)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method adds a user as contact
def add_contact check_if_myself(params[:user_id]) user = User.find(params[:user_id]) to_add = User.find(params[:to_add_id]) if to_add && user != to_add && !Contact.where(from_user: user.id).map {|c| c.to_user.id}.include?(to_add.id) user.contacts.push(to_add) user.save redirect_to contacts_page_path(id...
[ "def addContact(user)\n \tif(!self.isContact?(user))\n \t\tself.mycontacts << user\n \telse\n \t #add code to change the update code so we can track user you recently interacted with\n \tend\n end", "def add_contact(user_to_add)\n self << user_to_add\n user_to_add.contact_list << user\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is used to change the preference list of a user
def change_preference_list check_if_myself user = current_user new_preference_list = user_pref_list_params[:preference_list] if new_preference_list != user.preference_list user.update_attributes(user_pref_list_params) user.save RecomputeMeetingParticipationsJob.perform_later (0..6).to_a, user end r...
[ "def update_prefs\n current_user.preferences = params[:preferences]\n render plain: \"1\"\n end", "def preferences\n @user = current_user\n end", "def set_user_preferences(params = {})\n commit(Ebay::Requests::SetUserPreferences, params)\n end", "def remember_preference settings\n self.p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is used to create a new constraint and add it to the user's ones
def create_constraint travel_mean = params[:constraint][:travel_mean] subject = Subject.find(params[:constraint][:subject].to_i) operator = Operator.find_by(description: params[:constraint][:operator], subject_id: subject.id) value = Value.find_by(value: params[:constraint][:value], subject_id: subject.id) c ...
[ "def add_constraint(constraint); end", "def add_constraint(constraint, options = {})\n self.constraints.delete_if { |saved_constraint| saved_constraint == constraint }\n self.constraints.push(constraint)\n self.update_attributes(options)\n self.save\n end", "def add_constraint(constraint)\n\t self...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is used to delete a social form the user page
def delete_social check_if_myself(params[:user_id]) SocialUser.find(params[:social_user_id]).delete redirect_to current_user end
[ "def delete\n @profile.destroy\n redirect_to user_page_path(current_user)\n end", "def destroy\n @social_profile.destroy\n head :no_content\n end", "def delete_user\n end", "def delete_account\n @user = current_user\n if @user.tumblr_account.destroy\n flash[:notice] = 'Yo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method returns all the user to be managed by an html format page
def html_index @users = User.all end
[ "def get_page_users(context=PROFILE_CONTEXT)\n usrs = []\n Secure::UserProfile.page_users(context).each do |u|\n usrs << {username: u.username,\n display_name: u.display_name,\n user_options: u.user_options || [],\n get_content_object_url: factory.page_action_pat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method checks if the contact that the user want to delete is available in the user's contacts
def contact_delate_check(user, action_user) unless (current_user.id == user.to_i) && (current_user.contacts.where(id: action_user).count > 0) raise ActionController::RoutingError, 'Not Found' end end
[ "def can_delete?\n !closed? && contact_links.blank?\n end", "def contact_add_check(user, action_user)\n\t\tunless (current_user.id == user.to_i) && (current_user.contacts.where(id: action_user).count == 0)\n\t\t\traise ActionController::RoutingError, 'Not Found'\n\t\tend\n\tend", "def in_contact_list?(perso...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method checks if the contact that the user want to add is not yet present in the user's contacts
def contact_add_check(user, action_user) unless (current_user.id == user.to_i) && (current_user.contacts.where(id: action_user).count == 0) raise ActionController::RoutingError, 'Not Found' end end
[ "def in_contact_list?(person)\n contact_by_name(person.name) != nil\n end", "def contact_delate_check(user, action_user)\n\t\tunless (current_user.id == user.to_i) && (current_user.contacts.where(id: action_user).count > 0)\n\t\t\traise ActionController::RoutingError, 'Not Found'\n\t\tend\n\tend", "def addC...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is used to check the consistency of params used in constraint add options
def check_constraint_params params.require(:constraint).permit(:travel_mean, :subject, :operator, :value) end
[ "def check_constraint_adds; end", "def supports_check_constraints?; end", "def supports_validate_constraints?; end", "def validate_params_present!; end", "def constraint_validations; end", "def check_required_parameters()\n params_good = true\n @required_parameters.each do |req_par|\n passed_re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method is used to check the consistency of params used in deleting an email
def check_delete_email_params params.permit(:user_id, :email_id) unless (current_user.id == params[:user_id].to_i) && (current_user.emails.where(id: params[:email_id]).count > 0) raise ActionController::RoutingError, 'Not Found' end end
[ "def check_email_change\n if changed.include?('email')\n answers.destroy_all\n # Every time the email address changes, generate a new access_key\n generate_access_key\n self.email_sent_at = nil\n self.status = 'created'\n end\n end", "def check_and_clean_deleted_mem...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Some information to store in the node. Defaults to the basename of the file/directory
def value @value ||= basename end
[ "def file_name\n @info['name']\n end", "def data_filename; base_name + \".data\"; end", "def file_name\n @file_name ||= File.basename tree\n end", "def file_base_name; end", "def filename\n @properties[:filename]\n end", "def name() @filename end", "def filename\n @metadata[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
all_backlinks method (below) is currently not used. Integrate this when I want to have weighted averages based on URL backlinks.
def all_backlinks @data = UrlData.all @backlinks = Array.new @data.each do |details| @backlinks.push details.google_backlinks @backlinks.push details.moz_backlinks end @backlinks = @backlinks.compact.reject { |s| s.blank? } @backlinks = @backlinks.inject(:+) return @backlinks end
[ "def index\n @backlinks = Backlink.all\n end", "def backlink_merge_count\n counts_in_backlinks = backlinks.map {|page| page.total_backlink_count}\n indirect_backlink_total = counts_in_backlinks.inject(0) {|total, value| total + value}\n largest_count_in_backlinks = (counts_in_backlinks.max or 0)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Number of seconds from the given time until closing time.
def seconds_in_day_from(time) if @is_closed || time > time.set_time_to( @closing_time ) 0 else time.set_time_to( @closing_time ) - start_time(time) end end
[ "def seconds_until\n (start_time - Time.now).to_i\n end", "def quantity_of_seconds(time)\n time.hour * 60 + time.minute * 60 + time.second + time.second_fraction\nend", "def time_counter\n counter = Time.new.to_i - @time_counter\n return counter < 0 ? 0 : counter\n end", "def seconds_sin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Bring a time forward to the opening time if it is earlier.
def start_time(time) if time < time.set_time_to( @opening_time ) time.set_time_to( @opening_time ) else time end end
[ "def next_open_time_after(time)\n begin\n time = Time.parse(\"#{Date.new(time.year, time.month, time.day).next.to_s} #{opening_hour_on(time)}\")\n end while closed?(time)\n time\n end", "def is_before?(other_time, leeway = 5)\n other_time += leeway\n self <= other_time\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find the matching day rule. First check using the specific date as those rules have precedence over the day of the week rules.
def day_rule @day_rules[@this_day.key_by_date] || @day_rules[@this_day.key_by_day] end
[ "def get_nearest_day(date)\n\n nearest_day = nil\n\n date = UtilDate.new(date.year, date.month, date.day)\n\n if self.repeat?\n\n excepts = self.get_excepts_a\n\n self.get_rules_a.each do |rule|\n\n backward = false\n if !self.repeat_start.nil? and date.before?(self.repeat_start)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns whether this atom is equivalent to another object. This defines a helper which unwraps the inner value of the atom to compare against a literal value, saving us having to do it ourselves everywhere else.
def ==(other) @value == (other.is_a?(Atom) ? other.instance_variable_get(:@value) : other) end
[ "def equivalentValues(other) # JS == operator\n other.is_a?(Object) && unwrap.eql?(other.unwrap)\n end", "def equivalent?(other)\n Equivalence.new.call(self, other)\n end", "def ==(other)\n case other\n when Literal\n case\n when self.eql?(other)\n true\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
calls missing methods on component
def method_missing(method, *args, &block) if component.respond_to?(method) component.__send__ method, *args, &block else super end end
[ "def method_missing(method, *args, &block)\n if component.respond_to?(method)\n component.__send__ method, *args, &block\n else\n super\n end\n end", "def respond_to_missing?( meth, include_private = false )\n super || ( ( pc = prior_component ) && pc.respond_to?( meth ) )\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
format the value output depending on the metric format
def formatted_metric_value metric_value return "MISSING" unless metric_value.value case metric_value.metric.metric_format(:type) when :currency number_to_currency(metric_value.value, :unit => metric_value.metric.metric_format(:before)) when :days, :hours, :minutes, :percentage "#{metric_valu...
[ "def formatted_value\n @formatted_value\n end", "def format_measure(v)\n v\n end", "def to_s\n nr = can_display_metric? ? number_with_metric : number_with_delimiter\n \"#{nr}#{number_text}\"\n end", "def do_format(val, err_val=nil)\n if val.to_s.empty?\n return err_v...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Processed when the form is submitted, see the controller 'processFormSubmission()' method
def onSubmit(request, response, form, errors) return form end
[ "def onSubmit(request, response, form, errors)\r\n return form\r\n end", "def onSubmit(request, response, form, errors) \r\n return form\r\n end", "def submit_form\n portlet = Portlet.find(params[:id])\n @form = CustomForm.find_by_id(self.custom_form_id.to_i)\n\n @custom_form = CustomFormS...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
find or create a stack object
def stack(id) c = id.to_s.split(/[_-]/).map(&:capitalize).join # convert symbol to class string object = Stax.const_get(c) ObjectSpace.each_object(object).first || object.new([], options) end
[ "def create_stack_obj(stack_name, config)\n stack = CfnCli::Stack.new(stack_name, config)\n stack.fetch_stack_id if stack.exists?\n stack\n end", "def find_stack(stack_name)\n stacks = @client.describe_stacks()[:stacks]\n puts \"#{stacks.length} stacks found in total.\" if @verbose\n if...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return true only if all given env vars are set
def env_set?(*vars) vars.map{ |v| ENV.has_key?(v) }.all? end
[ "def env?(*keys)\n if keys.respond_to?(:all?)\n !keys.all? { |k| ENV[k].blank? }\n else\n !ENV[keys].blank?\n end\n end", "def env_vars_set?\n env_var_ids = [\n 'P_USER',\n 'P_PASSWORD',\n 'P_IP_ADDRESS',\n 'P_PORT',\n 'P_SERVER_PATH',\n 'P_SECRET'\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
fail unless given env vars are set
def ensure_env(*vars) unless env_set?(*vars) fail_task("Please set env: #{vars.join(' ')}") end end
[ "def ensure_env(envs)\n envs.each do |env|\n raise \"Variable `#{env}` is not set!\".red if !ENV[env]\n end\n true\nend", "def check_vars\n req_env_vars = ['REDMINE_BASE_URL', 'REDMINE_API_KEY', 'SLACK_WEBHOOK_URL', 'DATABASE_URL']\n missing_env_vars = req_env_vars - ENV.keys\n unless missing_env_vars.em...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Authenticate at Podio with script credentials
def authenticate sleep(3600) unless $podio_flag == true $podio_flag = true Podio.setup(:api_key => @enum_robot[:api_key], :api_secret => @enum_robot[:api_secret]) Podio.client.authenticate_with_credentials(@enum_robot[:username], @enum_robot[:password]) end
[ "def setup_credentials\n\n cmd = @config[:path] + @command_line_tool + \" \" + @@login_command\n\n Open3.popen3( cmd ) { |input, output, error|\n input.puts @config[:url]\n input.puts @config[:user]\n input.puts @config[:password]\n input.close\n } ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Queries Twitter for all the lists that this username has
def lists Rails.cache.fetch("#{owner_screen_name}.lists", :expires_in => 12.hours) do begin list = Twitter.lists(owner_screen_name) rescue Twitter::Error::TooManyRequests rescue Twitter::Error::NotFound [] end if list list.collect do |item| [item.name, item.slug] end else [...
[ "def list_tweets\n tweets\n end", "def check_lists\n PreyFetcher::protect_from_twitter do\n list_tweets = Twitter::Base.new(oauth).list_timeline(twitter_username, notification_list,\n :count => 1,\n :since_id => list_since_id\n )\n \n if list_tweets.size > 0\n send_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /weekly_updates GET /weekly_updates.json
def index @weekly_updates = WeeklyUpdate.all end
[ "def weekly_goals\n get(\"/user/#{@user_id}/activities/goals/weekly.json\")\n end", "def manager_stats_by_weekly\n get '/manager/stats/weekly'\n end", "def weekly_trends\n search_get(\"/trends/weekly.json\")\n end", "def weekly_activity_goals\n get(\"user/#{user_id}/activi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /weekly_updates/1 DELETE /weekly_updates/1.json
def destroy @weekly_update.destroy respond_to do |format| format.html { redirect_to weekly_updates_url, notice: 'Weekly update was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @extract_weekly = ExtractWeekly.find(params[:id])\n @extract_weekly.destroy\n\n respond_to do |format|\n format.html { redirect_to extract_weeklies_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @weekly_add = WeeklyAdd.find(params[:id])\r\n @wee...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
store a dream into the db. A dream has user_id(FK), user_name, content, rank(likes), privacy(boolean)
def create @user = User.find_by_id(session[:remember_token]) @p = params[:dream][:privacy] if @p == 'false' @privacy = false else @privacy = true #private, dream not visible to others end @dream = Dream.new(:name => @user.name, :user_id => @user.id, :content => params[:dre...
[ "def save\n \tCSV.open(\"./db/gossip.csv\", \"a\") do |csv|\n \t csv << [@author, @content, @id]\n \tend\n end", "def create\n @dream = current_user.dreams.new(params[:dream])\n\n respond_to do |format|\n if @dream.save\n format.html { redirect_to @dream, notice: 'Dream was successfully cre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
method for the view that shows dreams from all users
def dreamList @user = User.find_by_id(session[:remember_token]) @dreamlist = Dream.all end
[ "def index\n\t\t@dreams = Dream.all\n\tend", "def index\n @user_foods = UserFood.all\n end", "def index\n @users = User.find_all_by_admin(false)\n @episodes = Episode.find(:all)\n end", "def index\n @current_user_id = current_user.id\n @foods = Food.where(userid: @current_user_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
updates the dream based on user input
def update @dream = Dream.find(params[:id]) respond_to do |format| if @dream.update_attributes(params[:dream]) format.html { redirect_to @dream, :notice => 'Dream was successfully updated.' } format.json { head :ok } else format.html { render :action => "edit" } form...
[ "def scream\n\t\tprint \"Good choice. How many times should #{@name} scream? \"\n\t\tnumber = gets.chomp.to_i\n\t\tnumber.times { print \"\\n AAAGGGHHHHHH!! \\n\\n\" }\n\t\tputs \"Wow! That's some scary screaming #{@name}!\"\n\t\tactions[:screams] += 1\n\tend", "def update\n @dream = Dream.find(params[:id])\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
deletes a dream (recursively deletes its likes and comments first)
def destroy @dream = Dream.find(params[:id]) likes = @dream.likes.all likes.each do |l| l.destroy end comments = @dream.comments.all comments.each do |c| c.destroy end @dream.destroy redirect_to(:back) #redirects to the previous page end
[ "def destroy\n @dream = Dream.find(params[:id])\n @dream.destroy\n FileUtils.remove_file(\"public\" + PATH_TO_DREAMS + @dream.id.to_s + DREAM_EXTENSION)\n respond_to do |format|\n flash[:success] = \"Dream was successfully deleted!\"\n format.html { redirect_to dreams_url }\n format.json ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Unwrap an `AXValueRef` into the `Boxed` instance that it is supposed to be. This will only work for the most common boxed types, you will need to check the AXAPI documentation for an up to date list.
def to_ruby type = AXValueGetType(self) return self if type.zero? ptr = Pointer.new BOX_TYPES[type] AXValueGetValue(self, type, ptr) ptr.value.to_ruby end
[ "def unwrap\n @value\n end", "def process_box value\n box_type = AXValueGetType(value)\n ptr = Pointer.new BOX_TYPES[box_type]\n AXValueGetValue(value, box_type, ptr)\n ptr[0]\n end", "def unwrap(value)\n if value.instance_of?(Array) && !value.instance_of?(Hash)\n val...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Draw Name actor : actor x : draw spot xcoordinate y : draw spot ycoordinate
def draw_actor_name(actor, x, y) self.contents.font.size = Scan_Window_Font_Size self.contents.font.color = normal_color self.contents.draw_text(x, y, 120, 32, actor.name) end
[ "def draw_actor_graphic(actor, x, y)\n draw_character(actor.character_name, actor.character_index, x, y)\n end", "def draw_actor_name2 (actor,x,y)\n self.contents.font.color = normal_color\n self.contents.draw_text(x, y, 120, 32, actor.name, 2)\n end", "def draw_actor_simple_status(actor, x, y)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Draw Level actor : actor x : draw spot xcoordinate y : draw spot ycoordinate
def draw_actor_level(actor, x, y, fake = false) self.contents.font.size = Scan_Window_Font_Size self.contents.font.color = system_color name = 'Nv' size = contents.text_size(name).width self.contents.draw_text(x, y, size + 4, 32, name) self.contents.font.color = normal_color level = fake ? '...
[ "def draw_actor_level(actor, x, y)\n self.contents.font.color = system_color\n self.contents.draw_text(x, y, 32, 32, \"Lv\")\n self.contents.font.color = normal_color\n self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)\n end", "def draw_level\n # set current variable\n @level = ac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Draw Parameter actor : actor x : draw spot xcoordinate y : draw spot ycoordinate type : parameter type w : width fake : hide parameter
def draw_actor_parameter(actor, x, y, type, w = 132, fake = false) case type when 'atk' parameter_name = $data_system.words.atk parameter_value = actor.atk when 'pdef' parameter_name = $data_system.words.pdef parameter_value = actor.pdef when 'mdef' parameter_name = $data_s...
[ "def draw_parameter(x, y, type)\n case type\n when 0\n name = Vocab::atk\n value = @actor.atk\n new_value = @new_atk\n when 1\n name = Vocab::def\n value = @actor.def\n new_value = @new_def\n when 2\n name = Vocab::spi\n value = @actor.spi\n new_value = @new_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Draw HP actor : actor x : draw spot xcoordinate y : draw spot ycoordinate width : draw spot width fake : hide parameter
def draw_actor_hp(actor, x, y, width = 144, fake = false) self.contents.font.size = Scan_Window_Font_Size self.contents.font.color = system_color self.contents.draw_text(x, y, 32, 32, $data_system.words.hp) self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? c...
[ "def draw_actor_hp(actor, x, y, width = 144)\n # Draw \"HP\" text string\n self.contents.font.color = system_color\n self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)\n # Calculate if there is draw space for MaxHP\n if width - 32 >= 108\n hp_x = x + width - 108\n flag = true\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Draw SP actor : actor x : draw spot xcoordinate y : draw spot ycoordinate width : draw spot width fake : hide parameter
def draw_actor_sp(actor, x, y, width = 144, fake = false) self.contents.font.size = Scan_Window_Font_Size self.contents.font.color = system_color self.contents.draw_text(x, y, 32, 32, $data_system.words.sp) self.contents.font.color = actor.sp == 0 ? knockout_color : actor.sp <= actor.maxsp / 4 ? c...
[ "def draw_actor_sp(actor, x, y, width = 144)\n # Draw \"SP\" text string\n self.contents.font.color = system_color\n self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)\n # Calculate if there is draw space for MaxHP\n if width - 32 >= 108\n sp_x = x + width - 108\n flag = true\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Draw elemental resistance battler : actor x : draw spot xcoordinate y : draw spot ycoordinate
def draw_element_resist(battler, x, y) self.contents.font.size = Scan_Window_Font_Size max_elment = [Scan_Max_Elements_Shown, 8].min y = y + (200 - (max_elment * 25)) / 2 if battler.actor? and not $atoa_script['Atoa New Resistances'] elements = $data_classes[battler.class_id].element_ranks els...
[ "def draw_at(x, y)\r\n draw_relative(x,y)\r\n end", "def draw(x_position, y_position)\n $app.fill(rgb(255,255,255))\n\t$app.title(@number)\n #$app.oval(x_position * Game::PIECE_SIZE + Game::PIECE_SIZE, y_position * Game::PIECE_SIZE + Game::PIECE_SIZE, \n # Game::PIECE_SIZE * Game::PIECE_SCAL...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Turn a version string like "1.2.34" into an array of integers [1,2,3,4]
def to_array(version) version.split(/[.-]/).map do |x| if x =~ /\A.*([0-9]+).*\Z/ $1.to_i else 0 end end end
[ "def version_string_to_a( v )\n if v.is_a?( String )\n v.split(/[.\\-]/).map do |p|\n if p =~ /^\\d+$/\n p.to_i\n else\n p\n end\n end\n else\n v\n end\n end", "def to_a()\n major, minors = @string.split(DOT)\n versi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new user Requires: user_name, type, first_name, last_name Optional: section_name, grace_credits
def create if has_missing_params?([:user_name, :type, :first_name, :last_name]) # incomplete/invalid HTTP params render 'shared/http_status', locals: {code: '422', message: HttpStatusHelper::ERROR_CODE['message']['422']}, status: 422 return end # Check if that user_n...
[ "def new_user(user_name, first, last, password, quota=nil)\n set_values suspended: 'false', username: user_name, password: password, first_name: first, last_name: last, quota: quota\n \t\tend", "def create\n if has_missing_params?([:user_name, :type, :first_name, :last_name])\n # incomplete/in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
configure how to compute class names for events.
def compute_event_class_name(event) # User::EventStore => User::CreatedEvent self.class.name.gsub(/::EventStore/, "::#{event.to_s.camelize}Event") end
[ "def event_name(event)\n \"#{self.class.name.underscore}_#{event}\"\n end", "def add_events(*)\n super.each do |new_event|\n new_event.human_name = ->(event, klass) { translate(klass, :event, event.name) }\n end\n end", "def identifiers_for_klass(event_klass, _event = nil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Aooly the event to the aggregate and save!
def apply_event_and_save aggregate.lock! if aggregate.persisted? # Apply! event = event_class.new(aggregate, data) event.apply # record the metadata if event.respond_to?(:metadata) self.metadata.merge!(event.metadata || {}) end # Set created_at self.creat...
[ "def save(aggregate)\n new_events = aggregate.changes\n if new_events.any?\n event_sink.sink(new_events,\n expected_version: aggregate.version - new_events.count)\n end\n aggregate.clear_changes\n end", "def save(aggregate)\n transaction { track(aggregate)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Link to kata: Description: Oh no! Santa's little elves are sick this year. He has to distribute the presents on his own. But he has only 24 hours left. Can he do it? Your job is to determine if Santa can distribute all the presents in 24 hours. Your Task: You will get an array as input with time durations as string in ...
def determineTime(durations) h = [] m = [] s = [] if durations.empty? return true else durations.each do |time| split_time = time.split(":").map(&:to_i) h << split_time[0] m << split_time[1] s << split_time[2] end hours_seconds = h.inject(:+) * 3600 minutes_seconds ...
[ "def time_check(time, array)\n for i in 0...48\n if time.casecmp(array[i]) == 0\n match = false\n break\n else\n match = true\n end\n end\n\n return match\n end", "def time...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ensure rdfs label and pref label and the same.
def add_label self.rdfs_label = preflabel if preflabel.present? self.preflabel = rdfs_label if rdfs_label.present? end
[ "def add_preflabel\n self.preflabel = rdfs_label\n end", "def add_label\n self.rdfs_label = name if name.present?\n self.rdfs_label += \" (id: #{identifier.join})\" if identifier.present?\n add_preflabel\n end", "def ensure_label_has_a_value\n self.label ||= independent\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get infos about a specific tag via the hardware identifier.
def show_by_hardware_id hardware_id = params[:id] hardware_type = params[:type] # optional lang_code = params[:lang] latitude = params[:lat] longitude = params[:lon] ble_major = params[:major] ble_minor = params[:minor] error = [] if hardware_id.nil? error << 'id' end...
[ "def info(tag)\n _params = {:tag => tag}\n return @master.call 'tags/info', _params\n end", "def info(tag)\n _params = {:tag => tag}\n return @master.call 'tags/info', _params\n end", "def get_devices_by_tag(app_id, tag)\n get \"/application/#{app_id}/tag/#{tag}\"\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Show all tags from the current customer.
def show_my_tags tags = Tag.where('customer_id = ? AND active = ?', current_customer.id, true) if tags.nil? return_error_infos(400, 'No tags found', 'NoTagsFound', nil) else json_tags = [] tags.each { |tag| json_tags << create_tag_infos(tag, nil) } render :status => 200, :json => ...
[ "def list\n customers = @customers_repository.all\n @view.list(customers)\n end", "def show_contact_tags(**params)\n get('contactTags', params)\n end", "def customer_list\n perform_get_request('/customer/list')\n end", "def list\n # 1. Ask the repo to bring all customers #all...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get all supported iBeacon UUIDs from the server.
def get_all_uuids ble_uuids = Hardware.all_ble_uuids.map { |hw| hw.identifier } render :status => 200, :json => { :uuids => ble_uuids } end
[ "def zone_uuids()\n q = Net::HTTP::Get.new('/api/v5/zones')\n q['X-Api-Key'] = @apikey\n r = @api.request(q)\n return r.code, r.body\n end", "def get_uuids(count=1)\n url = \"#{@couch_db_url}/_uuids\"\n url << \"?count=#{count}\" if count > 1\n\n data = RestClie...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Increments the tag scan counter.
def tag_scanned(tag) unless tag.nil? if tag.scan_count.nil? tag.scan_count = 1 else tag.scan_count += 1 end tag.save end end
[ "def tag_increment(element)\n self.tags.each {|tagv| puts \"incrementing #{tagv} element: #{element}\" if @debug\n increment_stats(tagv,element)}\n \n end", "def increase_tagcloud_count\n if tc = Tagcloud.find_by_id( self.tagcloud_id )\n tc.tagged += 1\n tc.s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Author: Donia Magdy, Hanan Hosny Description: this action displays the Hairdressers and the results of the search filtering Params: q (this contains a hash of the search parameters that the user passes in) Success: The user gets the list of the hairdressers specified in the search params Failure: The user gets a messag...
def indexHairdressers @q = Vendor.where(entry:'Hairdresser').ransack(params[:q]) @per_page = params[:per_page] || Vendor.per_page || 20 @vendors = @q.result(:distinct=>true).paginate( :per_page => @per_page, :page => params[:page]) if @vendors.size.zero? flash[:notice] =...
[ "def search\n @uurl = params[:uurl]\n searchexpr = params[:searchexpr]\n @hpexpr = 'hpricot_object.search(' + '\"' + searchexpr + '\"' + ').to_html'\n hpricot_object = get_my_hp_elem(@uurl)\n @myhtml = hpricot_object.search(searchexpr).to_html\n render(:layout => \"nada\", :action => \"demoout\")\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Author: Donia Magdy, Hanan Hosny Description: this action displays the photographers and the results of the search filtering Params: q (this contains a hash of the search parameters that the user passes in) Success: The user gets the list of the photographers specified in the search params Failure: The user gets a mess...
def indexPhotographers @q = Vendor.where(entry:'Photographer').ransack(params[:q]) @per_page = params[:per_page] || Vendor.per_page || 20 @vendors = @q.result(:distinct=>true).paginate( :per_page => @per_page, :page => params[:page]) if @vendors.size.zero? flash[:notice] = "No Matche...
[ "def search \n filters = params[:filters] ||= {}\n thumb_image_url = nil\n \n results = {}\n results['newly_crafted'] = {}\n results['antiques'] = {}\n \n newly_crafted = Material.filter_search_results(filters,'newly_crafted')\n antique_in_title = Material.filter_search_results(filte...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Author: Donia Magdy, Hanan Hosny Description: this action displays the Djs and the results of the search filtering Params: q (this contains a hash of the search parameters that the user passes in) Success: The user gets the list of the Djs specified in the search params Failure: The user gets a message "no matches foun...
def indexDjs @q = Vendor.where(entry:'Dj').ransack(params[:q]) @per_page = params[:per_page] || Vendor.per_page || 20 @vendors = @q.result(:distinct=>true).paginate( :per_page => @per_page, :page => params[:page]) if @vendors.size.zero? flash[:notice] = "No Matches Found" end en...
[ "def search\n Log.add_info(request, params.inspect)\n\n list\n render(:action => 'list')\n end", "def list\n find = params[:find].blank? ? 0 : params[:find].to_i\n keyword = params[:keyword].blank? ? '' : params[:keyword]\n pgnum = params[:pgnum].blank? ? 1 : params[:pgnum].to_i\n pgsize = p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Author: Donia Magdy, Hanan Hosny Description: this action displays the Halls and the results of the search filtering Params: q (this contains a hash of the search parameters that the user passes in) Success: The user gets the list of the Halls specified in the search params Failure: The user gets a message "no matches ...
def indexHall @q = Vendor.where(entry:'Hall').ransack(params[:q]) @per_page = params[:per_page] || Vendor.per_page || 20 @vendors = @q.result(:distinct=>true).paginate( :per_page => @per_page, :page => params[:page]) if @vendors.size.zero? flash[:notice] = "No Matches Found" end ...
[ "def index\n @search = Hof.search(params[:q])\n @hofs = @search.result\n end", "def search\n Log.add_info(request, params.inspect)\n\n list\n render(:action => 'list')\n end", "def search\n @uurl = params[:uurl]\n searchexpr = params[:searchexpr]\n @hpexpr = 'hpricot_object.search(' + ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Author: Donia Magdy, Hanan Hosny Description: this action displays the villas and the results of the search filtering Params: q (this contains a hash of the search parameters that the user passes in) Success: The user gets the list of the Gardens specified in the search params Failure: The user gets a message "no match...
def indexGarden @q = Vendor.where(entry:'Garden').ransack(params[:q]) @per_page = params[:per_page] || Vendor.per_page || 20 @vendors = @q.result(:distinct=>true).paginate( :per_page => @per_page, :page => params[:page]) if @vendors.size.zero? flash[:notice] = "No Matches Found" ...
[ "def index\n @gardens = Garden.search(params[:query])\n end", "def search\n Log.add_info(request, params.inspect)\n\n list\n render(:action => 'list')\n end", "def index\n @cetak_gtgs = params[:q] ? CetakGtg.search_for(params[:q]) : CetakGtg.all \n end", "def index\n q_param = para...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Performs an OR operation on register_a and register_b and stores the result in "destination". Example: 725A => 0111001001011010=> OR the contents of registers 2 and 5 and store the result in register A.
def execute operand_a = @emulator.register_read(@register_a) operand_b = @emulator.register_read(@register_b) result = perform_or(operand_a, operand_b) @emulator.register_write(@destination, result) end
[ "def execute_OR(destination, source)\n\t\t# all flags are affected except AF is undefined\n\t\tdestination.value |= source.value\n\t\tset_logical_flags_from destination.value, destination.size\n\tend", "def bitwise_or(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif val == '1' || b[index] ==...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
validate that there is either a debit or credit, for each instance, not both not working
def check_only_one_entry if self.credit != nil && self.debit != nil false end end
[ "def user_has_enough_credit?\n case @campaign.payment_type\n when \"coin\"\n if @campaign.owner.coin_credit < 0\n @campaign.errors.add(:budget, :not_enough_credit)\n end\n when \"like\"\n if @campaign.owner.like_credit < 0\n @campaign.errors.add(:budget, :not_enough_credit)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /nursing_times/1 GET /nursing_times/1.json
def show @nursing_time = NursingTime.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @nursing_time } end end
[ "def new\n @nursing_time = NursingTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nursing_time }\n end\n end", "def index\n @time_entries = TimeEntry.all\n render :json => @time_entries, status: :ok\n end", "def index\n @timecards = Ti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /nursing_times/new GET /nursing_times/new.json
def new @nursing_time = NursingTime.new respond_to do |format| format.html # new.html.erb format.json { render json: @nursing_time } end end
[ "def create\n @nursing_time = NursingTime.new(params[:nursing_time])\n\n respond_to do |format|\n if @nursing_time.save\n format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully created.' }\n format.json { render json: @nursing_time, status: :created, location: @nurs...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /nursing_times POST /nursing_times.json
def create @nursing_time = NursingTime.new(params[:nursing_time]) respond_to do |format| if @nursing_time.save format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully created.' } format.json { render json: @nursing_time, status: :created, location: @nursing_time } ...
[ "def new\n @nursing_time = NursingTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nursing_time }\n end\n end", "def evening_nautical_twilight\n create_time @data['evening']['twilight']['nautical']\n end", "def create\n @timing = Timin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /nursing_times/1 PUT /nursing_times/1.json
def update @nursing_time = NursingTime.find(params[:id]) respond_to do |format| if @nursing_time.update_attributes(params[:nursing_time]) format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully updated.' } format.json { head :ok } else format.html { r...
[ "def update\n @event = Event.from_param(params[:event_id])\n @time_table = @event.time_tables.where(:permalink => params[:id]).first\n success = params[:time_table] && params[:time_table][:times] && \n @time_table.update_attributes(:times => JSON.parse(params[:time_table][:times]))\n succes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /nursing_times/1 DELETE /nursing_times/1.json
def destroy @nursing_time = NursingTime.find(params[:id]) @nursing_time.destroy respond_to do |format| format.html { redirect_to nursing_times_url } format.json { head :ok } end end
[ "def destroy\n @ignitor_time = IgnitorTime.find(params[:id])\n @ignitor_time.destroy\n\n respond_to do |format|\n format.html { redirect_to ignitor_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hurdle_time = HurdleTime.find(params[:id])\n @hurdle_time.de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create relative (user friendly) sub path for pallet below current pallet root path, without leading slash
def relative_pallet_path_for(element) sub_path = @sub_path.to_s sub_path = sub_path[1..-1] + '/' unless sub_path.blank? return sub_path << element end
[ "def base_path_to(resource = '')\n result = resource\n level.times { result = \"../#{result}\" }\n result\n end", "def construct_path_upwards(sub_file, path)\n sub_file ? \"../#{path}\" : path\n end", "def relative_path(path)\n\t\t\tcurrent_hierarchy = Quarto::Generator.current_out...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Show all recordings belonging to user (not show)
def index puts "index params = #{params}" if params[:user_id] @recordings = current_user.recordings else flash[:notice] = "You can only view recordings from your account." redirect_to user_path(current_user) end end
[ "def index\n @recording_users = RecordingUser.all\n end", "def get_recordings()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/recordings\"))[0]\n end", "def index\n @planif_records = current_user.planif_records.all\n end", "def list_recordings\n @page_title = _(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds the nth digit of Champernowne's constant. Champernowne's constant is an irrational decimal fraction created by concatenating all the positive integers: 0.12345678910111213141516.... Ex: champernowne(12) > 1
def champernowne(n) # Find which base-10 'power' n belongs to. # (if it is ones, tens, hundreds, thousands, etc) power = 0 0.step do |d| if 9*(d+1) * 10**(d) >= n power = d break end end return n if power == 0 digits = power + 1 # Get all the numbers that we've passed through before ...
[ "def find_nth_digit(n)\n base = 9\n digits = 1\n numbers_with_digits = base * digits \n while n > numbers_with_digits\n n -= numbers_with_digits\n digits += 1\n base *= 10\n numbers_with_digits = base * digits\n end\n (10 ** (digits - 1) + (n - 1) / digits).to_s[(n - 1)% digits].to_i\nend", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
handle updates AND SMS status requests
def update source = 'web' # get the parameters from the POST if params[:Body].present? && params[:From].present? # SMS message from Twilio received to webhook if params[:Body][0..2] == '999' # SMS request for status - NOT an update unique_id = params[:Body][3, (params[:Body].len...
[ "def sms_update\n # find notification through external id\n notif = Notification.find_by(sms_notification_external_id: required_params[:id])\n # log external id if notification doesn't exist\n return log_error(required_params[:notification_type]) unless notif\n\n # update notification if it exists\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates the PrismicRails::Result object with the initial documents. ==== Attributes +response+ The response of the Prismic API query
def initialize(response) if response && response.results && !response.results.empty? @documents = response.results.map do |document| PrismicRails::Document.new(document) end else #Handles the case if the response is nil or empty nil_document = PrismicRails::NilDocument.new ...
[ "def evaluate_ruby_response request, response\n result = super request, response\n if request[:page] && request[:per_page] && result[\"response\"] && result[\"response\"][\"docs\"]\n d = result['response']['docs'].extend PaginatedDocSet\n d.per_page = request[:per_page]\n d.start = re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find a specific fragment in the list of all document. ==== Examples PrismicRails::Result.find_fragment('image') This call walks through all the document and looks for a fragment with the type 'image'.
def find_fragment(type) @documents.each do |document| return document.find_fragment(type) end end
[ "def find_fragment(type)\n fragment = @document.fragments[type]\n if fragment\n PrismicRails::Fragment.new(fragment)\n else\n NilDocument.new\n end\n end", "def find_fragment(jid, node)\n raise 'subclass must implement'\n end", "def load_fragment\n images.each...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build a nicely formatted list of builtin formatter keys and their descriptions
def format_descriptions formats = MetricFu::Formatter::BUILTIN_FORMATS max = formats.keys.map(&:length).max formats.keys.sort.map do |key| " #{key}#{' ' * (max - key.length)} : #{formats[key][1]}" end end
[ "def formatters\n mentos(:get_all_formatters).inject(Hash.new) do | hash, (name, desc, aliases) |\n # Remove the long-winded and repetitive 'Formatter' suffix\n name.sub!(/Formatter$/, '')\n hash[name] = {\n :name => name,\n :description => desc,\n :aliases => al...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /safety_manuals GET /safety_manuals.json
def index @safety_manuals = SafetyManual.all end
[ "def index\n @manuals = Manual.all\n\n render json: @manuals\n end", "def index\n @manuals = Manual.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @manuals }\n end\n end", "def show\n @manual = Manual.find(params[:id])\n respond_to ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /safety_manuals POST /safety_manuals.json
def create @safety_manual = SafetyManual.new(safety_manual_params) respond_to do |format| if @safety_manual.save format.html { redirect_to @safety_manual, notice: 'Safety manual was successfully created.' } format.json { render action: 'show', status: :created, location: @safety_manual } ...
[ "def create\n @manual = Manual.new(manual_params)\n\n if @manual.save\n render json: @manual, status: :created, location: @manual\n else\n render json: @manual.errors, status: :unprocessable_entity\n end\n end", "def create\n @manual = Manual.new(manual_params)\n\n respond_to do |form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /safety_manuals/1 PATCH/PUT /safety_manuals/1.json
def update respond_to do |format| if @safety_manual.update(safety_manual_params) format.html { redirect_to @safety_manual, notice: 'Safety manual was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render ...
[ "def update\n @manual = Manual.find(params[:id])\n\n if @manual.update(manual_params)\n head :no_content\n else\n render json: @manual.errors, status: :unprocessable_entity\n end\n end", "def update\n need_edit!\n @manual = Manual.find(params[:id])\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /safety_manuals/1 DELETE /safety_manuals/1.json
def destroy @safety_manual.destroy respond_to do |format| format.html { redirect_to safety_manuals_url } format.json { head :no_content } end end
[ "def destroy\n need_admin!\n\n @manual = Manual.find(params[:id])\n @manual.destroy\n\n respond_to do |format|\n format.html { redirect_to manuals_url }\n format.json { head :ok }\n end\n end", "def destroy\n @manual = Manual.find(params[:id])\n @manual.destroy\n\n respond_to do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads language definition from the service
def fetch update_attributes(application.api_client.get( "language/#{locale}/definition", {}, { cache_key: self.class.cache_key(locale) } )) rescue Tml::Exception => ex Tml.logger.error("Failed to load language: #{ex}") self end
[ "def load_lang_file\n file_content = File.read(lang_path)\n parsed_json = JSON.parse(file_content, symbolize_names: true)\n @dictionary = parsed_json[:dictionary]\n @pluralization_rule = parsed_json[:pluralization_rule]\n\n nil\n end", "def load_language\n load_order.each do |lang|\n next ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns context by keyword
def context_by_keyword(keyword) hash_value(contexts, keyword) end
[ "def _rg_info(keyword) # :nodoc:\n _rg_inner_contexts.each do |context|\n h = context._rgc_context_info\n if h.has_key?(keyword)\n return h[keyword]\n end\n end\n nil\n end", "def _gvn_info(keyword) # :nodoc:\n _gvn_inner_contexts.each d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns context by token name
def context_by_token_name(token_name) contexts.values.detect{|ctx| ctx.applies_to_token?(token_name)} end
[ "def token(tokenname)\n @tokens[tokenname.to_sym]\n end", "def get_token(token_name)\n REPOSITEXT_TOKENS.detect { |e| token_name == e.name }\n end", "def get_contexts_named( name )\n @context_list.values.map{ |context| context if context.name == name }.compact\n end", "def find_by_token(na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return the number of hosts with data in the given set of results
def hosts_with_data(resultset) resultset.count { |_host, values| !values['data'].empty? } end
[ "def hosts_count\r\n return @hosts.length\r\n end", "def number_of_results(results)\n printf(\"\\n%<results>d results found.\\n\\n\", results: results.length)\n end", "def count\n\t\tputs \"Counting number of entries in the local host repository ...\"\n\t\tcnt=0\n\t\t@known_hosts.keys.map do |key|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /api/ratings/:id Get a specific rating
def show rating = Rating.where(rater_id: current_user.id, ratee_id: params[:id]).first render json: rating end
[ "def show\n @rating = Rating.find(params[:id])\n\n render json: @rating\n end", "def show\n @dev = User.find(params[:id])\n @ratings = RatingService::get_ratings(@dev)\n end", "def show\n @rating_alt = Rating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
searcher_class allows spree extension writers to provide their own Search class
def searcher_travel_class @searcher_travel_class ||= Spree::Core::Search::SpreeTravelBase end
[ "def searcher_class\n @searcher_class ||= Spree::Core::Search::ProductCustomeSearch\n end", "def searcher_class\n ActiveSupport::Deprecation.warn('`Spree::Config.searcher_class` is deprecated and will be removed in Spree v5, please use `Spree.searcher_class` instead.')\n @searcher_class ||= ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
initialsze Add plant to plants array
def add_plant(plant) @plants_planted << plant end
[ "def add_planets(new_planet_array)\n @planets.concat(new_planet_array)\n end", "def add_planets(planets)\n planets.each do |planet|\n @planets.push(planet)\n end\n end", "def plant_a_tree\n new_tree = [OrangeTree.new]\n @tree_array = @tree_array + new_tree\n end", "def n_plus_one_seeds\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate a header (metadata information) for all the code object types: methods, modules, commands, procs...
def header(code_object) file_name, line_num = code_object.source_file, code_object.source_line h = "\n#{Pry::Helpers::Text.bold('From:')} #{file_name} " if real_method_object?(code_object) && code_object.source_type == :c h << "(C Method):" else h << "@ line #{line_num}:" e...
[ "def header(code_object)\n file_name, line_num = file_and_line_for(code_object)\n h = \"\\n#{Pry::Helpers::Text.bold('From:')} #{file_name} \"\n if real_method_object?(code_object) && code_object.source_type == :c\n h << \"(C Method):\"\n else\n h << \"@ line #{line_num}:\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Humanize. to_s returns "true"
def to_human "yes" end
[ "def humanize(normalized)\n\t\t\t\tnormalized.to_s\n\t\t\tend", "def to_human\n @string\n end", "def human_format?\n @format == :human\n end", "def to_human\n \"\"\n end", "def to_s\n return 'true'\n end", "def human_data\n value.to_s\n end", "def to_s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Humanize. to_s returns "" as well, this is really to be consistent with other classes.
def to_human "" end
[ "def humanize(normalized)\n\t\t\t\tnormalized.to_s\n\t\t\tend", "def to_human\n @string\n end", "def to_human\n ary = map(&:string)\n np = name_from_pointer\n ary << np if np\n str = ary.join('.')\n str.empty? ? '.' : str\n end", "def default_hum...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /dynamic_images/new GET /dynamic_images/new.xml
def new @dynamic_image = DynamicImage.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @dynamic_image } end end
[ "def new\n @image = @site.images.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image }\n end\n end", "def new\n @img = Img.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @img }\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /dynamic_images POST /dynamic_images.xml
def create @dynamic_image = DynamicImage.new(params[:dynamic_image]) respond_to do |format| if @dynamic_image.save format.html { redirect_to(@dynamic_image, :notice => 'Image description successfully entered!') } format.xml { render :xml => @dynamic_image, :status => :created, :location ...
[ "def create\n @dyn_image = DynImage.new(dyn_image_params)\n\n respond_to do |format|\n if @dyn_image.save\n format.html { redirect_to @dyn_image, notice: 'Dyn image was successfully created.' }\n format.json { render :show, status: :created, location: @dyn_image }\n else\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Overrides Devise method Facebook users won't need password
def password_required? super unless has_facebook_auth end
[ "def update_with_password(params = {})\n if has_facebook_profile?\n params.delete(:current_password)\n update_without_password(params)\n else\n super\n end\n end", "def facebook_user?\n return facebook_authenticated? #encrypted_password.blank?\n end", "def password_required?\n # ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get setting default time
def get_setting_time return {setting_time: @config.encounter_duration} end
[ "def default_time\n Time.now.utc\n end", "def default_time\n Time.now.utc\n end", "def get_default_start_time(suggestion)\n if suggestion.new_record?\n return \"10:00\"\n else\n start_hour = suggestion.start.hour.to_s\n start_minutes = (suggestion.start.min < 10 ? ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get current state of the timer
def get_timer_state return current_user.timer.get_state end
[ "def current_timer; end", "def state(timer)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n if timer.handle.ptr == nil\n raise \"timer is disposed\"\n end\n result = TotalPlaytimeComponentState.new(Native.TotalPlayti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get break default time
def get_break_time return {break_time: @config.short_break_duration} end
[ "def default_time_to_run\n raise \"Not Implemented\"\n end", "def get_default_start_time(suggestion)\n if suggestion.new_record?\n return \"10:00\"\n else\n start_hour = suggestion.start.hour.to_s\n start_minutes = (suggestion.start.min < 10 ? \"0\" : \"\") << suggestion.start.min.t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This API is used to retrieve all of the profile data, associated with the specified account by email in Cloud Storage.
def get_account_profile_by_email(email, fields = '') if isNullOrWhiteSpace(email) raise LoginRadius::Error.new, getValidationMessage('email') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret query_parameters['email']...
[ "def load_profile(token)\n profile = GoogleService.user_info(token)\n email_field = profile[\"emails\"].select do |email| \n email[\"type\"] == \"account\"\n end\n\n email = email_field[0][\"value\"] if email_field && email_field.size > 0\n\n {:displayName => profile[\"displayName\"]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This API is used to retrieve all of the profile data, associated with the account by phone number in Cloud Storage.
def get_account_profile_by_phone(phone, fields = '') if isNullOrWhiteSpace(phone) raise LoginRadius::Error.new, getValidationMessage('phone') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret query_parameters['phone']...
[ "def profile\n if !defined? @profile\n request = get(\"/v1/people/~:(id,email-address,first-name,last-name,public-profile-url,picture-url)\")\n\n @profile = request.parsed_response['person']\n end\n\n return @profile\n end", "def profile_detail()\n get(\"profile\")\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This API is used to update the PhoneId by using the Uid's. Admin can update the PhoneId's for both the verified and unverified profiles. It will directly replace the PhoneId and bypass the OTP verification process.
def update_phone_id_by_uid(phone, uid, fields = '') if isNullOrWhiteSpace(phone) raise LoginRadius::Error.new, getValidationMessage('phone') end if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_param...
[ "def update_phone(user_id:, number:)\n path = '/users/{userId}/phone'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n if number.nil?\n raise Appwr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This API use to retrive the hashed password of a specified account in Cloud Storage.
def get_account_password_hash_by_uid(uid) if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret resource_path = 'identity/v2/manage/acc...
[ "def get_password_hash\n if account_password_hash_column\n account![account_password_hash_column]\n elsif use_database_authentication_functions?\n db.get(Sequel.function(function_name(:rodauth_get_salt), account ? account_id : session_value))\n else\n # :nocov:\n password_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This API is used to invalidate the Email Verification status on an account.
def invalidate_account_email_verification(uid, email_template = '', verification_url = '') if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secr...
[ "def resend_email_verification(email)\n start.uri('/api/user/verify-email')\n .url_parameter('email', email)\n .put()\n .go()\n end", "def resend_registration_verification(email, application_id)\n start.uri('/api/user/verify-registration')\n .url_parameter('email',...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This API Returns a Forgot Password Token it can also be used to send a Forgot Password email to the customer. Note: If you have the UserName workflow enabled, you may replace the 'email' parameter with 'username' in the body.
def get_forgot_password_token(email, email_template = '', reset_password_url = '', send_email = false) if isNullOrWhiteSpace(email) raise LoginRadius::Error.new, getValidationMessage('email') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecr...
[ "def forgot\n\t\tif params.key?(:email)\n\t\t\temail = params[:email]\n\t\t\tif email.blank?\n\t\t\t\t@error_manager.add_error(I18n.t(\"errors.messages.email_not_present\"))\n\t\t\t\trender json: {errors: @error_manager.get_errors}, status: :not_found\n\t\t\tend\n\t\t\tuser = User.find_by(email: email)\n\t\t\tif us...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This API Returns an Email Verification token.
def get_email_verification_token(email) if isNullOrWhiteSpace(email) raise LoginRadius::Error.new, getValidationMessage('email') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret body_parameters = {} body_param...
[ "def generate_email_authentication_token\n token = generate_token\n update(email_verification_token: BCrypt::Password.create(token))\n token\n end", "def email_verification(email)\n params={'email':email}\n get_request('emailVerification?'+get_url_parameters(params)).body\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The API is used to get LoginRadius access token based on UID.
def get_access_token_by_uid(uid) if isNullOrWhiteSpace(uid) raise LoginRadius::Error.new, getValidationMessage('uid') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret query_parameters['uid'] = uid resource_pat...
[ "def user_api_token()\n self.class.get('/user/api_token', create_params({}))['result']\n end", "def api_token\n client.get(\"/user/api_token\").fetch(\"result\")\n end", "def find_access_token(params)\n ThirdPartyAccessToken.where(provider: params[:provider], uid: params[:uid]).first\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Note: This is intended for specific workflows where an email may be associated to multiple UIDs. This API is used to retrieve all of the identities (UID and Profiles), associated with a specified email in Cloud Storage.
def get_account_identities_by_email(email, fields = '') if isNullOrWhiteSpace(email) raise LoginRadius::Error.new, getValidationMessage('email') end query_parameters = {} query_parameters['apiKey'] = @api_key query_parameters['apiSecret'] = @api_secret query_parameters['emai...
[ "def complete_email_list\n #Email.select(:email).map{|email_record| email_record.email}\n User.all.map(&:email)\n end", "def identities\n User.where(:provider => provider, :uid => uid)\n end", "def emails\n respond_with_entity(api.get('/api/v1/profile/emails'),\n Nexaa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }