query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
GET /stories/1/chapters/all GET /stories/1/all
def showall session[:adult] = true if params[:adult] if @story.is_adult? && !can_see_adult? @page_title = 'Warning' render 'users/adulttemp' else @page_title = @story.title render :show, locals: { chapters: @story.get_chapters } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @chapters = Chapter.all\n end", "def index\n @course = Course.find(params[:course_id])\n @chapters = @course.chapters\n end", "def index\n @chapters = @book.chapters\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chapters }\n en...
[ "0.71855634", "0.7164543", "0.7064827", "0.7064827", "0.6989245", "0.6989245", "0.6989245", "0.6989245", "0.6989245", "0.6989245", "0.69878286", "0.6817308", "0.6810551", "0.6763531", "0.67417914", "0.6710561", "0.6710561", "0.66886646", "0.6666882", "0.66522294", "0.6633266"...
0.59180814
77
POST /stories POST /stories.json
def create @story = Story.new(story_params) if @story.valid? current_user.stories << @story redirect_to @story else # @errors = @story.errors.messages render :new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @story = Story.new(story_params)\n if @story.save\n render json: @story, status: :ok\n else\n render json: @story.errors, status: :unprocessable_entity\n end\n end", "def create\n @story = Story.new(params[:story])\n\n respond_to do |format|\n if @story.save\n ...
[ "0.772964", "0.76415455", "0.7610398", "0.7505145", "0.74521095", "0.7439946", "0.7439946", "0.73842067", "0.73842067", "0.73842067", "0.7328209", "0.7292121", "0.7206045", "0.69638777", "0.6957411", "0.692288", "0.6892234", "0.68875116", "0.6872017", "0.6849194", "0.6840574"...
0.67087775
27
PATCH/PUT /stories/1 PATCH/PUT /stories/1.json
def update #we do this here rather than in the model because we don't want timestamps #to update when tag implications are changed old_holder = {} assocs = %w[tag character source] # old_tags = @story.tag_ids.sort assocs.each do |assoc| old_holder[assoc] = @story.send((assoc + '_ids').to_sym).sort end pars = story_params if @story.update(pars) assocs.each do |assoc| #need to do this to force Rails to refresh from the DB @story.send((assoc + 's').to_sym).reload new_holder = @story.send((assoc + '_ids').to_sym).sort @story.touch unless old_holder[assoc] == new_holder end redirect_to @story, notice: 'Story was successfully updated.' else render :edit end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @story.update(story_params)\n format.json { render json: @story, root: false, status: :ok, location: @story }\n else\n format.json { render json: @story.errors, root: false, status: :unprocessable_entity }\n end\n end\n end", "def upda...
[ "0.7267746", "0.7099299", "0.7072093", "0.7072093", "0.706577", "0.70631224", "0.7057944", "0.7057944", "0.69516414", "0.6916157", "0.6916157", "0.6916157", "0.6916157", "0.69078785", "0.68319225", "0.68319225", "0.68319225", "0.68319225", "0.68319225", "0.6823768", "0.674233...
0.0
-1
DELETE /stories/1 DELETE /stories/1.json
def destroy @story.destroy redirect_to stories_path # respond_to do |format| # format.html { redirect_to stories_url, notice: 'Story was successfully destroyed.' } # format.json { head :no_content } # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_story(id)\n @client.raw('delete', \"/content/stories/#{id}\")\n end", "def destroy\n @story = Story.find(params[:id])\n @story.destroy\n\n respond_to do |format|\n format.html { redirect_to stories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @story = S...
[ "0.8022553", "0.7939624", "0.7939624", "0.7932404", "0.7932404", "0.7932404", "0.7932404", "0.7932064", "0.7927896", "0.7873805", "0.7873805", "0.7873805", "0.77658767", "0.7757827", "0.7713006", "0.7713006", "0.7713006", "0.76207054", "0.7600566", "0.7600566", "0.7600566", ...
0.73521495
36
todo: do we always need tags?
def set_story @story = Story.find(params[:id]) @tags = @story.tags end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag; end", "def tag; end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def tagged?; end", "def tag_name; end", "def tag_name; end", "def tag_name; end", "def tag(tag); end", "def tag(tag); end", "def tag(name); end", "def tag\n end", "d...
[ "0.7914961", "0.7914961", "0.76468027", "0.76468027", "0.76468027", "0.76468027", "0.76468027", "0.7600823", "0.7528347", "0.7528347", "0.7528347", "0.74943966", "0.74943966", "0.74654865", "0.7345116", "0.7345116", "0.72881633", "0.7261277", "0.72215647", "0.72203225", "0.71...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_project @project = FortyTwo::Project.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) min = nil out = nil name_hash.each{|k,v,i| #puts i if !min||v<min out=k min=v end } out end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n...
[ "0.8821222", "0.8777674", "0.87769854", "0.8745862", "0.8689437", "0.86553806", "0.865241", "0.86165065", "0.8587693", "0.8572328", "0.85674095", "0.8550907", "0.8529734", "0.8529734", "0.85182345", "0.84936565", "0.8475531", "0.8475531", "0.8466132", "0.8449126", "0.84490585...
0.0
-1
Remind user to fill in payment details
def payment_settings_reminder(listing, recipient, community) set_up_layout_variables(recipient, community) with_locale(recipient.locale, community.locales.map(&:to_sym), community.id) do @listing = listing @recipient = recipient if community.payments_in_use? @payment_settings_link = paypal_account_settings_payment_url(recipient, @url_params.merge(locale: recipient.locale)) end premailer_mail(:to => recipient.confirmed_notification_emails_to, :from => community_specific_sender(community), :subject => t("emails.payment_settings_reminder.remember_to_add_payment_details")) do |format| format.html {render :locals => {:skip_unsubscribe_footer => true} } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def payment_params\n params.require(:payment).permit(:first_name, :last_name, :last4, :card_security_code, :credit_card_number, :expiration_month, :expiration_year, :amount, :amount, :success, :authorization_code, :user_id, :notify, :parking_id)\n end", "def payment_form \n unless params[:payment_meth...
[ "0.6366082", "0.6306154", "0.62494206", "0.62494206", "0.62494206", "0.62202424", "0.62132996", "0.6206791", "0.61795735", "0.6153279", "0.61506045", "0.60996294", "0.60972005", "0.6079605", "0.60698265", "0.6047013", "0.6025383", "0.6025383", "0.6025342", "0.60138553", "0.60...
0.0
-1
Remind users of conversations that have not been accepted or rejected
def confirm_reminder(conversation, recipient, community, days_to_cancel) @email_type = "email_about_confirm_reminders" recipient = conversation.buyer set_up_layout_variables(recipient, community, @email_type) with_locale(recipient.locale, community.locales.map(&:to_sym), community.id) do @conversation = conversation @days_to_cancel = days_to_cancel template = "confirm_reminder" premailer_mail(:to => recipient.confirmed_notification_emails_to, :from => community_specific_sender(community), :subject => t("emails.confirm_reminder.remember_to_confirm_request")) do |format| format.html { render template } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_pending\n if user.incoming_friend_requests.pluck(:user_id).include?(friend_id)\n errors.add(:friend, 'already requested friendship')\n end\n end", "def user_candidates_for_reminder\n states = ['submitted', 'under_review', 'reviewed', 'scheduled', 'received',\n 'receiving', 'inactive']...
[ "0.6336204", "0.6250958", "0.6188405", "0.6093664", "0.607747", "0.60472023", "0.6013192", "0.5955956", "0.5931874", "0.59276783", "0.58668715", "0.5860761", "0.5856417", "0.5840829", "0.58334833", "0.5832425", "0.5827985", "0.5823412", "0.5819636", "0.58138144", "0.58131665"...
0.0
-1
Remind users to give feedback
def testimonial_reminder(conversation, recipient, community) @email_type = "email_about_testimonial_reminders" set_up_layout_variables(recipient, community, @email_type) with_locale(recipient.locale, community.locales.map(&:to_sym), community.id) do @conversation = conversation @other_party = @conversation.other_party(recipient) premailer_mail(:to => recipient.confirmed_notification_emails_to, :from => community_specific_sender(community), :subject => t("emails.testimonial_reminder.remember_to_give_feedback_to", :name => @other_party.name(community))) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feedback\n end", "def feedback\n if correct?\n \"Correct!\"\n else\n \"Incorrect.\"\n end\n end", "def ask_for_feedback\n feedback = show do\n title \"We want your feedback\"\n \n note \"Notice anything weird with this protocol? Tell us below!\"\n \n get \"t...
[ "0.75590616", "0.72524184", "0.700369", "0.689417", "0.6792127", "0.66878545", "0.6589748", "0.65879005", "0.65505856", "0.65366846", "0.63776594", "0.63468504", "0.63351595", "0.63336164", "0.6292917", "0.62878555", "0.6244287", "0.62211484", "0.62141013", "0.61952555", "0.6...
0.0
-1
A message from the community admin to a single community member
def community_member_email(sender, recipient, email_subject, email_content, community) @email_type = "email_from_admins" set_up_layout_variables(recipient, community, @email_type) with_locale(recipient.locale, community.locales.map(&:to_sym), community.id) do @email_content = email_content @no_recipient_name = true premailer_mail(:to => recipient.confirmed_notification_emails_to, :from => community_specific_sender(community), :subject => email_subject, :reply_to => "\"#{sender.name(community)}\"<#{sender.confirmed_notification_email_to}>") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toAdmin(message, sessionID); end", "def send_message\n if self.id != 1\n admin_sender = User.find(1)\n user_receiver = self\n message = Message.new\n message.subject = \"It's Official! You're in.\"\n message.body = \"As a member of the VVI community, you're now able to contact oth...
[ "0.69996977", "0.6514049", "0.64130527", "0.6235058", "0.6199979", "0.61757517", "0.6167339", "0.61649907", "0.6161816", "0.61119807", "0.6028942", "0.5988112", "0.5963588", "0.59412575", "0.59313", "0.59161735", "0.590218", "0.5892836", "0.5865745", "0.5852454", "0.5837331",...
0.6207532
4
Used to send notification to marketplace admins when somebody gives feedback on marketplace throught the contact us button in menu
def new_feedback(feedback, community) subject = t("feedback.feedback_subject", service_name: community.name(I18n.locale)) premailer_mail( :to => mail_feedback_to(community, APP_CONFIG.feedback_mailer_recipients), :from => community_specific_sender(community), :subject => subject, :reply_to => feedback.email) do |format| format.html { render locals: { author_name_and_email: feedback_author_name_and_email(feedback.author, feedback.email, community), community_name: community.name(I18n.locale), content: feedback.content } } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_place_notification (merchant)\n @merchant = merchant\n mail to: \"sales@halalfoodhunt.com\", subject: \"A Place Has Been Listed\"\n end", "def send_new_listing_notification(merchant)\n @merchant = merchant\n mail to: \"sales@halalfoodhunt.com\", subject: \"A New Merchant has Subscribed!...
[ "0.72407365", "0.69117635", "0.68208724", "0.68143266", "0.6732151", "0.67313135", "0.67008173", "0.65841204", "0.65726763", "0.65551627", "0.655344", "0.6519822", "0.64797235", "0.6479473", "0.6476382", "0.64703166", "0.6464862", "0.64602184", "0.6451091", "0.644801", "0.641...
0.0
-1
returns an array [modified+created, unmodified]
def changes map_old, map_new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modified; status[:modified] || []; end", "def altered_files; (modified + added + removed).sort; end", "def records_modified_since(time)\n []\n end", "def changes\n if @changes\n @changes.dup\n else\n []\n end\n end", "def modifications\n\t\treturn unless ...
[ "0.72220534", "0.6679927", "0.63646764", "0.63503003", "0.62643516", "0.6230171", "0.61744183", "0.6172236", "0.6093904", "0.60706997", "0.6051089", "0.6034168", "0.6034168", "0.6017387", "0.60041773", "0.5962602", "0.5957802", "0.5931494", "0.59259194", "0.58846426", "0.5876...
0.0
-1
Need a list of modified files (and unmodified files), given two release maps in opt.temp, clone opt.repo (with n) check out .gitignore from git check out unmodified files from git check out modified or created files from CMVC commit changes to master push branch to opt.repo ideally, we'd break down changed files by track which is to say, partition changes by track, create a branch for each, commit the changes to git Get the latest cmvc level for a release
def cmvc_level release ctx = Cmvc::Context.new(nil, nil, $mode) level = nil ctx.last_levels(release, 1) do |levels| level = levels.first.first end.exec return level end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def altered_files; `git show --name-only #{node} 2> /dev/null`.split(\"\\n\"); end", "def get_files_modified\r\n\tgit_result = IO.popen('git status -u --porcelain').read\r\n\tgit_result.split(/[\\r\\n]+/).uniq.map!{|file| file.slice 3..-1}\r\nend", "def modified_files\n `git diff --cached --name-only --...
[ "0.6874815", "0.6756286", "0.6678458", "0.6676507", "0.66698843", "0.6669238", "0.66395247", "0.655419", "0.6525738", "0.65114194", "0.6443683", "0.6425097", "0.63479257", "0.6331621", "0.6288034", "0.62513334", "0.6223704", "0.6194635", "0.6160352", "0.6111632", "0.610395", ...
0.0
-1
Get the latest level checked into git
def git_level # Assumes PWD is a valid git repo return nil unless File.exists? ".git/current_cmvc_level" return File.read(".git/current_cmvc_level").chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_tree_sha\n sha = nil\n trees = open('https://api.github.com/repos/twitter/bootstrap/git/trees/master').read\n trees = JSON.parse trees\n trees['tree'].find{|t| t['path'] == 'less'}['sha']\n end", "def last_updated\n repo = Grit::Repo.init_bare_or_open(File.join(path , '.git'))\n repo.c...
[ "0.6758579", "0.6517996", "0.6277419", "0.6273922", "0.62135893", "0.61986846", "0.61426157", "0.61346644", "0.6130961", "0.61237556", "0.61158574", "0.610153", "0.60702115", "0.6048304", "0.6031471", "0.60132146", "0.6009787", "0.6004033", "0.5981083", "0.59733486", "0.59495...
0.7167405
0
Tag the current branch/repo with the specified tag
def git_tag tag system "git tag #{tag}" raise "tag failed" unless $? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag(tag_name)\n git.tag(git_opts, tag_name)\n push(\"origin\", tag_name)\n self\n end", "def tag(tag_name)\n Git::Object.new(self, tag_name, 'tag', true)\n end", "def tag(tag, tag_msg=\"\", commit=nil)\n @tags << tag\n if commit\n gash.send(:git, 'tag', '-f'...
[ "0.7821585", "0.71126884", "0.7064397", "0.7059149", "0.7038629", "0.70311797", "0.6967032", "0.6959666", "0.69446784", "0.69357944", "0.69072413", "0.6873006", "0.6828252", "0.682746", "0.6824444", "0.67905116", "0.67848337", "0.6722644", "0.6679031", "0.6675912", "0.6558776...
0.67444515
17
commit all additions, deletions, etc.
def git_commit_all message system "git add --all ." return false unless $? system "git commit -q -m '#{message.gsub(/'/, "\'")}'" return $? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit!\n _commit( false )\n end", "def commit\n # no op\n end", "def commit\n sanity_check\n @handle.commit\n end", "def commit()\n #This is a stub, used for indexing\n end", "def commit\n db_interface.commit\n end", "def commit; end", "def commit...
[ "0.81308633", "0.8126921", "0.80446666", "0.7854549", "0.7808769", "0.7776686", "0.7776686", "0.7776686", "0.76801217", "0.7643824", "0.75066954", "0.75063735", "0.7505296", "0.7447256", "0.7447256", "0.7441003", "0.7347878", "0.7239524", "0.72276676", "0.71898335", "0.718983...
0.0
-1
Given an rmap, extract the changed or created files, and delete any deleted files
def cmvc_extract_changed rmap raise "oops, not done" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_maps\n own_maps.each do | map |\n logger.debug \"deleting map #{map.inspect}\"\n map.destroy\n end\n end", "def delete_maps\n own_maps.each do | map |\n logger.debug \"deleting map #{map.inspect}\"\n map.destroy\n end\n end", "def clear!\n \n # Removes old files i...
[ "0.58131886", "0.58131886", "0.57415473", "0.57370746", "0.57355213", "0.5688566", "0.5562375", "0.555419", "0.55425036", "0.55397713", "0.55250263", "0.5472779", "0.5387711", "0.53839636", "0.5354738", "0.53215075", "0.52835786", "0.526592", "0.5239939", "0.5214151", "0.5212...
0.6385133
0
Clone the main repository
def git_clone_main raise "oops, not done" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def git_clone\n\n Rugged::Repository.clone_at git_url, root_path.to_s if git_url\n end", "def clone_repository\n `cd #{client.config.tmp_folder} && git clone #{client.config.repository_url}.git`\n `cd #{client.config.tmp_folder}/#{client.config.repository_name} && git fetch origin #{client.config.r...
[ "0.792636", "0.76736474", "0.7660962", "0.7287097", "0.727533", "0.7232853", "0.71718276", "0.71193147", "0.70960814", "0.70732236", "0.70732236", "0.7008809", "0.6984852", "0.69743824", "0.6964502", "0.69544554", "0.693982", "0.6895681", "0.68774205", "0.68405807", "0.681841...
0.62559444
73
Stick the rmap onto disk
def write_rmap rmap end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nmap_save()\n print_status \"Nmap: saving nmap log file\"\n fh = self.nmap_log[0]\n nmap_data = fh.read(fh.stat.size)\n saved_path = store_local(\"nmap.scan.xml\", \"text/xml\", nmap_data, \"nmap_#{Time.now.utc.to_i}.xml\")\n print_status \"Saved NMAP XML results to #{saved_path}\"\nend", "def place_rov...
[ "0.6154629", "0.56928957", "0.5682441", "0.5649068", "0.5532678", "0.54314995", "0.53476137", "0.5338205", "0.53369904", "0.5307179", "0.5303931", "0.5278246", "0.52771723", "0.5268454", "0.5267135", "0.52585363", "0.52557874", "0.5237185", "0.52332973", "0.52055043", "0.5194...
0.6827883
0
For javascript adding deleting reminders
def remove_link f icon = image_tag 'subtract.gif', :class => 'icon' if f.object.new_record? link_to_function(icon, "$(this).up('.#{f.object.class.name.underscore}').remove()", :title => "Remove") else f.hidden_field(:_delete) + link_to_function(icon, "$(this).up('.#{f.object.class.name.underscore}').hide(); $(this).previous().value = '1'", :title => "Remove") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @reminder = @user.reminders.find(params[:id])\n return error_status(true, :cannot_delete_reminder) unless (@reminder.can_be_deleted_by(@logged_user))\n @reminder.updated_by = @logged_user\n @reminder.destroy\n\n respond_to do |format|\n format.html { redirect_to(reminders_url) }\n...
[ "0.7116342", "0.6874734", "0.68648386", "0.673454", "0.673454", "0.6651849", "0.6637635", "0.6621874", "0.6596913", "0.6593006", "0.6472011", "0.6410357", "0.6397968", "0.63874805", "0.63668245", "0.62870437", "0.627243", "0.62602884", "0.62226605", "0.617832", "0.616025", ...
0.0
-1
User helper: require_login (Helpers) Ensures that a route is only accessible to logged in users.
def require_login redirect R(:login) unless logged_in? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_login\n redirect_to login_path if !user_logged?\n end", "def require_login\n redirect_to login_path unless logged_in?\n end", "def require_login\n unless current_user\n redirect_to login_path(:referer => request.fullpath)\n return false\n end\n end", "def require_logi...
[ "0.8003565", "0.7908851", "0.78969854", "0.7864319", "0.78546274", "0.78546274", "0.7852413", "0.7852413", "0.78290874", "0.7817327", "0.779144", "0.77759355", "0.77626467", "0.7760311", "0.7760311", "0.77520204", "0.77520204", "0.77445614", "0.77086115", "0.7700498", "0.7699...
0.78288865
9
Overridden in aura to track last login time. This is called when a user logs in.
def redirect_to_return_url(session_key = :return_to, default = '/admin') u = current_user first_login = u.last_login.nil? u.last_login = Time.now u.save # On a user's first login, go to a admin welcome page # where they can change their password. if first_login redirect R(:admin, :welcome) end redirect session.delete(:return_to) || default end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def did_log_in\n self.last_logged_in_at = DateTime.now\n self.class.execute_without_timestamps { save }\n end", "def current_user\n @current_user ||= super\n if @current_user != nil && @current_user.id > 0\n loggedInUser = User.find(@current_user.id)\n loggedInUser.update(:lastlogintime=>T...
[ "0.7639294", "0.70015496", "0.69594103", "0.68509537", "0.6837654", "0.6837654", "0.67994845", "0.6768157", "0.67656636", "0.67492354", "0.6603999", "0.6561795", "0.6496236", "0.649099", "0.6453949", "0.643976", "0.6434136", "0.62938744", "0.6277433", "0.6268367", "0.6268367"...
0.0
-1
User defines a platform block
def platform(platform_name, &block) SupportedPlatforms.verify!platform_name @current_platform = platform_name block.call @current_platform = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def platform(&block)\n Loquacious::Configuration.for :platform, &block\n end", "def platform; end", "def platform; end", "def platform; end", "def is_platform_block?(key)\n raise 'No key given'.red unless key\n\n return false if (self.runner.blocks[nil][key.to_sym] rescue false)\n re...
[ "0.7160809", "0.6378967", "0.6378967", "0.6378967", "0.60587245", "0.59745026", "0.5950207", "0.5921882", "0.5689245", "0.5686215", "0.56734484", "0.56674194", "0.56674194", "0.56674194", "0.5665567", "0.5665188", "0.5644594", "0.5636268", "0.5595199", "0.5595199", "0.5515746...
0.666566
1
Is executed before each test run
def before_all(&block) @runner.set_before_all(@current_platform, block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_test(test); end", "def before_test(test); end", "def before_run; end", "def before_setup\n # do nothing by default\n end", "def before() ; end", "def before_setup; end", "def before_load(test_files); end", "def before() nil ; end", "def before\n end", "def before\n en...
[ "0.8191394", "0.8191394", "0.7743806", "0.7666647", "0.76002425", "0.7536173", "0.7434413", "0.7418728", "0.7411774", "0.73645866", "0.7357274", "0.73299724", "0.7199651", "0.71249783", "0.70662016", "0.7026113", "0.699139", "0.699139", "0.69620526", "0.69476277", "0.69476277...
0.0
-1
Is executed after each test run
def after_all(&block) @runner.set_after_all(@current_platform, block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_test(_test); end", "def after_test(_test); end", "def after_test(_test); end", "def testing_end\n end", "def after_teardown; end", "def teardown\n\t\tputs \"Completed unit test execution\"\n\tend", "def after; end", "def after; end", "def after\n end", "def after\n end", "def...
[ "0.86707735", "0.86707735", "0.86707735", "0.8007437", "0.78610283", "0.77998394", "0.7787088", "0.7787088", "0.77685463", "0.7731589", "0.7731589", "0.77110887", "0.75407887", "0.74501187", "0.7372534", "0.73336196", "0.73336196", "0.7324972", "0.7317415", "0.7313462", "0.73...
0.0
-1
Is executed if an error occured during fastlane execution
def error(&block) @runner.set_error(@current_platform, block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_failed; end", "def do_failure; end", "def handle_perform_error(_e); end", "def script_error(path, error); end", "def run_and_raise_on_failure\n # TODO ?\n end", "def error!\n @error = true\n end", "def run_failed(exception)\n super\n Chef::Log.warn(\"<< END...
[ "0.7450605", "0.68349755", "0.67693335", "0.64711595", "0.64388937", "0.6417038", "0.6408433", "0.6390398", "0.63609564", "0.6341201", "0.63392246", "0.6338438", "0.63048375", "0.6301034", "0.6284259", "0.62658155", "0.62390685", "0.62196827", "0.62176543", "0.61996114", "0.6...
0.6349904
9
Is used to look if the method is implemented as an action
def method_missing(method_sym, *arguments, &_block) # First, check if there is a predefined method in the actions folder class_name = method_sym.to_s.fastlane_class + 'Action' class_ref = nil begin class_ref = Fastlane::Actions.const_get(class_name) rescue NameError => ex # Action not found raise "Could not find method '#{method_sym}'. Check out the README for more details: https://github.com/KrauseFx/fastlane".red end if class_ref && class_ref.respond_to?(:run) collector.did_launch_action(method_sym) step_name = class_ref.step_text rescue nil step_name = method_sym.to_s unless step_name verify_supported_os(method_sym, class_ref) Helper.log_alert("Step: " + step_name) begin Dir.chdir('..') do # go up from the fastlane folder, to the project folder Actions.execute_action(method_sym) do # arguments is an array by default, containing an hash with the actual parameters # Since we usually just need the passed hash, we'll just use the first object if there is only one if arguments.count == 0 arguments = ConfigurationHelper.parse(class_ref, {}) # no parameters => empty hsh elsif arguments.count == 1 and arguments.first.kind_of?Hash arguments = ConfigurationHelper.parse(class_ref, arguments.first) # Correct configuration passed elsif not class_ref.available_options # This action does not use the new action format # Just passing the arguments to this method else Helper.log.fatal "------------------------------------------------------------------------------------".red Helper.log.fatal "If you've been an existing fastlane user, please check out the MigrationGuide to 1.0".yellow Helper.log.fatal "https://github.com/KrauseFx/fastlane/blob/master/docs/MigrationGuide.md".yellow Helper.log.fatal "------------------------------------------------------------------------------------".red raise "You have to pass the options for '#{method_sym}' in a different way. Please check out the current documentation on GitHub!".red end class_ref.run(arguments) end end rescue => ex collector.did_raise_error(method_sym) raise ex end else raise "Action '#{method_sym}' of class '#{class_name}' was found, but has no `run` method.".red end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_method?(name); end", "def action_method?(name)\n self.class.action_methods.include?(name)\n end", "def available_action?(action_name); end", "def action_method?\n nil\n end", "def respond_to?(method, include_private = false)\n (actions(current_api).include? method)...
[ "0.817691", "0.78048956", "0.75613153", "0.7503209", "0.74374497", "0.72178733", "0.7198545", "0.7082892", "0.70244944", "0.69918525", "0.6966761", "0.6958844", "0.6926446", "0.69153494", "0.6914703", "0.69070005", "0.68965054", "0.6891227", "0.6891227", "0.6879159", "0.68565...
0.0
-1
Is the given key a platform block or a lane?
def is_platform_block?(key) raise 'No key given'.red unless key return false if (self.runner.blocks[nil][key.to_sym] rescue false) return true if self.runner.blocks[key.to_sym].kind_of?Hash raise "Could not find '#{key}'. Available lanes: #{self.runner.available_lanes.join(', ')}".red end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block_tile?\n BLOCK_SIZES.has_key?(kind)\n end", "def key?(p0) end", "def key?(key); end", "def key?(key); end", "def key?(key); end", "def key?(key); end", "def key?(key); end", "def key?(key); end", "def is_elkey?(); @type == GRT_ELKEY; end", "def capable?(key); end", "def key?(key)\n...
[ "0.64562213", "0.64370704", "0.6307505", "0.6307505", "0.6307505", "0.6307505", "0.6307505", "0.6307505", "0.617565", "0.60650945", "0.60525006", "0.60525006", "0.6050762", "0.60384357", "0.59404975", "0.5932974", "0.5930782", "0.5859019", "0.5847788", "0.5832562", "0.5822329...
0.85934603
0
Fastfile was finished executing
def did_finish collector.did_finish end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finished; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def finish; end", "def file_finished(file, offenses); end", "def finish\n @Done = true \n end", "def finish()\n #This is a s...
[ "0.750005", "0.7226259", "0.7226259", "0.7226259", "0.7226259", "0.7226259", "0.7226259", "0.7226259", "0.7226259", "0.7210303", "0.7159294", "0.7111025", "0.7064878", "0.6993208", "0.69505966", "0.6888138", "0.68818", "0.6862629", "0.6853151", "0.6825578", "0.68123144", "0...
0.0
-1
api_request calls this (and gives it a method)
def request_params(method) @request_params = { :api_key => ENV['LASTFM_API_KEY'], :token => @auth_token, :api_sig => nil, :method => method, :format => 'json' } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request(*)\n raise 'HttpApiBuilder::BaseClient#request must be implemented, see documentation'\n end", "def method_missing(method_id, *params)\n _request(method_id.to_s.sub('_api', ''), *params)\n end", "def api_request(method, path, opts = {})\n request(method, path, opts)\n end", ...
[ "0.699395", "0.69817877", "0.68496406", "0.6819791", "0.6806654", "0.6804253", "0.6801593", "0.6784718", "0.6759607", "0.6753799", "0.6738722", "0.67318547", "0.66957235", "0.6672798", "0.6635364", "0.663438", "0.6602269", "0.6602269", "0.6602269", "0.6602269", "0.6602269", ...
0.0
-1
Builds a document using document template and XML or JSON data passed in request.
def assemble_document(request) begin data, _status_code, _headers = assemble_document_with_http_info(request) rescue ApiError => e if e.code == 401 request_token data, _status_code, _headers = assemble_document_with_http_info(request) else raise end end data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build\n if expand_document\n combine_layout\n combine_activity_metadata\n document.update! build_params\n else\n document.document_parts.delete_all\n document.update! document_params.merge(toc: template.toc, material_ids: template.toc.collect_material_...
[ "0.67430896", "0.6553285", "0.6527995", "0.64811975", "0.64162254", "0.6214854", "0.6136644", "0.6134135", "0.6080438", "0.6070958", "0.6042282", "0.595217", "0.5902387", "0.58985215", "0.5879439", "0.5873834", "0.58653307", "0.5848084", "0.5846657", "0.5801153", "0.5770462",...
0.6234749
5
Get all files and folders within a folder
def get_files_list(request) begin data, _status_code, _headers = get_files_list_with_http_info(request) rescue ApiError => e if e.code == 401 request_token data, _status_code, _headers = get_files_list_with_http_info(request) else raise end end data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_files(path)\n base_directory_content = Dir.glob(File.join(path, \"*\"))\n nested_directory_content = Dir.glob(File.join(path, \"*/**/*\"))\n [base_directory_content, nested_directory_content].flatten\n end", "def get_folder_files(folder_path)\n ensure_file_open!\n @file.g...
[ "0.7364895", "0.73456645", "0.72250926", "0.71962637", "0.7175641", "0.7150448", "0.7065755", "0.7058417", "0.6968796", "0.6967285", "0.6953533", "0.6876023", "0.68662673", "0.6864455", "0.6808971", "0.6770345", "0.67680633", "0.6763372", "0.674458", "0.67410696", "0.673175",...
0.0
-1
Retrieves list of supported file formats.
def get_supported_file_formats(request) begin data, _status_code, _headers = get_supported_file_formats_with_http_info(request) rescue ApiError => e if e.code == 401 request_token data, _status_code, _headers = get_supported_file_formats_with_http_info(request) else raise end end data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formats\n @formats ||= Dir[File.join(path, \"#{name}.{otf,svg,ttf,woff,woff2,eot}\")].map {|file| File.extname(file)[1..-1] }.sort\n end", "def supported_formats\n output = `vips --list` + `convert --version`\n\n formats = %w[jpg png webp gif jp2 avif].select do |format|\n output.include? form...
[ "0.78444517", "0.78438896", "0.76918375", "0.7190886", "0.7004789", "0.6818506", "0.67250556", "0.6519861", "0.6485713", "0.6476558", "0.6431124", "0.63256305", "0.6300773", "0.62428296", "0.6236999", "0.62342894", "0.6222733", "0.61798805", "0.61551636", "0.61292005", "0.612...
0.7956081
0
Gets device data from backend service and updates its color and ALS state. Params: +info+:: +DeviceInfo+ object. +state+:: +DeviceState+ object which will be updated with data from backend. Returns true if devState has been changed, false otherwise.
def getDeviceState(info, state) res = apiGet("devices/#{info.deviceId}") succeed = false if res.status == 200 response = nil begin response = JSON.parse(res.body) rescue Exception => e $LOG.warn("Invalid body received! Err: #{e.message}") end if !response.nil? and response.include?("als_enabled") and response.include?("color_hue") and response.include?("color_saturation") and response.include?("color_value") succeed = true end end changed = false if succeed alsEnabled = response["als_enabled"] color = [response["color_hue"].to_f, response["color_saturation"].to_f, response["color_value"].to_f] if alsEnabled != state._alsEnabled or color != state.color state._alsEnabled = alsEnabled state.color = color changed = true end else $LOG.warn("Failed to get device state from backend! Status: #{res.status}, Response: #{res.body}") end changed end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update?\n state == STATE_UPDATE\n end", "def postReadings(info, state)\r\n params = {\r\n :device_id => info.deviceId,\r\n :sensor_data => [\r\n {\r\n :type => \"Temperature\",\r\n :value => state.temperature,\r\n :time => Time.now.to_i...
[ "0.51228786", "0.4943882", "0.4931239", "0.49310255", "0.4870755", "0.47812158", "0.47313583", "0.46843687", "0.46770492", "0.4640897", "0.46286714", "0.46241808", "0.46197292", "0.4594584", "0.45819145", "0.45283353", "0.45273665", "0.4526295", "0.4526295", "0.45201463", "0....
0.8010385
0
Send device SW version and serial number to backend service. Params: +info+:: +DeviceInfo+ object.
def putDeviceInfo(info) params = { :software_version => info.swVersion, :serial_number => info.serialNb } res = apiPut("devices/#{info.deviceId}", params) if res.status != 200 $LOG.warn("Failed to put device info to backend! Status: #{res.status}, Response: #{res.body}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sendInfo(devInfo)\r\n msg = {\r\n :type => \"info\",\r\n :version => devInfo.swVersion\r\n }\r\n sendMsg(msg)\r\n end", "def device_params\n params.require(:device).permit(:name, :sn, :model, :coordinate, :address, :floor, :power, :powerstatu, :repottime, :status, :imsi, :t...
[ "0.7553182", "0.57382566", "0.546619", "0.53908426", "0.5350636", "0.53383636", "0.5246511", "0.52329963", "0.5203288", "0.51399523", "0.5123751", "0.51146525", "0.510888", "0.50191617", "0.5002172", "0.49679103", "0.49671125", "0.49658668", "0.49487564", "0.4938252", "0.4931...
0.79654753
0
Send device color to backend service. Params: +info+:: +DeviceInfo+ object. +color+:: HSV collor array.
def putColor(info, color) params = { :color_hue => color[0].to_s, :color_saturation => color[1].to_s, :color_value => color[2].to_s } res = apiPut("devices/#{info.deviceId}", params) if res.status != 200 $LOG.warn("Failed to put color to backend! Status: #{res.status}, Response: #{res.body}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sendUserColor(devInfo, color)\r\n msg = {\r\n :type => \"user-color\", \r\n :device_id => devInfo.deviceId,\r\n :user_color => {\r\n :hue => color[0],\r\n :saturation => color[1],\r\n :value => color[2]\r\n }\r\n }\r\n sendMsg(msg)\r\n en...
[ "0.77770764", "0.60814154", "0.59698147", "0.59685755", "0.5828013", "0.58269525", "0.5738051", "0.573183", "0.5708938", "0.5617696", "0.5591413", "0.5582966", "0.5569477", "0.55513763", "0.5540315", "0.5514176", "0.55106395", "0.5499607", "0.5475196", "0.5474615", "0.5460296...
0.8330073
0
Send device readings (temp. and humid.) to backend service. Params: +info+:: +DeviceInfo+ object. +state+:: +DeviceState+ object.
def postReadings(info, state) params = { :device_id => info.deviceId, :sensor_data => [ { :type => "Temperature", :value => state.temperature, :time => Time.now.to_i }, { :type => "Humidity", :value => state.humidity, :time => Time.now.to_i } ] } res = apiPostJson("readings", params) if res.status != 201 $LOG.warn("Failed to post readings to backend! Status: #{res.status}, Response: #{res.body}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sendStreaming(devInfo, devState)\r\n msg = {\r\n :type => \"streaming\", \r\n :version => devInfo.swVersion,\r\n :sensor_data => [\r\n {\r\n :type => \"Temperature\", \r\n :value => devState.temperature,\r\n :time => Time.now.to_i\r\n ...
[ "0.6142587", "0.6005751", "0.56190664", "0.5519432", "0.5501627", "0.52769345", "0.5195745", "0.5134593", "0.508595", "0.50521946", "0.50493795", "0.50198597", "0.4987756", "0.49458665", "0.48833528", "0.48647407", "0.4845068", "0.4843082", "0.48353758", "0.48174357", "0.4804...
0.78722006
0
Triggers new alarm upload sound file to S3 (if given), update storage url and post new alarm. Finally +alarm+ is updated with posted alarm Id. Params: +info+:: +DeviceInfo+ object. +alarm+:: +DeviceAlarms::State+ object. +type+:: Given alarm type.
def triggerAlarm(info, alarm, type) uploadSoundFile(info, alarm, type) params = { :device_id => info.deviceId, :alarm_type => type, :storage_url => alarm.storageUrl } res = apiPost("alarms", params) if res.status == 201 begin response = JSON.parse(res.body) alarm._id = response["id"] $LOG.info("Triggered \"#{type}\" alarm. Id: #{alarm._id}") rescue Exception => e $LOG.warn("Invalid body received on trigger alarm! Err: #{e.message}") end else $LOG.warn("Failed to post \"#{type}\" alarm to backend! Status: #{res.status}, Response: #{res.body}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uploadSoundFile(info, alarm, type)\r\n if !alarm.sound.nil?\r\n # reset storageUrl\r\n alarm.storageUrl = nil\r\n\r\n # get new urls\r\n params = {\r\n :device_id => info.deviceId,\r\n :alarm_type => type\r\n }\r\n res = apiPost(\"storage/alarm\"...
[ "0.8175491", "0.5168551", "0.5042993", "0.49938577", "0.4908464", "0.4809632", "0.47915807", "0.47878167", "0.47438142", "0.472263", "0.46991295", "0.46910834", "0.46700853", "0.46166387", "0.45644194", "0.4558445", "0.4551017", "0.45413992", "0.45273748", "0.45198497", "0.45...
0.78386617
1
Tries to upload associated sound, if given, and update storageUrl.
def uploadSoundFile(info, alarm, type) if !alarm.sound.nil? # reset storageUrl alarm.storageUrl = nil # get new urls params = { :device_id => info.deviceId, :alarm_type => type } res = apiPost("storage/alarm", params) if res.status == 201 uploadUrl = downloadUrl = nil begin response = JSON.parse(res.body) downloadUrl = response["read_url"] uploadUrl = response["signed_url"] rescue Exception => e $LOG.warn("Invalid body received on post storage/alarm! Err: #{e.message}") end if !uploadUrl.nil? and !downloadUrl.nil? # upload WAV @httpClient.default_header = @wavHeader begin File.open(alarm.sound) { |file| res = @httpClient.put(uploadUrl, :body => file ) if res.status == 200 # set storageUrl if everything succeed alarm.storageUrl = downloadUrl else $LOG.warn("Failed to put alarm sound to S3! Body: #{res.body}") end } rescue Exception => e $LOG.warn("Failed to open sound file! Err: #{e.message}") end else $LOG.warn("Failed to get S3 upload/download urls!") end else $LOG.warn("Failed to post \"#{type}\" alarm to get S3 urls from backend! Status: #{res.status}, Response: #{res.body}") end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_sound_file(data, name)\n resp = @api.UploadSoundFile({\n :FileBinary => data,\n :SoundFileID => name,\n :LicenseKey => @license_key }).uploadSoundFileResult\n resp[\"UploadSuccessful\"] == 'true' ? true : resp.ErrorResponse\n end", "def set_audio_upl...
[ "0.60508394", "0.60422975", "0.59490997", "0.59328616", "0.5852117", "0.577434", "0.56545883", "0.5580991", "0.5579508", "0.55746865", "0.5565497", "0.55517715", "0.553066", "0.55009806", "0.54924077", "0.54885375", "0.5478615", "0.54373944", "0.5430214", "0.54101914", "0.540...
0.6884488
0
The program handles divide when attempting to divide by zero
def divide(num_one, num_two) if num_two == 0 until num_two != 0 puts "You can't divide by zero. Enter the second number again: " num_two = gets.chomp.to_i end end return num_one / num_two end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_division_by_zero; 5 / 0; end", "def do_division_by_zero; 5 / 0; end", "def do_division_by_zero; 5 / 0; end", "def test_dived_by_zero\n assert_raise ZeroDivisionError do\n @calc.divide(1, 0)\n end\n end", "def divide(number, divisor)\n begin\n answer = number / divisor...
[ "0.7980506", "0.7980506", "0.7980506", "0.7628721", "0.76260185", "0.7625452", "0.7625452", "0.7625452", "0.7617759", "0.75840163", "0.7498947", "0.7467035", "0.741958", "0.72245634", "0.712313", "0.7015706", "0.7003806", "0.6954093", "0.69298834", "0.69163257", "0.6904398", ...
0.6234753
58
Time Complexity O(n) Space Complexity O(n) Hint, you may want a recursive helper method
def fib_helper(last, second_to_last, current, n) return n if n == 0 || n == 1 if current == n return last + second_to_last end sum = last + second_to_last last = second_to_last second_to_last = sum return fib_helper(last, second_to_last, current + 1, n) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recursive_solution\n\n end", "def recursive => nil", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def f...
[ "0.6395889", "0.63333136", "0.6307341", "0.6163818", "0.6062601", "0.60455203", "0.59980667", "0.5973596", "0.592667", "0.5882138", "0.5869365", "0.58544946", "0.584376", "0.58200246", "0.57896274", "0.57827806", "0.5782224", "0.57502013", "0.5740515", "0.573646", "0.5702108"...
0.0
-1
Generates a registration key for use with the course.
def generate_registration_key self.registration_key = 'C'.freeze + SecureRandom.base64(8) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_key; end", "def generate_registration_key(components)\n string_to_encode = components.join('|')\n\n Digest::MD5.hexdigest(string_to_encode)\n end", "def generate_user_key\n\t\tself.key = loop do\n random_hex = SecureRandom.urlsafe_base64\n break random_hex unless...
[ "0.7567376", "0.7466668", "0.68773484", "0.6737915", "0.6720664", "0.67189175", "0.66886556", "0.66753656", "0.66753656", "0.6663184", "0.6658071", "0.6612307", "0.6592411", "0.6568493", "0.6560976", "0.65485245", "0.653845", "0.6535912", "0.6535912", "0.6526784", "0.65215755...
0.82896674
0
Returns the root folder of the course.
def root_folder if new_record? material_folders.find(&:root?) || (raise ActiveRecord::RecordNotFound) else material_folders.find_by!(parent: nil) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def folder\n @root_folder\n end", "def root_folder\n scheduler_service.GetFolder(\"\\\\\")\n end", "def get_root_directory\n return @@root_directory\n end", "def get_root_directory\n return @@root_directory\n end", "def root_folder\n load unless loaded?\n @...
[ "0.76121235", "0.7424518", "0.7420176", "0.7420176", "0.7399154", "0.7246283", "0.7206369", "0.71779174", "0.716437", "0.70478123", "0.6980798", "0.6958754", "0.69286615", "0.6859045", "0.6853035", "0.6852559", "0.68472207", "0.6835592", "0.67934024", "0.67799634", "0.6778908...
0.6749608
25
Test if the course has a root folder.
def root_folder? if new_record? material_folders.find(&:root?).present? else material_folders.find_by(parent: nil).present? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root?\n \tfolder_id.nil?\n end", "def is_root?\n @path == '/' || @path == ''\n end", "def is_root?()\n @rootpath == @path\n end", "def root?\n !self.hier? || self.path == '/' || self.path.to_s.empty?\n end", "def root?\n #%r{\\A/+\\z} =~ @path ? true : false\n @absolute and...
[ "0.7659787", "0.75953543", "0.75504994", "0.75484115", "0.7547903", "0.72686625", "0.7230413", "0.7196258", "0.7129947", "0.700059", "0.68827796", "0.68824035", "0.68342066", "0.68228096", "0.6741974", "0.6735495", "0.67177004", "0.6713444", "0.6677862", "0.6677862", "0.66391...
0.76919776
0
This is the max time span that the student can access a future assignment. Used in self directed mode, which will allow students to access course contents in advance before they have started.
def advance_start_at_duration settings(:course).advance_start_at_duration end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_duration\n if start_time && end_time && (end_time - start_time) > 2.years\n errors.add :end_time, I18n.t('activerecord.errors.models.membership.attributes.end_time.max_duration_error')\n end\n end", "def max_time\n @max_time ||= 0.2\n end", "def max_time\n @max_time...
[ "0.65161735", "0.6395259", "0.61827666", "0.6162111", "0.6110366", "0.6030329", "0.5977856", "0.5964557", "0.5884338", "0.58637553", "0.58605313", "0.5844379", "0.58055365", "0.57782406", "0.57744265", "0.5771327", "0.5747992", "0.57369184", "0.5735673", "0.5702214", "0.56946...
0.5141335
77
Convert the days to time duration and store it.
def advance_start_at_duration_days=(value) value = if value.present? && value.to_i > 0 value.to_i.days else nil end settings(:course).advance_start_at_duration = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def duration_days\n return nil if self.duration.blank?\n number,units=duration_parts\n return unless number.present? && units.present?\n\n if units=='years'\n number=12*number\n units='months'\n end\n number.send(units)\n end", "def duration_in_day...
[ "0.67037094", "0.6609587", "0.65135217", "0.6428791", "0.63726586", "0.635334", "0.62266695", "0.6143979", "0.61352617", "0.6099018", "0.60483307", "0.59891057", "0.59835106", "0.5950215", "0.5941363", "0.5935504", "0.5919524", "0.5913908", "0.5909194", "0.5909194", "0.590754...
0.0
-1
POST /tests POST /tests.json
def create @admintheme = Theme.new(admintheme_params) respond_to do |format| if @admintheme.save format.html { redirect_to adminthemes_path, notice: 'Test was successfully created.' } format.json { render :show, status: :created, location: @admintheme } else format.html { render :new } format.json { render json: @admintheme.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def v2_tests_post(test_detail, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: TestsApi#v2_tests_post ...\"\n end\n \n # verify the required parameter 'test_detail' is set\n fail \"Missing the required parameter 'test_detail' when calling v2_tests...
[ "0.72139466", "0.70664746", "0.70649576", "0.698973", "0.68169713", "0.6594761", "0.6549934", "0.6549934", "0.6549934", "0.6549934", "0.6549934", "0.6549934", "0.65116346", "0.64799345", "0.64702207", "0.6453199", "0.6437914", "0.6407723", "0.63976455", "0.6325744", "0.632574...
0.0
-1
PATCH/PUT /tests/1 PATCH/PUT /tests/1.json
def update respond_to do |format| if @theme.update(adminthemes_params) format.html { redirect_to @admintheme, notice: 'Test was successfully updated.' } format.json { render :show, status: :ok, location: @admintheme } else format.html { render :edit } format.json { render json: @admintheme.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @test = Test.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:test])\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n...
[ "0.66275775", "0.6461822", "0.64604074", "0.64109653", "0.6391101", "0.6391101", "0.6391101", "0.6391101", "0.6391101", "0.6391101", "0.6391101", "0.63527983", "0.6351322", "0.6347684", "0.6342539", "0.6309748", "0.6279981", "0.62679595", "0.6245681", "0.62357527", "0.6209263...
0.0
-1
DELETE /tests/1 DELETE /tests/1.json
def destroy @theme.destroy respond_to do |format| format.html { redirect_to adminthemes_url, notice: 'Admin was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n e...
[ "0.771419", "0.771419", "0.7699507", "0.74376744", "0.7418487", "0.7418487", "0.7418487", "0.7418487", "0.7418487", "0.7418487", "0.7418487", "0.74170816", "0.7390183", "0.7322365", "0.73147345", "0.7270275", "0.72675836", "0.7227697", "0.7193399", "0.718793", "0.7176366", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_admintheme @admintheme = Theme.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def admintheme_params params.require(:theme).permit(:themecla_id,:title,:themeimg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6981273", "0.6783789", "0.67460483", "0.6742222", "0.67354137", "0.65934366", "0.65028495", "0.6497783", "0.64826745", "0.6479415", "0.6456823", "0.6440081", "0.63800216", "0.6376521", "0.636652", "0.6319898", "0.6300256", "0.62994003", "0.6293621", "0.6292629", "0.6291586...
0.0
-1
This method needs to be implemented by the dataSource of an NSTableView. This function is used by the NSTableView to populate itself
def tableView_objectValueForTableColumn_row_(view, col, row) case col.identifier.to_s when "ID" return @customers[row].id when "FNAME" return @customers[row].first_name when "LNAME" return @customers[row].last_name when "STREET1" return @customers[row].street_1 when "CITY" return @customers[row].city when "ZIP" return @customers[row].zip when "EMAIL" return @customers[row].email else return nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_source=(val)\n PPCurses.implements_protocol( val, %w(number_of_rows_in_table object_value_for ))\n @data_source = val\n @selected_row = 0\n \n # Determine frame size from datasource data\n height = @data_source.number_of_rows_in_table(self)\n width = 0 \n for i in 0..@data_sourc...
[ "0.58925354", "0.5593454", "0.5466672", "0.54511803", "0.5451133", "0.54354244", "0.53852814", "0.5290497", "0.5209445", "0.5180892", "0.5131673", "0.5120566", "0.5083637", "0.5077094", "0.5067756", "0.5061847", "0.50609744", "0.5058027", "0.5007701", "0.49867627", "0.4964787...
0.45416477
84
This method needs to be implemented by the dataSource of an NSTableView.
def numberOfRowsInTableView_(view) return 0 if @customers.nil? return @customers.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data_source=(val)\n PPCurses.implements_protocol( val, %w(number_of_rows_in_table object_value_for ))\n @data_source = val\n @selected_row = 0\n \n # Determine frame size from datasource data\n height = @data_source.number_of_rows_in_table(self)\n width = 0 \n for i in 0..@data_sourc...
[ "0.57290924", "0.56181127", "0.55382395", "0.55299723", "0.5509954", "0.5412743", "0.54053926", "0.53441733", "0.53330666", "0.5300346", "0.5251905", "0.5251905", "0.5251905", "0.5251905", "0.5236163", "0.5220334", "0.51958966", "0.51958966", "0.51958966", "0.51958966", "0.51...
0.0
-1
Converts the search attributes into an array only containing those that have nonblank values
def gen_conditions conditions = {} search_fields = [:title, :genre, :year, :directors, :actors] search_fields.each do |sf| conditions[sf] = self.send(sf).stringValue unless self.send(sf).nil? || self.send(sf).stringValue == "" end (conditions.empty?) ? nil : conditions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes\n (node.attributes['attrs'] || \"\").split(/\\s*,\\s*/).where_not.blank?\n end", "def search_attributes\n nil\n end", "def non_empty_attr\n attributes.reject {|x,y| x == 'id' or y.blank?}\n end", "def extra_attributes_to_filter\n # default value if not set\n ...
[ "0.6521453", "0.6448496", "0.6295388", "0.6236678", "0.6206599", "0.61815405", "0.6179791", "0.6101561", "0.6085985", "0.6054999", "0.60363144", "0.60348827", "0.60063154", "0.6003182", "0.5949406", "0.5944801", "0.5936023", "0.5936023", "0.5936023", "0.5936023", "0.5932954",...
0.0
-1
Reset to starting state
def reset_sales_stuff @last_sale = nil @sale = nil @item = nil @copy = nil @customers = nil @first_name_field.setStringValue("") @last_name_field.setStringValue("") @item_id_field.setStringValue("") @price_field.setStringValue("") @format_field.setStringValue("") @title_field.setStringValue("") @type_field.setStringValue("") @notification_label.setStringValue("") @status_label.setStringValue("") @customers_table.reloadData end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n @current = 0\n @state = :stopped\n end", "def reset_state\n @state = nil\n end", "def reset\n set InitialPosition\n end", "def reset\n end", "def reset\n end", "def reset\n end", "def reset\n end", "def reset\n end", "def reset\n end"...
[ "0.81629455", "0.8025223", "0.8012655", "0.79935545", "0.79935545", "0.7918337", "0.7918337", "0.7918337", "0.7918337", "0.79175967", "0.7870235", "0.7854956", "0.7833612", "0.78078103", "0.78078103", "0.7779504", "0.7770728", "0.7767353", "0.7758424", "0.7758424", "0.7738250...
0.0
-1
WRITE CODE BELOW HERE
def all_pages(array) sum = 0 array.each do |book| sum += book[:pages] end puts sum # array.reduce {|book| book[:pages]} # array.each {|book| puts book[:pages].class} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def writethis; end", "def probers; end", "def custom; end", "def custom; end", "def private; end", "def schubert; end", "def suivre; end", "def code_of_conduct; end", ...
[ "0.7163798", "0.7163798", "0.7163798", "0.7163798", "0.7163798", "0.7163798", "0.7163798", "0.6512597", "0.6442167", "0.6345179", "0.6345179", "0.6325178", "0.63037944", "0.6266899", "0.6242245", "0.6177981", "0.6126921", "0.60830444", "0.60670304", "0.60617733", "0.6022185",...
0.0
-1
Reset request options to defaults.
def reset @item_ids = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n VALID_OPTIONS_KEYS.each{|k| send(\"#{k}=\", nil)}\n self.endpoint = DEFAULT_ENDPOINT\n self.proxy = DEFAULT_PROXY\n self.api_version = DEFAULT_API_VERSION\n self\n end", "def reset!\n @options = defaults\n end", "def reset!\n @options = defaults\n ...
[ "0.8153717", "0.80049723", "0.80049723", "0.7852717", "0.7788182", "0.7753053", "0.7624409", "0.75732845", "0.7503362", "0.748633", "0.73618525", "0.72853756", "0.7262728", "0.71707886", "0.7157197", "0.71203005", "0.710231", "0.7066108", "0.70409876", "0.70287114", "0.692676...
0.0
-1
Create Employee notification for Owner.
def create_owner_with_service logger.info("creating owner>>>>>>>>>>>>>>>>>>>>>>>") if(property(:use_mobile_tribe)) empId = Employee.find_by_company_id(self.id) user = User.find_by_id(empId.user_id) mobile_tribe = Services::MobileTribe::Connector.new begin fields = { "companyId" => htmlsafe(empId.company_id.to_s), "userId" => htmlsafe(empId.user_id.to_s), "employeeId" => htmlsafe(empId.id.to_s), "firstName" => htmlsafe(user.firstname.to_s), "lastName" => htmlsafe(user.lastname.to_s), "status" => htmlsafe("active"), "phone" => htmlsafe(user.phone.to_s), "officePhone" => htmlsafe(empId.phone.to_s), "jobTitle" => htmlsafe(empId.job_title.to_s), "companyEmail" => htmlsafe(empId.company_email.to_s) } if empId.department_id.blank? fields["departmentId"] = "" else fields["departmentId"] = htmlsafe("-"+empId.department_id.to_s) end #"departmentId" => htmlsafe("-"+empId.department_id.to_s)} mobile_tribe.create_employee(fields) empId.update_attribute("is_mobiletribe_connect", "1") rescue Services::MobileTribe::Errors::MobileTribeError => e self.errors.add_to_base( "#{I18n.t('models.company.mobile_tribe_error')} #{e.to_s}" ) #self.owner_create_fail = true #Employee.find_by_company_id(self.id).delete self.delete_company_with_service Company.find_by_id(self.id).delete self.send(rollback_changes) return false end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notify_employee\n \t\temployees.each do |employee|\n \t\t\tputs \"Notification sent to #{employee.name} at #{employee.email}\"\n \t\t\tputs \"\"\n \t\tend\t\n end", "def set_NotifyNewEntityOwner(value)\n set_input(\"NotifyNewEntityOwner\", value)\n end", "def create\n @employee = cu...
[ "0.6703223", "0.64166325", "0.6370728", "0.6271908", "0.62403893", "0.62388295", "0.6210563", "0.62016505", "0.6201373", "0.6092097", "0.6064204", "0.6020513", "0.59770507", "0.59309435", "0.5919393", "0.5891983", "0.58870584", "0.5863825", "0.58543235", "0.58476496", "0.5839...
0.5859138
18
showing full object instead of just names of galleries asks Painting for a list of paintings by self Asks each Painting for its gallery asks the Gallery for its city returns cities in an array
def cities galleries.map do |gallery| gallery.city end #undefined method `city' for "New York":String end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cities\n galleries.map do |gallery| \n gallery.city \n end\n end", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n end", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n end", "def cities\n galleries.map {|gallery| gallery.city}\n...
[ "0.78167504", "0.77904457", "0.77904457", "0.7758796", "0.7758796", "0.7636955", "0.75682783", "0.75436413", "0.75296783", "0.74719405", "0.74590963", "0.73413813", "0.7328907", "0.72527254", "0.7055044", "0.7055044", "0.7055044", "0.7052989", "0.7041286", "0.70353687", "0.70...
0.73919636
11
helper method for delete:
def maximum(tree_node = @root) tree_node.right.nil? ? tree_node : maximum(tree_node.right) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n \n end", "def delete\n \n end", "def delete\n end", "def delete\n\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n\n\tend", "def delete\n ...
[ "0.8373501", "0.80260485", "0.8013269", "0.80042505", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.7956913", "0.79107374", "0.7799738", "0.77781236", "0.7493549", "0.7422571", "0.74152577", "0.7396308", "0.73679674", "0.7326224", "0.7326224...
0.0
-1
a scrambled word and a dictionary of real words. Your program must then output all words that our scrambled word can unscramble to. Helper function to check if words are anagram of each other.
def anagram?(s1, s2) s1_array = s1.split("") s2_array = s2.split("") if s1_array.sort == s2_array.sort return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def anagram?\n chars1 = @input1.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n chars2 = @input2.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n if\n self.allwords?\n if\n chars1 == chars2\n return \"These words are anagrams!\"\n elsif\n...
[ "0.81273913", "0.79925317", "0.7935563", "0.7902196", "0.79003805", "0.7887153", "0.78770083", "0.7840942", "0.7840666", "0.7779616", "0.7759835", "0.774859", "0.77033216", "0.77022153", "0.77022153", "0.77022153", "0.769376", "0.769376", "0.76767683", "0.76373047", "0.762375...
0.0
-1
I worked on this challenge [by myself ]. 2. Pseudocode 3. Initial Solution
def in_words(num) numbers = {0 => "zero", 1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five", 6 => "six", 7 => "seven", 8 => "eight", 9 => "nine", 10 => "ten", 11 => "eleven", 12 => "twelve", 13 => "thirteen", 15 => "fifteen", 20 => "twenty", 30 => "thirty", 50 => "fifty"} num_array = num.to_s.split(//).map(&:to_i) case num_array.length when 1 numbers[num_array[0]] when 2 if num_array[1] == 0 if numbers[num].nil? numbers[num_array[0]] + "ty" else numbers[num] end else case num_array[0] when 1 if numbers[num].nil? numbers[num_array[1]] + "teen" else numbers[num] end when 2 numbers[20] + " " + numbers[num_array[1]] when 3 numbers[30] + " " + numbers[num_array[1]] when 5 numbers[50] + " " + numbers[num_array[1]] else numbers[num_array[0]] + "ty " + numbers[num_array[1]] end end else "one hundred" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution4(input)\n end", "def solution(number)\nn = 0..number\na = []\nfor i in n\n if i % 3 == 0 || i % 5 == 0\n a = a.push(i)\n end\n end\ns = 0\n# a.pop\na.each {|x| s += x}\ns\nend", "def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length +...
[ "0.66333103", "0.63587576", "0.63541335", "0.6329571", "0.6275753", "0.62671983", "0.623466", "0.62310106", "0.62255913", "0.62245643", "0.6219843", "0.621371", "0.6173556", "0.6168815", "0.6165275", "0.6163942", "0.6151856", "0.6142871", "0.612441", "0.6119218", "0.60963804"...
0.0
-1
Register a record with the current transaction so that its after_commit and after_rollback callbacks can be called.
def add_transaction_record(record) current_transaction.add_record(record) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_to_transaction(*)\n @connection.add_transaction_record(self)\n end", "def after_commit(&blk)\n ActiveRecord::Base.connection.add_transaction_record(\n AfterCommitWrapper.new(&blk)\n )\n end", "def register_tx(data)\n transaction(:raw_register, data)\n end", "def in...
[ "0.67611736", "0.6569975", "0.580643", "0.5750828", "0.572886", "0.572886", "0.56294", "0.5553481", "0.5507917", "0.5484063", "0.5471472", "0.5470923", "0.5438455", "0.54281294", "0.5419102", "0.5401728", "0.53990597", "0.53990597", "0.5393163", "0.5388992", "0.5381024", "0...
0.7074739
0
via method_missing affected_rows will be recognized as async method
def affected_rows(*args, &blk) execute(false) do |conn| conn.send(:affected_rows, *args, &blk) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def affected_rows()\n #This is a stub, used for indexing\n end", "def async_result()\n #This is a stub, used for indexing\n end", "def fetch_rows(sql, &block)\n raise NotImplementedError, NOTIMPL_MSG\n end", "def handle_failed_rows?\n false\n end", "def affec...
[ "0.64348996", "0.61740804", "0.5846042", "0.5780616", "0.5659261", "0.5419465", "0.5415686", "0.5348129", "0.53349715", "0.5325317", "0.53207904", "0.5309817", "0.52947897", "0.52862483", "0.5277573", "0.5272878", "0.52659684", "0.52436966", "0.5200909", "0.519614", "0.519140...
0.5835859
3
TODO make more elaborate self.description = '...'
def run license_key = read_license_key email = guess_email_address # Collect details about the environment. osx_vers = `/usr/bin/sw_vers -productVersion`.strip if defined?(Pre::Motion::Version) rm_vers = "#{Motion::Version} (stable), #{Pre::Motion::Version} (pre-release)" else rm_vers = Motion::Version end xcode_vers = begin xcodebuild = `which xcodebuild`.strip xcodebuild = '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild' if xcodebuild.empty? vers = '' if File.exist?(xcodebuild) vers = `#{xcodebuild} -version`.strip.scan(/Xcode\s(.+)$/).flatten[0].to_s end vers = 'unknown' if vers.empty? vers end environment = URI.escape("OSX #{osx_vers}, RubyMotion #{rm_vers}, Xcode #{xcode_vers}") system("open \"https://secure.rubymotion.com/new_support_ticket?license_key=#{license_key}&email=#{email}&environment=#{environment}\"") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description; end", "def description\n super || \"\"\n end", "def desc...
[ "0.76804006", "0.76804006", "0.76804006", "0.76804006", "0.76804006", "0.76804006", "0.76804006", "0.76804006", "0.76804006", "0.76804006", "0.76240027", "0.7601409", "0.7576711", "0.7501892", "0.7395768", "0.7370072", "0.7355383", "0.7317543", "0.7303333", "0.7302497", "0.72...
0.0
-1
Validate and submit the request
def submit! raise InvalidRequest.new(self) unless valid? command.call(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def submit\n\t\tset_post_data\n get_response @url\n parse_response\n\tend", "def submit; end", "def perform\n validate_data_from_requests\n end", "def request \n\t\t\tif self.valid?\n\t\t\t\tpath = \"/#{Base.config.api_path}/#{self.request_action}\"\n\t\t\t\tconnection.post(path, self.to_xml).tap d...
[ "0.711916", "0.7014459", "0.6919038", "0.6829978", "0.6788692", "0.67806745", "0.6761566", "0.67257017", "0.6695757", "0.6630653", "0.6606051", "0.654261", "0.6488721", "0.6460057", "0.6430894", "0.63586116", "0.6322532", "0.6321476", "0.6309891", "0.6234208", "0.6222027", ...
0.7029805
1
GET /eods/1 GET /eods/1.json
def show @user = User.find(params[:user_id]) @eod = Eod.find_by(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @eobs = Eob.assigned\n @title = \"Posted EOBs\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @eobs }\n end\n end", "def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end", "def index\n @expedientes = Exp...
[ "0.6362789", "0.63448405", "0.62461716", "0.6200196", "0.60983086", "0.60964125", "0.60925984", "0.6072614", "0.60415006", "0.6040837", "0.5995396", "0.5984661", "0.59739596", "0.59710366", "0.59548473", "0.5951778", "0.594346", "0.594026", "0.59353954", "0.59284735", "0.5921...
0.5771239
38
POST /eods POST /eods.json
def create # redirect_to user_eod_path(@user,@eod) # render 'show' @user = User.find(params[:user_id]) sumott = 0 case @user.role when "QA" qaeods_attributes = params[:eod][:qaeods_attributes] qaeods_attributes.each do |key, value| sumott = sumott + value[:Pre_QA_H].to_f + value[:Review_H].to_f + value[:QA_H].to_f + value[:Bug_Management_H].to_f + value[:Audio_QA_H].to_f + value[:N_Review_H].to_f + value[:N_QA_H].to_f + value[:N_Bug_Management_H].to_f + value[:Project_Management_H].to_f + value[:Other_H].to_f + value[:mis_meeting].to_f + value[:mis_training].to_f + value[:mis_others].to_f + value[:ab_sickleave].to_f + value[:ab_shiftleave].to_f + value[:ab_annualleave].to_f + value[:ab_holiday].to_f + value[:ab_others].to_f + value[:vpp_H].to_f + value[:N_vpp_H].to_f end when "Loc" loceods_attributes = params[:eod][:loceods_attributes] loceods_attributes.each do |key, value| sumott = sumott + value[:familiarization_H].to_f + value[:Review_H].to_f + value[:translation_H].to_f + value[:bugfix_H].to_f + value[:audiodelivery_H].to_f + value[:N_Review_H].to_f + value[:N_translation_H].to_f + value[:N_bugfix_H].to_f + value[:Project_Management_H].to_f + value[:Other_H].to_f + value[:vpp_H].to_f + value[:N_vpp_H].to_f + value[:mis_meeting].to_f + value[:mis_training].to_f + value[:mis_others].to_f + value[:ab_sickleave].to_f + value[:ab_shiftleave].to_f + value[:ab_annualleave].to_f + value[:ab_holiday].to_f + value[:ab_others].to_f + value[:audioonsite_H].to_f + value[:polish_H].to_f end end params[:eod][:sumott] = sumott @eod = @user.eods.create(eod_params) if @eod.errors.any? render 'new' # render plain: @eod.errors.inspect else redirect_to @eod.user end #redirect_to @eod.user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eod_params\n params.require(:eod).permit!\n end", "def create\n @dia_evento = DiaEvento.new(dia_evento_params)\n\n if @dia_evento.save\n render json: @dia_evento, status: :created, location: @dia_evento\n else\n render json: @dia_evento.errors, status: :unprocessable_entity\n en...
[ "0.58552516", "0.5814527", "0.563768", "0.56346804", "0.5552279", "0.55255324", "0.5497939", "0.5427224", "0.5410804", "0.5385012", "0.5375739", "0.536578", "0.53646475", "0.53500783", "0.5341978", "0.53407824", "0.53286856", "0.5289954", "0.52610636", "0.5250427", "0.5244246...
0.0
-1
PATCH/PUT /eods/1 PATCH/PUT /eods/1.json
def update @eod = Eod.find(params[:id]) @user = @eod.user sumott = 0 case @user.role when "QA" qaeods_attributes = params[:eod][:qaeods_attributes] qaeods_attributes.each do |key, value| sumott = sumott + value[:Pre_QA_H].to_f + value[:Review_H].to_f + value[:QA_H].to_f + value[:Bug_Management_H].to_f + value[:Audio_QA_H].to_f + value[:N_Review_H].to_f + value[:N_QA_H].to_f + value[:N_Bug_Management_H].to_f + value[:Project_Management_H].to_f + value[:Other_H].to_f + value[:mis_meeting].to_f + value[:mis_training].to_f + value[:mis_others].to_f + value[:ab_sickleave].to_f + value[:ab_shiftleave].to_f + value[:ab_annualleave].to_f + value[:ab_holiday].to_f + value[:ab_others].to_f + value[:vpp_H].to_f + value[:N_vpp_H].to_f end when "Loc" loceods_attributes = params[:eod][:loceods_attributes] loceods_attributes.each do |key, value| sumott = sumott + value[:familiarization_H].to_f + value[:Review_H].to_f + value[:translation_H].to_f + value[:bugfix_H].to_f + value[:audiodelivery_H].to_f + value[:N_Review_H].to_f + value[:N_translation_H].to_f + value[:N_bugfix_H].to_f + value[:Project_Management_H].to_f + value[:Other_H].to_f + value[:vpp_H].to_f + value[:N_vpp_H].to_f + value[:mis_meeting].to_f + value[:mis_training].to_f + value[:mis_others].to_f + value[:ab_sickleave].to_f + value[:ab_shiftleave].to_f + value[:ab_annualleave].to_f + value[:ab_holiday].to_f + value[:ab_others].to_f + value[:audioonsite_H].to_f + value[:polish_H].to_f end end params[:eod][:sumott] = sumott if @eod.errors.any? render 'edit' else if @eod.update(eod_params) redirect_to @eod.user else render 'edit' end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def patch!\n request! :patch\n end", "def update # PATCH\n rai...
[ "0.6517392", "0.6462041", "0.63238883", "0.63200426", "0.63113713", "0.61453897", "0.61118037", "0.609613", "0.60948586", "0.609127", "0.6081107", "0.60590154", "0.60545415", "0.6027764", "0.60211766", "0.601166", "0.601166", "0.5998876", "0.5997617", "0.5997617", "0.59771824...
0.0
-1
DELETE /eods/1 DELETE /eods/1.json
def destroy @eod.destroy respond_to do |format| format.html { redirect_to eods_url, notice: 'Eod was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete\n client.delete(\"/#{id}\")\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': '...
[ "0.7037621", "0.69911313", "0.6830123", "0.67439836", "0.67431396", "0.6724506", "0.66881603", "0.66881543", "0.66649115", "0.6638534", "0.6617207", "0.6617207", "0.6617207", "0.6617207", "0.660277", "0.6581897", "0.65782344", "0.65676016", "0.65528125", "0.65462583", "0.6546...
0.68679804
2
Use callbacks to share common setup or constraints between actions.
def set_eod @eod = Eod.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def eod_params params.require(:eod).permit! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Helper methods Is user has specified permission ? perm:: Permission name
def has_perm? (perm) self.u_perms.each { |p| return true if perm == p.perm } false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def permission?(permission_key)\n current_user_has_permission? permission_key\n end", "def has_permission?(perm)\n !permissions.nil? && permissions.include?(perm.to_sym)\n end", "def has_permission?(perm)\n !permissions.nil? && permissions.include?(perm.to_sym)\n end", "def has_permission?(...
[ "0.7816381", "0.76925504", "0.7671803", "0.7650873", "0.7641437", "0.7624167", "0.7591785", "0.7566242", "0.7479298", "0.7401533", "0.73998207", "0.73507184", "0.7345575", "0.7329308", "0.7289794", "0.7253234", "0.72445464", "0.7239672", "0.7182424", "0.7142562", "0.71342486"...
0.6826681
45
Triangulation subroutine Takes as input vertices in array vertices Returned is a list of triangular faces in the array tris These triangles are arranged in a consistent clockwise order.
def triangulate(vertices) edges = [] tris = [] # sort by X coord vertices = vertices.sort_by {|p|p.x} # center/radius cache used by circum_circle cc_cache = {} # Set up the supertriangle # This is a triangle which encompasses all the sample points. # The supertriangle coordinates are added to the end of the # vertex list. The supertriangle is the first triangle in # the triangle list. number_of_vertices = vertices.size bounding_p1, bounding_p2, bounding_p3 = get_bounding_vertices(vertices) vertices << bounding_p1 << bounding_p2 << bounding_p3 tris << ITRIANGLE.new(number_of_vertices, number_of_vertices+1, number_of_vertices+2) # Include each point one at a time into the existing mesh vertices.each_with_index { |current_point, i| edges.clear # Set up the edge buffer. # If the point (xp,yp) lies inside the circumcircle then the # three edges of that triangle are added to the edge buffer # and that triangle is removed. j = 0 tris_size = tris.size while j < tris_size current_triangle = tris[j] if !current_triangle.complete p1 = vertices[current_triangle.p1] p2 = vertices[current_triangle.p2] p3 = vertices[current_triangle.p3] inside,xc,yc,r = circum_circle(current_point, p1, p2, p3, cc_cache) if (xc + r) < current_point.x current_triangle.complete = true end if inside edges << IEDGE.new(current_triangle.p1, current_triangle.p2) edges << IEDGE.new(current_triangle.p2, current_triangle.p3) edges << IEDGE.new(current_triangle.p3, current_triangle.p1) tris.delete_at(j) tris_size -= 1 j -= 1 end end j += 1 end #while j while !edges.empty? edge = edges.shift rejected = edges.reject! {|e| e == edge} tris << ITRIANGLE.new(edge.p1, edge.p2, i) if rejected.nil? end } #each i # Remove supertriangle vertices 3.times do vertices.pop end number_of_vertices = vertices.size # Remove triangles with supertriangle vertices # These are triangles which have a vertex number greater than number_of_vertices tris.delete_if {|tri| tri.p1 >= number_of_vertices || tri.p2 >= number_of_vertices || tri.p3 >= number_of_vertices} [ vertices, tris ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def triangulate(geometry)\n ring = geometry.exterior_ring\n\n input = ring.points.map { |point| [point.x, point.y] }\n input.pop if input.first == input.last\n\n cdt = Poly2Tri::CDT.new(input)\n cdt.triangulate!\n cdt.triangles\n end", "def validate_triangulation(triangles, messa...
[ "0.5961779", "0.59357077", "0.57481325", "0.56980664", "0.5694085", "0.55993134", "0.5536002", "0.5523026", "0.55033845", "0.54762787", "0.54762787", "0.54664916", "0.5460731", "0.54319644", "0.54158217", "0.54020816", "0.5386715", "0.5336958", "0.5319766", "0.5317978", "0.53...
0.7567029
0
Return TRUE if a point p is inside the circumcircle made up of the points p1, p2, p3 The circumcircle center is returned in (xc,yc) and the radius r The return value is an array [ inside, xc, yc, r ] Takes an optional cache hash to use for radius/center caching NOTE: A point on the edge is inside the circumcircle
def circum_circle(p, p1, p2, p3, cache = nil) dx,dy,rsqr,drsqr = [] cached = cache && cache[[p1, p2, p3]] xc, yc, r = [] rsqr = 0 if cached xc, yc, r, rsqr = cached else # Check for coincident points if (points_are_coincident(p1,p2) || points_are_coincident(p2,p3) || points_are_coincident(p1,p3)) #puts("CircumCircle: Points are coincident.") return [ false, 0, 0, 0 ] end if (p2.y-p1.y).abs < EPSILON m2 = - (p3.x-p2.x) / (p3.y-p2.y) mx2 = (p2.x + p3.x) * 0.5 my2 = (p2.y + p3.y) * 0.5 xc = (p2.x + p1.x) * 0.5 yc = m2 * (xc - mx2) + my2 elsif (p3.y-p2.y).abs < EPSILON m1 = - (p2.x-p1.x) / (p2.y-p1.y) mx1 = (p1.x + p2.x) * 0.5 my1 = (p1.y + p2.y) * 0.5 xc = (p3.x + p2.x) * 0.5 yc = m1 * (xc - mx1) + my1 else m1 = - (p2.x-p1.x) / (p2.y-p1.y) m2 = - (p3.x-p2.x) / (p3.y-p2.y) mx1 = (p1.x + p2.x) * 0.5 mx2 = (p2.x + p3.x) * 0.5 my1 = (p1.y + p2.y) * 0.5 my2 = (p2.y + p3.y) * 0.5 xc = (m1 * mx1 - m2 * mx2 + my2 - my1) / (m1 - m2) yc = m1 * (xc - mx1) + my1 end dx = p2.x - xc dy = p2.y - yc rsqr = dx*dx + dy*dy r = Math.sqrt(rsqr) cache[[p1, p2, p3]] = [ xc, yc, r, rsqr ] if cache end dx = p.x - xc dy = p.y - yc drsqr = dx*dx + dy*dy [ (drsqr <= rsqr), xc, yc, r ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def point_in_circle(p, c)\n difference_v = T_VECTORS.pop.set(p) - c.position\n radius_sq = c.r * c.r\n distance_sq = difference_v.lengthsq\n T_VECTORS.push(difference_v)\n # If the distance between is smaller than the radius then the point is inside the circle.\n distance_...
[ "0.6527931", "0.64388806", "0.6419674", "0.6232615", "0.6070144", "0.60322005", "0.59882295", "0.5920445", "0.5892221", "0.58235496", "0.5785036", "0.57087463", "0.56787616", "0.567436", "0.56622255", "0.5594087", "0.55539906", "0.5534976", "0.5505675", "0.55012363", "0.54830...
0.7627279
0
The token_type of the token_permission_type Returns String
def to_s token_type end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n self.token_type\n end", "def token_type; end", "def token_type\n \"Bearer\"\n end", "def getTokenKind()\r\n return @curr_token.id\r\n end", "def token_type\n 'Bearer'\n end", "def parse_token_type\n token_type = get_element('//t:RequestSecurityTokenResponse/t:Token...
[ "0.78728765", "0.7169333", "0.68952453", "0.6755076", "0.6750078", "0.6668135", "0.66671294", "0.6665158", "0.66342777", "0.65830404", "0.6532922", "0.6527771", "0.64109445", "0.638725", "0.63509697", "0.63202524", "0.62928003", "0.6112256", "0.6112256", "0.610819", "0.610085...
0.80233765
0
GET /prd_attributes GET /prd_attributes.xml
def index @prd_attributes = PrdAttribute.all(:include => [:products, :prd_attribute_devices], :order => "id DESC") respond_to do |format| format.html # index.html.erb format.xml { render :xml => @prd_attributes } format.json { @returns = [] @prd_attributes.each do |factor| @returns << mapping_to_hash(factor, PrdAttribute.json_mapping_table) end render :json => @returns } format.rule { @prd_attribute_list_output = [] # prd_attribute_list_output에 product_list.rule에 사용할 row를 정리 # @prd_attributes.each do |prd_attribute| if not prd_attribute.data_to_ruleset_list.blank? @prd_attribute_list_output << prd_attribute.data_to_ruleset_list + "\n" end end # product_list.rule에 대해서 정의함 # @output = render_to_string(:file => TMPL_PATH + RULE['PrdAttribute']['tmpl_list']) file_name = RULE_PATH + RULE['PrdAttribute']['rule_list'] File.delete(file_name) if File.exist?(file_name) file = File.open(file_name, "w") file << @output file.close # prd_attributres에 대해서 # #@prd_attributes.each { |prd_attribute| # @prd_conditions_what, @prd_conditions_where, @prd_conditions_when, @prd_conditions_who = [], [], [], [] # @prd_conditions = Hash.new # @prd_conditions[:what] = @prd_conditions_what # @prd_conditions[:where] = @prd_conditions_where # @prd_conditions[:who] = @prd_conditions_who # @prd_conditions[:when] = @prd_conditions_when # charging_account.rule # #@prd_balances_output = PrdBalance.data_to_prd_ruleset(prd_attribute.products[0].id, @prd_conditions) #save_to_ruleset_charging_account(prd_attribute.name, @prd_balances_output) #} render :rule => @output } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @catalog_product_attributes = CatalogProductAttributes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @catalog_product_attributes }\n end\n end", "def new\n @prd_attribute = PrdAttribute.new\n\n respond_to do |format|...
[ "0.65538925", "0.64128906", "0.62780434", "0.61299366", "0.61127985", "0.60396576", "0.6029874", "0.60003895", "0.5939791", "0.5900972", "0.58877265", "0.5884976", "0.5880299", "0.5870859", "0.5822988", "0.58207846", "0.5759431", "0.5735771", "0.5735414", "0.56915164", "0.569...
0.5057427
100
GET /prd_attributes/1 GET /prd_attributes/1.xml
def show require 'open-uri' @prd_attribute = PrdAttribute.find(params[:id], :include => [:products, :prd_attribute_devices]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @prd_attribute } format.json { render :json => mapping_to_hash(@prd_attribute, PrdAttribute.json_mapping_table) } format.rule { product = @prd_attribute.products[0] f = open("http://localhost:3000/products/"+product.id.to_s+".rule") @webpage = f.read f.close render :rule => @webpage } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @catalog_product_attributes = CatalogProductAttributes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @catalog_product_attributes }\n end\n end", "def new\n @prd_attribute = PrdAttribute.new\n\n respond_to do |format|...
[ "0.6534519", "0.63717496", "0.616081", "0.6001217", "0.5922237", "0.5906426", "0.5858503", "0.5826477", "0.5826188", "0.5795023", "0.5787475", "0.57841873", "0.57708144", "0.57056504", "0.5701562", "0.56770927", "0.56564415", "0.5638742", "0.5630739", "0.55832416", "0.5581015...
0.6185393
2
GET /prd_attributes/new GET /prd_attributes/new.xml
def new @prd_attribute = PrdAttribute.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @prd_attribute } format.json { render :json => @prd_attribute } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @attr_type = AttrType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attr_type }\n end\n end", "def new\n @actattribute = Actattribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml...
[ "0.71981746", "0.70892644", "0.70838976", "0.70710653", "0.7034725", "0.68184686", "0.673044", "0.66846985", "0.66785336", "0.6670787", "0.6628466", "0.65922934", "0.65876406", "0.6562596", "0.65579057", "0.6534814", "0.6501297", "0.648799", "0.6471098", "0.64651185", "0.6458...
0.792203
0
POST /prd_attributes POST /prd_attributes.xml
def create @prd_attribute = PrdAttribute.new @prd_attribute.bill_type_id = params[:prd_attribute]['bill_type'].to_i @prd_attribute.name = params[:prd_attribute]['name'] @prd_attribute.rollover = params[:prd_attribute]['rollover'] @prd_attribute.code = params[:prd_attribute]['code'] @prd_attribute.prd_type = params[:prd_attribute]['prd_type'] @prd_attribute.description = params[:prd_attribute]['description'] @prd_attribute.status_id = params[:prd_attribute]['status'].to_i @prd_attribute.service_type_id = params[:prd_attribute]['service_type'].to_i @prd_attribute.monthly_fee = params[:prd_attribute]['monthly_fee'].to_i @prd_attribute.subscription_fee = params[:prd_attribute]['subscription_fee'].to_i @prd_attribute.target_user = params[:prd_attribute]['target_user'] @prd_attribute.start_date = params[:prd_attribute]['start_date'] @prd_attribute.end_date = params[:prd_attribute]['end_date'] respond_to do |format| if @prd_attribute.save format.html { redirect_to(@prd_attribute, :notice => 'PrdAttribute was successfully created.') } format.xml { render :xml => @prd_attribute, :status => :created, :location => @prd_attribute } format.json { product = Product.new product.prd_attribute_id = @prd_attribute.id product.save! # bundle일 때에는 해당하는 product id들을 저장 # if params[:prd_attribute]['prd_type'].upcase == 'BUNDLE' product_ids = [] params[:prd_attribute]['ref_products'].each do |product_id| product_ids << product_id['product_id'].to_s end @prd_attribute.ref_products = product_ids.join(",") end @prd_attribute.save # product devices 저장 # if not params[:prd_attribute]['devices'].blank? params[:prd_attribute]['devices'].each do |device| prd_attribute_device = PrdAttributeDevice.new prd_attribute_device.code_factor_id = device['device'].to_i prd_attribute_device.prd_attribute_id = @prd_attribute.id prd_attribute_device.product_id = product.id prd_attribute_device.save! end end # product에 대한 기본 conditions 설정 # product.set_default_conditions(@prd_attribute, product) render :json => mapping_to_hash(@prd_attribute, PrdAttribute.json_mapping_table), :status => :created, :location => @prd_attribute } else format.html { render :action => "new" } format.xml { render :xml => @prd_attribute.errors, :status => :unprocessable_entity } format.json { render :json => @prd_attribute.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @prd_attribute = PrdAttribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prd_attribute }\n format.json { render :json => @prd_attribute }\n end\n end", "def create\n @idp_attribute = IdpAttribute.new(idp_attribute_params)\n\n...
[ "0.6226755", "0.6016898", "0.59168947", "0.58473545", "0.5731617", "0.573151", "0.5638003", "0.561468", "0.5600245", "0.5581907", "0.5556145", "0.55492705", "0.55184126", "0.55076", "0.54967743", "0.5494441", "0.54814786", "0.5480252", "0.54514563", "0.5427169", "0.5426517", ...
0.6485095
0
PUT /prd_attributes/1 PUT /prd_attributes/1.xml
def update @prd_attribute = PrdAttribute.find(params[:id]) @prd_attribute.code = params[:prd_attribute]['code'] @prd_attribute.name = params[:prd_attribute]['name'] @prd_attribute.rollover = params[:prd_attribute]['rollover'] @prd_attribute.description = params[:prd_attribute]['description'] @prd_attribute.status_id = params[:prd_attribute]['status'].to_i @prd_attribute.prd_type = params[:prd_attribute]['prd_type'] @prd_attribute.bill_type_id = params[:prd_attribute]['bill_type'].to_i @prd_attribute.service_type_id = params[:prd_attribute]['service_type'].to_i @prd_attribute.monthly_fee = params[:prd_attribute]['monthly_fee'] @prd_attribute.subscription_fee = params[:prd_attribute]['subscription_fee'] @prd_attribute.target_user = params[:prd_attribute]['target_user'] @prd_attribute.start_date = params[:prd_attribute]['start_date'] @prd_attribute.end_date = params[:prd_attribute]['end_date'] respond_to do |format| format.html { if @prd_attribute.update_attributes(params[:prd_attribute]) redirect_to(@prd_attribute, :notice => 'PrdAttribute was successfully updated.') else format.html { render :action => "edit" } end } format.xml { if @prd_attribute.update_attributes(params[:prd_attribute]) head :ok else format.xml { render :xml => @prd_attribute.errors, :status => :unprocessable_entity } end } format.json { # bundle일 때에는 해당하는 product id들을 저장 # if params[:prd_attribute]['prd_type'].upcase == 'BUNDLE' product_ids = [] params[:prd_attribute]['ref_products'].each do |product_id| product_ids << product_id['product_id'].to_s end @prd_attribute.ref_products = product_ids.join(",") end @prd_attribute.save # product devices 저장 # if not params[:prd_attribute]['devices'].blank? params[:prd_attribute]['devices'].each do |device| prd_attribute_device = PrdAttributeDevice.new prd_attribute_device.code_factor_id = device['device'].to_i prd_attribute_device.prd_attribute_id = @prd_attribute.id prd_attribute_device.product_id = @prd_attribute.products[0].id prd_attribute_device.save! end end #render :json => @prd_attribute.errors, :status => :unprocessable_entity head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @catalog_product_attributes = CatalogProductAttributes.find(params[:id])\n\n respond_to do |format|\n if @catalog_product_attributes.update_attributes(params[:catalog_product_attributes])\n flash[:notice] = 'CatalogProductAttributes was successfully updated.'\n format.html { r...
[ "0.64087325", "0.6311469", "0.61315656", "0.60436094", "0.58606386", "0.5845868", "0.5800207", "0.57984424", "0.5787223", "0.57798105", "0.5776507", "0.5734052", "0.57293284", "0.572496", "0.5718098", "0.57012695", "0.5687673", "0.5682747", "0.5672973", "0.56634986", "0.56619...
0.645485
0
DELETE /prd_attributes/1 DELETE /prd_attributes/1.xml
def destroy @prd_attribute = PrdAttribute.find(params[:id]) @prd_attribute.destroy #delete_rules() respond_to do |format| format.html { redirect_to(prd_attributes_url) } format.xml { head :ok } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @catalog_product_attributes = CatalogProductAttributes.find(params[:id])\n @catalog_product_attributes.destroy\n\n respond_to do |format|\n format.html { redirect_to(catalog_product_attributes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @actattribute = A...
[ "0.67909056", "0.66456294", "0.6457805", "0.644428", "0.643452", "0.64122725", "0.64104486", "0.63862956", "0.6329849", "0.6303584", "0.63021", "0.63020825", "0.62941283", "0.62666476", "0.6243546", "0.62334406", "0.62334406", "0.62170446", "0.62099105", "0.62030715", "0.6202...
0.72387856
0
Reads a file for an xml document
def read(file) f = File.open file @doc = Nokogiri::XML(f) @current_node = @doc.root; f.close end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_file(filename)\n File.open(filename, \"r\") {|f| load_xml(f.read)}\n end", "def read_xml\n @epub.file.read_xml(abs_filepath)\n end", "def load_xml file\n f = File.open file\n doc = Nokogiri::XML f\n f.close\n doc\n end", "def xml\n File.read(\"#{@file_path}.xml\")\n...
[ "0.79731673", "0.76209915", "0.74321127", "0.7430983", "0.73843217", "0.72938585", "0.72395647", "0.70664537", "0.69445425", "0.69028014", "0.69028014", "0.6876141", "0.67945975", "0.6754631", "0.66623855", "0.66580325", "0.66309625", "0.6566314", "0.652696", "0.6508213", "0....
0.73612195
5
Returns true if the given node is valid
def is_valid(node = @current_node) return node != nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid?\n inner_root.children.detect{|node| node.valid? == false} == nil # should be explicitely nil !!\n end", "def valid?\n return true unless applicable?\n\n inclusive = spec['inclusive']\n\n case inclusive\n when true, false\n nodes.size > 0\n else\n ...
[ "0.72213846", "0.7154274", "0.7041897", "0.70019966", "0.69212425", "0.67188084", "0.6704628", "0.66957223", "0.66861844", "0.6680971", "0.6680971", "0.66616297", "0.66254604", "0.66079724", "0.6578558", "0.653918", "0.6476036", "0.6467516", "0.645639", "0.64520454", "0.64463...
0.8611224
0
Sets the current node.
def set_current(node) @current_node = node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_node(val)\n self.node = val\n self\n end", "def set_node(val)\n self.node = val\n self\n end", "def current=(node)\n\t\t\t@try_current[-1] = node\n\t\tend", "def node=(node)\n @node = node\n end", "def node=(val)\r\n case val\r\n when Node, NilClass\r\n @nod...
[ "0.7911279", "0.7911279", "0.7470951", "0.739517", "0.7286752", "0.69640344", "0.69640344", "0.69106114", "0.689993", "0.689993", "0.689993", "0.6890156", "0.6852821", "0.6783472", "0.67271954", "0.670349", "0.6699798", "0.6671914", "0.6670677", "0.6619546", "0.6579447", "0...
0.85755503
0
Returns a set of nodes based on the provided xpath query
def xpath(query) return is_valid ? @doc.xpath(query) : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_elements(xpath); end", "def find_all_nodes(xpath, select_result_value=false)\n if self.feed_data_type != :xml\n raise \"The feed data type is not xml.\"\n end\n return FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [xpath],\n :select_result_value => select_result_valu...
[ "0.7205551", "0.71301764", "0.69440466", "0.6718571", "0.67178035", "0.65306026", "0.65018433", "0.6460227", "0.6439678", "0.6438726", "0.64033467", "0.63817286", "0.63785887", "0.6378162", "0.6378062", "0.6353705", "0.63107264", "0.63105214", "0.62567365", "0.61916524", "0.6...
0.6144487
23
Returns a set of nodes with a type included in the provided array
def get_all_xpath(values) if values.nil? then return [] end return xpath('//' + values.join(XPATH_JOIN)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def types(types)\n select { |node| types.include?(node.type) }\n end", "def types(types)\n select { |node| types.include?(node.type) }\n end", "def array_of(*kinds, &block)\n lambda do |node|\n result = NodeFilters.filter(node, kinds)\n block ? result.map(&block) : re...
[ "0.6270133", "0.6270133", "0.6219962", "0.58022994", "0.5709348", "0.5707796", "0.5702014", "0.5658399", "0.5600445", "0.55492353", "0.54454195", "0.5416081", "0.53924054", "0.5359042", "0.53554666", "0.53327984", "0.5291171", "0.5253226", "0.5240951", "0.5231185", "0.5205468...
0.0
-1
Returns a set of nodes based on the provided css query
def css(query) return is_valid ? @doc.css(query) : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def css *args\n if children.any?\n children.css(*args)\n else\n NodeSet.new(document)\n end\n end", "def search(*selectors)\n NodeSet.new selectors.map {|selector|\n xpath(selector).to_a.concat(css(selector).to_a)\n }.flatten.uniq\n end", "def elements(cs...
[ "0.6573356", "0.6561223", "0.6100464", "0.60985225", "0.6066445", "0.5941786", "0.59309095", "0.59168774", "0.5831138", "0.57481235", "0.5699979", "0.56963116", "0.56922334", "0.5687673", "0.5544549", "0.5489984", "0.5481854", "0.5461843", "0.5452489", "0.5447596", "0.5412925...
0.64105386
2
Returns the root node of the current xml document
def root return @doc == nil ? nil : @doc.root; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root_node\n if @root_node.nil?\n # TODO: Fix this so that added content at the end of the file doesn't\n # break this stuff.\n # E.g.: http://smogzer.tripod.com/smog.rdf\n # ===================================================================\n begin\n if self.xm...
[ "0.86464584", "0.80143654", "0.7838439", "0.78090966", "0.78021294", "0.77411765", "0.75728893", "0.7465455", "0.7465455", "0.7384013", "0.7384013", "0.7369182", "0.7290095", "0.7176249", "0.71647877", "0.7164394", "0.7126299", "0.7118492", "0.7091329", "0.700699", "0.6981143...
0.80426675
1
Returns the line of the given node
def line(node = @current_node) return is_valid(node) ? node.line : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line\n @line ||= Line.get(@attrs['LineCode'])\n end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def line\n @line ||= Line.get(@attrs['Line'])\n end", "def node_at(line, column); end", "def node_at(line, c...
[ "0.71782935", "0.7125175", "0.70600444", "0.6977402", "0.69341874", "0.678375", "0.67634153", "0.6708213", "0.670025", "0.6694176", "0.6694176", "0.6694176", "0.66926646", "0.66926646", "0.66926646", "0.66926646", "0.66926646", "0.66711825", "0.6632219", "0.6618952", "0.65936...
0.87152517
0
Returns an array of children of the current node
def children return children_of @current_node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def children\n node.children\n end", "def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end", "def get_children\n return children\n end", "def get_children\n return @children\n end", "def children\n self.node....
[ "0.85183483", "0.8328256", "0.8261618", "0.8234224", "0.8159584", "0.8103686", "0.8103686", "0.8075742", "0.8075742", "0.8075742", "0.8053072", "0.7976374", "0.7973109", "0.7956186", "0.79393244", "0.79280365", "0.7924833", "0.7895326", "0.7877886", "0.7867015", "0.78425753",...
0.87402105
0
Returns an array of children of the given parent node
def children_of(node) return is_valid(node) ? node.children : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_node_children(parent,parent_id)\n @kids = []\n children = parent.get_elements(\"children\")\n children.each do |child|\n ps = construct_node(child,parent_id)\n if ps != nil\n @kids << ps\n end\n end\n if !@kids.empty?\n @kids = @kids.sort_by { |k| k.name.downcase }...
[ "0.7896279", "0.7297625", "0.72965854", "0.7293801", "0.7281092", "0.72345966", "0.71894103", "0.71894103", "0.71894103", "0.71709126", "0.71709126", "0.7163972", "0.7153677", "0.7138193", "0.70532924", "0.70358676", "0.7027525", "0.7010547", "0.693609", "0.69115555", "0.6890...
0.64241475
62
Extract children from an object into an array. Intended for use with Node and NodeSet objects
def extract_children_from(obj) if obj.nil? then return [] end output = [] set = obj.children set.each do |node| output << node end return output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end", "def children\n @children ||= {}.with_indifferent_access\n end", "def children\n result = []\n @children.each do |_, child_group|\n result.concat(child_group...
[ "0.7106915", "0.6998907", "0.6959831", "0.6923284", "0.69081885", "0.6811364", "0.6805195", "0.6761696", "0.67529523", "0.6745616", "0.6731596", "0.67303765", "0.67075676", "0.6700036", "0.6700036", "0.6700036", "0.669388", "0.66851604", "0.66851604", "0.6681883", "0.6660352"...
0.8473741
0
Returns the attribute keys of the current node
def attr_keys return attr_keys_in @current_node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keys\n attribute_nodes.map(&:node_name)\n end", "def attr_keys_in(node)\n\t\treturn is_valid(node) ? node.keys : nil\n\tend", "def keys\n @attributes.keys\n end", "def attribute_keys\n return [] unless self[:attributes]\n self[:attributes].keys\n end", "de...
[ "0.90559864", "0.81568533", "0.80238926", "0.798886", "0.7812277", "0.77941734", "0.7712413", "0.7712413", "0.7712413", "0.7467831", "0.74057436", "0.73241997", "0.723899", "0.7219216", "0.7219216", "0.7219216", "0.7219216", "0.7200891", "0.7109218", "0.7092491", "0.70062256"...
0.8992906
1
Returns the attribute keys of the given node
def attr_keys_in(node) return is_valid(node) ? node.keys : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keys\n attribute_nodes.map(&:node_name)\n end", "def attr_keys\n\t\treturn attr_keys_in @current_node\n\tend", "def attributes_of(node)\n\t\tmap = Hash.new\n\t\t\n\t\tif !is_valid node then\n\t\t\treturn map\n\t\tend\n\t\t\n\t\tvarKeys = attr_keys_in node\n\t\tif !varKeys.nil? then\n\t\t\tvarKe...
[ "0.8781843", "0.81699824", "0.77056885", "0.7474048", "0.7474048", "0.7474048", "0.74337006", "0.73340183", "0.7273205", "0.72146", "0.7184335", "0.6848043", "0.68173", "0.6806917", "0.6763627", "0.6697388", "0.664985", "0.664917", "0.664917", "0.664917", "0.664917", "0.664...
0.8404115
1
Returns a hash of attributes for the current node
def attributes return attributes_of @current_node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes\n attribute_nodes.each_with_object({}) do |node, hash|\n hash[node.node_name] = node\n end\n end", "def hash\n @attrs\n end", "def attributes\n node[1]\n end", "def hash\n node_id.hash\n end", "def attributes_of(node)\n\t\tmap =...
[ "0.80647045", "0.75737137", "0.7371458", "0.7178217", "0.7173893", "0.7097687", "0.70500326", "0.701273", "0.69741315", "0.69741315", "0.69741315", "0.69466156", "0.6904702", "0.68266094", "0.68118197", "0.67625374", "0.67510116", "0.67456764", "0.6737818", "0.6679685", "0.66...
0.75875473
1
Returns a hash of attributes for a given node
def attributes_of(node) map = Hash.new if !is_valid node then return map end varKeys = attr_keys_in node if !varKeys.nil? then varKeys.each do |key| map[key] = node[key] end end return map end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes\n attribute_nodes.each_with_object({}) do |node, hash|\n hash[node.node_name] = node\n end\n end", "def xml_node_to_hash(nokogiri_node)\n\t\t\tattributes = Hash.new\n\n\t\t\tnokogiri_node.each do |k,v|\n\t\t\t\tattributes[k.to_sym] = v.value\n\t\t\tend\n\n\t\t\treturn a...
[ "0.7783991", "0.7623897", "0.7268262", "0.72092825", "0.7129924", "0.6954855", "0.6922437", "0.6921246", "0.6772712", "0.6702666", "0.66946703", "0.6683129", "0.6681362", "0.66218", "0.661858", "0.654317", "0.6523913", "0.6523913", "0.6523913", "0.6508815", "0.64791906", "0...
0.7868834
0
Returns the value of the given node attribute
def attribute_value(key, node = @current_node) if is_valid(node) && node.key?(key) then return node.attribute(key).to_s else return '' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr(node,name_attribute='Name')\n node.attributes[name_attribute].value\n end", "def value(node, attribute); end", "def value(node, attribute); end", "def get_attribute(node, attr_name)\n node.attribute(attr_name)\n end", "def attr(node, attribute_name, namespace = nil)\n attr...
[ "0.83067316", "0.8283919", "0.8283919", "0.7901861", "0.78216064", "0.7587308", "0.7465562", "0.74578124", "0.7332146", "0.7314536", "0.7304191", "0.7230568", "0.70928967", "0.7020404", "0.6947947", "0.69438", "0.69315314", "0.69215864", "0.68275833", "0.6819721", "0.6816775"...
0.7726517
5
Returns the parent of the current node
def parent return parent_of @current_node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parent\n unless @node.send(@parent).nil?\n @node = @node.send(@parent)\n end\n end", "def parent_node(node)\n return node.respond_to?(:parent) ? node.parent : node\n end", "def parent_of node\n\t\treturn is_valid(node) ? node.parent : nil\n\tend", "def parent\n tree.parent_fo...
[ "0.82663214", "0.8248503", "0.8191364", "0.81071085", "0.804401", "0.78610647", "0.77705085", "0.7767879", "0.7737364", "0.76905674", "0.7676077", "0.7650954", "0.7615633", "0.7582549", "0.7560485", "0.74919134", "0.7448836", "0.7413001", "0.7413001", "0.7413001", "0.7413001"...
0.8939264
0