query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Below code is used in show and edit_task to get lawyer details. | def lawyer_details(notes)
@allowed_ids=[]
lawyer = Employee.find_by_user_id(notes.assigned_by_employee_user_id, :include => [:company => :employees])
lawyer.company.employees.each do |employee|
@allowed_ids << employee.user_id
end
end | [
"def get_lawyer_info(matter)\n @lawyer = User.find(matter.employee_user_id)\n end",
"def find_lawyer\n @lawyer = Lawyer.find(params[:id])\n end",
"def show_lawyer_list\n authorize!(:show_lawyer_list,current_user) unless current_user.role?:secretary\n #session[:verified_secretary_id1] = params[:ser... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Searches enquiries based on agents or agencies. | def enquiries_search(opts = {})
data, _status_code, _headers = enquiries_search_with_http_info(opts)
data
end | [
"def enquiries_search_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: EnquiriesApi.enquiries_search ...'\n end\n # resource path\n local_var_path = '/v1/enquiries'\n\n # query parameters\n query_params = {}\n query... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Searches enquiries based on agents or agencies. | def enquiries_search_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: EnquiriesApi.enquiries_search ...'
end
# resource path
local_var_path = '/v1/enquiries'
# query parameters
query_params = {}
query_params[:'agen... | [
"def enquiries_search(opts = {})\n data, _status_code, _headers = enquiries_search_with_http_info(opts)\n data\n end",
"def all_search\n @results ||= []\n feat_keyword ||= {:name_contains => params[:q]}\n reward_keyword ||= {:partner_business_name_contains => params[:q]}\n\n Feat.search(f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use this method to tell the server this plugin defines additional HTTP methods. This method is passed a uri. It should only return HTTP methods that are available for the specified uri. | def http_methods(_path)
[]
end | [
"def http_methods(uri)\n tree = @server.tree\n\n if tree.node_exists(uri)\n node = tree.node_for_path(uri)\n return ['PATCH'] if node.is_a?(IPatchSupport)\n end\n []\n end",
"def http_methods(uri)\n begin\n node = @server.tree.no... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a bunch of metadata about the plugin. Providing this information is optional, and is mainly displayed by the Browser plugin. The description key in the returned array may contain html and will not be sanitized. | def plugin_info
{
'name' => plugin_name,
'description' => nil,
'link' => nil
}
end | [
"def plugin_info\n {\n 'name' => plugin_name,\n 'description' => 'Generates HTML indexes and debug information for your sabre/dav server',\n 'link' => 'http://sabre.io/dav/browser-plugin/'\n }\n end",
"def plugin_meta(slice=nil)\n # see ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
use in auth_rules(examquestion) return [programme_id] for academician | def lecturers_programme
mypost = Position.find(:first, :conditions => ['staff_id=?',staff_id])
myunit = mypost.unit
postbasics=['Pengkhususan', 'Pos Basik', 'Diploma Lanjutan']
post_prog=Programme.find(:all, :conditions => ['course_type IN(?)', postbasics])
dip_prog=Programme.find(:all, :conditions ... | [
"def get_quiz_id(assessment_division)\n if assessment_division.is_a?(Quiz)\n return assessment_division.id\n else\n return assessment_division.quiz_id\n end\n\n end",
"def get_instructor_id\n Questionnaire.find_by(id: node_object_id).try(:instructor_id)\n end",
"def transform_question_id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
maps a score to 3 rgb values | def scoreToColor(score, minVal, maxVal)
maxColor = 230.0
minColor = 10.0
norm = (((score.to_f - minVal ) / (maxVal - minVal ) ) * (maxColor - minColor)) + minColor
norm = [maxColor, norm].min
return [minColor, norm, norm]
end | [
"def get_color_from_score(score, lod_score, use_dprime)\n color = 'white'\n if use_dprime then\n if lod_score > 2\n if score < 0.5\n # high LOD, low D'\n color = \"rgb(255,224,244)\"\n else\n # high LOD, high D' => shades of red\n blue_green = (255-32)*2*... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find parts that are definitely required and should raise an error if they're not present | def __required_parts
required = []
required << 'body' if (@spec['body'] && @spec['body']['required'])
# Get required variables from paths:
req_variables = __path_variables.inject(:&) # find intersection
required << req_variables unless req_variables.empty?
required.flatt... | [
"def parse_required_parts(spec)\n required = []\n return required if @endpoint_name == 'tasks.get'\n\n required << 'body' if (spec['body'] && spec['body']['required'])\n # Get required variables from paths:\n req_variables = parse_path_variables.inject(:&) # find intersection\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set locales and regions | def set(locales = nil, regions = nil)
@Locales = locales unless locales.nil?
@Regions = regions unless regions.nil?
self
end | [
"def available_locales=(locales); end",
"def configure(&block)\n block.call @locale\n end",
"def setLocale\n if @lOptions.count\n @lOptions.each do | key, value |\n case key\n when :locale_group\n @lgrp = @@lOptions... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If child_id is not set, then link_url is used to find/create a Shadow and set the shadow_id | def create_shadow_if_needed
if self.link_url.present?
self.shadow = Shadow.special_find_or_create_by_web_url( self.link_url )
if( self.shadow.errors.empty? )
write_attribute(:shadow_id, self.shadow.id)
return true
else
errors.add_to_base( self.shadow.errors.fu... | [
"def generate_new_child_link(resource, attr)\n\t\t\tnil\n\t\tend",
"def hydrate_link(parent, name)\n record = get_record(@data, name)\n if record\n link = add_link_properties(parent, name, record)\n else\n puts \"\\e[31mNot found -... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method is used to generate the token from UAA server by providing the UAA url and usename and password. | def get_access_token()
if @api_url[4] != "s"
temp = @api_url[10..@api_url.length]
@uaa_target = "https://uaa#{temp}"
else
temp=@api_url[11..@api_url.length]
@uaa_target = "https://uaa#{temp}"
end
Dir.chdir @home_directory
FileUtils.rm_rf(".uaac.yml")
system("uaac target #{@uaa_target} --skip-ssl-validatio... | [
"def gen_token\n nonce = Array.new(10){rand(0x100000000)}.pack('I*')\n nonce_base64 = [nonce].pack('m').chomp\n now = Time.now.utc.iso8601\n digest = [Digest::SHA1.digest(nonce + now + @password)].pack('m').chomp\n sprintf(%Q<UsernameToken Username=\"%s\", PasswordDigest=\"%s\", N... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method is used to prompt for getting api url and return the api url. | def get_api_url()
print "Enter the API URL(include http:// or https://)::".yellow
@api_url = gets.chomp
end | [
"def api_url\n api_mode + api_interface\n end",
"def get_api_key\n green \"****************************************\"\n green \"****************************************\"\n green \"**** API SETUP TIME! ****\"\n green \"****************************************\"\n gr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /sysconfigs/1 GET /sysconfigs/1.json | def show
@sysconfig = Sysconfig.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sysconfig }
end
end | [
"def index\n @sys_configs = SysConfig.all\n end",
"def retrieve_system_configuration()\n start.uri('/api/system-configuration')\n .get()\n .go()\n end",
"def retrieve_system_configuration()\n start.uri('/api/system-configuration')\n .get()\n .go()\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /sysconfigs/new GET /sysconfigs/new.json | def new
@sysconfig = Sysconfig.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @sysconfig }
end
end | [
"def new\n @sys_configuration = SysConfiguration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sys_configuration }\n end\n end",
"def new\n @sys_config = SysConfig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.x... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /sysconfigs POST /sysconfigs.json | def create
@sysconfig = Sysconfig.new(params[:sysconfig])
respond_to do |format|
if @sysconfig.save
format.html { redirect_to @sysconfig, notice: 'Sysconfig was successfully created.' }
format.json { render json: @sysconfig, status: :created, location: @sysconfig }
else
form... | [
"def create\n @sysconfig = Sysconfig.new(sysconfig_params)\n\n respond_to do |format|\n if @sysconfig.save\n format.html { redirect_to @sysconfig, notice: 'Sysconfig was successfully created.' }\n format.json { render :show, status: :created, location: @sysconfig }\n else\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /sysconfigs/1 PUT /sysconfigs/1.json | def update
@sysconfig = Sysconfig.find(params[:id])
respond_to do |format|
if @sysconfig.update_attributes(params[:sysconfig])
format.html { redirect_to @sysconfig, notice: 'Sysconfig was successfully updated.' }
format.json { head :no_content }
else
format.html { render act... | [
"def update\n respond_to do |format|\n if @sysconfig.update(sysconfig_params)\n format.html { redirect_to @sysconfig, notice: 'Sysconfig was successfully updated.' }\n format.json { render :show, status: :ok, location: @sysconfig }\n else\n format.html { render :edit }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /sysconfigs/1 DELETE /sysconfigs/1.json | def destroy
@sysconfig = Sysconfig.find(params[:id])
@sysconfig.destroy
respond_to do |format|
format.html { redirect_to sysconfigs_url }
format.json { head :no_content }
end
end | [
"def destroy\n @sys_config.destroy\n respond_to do |format|\n format.html { redirect_to sys_configs_url, notice: 'Sys config was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sys_configuration = SysConfiguration.find(params[:id])\n @sys_confi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /defenses GET /defenses.json | def index
@defenses = Defense.all
end | [
"def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end",
"def show\r\n @defense = Defense.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.jso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /defenses POST /defenses.json | def create
@defense = Defense.new(defense_params)
respond_to do |format|
if @defense.save
format.html { redirect_to @defense, notice: 'Defense was successfully created.' }
format.json { render :show, status: :created, location: @defense }
else
format.html { render :new }
... | [
"def create\n @expense = Expense.new(expense_params)\n\n if @expense.save\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end",
"def index\n @defenses = Defense.all\n end",
"def post_expense(expense)\n post '/expenses', JSON.ge... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Closes the open remote shell session. This method can be called multiple times, even if there is no open session. | def close
return if shell.nil?
service.close_shell(shell)
@shell = nil
end | [
"def close\n @shell.close\n end",
"def close\n @ssh.close\n end",
"def close\n begin\n close_session\n rescue => e\n STDERR.puts \"Failed to send or receive close-session: #{e}\"\n ensure\n @connection.close\n end\n end",
"def close_ssh\n puts \"Close conne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Opens a remote shell session for reuse. The maxiumum commandpershell threshold is also determined the first time this method is invoked and cached for later invocations. | def open
close
@shell = service.open_shell
@command_count = 0
determine_max_commands unless max_commands
shell
end | [
"def open\n close\n retryable(service.retry_limit, service.retry_delay) do\n @shell = service.open_shell(codepage: code_page)\n end\n add_finalizer(shell)\n @command_count = 0\n shell\n end",
"def remote_shell(&block)\n RemoteShell.new(@dest,&block)\n end",
"def c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines the safe maximum number of commands that can be executed on a remote shell session by interrogating the remote host. | def determine_max_commands
os_version = run_powershell_script(PS1_OS_VERSION).stdout.chomp
@max_commands = os_version < "6.2" ? LEGACY_LIMIT : MODERN_LIMIT
@max_commands -= 2 # to be safe
end | [
"def max_command_length\n @max_command_length ||=\n if Gem.win_platform?\n # Windows is limited to 2048 since that is a worst-case scenario.\n # http://blogs.msdn.com/b/oldnewthing/archive/2003/12/10/56028.aspx\n 2048\n else\n # We fudge factor th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /families/new GET /families/new.json | def new
@family = Family.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @family }
end
end | [
"def new\n @family = Family.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @family }\n end\n end",
"def new\n @family_type = FamilyType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @family_ty... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lazy read the contact information | def contact
@contact ||= get_contact(@data_object.user_contact)
end | [
"def read_other_details\n # Get Contact information\n @base_xml.elements.each(\"#{@ns}:Contacts/#{@ns}:Contact\") do |contact|\n @contacts << BuildingSync::Contact.new(contact, @ns)\n end\n end",
"def contact\n response[\"contact\"]\n end",
"def display_one_contact\n cont... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
put this user's stuff into a hash | def add_to_hash(hash)
super
contact.add_to_hash(hash)
hash['user_over_13'] = @user_over_13 || !@new_user
hash['last_logged_in'] = fmt_date_time(@data_object.user_last_logged_in)
hash['first_logged_in'] = fmt_date_time(@data_object.user_first_logged_in)
# aff_opts = Affiliate.options
hash
e... | [
"def auth_hash\n\n hash = user_data(@access_token)\n puts \"got final hash with user info:\"\n pp hash\n\n # Preparing hash as per OmniAuth convention and returning to caller\n OmniAuth::Utils.deep_merge(\n super, {\n 'uid' => hash['orcid'], # The unique contri... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
log to the UserHistory table | def log(notes)
@uh_log ||= UserHistory.new
@uh_log.log(self, notes)
end | [
"def history\n\t\t@user.show_log\n\tend",
"def insert_to_history(order)\n @user_history << order\n @user_history\n end",
"def index\n @user = User.find(current_user.id)\n @history_logs = @user.history_logs\n end",
"def record_work_edit_history(work, user)\n history = work.histories.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lazy load an affiliate | def affiliate
@affiliate || Affiliate.with_id(@data_object.user_affiliate)
end | [
"def affiliate_affiliations\n @affiliate_affiliations ||= Affiliation.find_by_uid(uid)\n end",
"def set_affiliate\n if affiliate.present?\n account.affiliate_id = affiliate.id\n account.affiliate_other = affiliate.subaffiliates_enabled? ? account_params[:affiliate_other] : nil\n else\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
record the fact that this user is registered in an affiliate | def register_affiliate_role
Role.set_user_role(@data_object.user_id,
user_affiliate,
nil,
RoleNameTable::REGISTERED,
TargetTable::AFFILIATE,
user_affiliate)
end | [
"def affiliate\n @affiliate || Affiliate.with_id(@data_object.user_affiliate)\n end",
"def set_affiliate\n if affiliate.present?\n account.affiliate_id = affiliate.id\n account.affiliate_other = affiliate.subaffiliates_enabled? ? account_params[:affiliate_other] : nil\n else\n account.aff... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Affiliate stuff. A user has one primary and any number of secondary affiliates. Is this user associated with the given affiliate? | def associated_with_affiliate?(aff_id)
(aff_id == @data_object.user_affiliate) ||
role_assoc_with_affiliate?(aff_id)
end | [
"def affiliate?\n role == 'affiliate'\n end",
"def has_affiliation?(affiliation)\n affiliations.include?(affiliation.upcase)\n end",
"def affiliated?\n !affiliations.empty?\n end",
"def affiliate_visiting?\n has_affiliation? 'AFFILIATE-TYPE-VISITING'\n end",
"def using_af... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
renvoie un tableau de cases contenant les erreurs qu'il y a dans la grille (lorsque la case est VIDE, ce n'est pas une erreur) | def casesIncorrect
newStatutVide = StatutVide.new(VIDE)
newStatutArbre = StatutArbre.new(ARBRE)
tabCasesErr = Array.new
grille=@grille.grille
for i in 0..grille.length-1
for j in 0..grille.length-1
tabCasesErr.unshift(grille[i][j]) if (grille[i][j].statutVisible != grille[i][j].statu... | [
"def verifErreur()\n self.grille.grille.each{ |ligne|\n ligne.each{ |cases|\n if !self.verifCase(cases) \n @erreur += 1\n @locErreur.push([cases.ligne,cases.colonne])\n end\n }\n }\n end",
"def valider_cours... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
before_action :authenticate_admin! GET /smsloans GET /smsloans.json | def index
@smsloans = Smsloan.all
end | [
"def index\n #before_action :authenticate_user\n #if current_user.admin?\n @users = User.all\n render json: @users, status: :ok\n #else\n # render json: [], status: :unauthorized\n #end\n end",
"def smsmark\n http = get_http_connection() \n post_args = { 'ids' => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /smsloans/1 PATCH/PUT /smsloans/1.json | def update
respond_to do |format|
if @smsloan.update(smsloan_params)
format.html { redirect_to @smsloan, notice: 'Smsloan was successfully updated.' }
format.json { render :show, status: :ok, location: @smsloan }
else
format.html { render :edit }
format.json { render json... | [
"def update\n @sms_lingo = SmsLingo.find(params[:id])\n\n respond_to do |format|\n if @sms_lingo.update_attributes(params[:sms_lingo])\n format.html { redirect_to @sms_lingo, notice: 'Sms lingo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /smsloans/1 DELETE /smsloans/1.json | def destroy
@smsloan.destroy
respond_to do |format|
format.html { redirect_to smsloans_url, notice: 'Smsloan was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @sms = Sms.find(params[:id])\n @sms.destroy\n\n respond_to do |format|\n format.html { redirect_to sms_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sms_lingo = SmsLingo.find(params[:id])\n @sms_lingo.destroy\n\n respond_to do |format|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /image_groups/1 GET /image_groups/1.json | def show
@image_group = ImageGroup.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @image_group }
end
end | [
"def index\n @image_groups = ImageGroup.all\n end",
"def retrieve_groups()\n start.uri('/api/group')\n .get()\n .go()\n end",
"def retrieve_groups()\n start.uri('/api/group')\n .get()\n .go()\n end",
"def group_album\n @discussion_group = Discussion... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /image_groups/1 PUT /image_groups/1.json | def update
puts params[:image_group]
puts params[:image_group][:promoted]
p ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
if !params[:images][:removed].blank?
puts "removed images" + params[:images][:removed]
removedImages = Image.where(" id in (?)", params[:images][:removed].split(','))
... | [
"def update\n respond_to do |format|\n begin\n if @image_group.update(image_group_params)\n flash[:success] = 'Image group was successfully updated.'\n format.html { redirect_to admin_image_group_url(@image_group) }\n format.json { render :show, status: :ok, location: @imag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /image_groups/1 DELETE /image_groups/1.json | def destroy
@image_group = ImageGroup.find(params[:id])
@image_group.destroy
respond_to do |format|
format.html { redirect_to image_groups_url }
format.json { head :no_content }
format.js {}
end
end | [
"def destroy\n @image_group_item.destroy\n respond_to do |format|\n flash[:success] = 'Image group item was successfully deleted.'\n format.html { redirect_to admin_image_group_url(@image_group) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image_gallery_group = Im... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the build numbers for this Windows, e.g. 5.2.3790. | def get_build
if defined?(@major) and defined?(@minor) and defined?(@build) then
return @major, @minor, @build
else
@major, @minor, @build = nil
end
search = File.join(@path, '{*/system32,{i386,amd64}}/ntdll.dll')
ntdlls = Dir.glob(search, File::FNM_CASEFOLD)
if ntdll... | [
"def os_build_number\n return @os_build_number\n end",
"def windows_version_parts\n version = self.version\n if version\n # windows-server-* -> windows-*\n if version.split(\"-\", 2)[0] == \"server\"\n version = version.split... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a description string for this version of Windows. | def get_winstring
if defined?(@description) then return @description else @description = nil end
get_build if not @major
if @major < 6 # Vista and up use install.wim
version = "#{@major}.#{@minor}"
releases = {
'5.0' => { 2195 => 'Windows 2000' },
'5.1' => { 2600 =>... | [
"def version_description\n VERSIONS[version]\n end",
"def os_description\n return @os_description\n end",
"def generate_description\n\t\t\tself.log.debug \"Auto-generating description for %p\" % [ self ]\n\t\t\tdesc = self.name.to_s.\n\t\t\t\tgsub( /.*\\[(\\w+)\\]/, \"\\\\1\" )... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dump [1].xml from a Windows install image. | def get_xmlinfo
def do_xmlget(imagepath)
xmlinfo = %x{imagex info --xml #{imagepath}}
@xmlinfo = REXML::Document.new xmlinfo
return @xmlinfo
end
if defined?(@xmlinfo) then return @xmlinfo else @xmlinfo = nil end
search = File.join(@path, 'sources/install.wim')
wimag... | [
"def write_manifest_xml(path, properties)\n properties = { :xmlns => \"http://schemas.microsoft.com/deepzoom/2008\" }.merge properties\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\" +\n \"<Image TileSize=\\\"#{properties[:tile_size]}\\\" Overlap=\\\"#{properties[:tile_overlap]}\\\" \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
localhost:3000/addresses/5/edit http method :GET pathedit_address_path roles and responsibilities | def edit
@address=Address.new
@address=Address.find(params[:id])
end | [
"def edit\n\t\t@address = current_user.addresses.find(params[:id])\n\tend",
"def edit\r\n @address = Address.find(params[:id])\r\n end",
"def edit\n @user = User.find(params[:id])\n #@form_submit_url = update_customer_path\n #render \"user_addresses/edit\"\n end",
"def update\n @address = @ad... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
EPIC TWEET GEN takes a user hashtag and how many tweets to gen returns the total rating | def generate_tweets(hashtag, how_many)
total_stars = 0
how_many.times do
stars = rand(5)+1
total_stars += stars
Tweet.create(
user_handle: Faker::Lorem.words(2).join('_'),
user_display: Faker::Name.name,
feedback: Faker::Lorem.sentences(2).join << " #{stars}star #doha ##{hashtag} #dmk... | [
"def tweet_score(favorite_count, retweet_count)\n return favorite_count + (retweet_count * 2)\n end",
"def total_tweets(user)\n total_tweets = TwitterAccount.find_by(user_id: user.id).total_num_tweets\n total_tweets\n end",
"def tweet(user)\n length = rand(1..140)\n text = words.shuffle.join(' ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /empleadobitacoras/1 GET /empleadobitacoras/1.xml | def show
@empleadobitacora = Empleadobitacora.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @empleadobitacora }
end
end | [
"def show\n @empleadosautorizado = Empleadosautorizado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @empleadosautorizado }\n end\n end",
"def show\n @empleadostipo = Empleadostipo.find(params[:id])\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /empleadobitacoras/new GET /empleadobitacoras/new.xml | def new
@empleadobitacora = Empleadobitacora.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @empleadobitacora }
end
end | [
"def new\n @empleadosautorizado = Empleadosautorizado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @empleadosautorizado }\n end\n end",
"def new\n @empleadostipo = Empleadostipo.new\n\n respond_to do |format|\n format.html # new.html.erb... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /empleadobitacoras POST /empleadobitacoras.xml | def create
@empleadobitacora = Empleadobitacora.new(params[:empleadobitacora])
respond_to do |format|
if @empleadobitacora.save
format.html { redirect_to(@empleadobitacora, :notice => 'Empleadobitacora was successfully created.') }
format.xml { render :xml => @empleadobitacora, :status =... | [
"def create\n @etapasproceso = Etapasproceso.new(params[:etapasproceso])\n\n respond_to do |format|\n if @etapasproceso.save\n flash[:notice] = 'Etapasproceso was successfully created.'\n format.html { redirect_to(@etapasproceso) }\n format.xml { render :xml => @etapasproceso, :stat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /empleadobitacoras/1 PUT /empleadobitacoras/1.xml | def update
@empleadobitacora = Empleadobitacora.find(params[:id])
respond_to do |format|
if @empleadobitacora.update_attributes(params[:empleadobitacora])
format.html { redirect_to(@empleadobitacora, :notice => 'Empleadobitacora was successfully updated.') }
format.xml { head :ok }
... | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end",
"def update\n @etap... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /empleadobitacoras/1 DELETE /empleadobitacoras/1.xml | def destroy
@empleadobitacora = Empleadobitacora.find(params[:id])
@empleadobitacora.destroy
respond_to do |format|
format.html { redirect_to(empleadobitacoras_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @atendimento_aee = AtendimentoAee.find(params[:id])\n @atendimento_aee.destroy\n\n respond_to do |format|\n format.html { redirect_to(home_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @empleadosautorizado = Empleadosautorizado.find(params[:id])\n @emp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check that a domain exists | def verify_domain(domain)
begin
Socket.gethostbyname(domain)
rescue SocketError
return false
end
true
end | [
"def domain_exist?\n !@conn.get('/').body.include? 'Domain name is unregistered!'\n end",
"def domain_exists?(domain)\n domain = ::Postfix::Domain.find_by_name(domain)\n !domain.nil?\n end",
"def domain_defined?(domain_name)\n domain_list.key? domain_name\n end",
"def exist?(domain)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check that every element of an array is an integer | def int_array_check(arr)
arr.each do |element|
Integer(element) != nil rescue return false
end
return true
end | [
"def is_int_array(arr)\n arr.is_a?(Array) && arr.all? {|e| e.to_i == e}\nend",
"def is_integer_array? array\n\t\treturn array.all? {|a| a.is_a? Integer}\n\tend",
"def is_int_array_alt(arr)\n arr.is_a?(Array) && arr.all? { |e| e.is_a?(Integer) || e.is_a?(Float) && e % 1 == 0}\nend",
"def not_int?(array)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of DomainInfo objects from each row of the worksheet | def fetch_certs_from_worksheet(worksheet) # class method
domain_infos = Array.new
(2..worksheet.num_rows).each do |row| # first row is header
domain = worksheet[row, DOMAIN_COL]
days_to_notify = fetch_csv_array(worksheet[row, DAYS_COL])
# Don't use row if it is invalid
if domain.emp... | [
"def domains\n domains = []\n nextToken = nil\n base_options = {:Action => 'ListDomains'}\n continue = true\n \n while continue\n options = base_options.dup\n options[:NextToken] = nextToken unless nextToken.nil?\n \n sdb_query(options) d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Expecting string: "A1:hit B10:miss" Processes the result, marks the field appropriately, changes the sequence of shots accordingly. | def process_shot_result(shot_result)
shot_result.split(/:|\s/).each_slice(2) do |location, result|
field[location] = result.to_sym
has_hit(location) if field[location] == :hit
end
end | [
"def format_hit(str)\n hit_display_id = \"\"\n hit_def = \"\"\n\n hit = str.split(\" \", 2)\n if hit.length < 2\n hit_display_id = hit.first\n hit_def = \"None\"\n else\n hit_display_id = hit.first\n hit_def = hit.last\n end\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
::new Application with parameters. Parses options Sets loglevel | def initialize(*args)
parse_options(*args)
set_log_level
@@application = self
end | [
"def initialize(appname = nil)\n @appname = appname\n @log = Logger.new(STDERR)\n @log.progname = @appname\n @level = @log.level\n end",
"def initialize(options = {})\n @application = options[:application]\n @socket = options[:socket] || new_socket\n @logfile = op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add Examiner to report on. The report will output results for all added examiners. | def add_examiner(examiner)
@total_smell_count += examiner.smells_count
@examiners << examiner
self
end | [
"def add_examiner(examiner)\n self.total_smell_count += examiner.smells_count\n examiners << examiner\n self\n end",
"def << reporter\n self.reporters << reporter\n end",
"def assign_examiner\n valid_examiners = User.examiners\n .can_take_test_instan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds a function that return a list of fitnesses for a list of genotypes. Since Parallel runs in separate fork, this overload is needed to fetch out the training set before returning the fitness to the optimizer | def gen_fit_fn type, ntrials: ntrials_per_ind
return super unless type.nil? || type == :parallel
nprocs = Parallel.processor_count - 1 # it's actually faster this way
puts "Running in parallel on #{nprocs} processes"
-> (genotypes) do
print "Fits: "
fits, parall_infos = Parallel.... | [
"def gen_fit_fn type, ntrials: nil\n type ||= :parallel\n case type\n # SEQUENTIAL ON SINGLE ENVIRONMENT\n # => to catch problems with `Parallel` env spawning\n when :sequential_single\n -> (genotypes) { genotypes.map &method(:fitness_one) }\n # SEQUENTIAL ON MULTIPLE ENVIRONMEN... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return an action for an encoded observation The neural network is activated on the code, then its output is interpreted as a corresponding action | def action_for code
output = net.activate code
nans = output.isnan
# this is a pretty reliable bug indicator
raise "\n\n\tNaN network output!!\n\n" if nans.any?
# action = output[0...6].max_index # limit to 6 actions
action = output.max_index
end | [
"def action_for observation\n # TODO: continuous actions (checked at `init_env`)\n input = observation.tolist.to_a\n # TODO: probably a function generator here would be notably more efficient\n # TODO: the normalization range depends on the net's activation function!\n output = net.activate... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tasks_translations/1 GET /tasks_translations/1.xml | def show
@tasks_translation = TasksTranslation.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @tasks_translation }
end
end | [
"def list\n @client.get('/translations/requests')\n end",
"def index\n @translate_tasks = TranslateTask.all\n end",
"def show\n @translation = @locale.translations.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @translati... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tasks_translations/new GET /tasks_translations/new.xml | def new
@tasks_translation = TasksTranslation.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @tasks_translation }
end
end | [
"def new\n @newtask = Newtask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newtask }\n end\n end",
"def new\n @translation = Translation.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tran... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /tasks_translations POST /tasks_translations.xml | def create
@tasks_translation = TasksTranslation.new(params[:tasks_translation])
respond_to do |format|
if @tasks_translation.save
format.html { redirect_to([:admin,@tasks_translation], :notice => 'Tasks translation was successfully created.') }
format.xml { render :xml => @tasks_transla... | [
"def create_translations\n end",
"def create\n @translate_task = TranslateTask.new(translate_task_params)\n\n respond_to do |format|\n if @translate_task.save\n format.html { redirect_to @translate_task, notice: 'Translate task was successfully created.' }\n format.json { render :show, s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /tasks_translations/1 PUT /tasks_translations/1.xml | def update
@tasks_translation = TasksTranslation.find(params[:id])
respond_to do |format|
if @tasks_translation.update_attributes(params[:tasks_translation])
format.html { redirect_to([:admin,@tasks_translation], :notice => 'Tasks translation was successfully updated.') }
format.xml { he... | [
"def update\n respond_to do |format|\n if @translate_task.update(translate_task_params)\n format.html { redirect_to @translate_task, notice: 'Translate task was successfully updated.' }\n format.json { render :show, status: :ok, location: @translate_task }\n else\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /tasks_translations/1 DELETE /tasks_translations/1.xml | def destroy
@tasks_translation = TasksTranslation.find(params[:id])
@tasks_translation.destroy
respond_to do |format|
format.html { redirect_to(admin_tasks_translations_url) }
format.xml { head :ok }
end
end | [
"def delete_translations\n end",
"def delete(id)\n @client.delete(\"/translations/requests/#{id}\")\n end",
"def delete_translations\n TranslationKey.find_by(name: description_translation_key).try(:destroy)\n end",
"def destroy\n @translation = @locale.translations.find(params[:id])\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /contentareas/1 GET /contentareas/1.json | def show
@contentarea = Contentarea.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @contentarea }
end
end | [
"def show\n @content_area = ContentArea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @content_area }\n end\n end",
"def index\n @content_areas = ContentArea.find_all_by_department_id(current_user.department.id)\n\n respond_to do ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /contentareas/new GET /contentareas/new.json | def new
@contentarea = Contentarea.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @contentarea }
end
end | [
"def new\n @content_area = ContentArea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content_area }\n end\n end",
"def new\n @area = Area.new\n @other_areas = Area.all\n respond_to do |format|\n format.html # new.html.erb\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /contentareas POST /contentareas.json | def create
@contentarea = Contentarea.new(params[:contentarea])
respond_to do |format|
if @contentarea.save
format.html { redirect_to @contentarea, notice: 'Contentarea was successfully created.' }
format.json { render json: @contentarea, status: :created, location: @contentarea }
e... | [
"def create\n @question_content_area = QuestionContentArea.new(params[:question_content_area])\n\n respond_to do |format|\n if @question_content_area.save\n format.html { redirect_to @question_content_area, notice: 'Question content area was successfully created.' }\n format.json { render j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /contentareas/1 PUT /contentareas/1.json | def update
@contentarea = Contentarea.find(params[:id])
respond_to do |format|
if @contentarea.update_attributes(params[:contentarea])
format.html { redirect_to @contentarea, notice: 'Contentarea was successfully updated.' }
format.json { head :no_content }
else
format.html ... | [
"def update\n @content_area = ContentArea.find(params[:id])\n require_unlocked\n require_owner\n respond_to do |format|\n if @content_area.update_attributes(params[:content_area])\n format.html { redirect_to @content_area, notice: 'Content area was successfully updated.' }\n format.js... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /contentareas/1 DELETE /contentareas/1.json | def destroy
@contentarea = Contentarea.find(params[:id])
@contentarea.destroy
respond_to do |format|
format.html { redirect_to contentareas_url }
format.json { head :no_content }
end
end | [
"def destroy\n @content_area = ContentArea.find(params[:id])\n @content_area.destroy\n\n respond_to do |format|\n format.html { redirect_to content_areas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exam_content_area = ExamContentArea.find(params[:id])\n @exa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /embed_code_universities POST /embed_code_universities.json | def create
@embed_code_university = EmbedCodeUniversity.new(embed_code_university_params)
if params[:contact_id]
contact = params.require(:contact_id)
@embed_code_university.university_contacts << UniversityContact.find(contact)
end
respond_to do |format|
if @embed_code_university.save
format.htm... | [
"def update\n\t\trespond_to do |format|\n\t\t\tif @embed_code_university.update(embed_code_university_params)\n\t\t\t\tformat.html { redirect_to embed_code_universities_url, notice: 'Embed code university was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @embed_code_university... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /embed_code_universities/1 PATCH/PUT /embed_code_universities/1.json | def update
respond_to do |format|
if @embed_code_university.update(embed_code_university_params)
format.html { redirect_to embed_code_universities_url, notice: 'Embed code university was successfully updated.' }
format.json { render :show, status: :ok, location: @embed_code_university }
else
format.... | [
"def update\n respond_to do |format|\n if @university.update(university_params)\n format.html { redirect_to @university, notice: 'University was successfully updated.' }\n format.json { respond_with_bip(@university) }\n else\n format.html { render :edit }\n format.json { res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /embed_code_universities/1 DELETE /embed_code_universities/1.json | def destroy
@embed_code_university.destroy
respond_to do |format|
format.html { redirect_to embed_code_universities_url, notice: 'Embed code university was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n #not in use\n @university.destroy\n \n respond_to do |format|\n format.html { redirect_to universities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @university = University.find(params[:id])\n @university.destroy\n\n respond_to do |format|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Asks the user to select a player to get a card from and a rank to ask for calls add_and_reaveal and returns true if the player gets the card and calls | def try_getting_cards_from_player(selected_rank)
selected_player = select_other_player
selected_player_id = game.get_player_index(selected_player)
if game.players[selected_player_id].has_card_with_rank?(selected_rank)
add_and_reveal(game.players[selected_player_id].remove_cards_with_rank(selected_rank... | [
"def ask_for_card(other_player, card)\n if other_player.hand.include_rank?(card.rank)\n\t push_card_to_hand(other_player.pop_card_from_hand(card))\n\t return true\n\telse\n\t push_card_to_hand\n\t return false\n\tend\n end",
"def ask_for_cards_until_go_fish_and_get_last_requested_rank\n while true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lets the user ask for cards unitl they don't get a card with the rank they ask for. Returns the last requested rank. | def ask_for_cards_until_go_fish_and_get_last_requested_rank
while true
selected_rank = player.select_rank
if !try_getting_cards_from_player(selected_rank)
return selected_rank
end
end
end | [
"def rank\n puts 'RANK'\n puts self\n puts current_value\n value_idx = Card.possible_ranks.index(current_value)\n ranks[value_idx]\n end",
"def ask_for_card(other_player, card)\n if other_player.hand.include_rank?(card.rank)\n\t push_card_to_hand(other_player.pop_card_from_hand(card))\n\t ret... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a card to the player's hand. Announces it to other players, but doesn't show what card got added | def add_card_without_revealing_details(card)
player.add_card_to_hand(card)
message = "#{player.name} drew a card from the center."
game.players.each {|player| player.send_message_to_user(message)}
end | [
"def add_card(card)\n add_card_to_hand(card)\n end",
"def add_card_to_hand(card)\n @hand.add_card(card)\n end",
"def addCard(card)\n \tif @can_get_cards\n \t @cards.push(card)\n else\n raise ArgumentError, \"Cards cannot be added to this hand anymore.\"\n \tend\n end",
"def give_card(card... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /alco_drinks GET /alco_drinks.json | def index
@alco_drinks = AlcoDrink.all
end | [
"def get_cocktail_info_from_cocktail_db(cocktail_db_drink_id)\n response = RestClient.get 'https://www.thecocktaildb.com/api/json/v1/1/lookup.php?i=' + cocktail_db_drink_id\n drink_info = JSON.parse(response)[\"drinks\"][0]\nend",
"def get_drink_catagory_from_api(drink_hash)\n return drink_hash[\"drinks\"]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /alco_drinks POST /alco_drinks.json | def create
@alco_drink = AlcoDrink.new(alco_drink_params)
respond_to do |format|
if @alco_drink.save
format.html { redirect_to @alco_drink, notice: 'Alco drink was successfully created.' }
format.json { render :show, status: :created, location: @alco_drink }
else
format.html... | [
"def create_drinks\n drink_ids = get_drink_ids\n drink_ids.each do |id|\n raw_data = RestClient.get(\"http://www.thecocktaildb.com/api/json/v1/1/lookup.php?i=#{id}\")\n drink_data = JSON.parse(raw_data)['drinks'][0]\n new_drink = Drink.find_or_create_by(drink_name: drink_data['strDrink'])\n new_drink.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /alco_drinks/1 PATCH/PUT /alco_drinks/1.json | def update
respond_to do |format|
if @alco_drink.update(alco_drink_params)
format.html { redirect_to @alco_drink, notice: 'Alco drink was successfully updated.' }
format.json { render :show, status: :ok, location: @alco_drink }
else
format.html { render :edit }
format.jso... | [
"def update\n @bubble_tea = BubbleTea.find(params[:id])\n\n if @bubble_tea.update(bubble_tea_params)\n render json: @bubble_tea\n else\n render plain: \"Failed to update drink information\"\n end\n end",
"def update\n @cocktail_ingredient = CocktailIngredient.find(params[:id])\n\n res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /alco_drinks/1 DELETE /alco_drinks/1.json | def destroy
@alco_drink.destroy
respond_to do |format|
format.html { redirect_to alco_drinks_url, notice: 'Alco drink was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @drink.destroy\n respond_to do |format|\n format.html { redirect_to drinks_url }\n format.json { head :no_content }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Con un objeto de tipo MenuUsuarioTipo, arma el item del menu | def mostrar_item(menu)
# Si el item tiene url, controlador o accion, arma link, sino solo label
if (menu.controller != '') or (menu.action != '') or (menu.url != '')
if menu.url != ''
link_to menu.nombre, menu.url
else
link_to menu.nombre, :controller => menu.controller, :action => menu.action
end... | [
"def getItemMenu( item)\n h = { \n UONConnection => @connectionItemMenu, \n\t\t\tUONCard => @cardItemMenu,\n UONPrimitive => @primitiveItemMenu\n }\n menu = @itemMenu # default return value\n if h.key?( item.class) then\n menu = h[item.class]\n end\n menu # return value\n\tend",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
any character existing in remove must be deleted from str. eg "Battle of the Vowels: Hawaii vs. Grozny" and remove "aeiou" => "Bttl f th Vwls: Hw vs. Grzny" Ruby | def remove_str(str, remove)
original = str.split(//)
deleted = remove.split(//)
deleted.each {|char| original.delete(char)}
return original.join
end | [
"def remove(str, char)\n output = \"\"\n i = 0\n while i < str.length\n if str[i] != char\n output << str[i]\n end\n i += 1\n end\n return output\nend",
"def remove(str, char)\n i = 0\n new_str = \"\"\n while i < str.length\n if str[i] != char\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /early_pregnancies/1 GET /early_pregnancies/1.json | def show
@early_pregnancy = EarlyPregnancy.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @early_pregnancy }
end
end | [
"def new\n @early_pregnancy = EarlyPregnancy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @early_pregnancy }\n end\n end",
"def show\n @pregnancy_state = PregnancyState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /early_pregnancies/new GET /early_pregnancies/new.json | def new
@early_pregnancy = EarlyPregnancy.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @early_pregnancy }
end
end | [
"def create\n @early_pregnancy = EarlyPregnancy.new(params[:early_pregnancy])\n\n respond_to do |format|\n if @early_pregnancy.save\n format.html { redirect_to @early_pregnancy, notice: 'Early pregnancy was successfully created.' }\n format.json { render json: @early_pregnancy, status: :cre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /early_pregnancies POST /early_pregnancies.json | def create
@early_pregnancy = EarlyPregnancy.new(params[:early_pregnancy])
respond_to do |format|
if @early_pregnancy.save
format.html { redirect_to @early_pregnancy, notice: 'Early pregnancy was successfully created.' }
format.json { render json: @early_pregnancy, status: :created, locat... | [
"def new\n @early_pregnancy = EarlyPregnancy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @early_pregnancy }\n end\n end",
"def create\n @pregnancy_state = PregnancyState.new(params[:pregnancy_state])\n\n respond_to do |format|\n if @pregn... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /early_pregnancies/1 PUT /early_pregnancies/1.json | def update
@early_pregnancy = EarlyPregnancy.find(params[:id])
respond_to do |format|
if @early_pregnancy.update_attributes(params[:early_pregnancy])
format.html { redirect_to @early_pregnancy, notice: 'Early pregnancy was successfully updated.' }
format.json { head :no_content }
el... | [
"def create\n @early_pregnancy = EarlyPregnancy.new(params[:early_pregnancy])\n\n respond_to do |format|\n if @early_pregnancy.save\n format.html { redirect_to @early_pregnancy, notice: 'Early pregnancy was successfully created.' }\n format.json { render json: @early_pregnancy, status: :cre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /early_pregnancies/1 DELETE /early_pregnancies/1.json | def destroy
@early_pregnancy = EarlyPregnancy.find(params[:id])
@early_pregnancy.destroy
respond_to do |format|
format.html { redirect_to early_pregnancies_url }
format.json { head :no_content }
end
end | [
"def destroy\n @pregnancy.destroy\n respond_to do |format|\n format.html { redirect_to pregnancies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pregnancy_state = PregnancyState.find(params[:id])\n @pregnancy_state.destroy\n\n respond_to do |format|\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The main view. This method builds the layout and returns the root view. | def view
unless is_parent_layout?
return parent_layout.view
end
@view ||= build_view
end | [
"def build_view\n # Only in the 'layout' method will we allow default container to be\n # created automatically (when 'add' is called)\n @assign_root = true\n prev_should_run = @should_run_deferred\n @should_run_deferred = true\n layout\n unless @view\n if @assign_root\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the layout has been built yet or not. | def built?
!@view.nil?
end | [
"def components_pending?\n not layout.components.empty?\n end",
"def layout_exists?(layout); end",
"def place_in_layout?\n !(asset_file? || yaml_file? || no_layout?)\n end",
"def place_in_layout?\n !(asset_file? || no_layout?)\n end",
"def build?(file)\n !partial?(file) && !layout... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
just in case Assign a view to act as the 'root' view for this layout. This method can only be called once, and must be called before `add` is called for the first time (otherwise `add` will create a default root view). This method must be called from inside `layout`, otherwise you should just use `create`. You can also... | def root(element, element_id=nil, &block)
if @view
raise ContextConflictError.new("Already created the root view")
end
unless @assign_root
raise InvalidRootError.new("You should only create a 'root' view from inside the 'layout' method (use 'create' elsewhere)")
end
@assign... | [
"def root(element, element_id=nil, &block)\n if element && element.is_a?(NSString)\n element = NSMenu.alloc.initWithTitle(element)\n end\n super(element, element_id, &block)\n end",
"def build_view\n # Only in the 'layout' method will we allow default container to be\n # created... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls the style method of all objects in the view hierarchy that are part of this layout. The views in a child layout are not styled, but those layouts will receive a `reapply!` message if no root is specified. | def reapply!
root ||= self.view
@layout_state = :reapply
run_reapply_blocks
@child_layouts.each do |child_layout|
child_layout.reapply!
end
@layout_state = :initial
return self
end | [
"def reapply!\n root ||= self.view\n @layout_state = :reapply\n\n @elements.each do |element_id, elements|\n elements.each do |element|\n style_and_context(element, element_id)\n end\n end\n\n @child_layouts.each do |child_layout|\n child_layout.reapply!\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Just like `last`, but if `last` returns a Layout, this method returns the layout's view. | def last_view(element_id)
element = last(element_id)
if element.is_a?(Layout)
element = element.view
end
element
end | [
"def view\n unless is_parent_layout?\n return parent_layout.view\n end\n @view ||= build_view\n end",
"def find\n self.class.find(@view.layout)\n end",
"def layout\n lookup_layout\n end",
"def layout \n return @layout\n end",
"def parent_layout(of_lay... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all the elements with a given element_id | def all(element_id)
unless is_parent_layout?
return parent_layout.all(element_id)
end
@elements[element_id] || []
end | [
"def find(id)\n @elements.find { |element| element.id == id}\n end",
"def get_element id\n @elements[id.to_s]\n end",
"def element_by_id(elem_id)\r\n @web_browser.element_by_id(elem_id)\r\n end",
"def get id\n get_single id\n @elements[id]\n end",
"def include?( element_id )... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Just like `nth`, but if `nth` returns a Layout, this method returns the layout's view. | def nth_view(element_id, index)
element = nth(element_id)
if element.is_a?(Layout)
element = element.view
end
element
end | [
"def find\n self.class.find(@view.layout)\n end",
"def view\n unless is_parent_layout?\n return parent_layout.view\n end\n @view ||= build_view\n end",
"def get_view(element_id)\n element = get(element_id)\n if element.is_a?(Layout)\n element = element.v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This searches for the "nearest" view with a given id. First, all child views are checked. Then the search goes up to the parent view, and its child views are checked. This means any view that is in the parent view's hierarchy is considered closer than a view in a grandparent's hierarchy. This is a "depthfirst" search, ... | def nearest(element_id)
nearest(element_id, from: target)
end | [
"def parent_of(id)\n item = find_by_id(id)\n find_by_id(eval(comparision_childrem_value(\"item\")))\n end",
"def nearest_child\n c = nil\n children.each do |n|\n c=n if not c or distance(n)<distance(c)\n end\n c\n end",
"def findCloserNode(target_id, joining_id)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes a view from the list of elements this layout is "tracking", but leaves it in the view hierarchy. Returns the views that were removed. | def forget(element_id)
unless is_parent_layout?
return parent_layout.remove(element_id)
end
removed = nil
context(self.view) do
removed = all(element_id)
@elements[element_id] = nil
end
removed
end | [
"def remove\n selected.each { |view| view.parent.removeView(view) }\n self\n end",
"def remove_all_views\n subviews.each { |view| view.removeFromSuperview }\n relayout!\n end",
"def remove_view view\n unless subviews.include? view\n raise ArgumentError, \"view #{view} not a subvi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method builds the layout and returns the root view. | def build_view
# Only in the 'layout' method will we allow default container to be
# created automatically (when 'add' is called)
@assign_root = true
prev_should_run = @should_run_deferred
@should_run_deferred = true
layout
unless @view
if @assign_root
create_... | [
"def view\n unless is_parent_layout?\n return parent_layout.view\n end\n @view ||= build_view\n end",
"def get_layout\n template = Erubis::Eruby.new File.read(\"#{ROOT}/app/views/layout/application.html.erb\")\n template.result(binding)\n end",
"def layout\n layout_for(curre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls the `_style` method with the element as the context, and runs the optional block in that context. This is usually done immediately after `initialize_element`, except in the case of `add`, which adds the item to the tree before styling it. | def style_and_context(element, element_id, &block)
style_method = "#{element_id}_style"
if parent_layout.respond_to?(style_method) || block_given?
parent_layout.context(element) do
if parent_layout.respond_to?(style_method)
parent_layout.send(style_method)
end
... | [
"def render_style(&block)\n \"#{style}#{yield}\"\n end",
"def render_style(&block)\n [ style.to_s, yield, parent_style ].join\n end",
"def process_style(*args, &block)\n # Avoid #instance_exec if possible for ruby 1.8.\n evaluator = args.empty? ? :instance_eval : :instance_exec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the open and close times for the specified date or an empty array if closed on that date | def open_close_times(date)
open_close = @open_close[as_string(date)] || @open_close[as_sym(date)] || @default_open_close
open_close.collect { |h| Time.parse("#{as_string(date)} #{h}") }
end | [
"def opening_time(date)\n closed?(date) ? nil : schedule(date)[0]\n end",
"def open_slots_for_select(date)\n open_slots(date).map do |slot|\n [\"#{slot.starts_at.strftime('%d/%m/%Y, %H:%M ')}\", slot.starts_at]\n end\n end",
"def closing_time(date)\n closed?(date) ? nil : schedule(date)[1]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
the length of time available during a specified day to do work e.g., there are 6 hours available if we open at 9:00 AM, close at 3:00 PM, and the item was dropped off at 9:00 AM there are 5 hours available if we open at 9:00 AM, close at 3:00 PM, and the item was dropped off at 10:00 AM | def work_time(date)
open, closed = open_close_times(date)
closed - open - time_already_open(date)
end | [
"def working_day_duration_minutes\n ((self.working_day_end_time - self.working_day_start_time) / 60).to_i\n end",
"def working_duration\n (start_date && due_date) ? working_days(start_date, due_date) : 0\n end",
"def hours_left\n remaining = WorkingTime::Interval.new(self, close_of_business)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
advance the specified date by 24 hours | def next_day(date)
date + (60 * 60 * 24)
end | [
"def next_hourly\n @current_date += @interval.hours\n end",
"def advance(date, time)\n date.advance(hours: time.hour, minutes: time.min, seconds: time.sec)\n end",
"def extendbythirthydays\n update_at = update_at + 14.days.from_now\n end",
"def advance_hours(hours)\n self + (hours *... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
use imageserver and blob csid to serve audio | def render_audio_csid options={}
# render audio player
content_tag(:div) do
options[:value].collect do |audio_csid|
content_tag(:audio,
content_tag(:source, "I'm sorry; your browser doesn't support HTML5 audio in MPEG format.",
src: "https://webapps.cspace.berkeley.edu/#TENA... | [
"def audio_url(path); end",
"def audio_url(source, options = T.unsafe(nil)); end",
"def streaming_url\n audio_url(self, :format => :mp3)\n end",
"def download\n @audio = Audio.find(params[:id])\n send_file(RAILS_ROOT+\"/public\"+@audio.audio.url.split(\"?\")[0], :disposition => 'inline', :stream => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
use imageserver and blob csid to serve video | def render_video_csid options={}
# render video player
content_tag(:div) do
options[:value].collect do |video_csid|
content_tag(:video,
content_tag(:source, "I'm sorry; your browser doesn't support HTML5 video in MP4 with H.264.",
src: "https://webapps.cspace.berkeley.edu/#T... | [
"def render_video_csid options = {}\n # render video player\n content_tag(:div) do\n options[:value].collect do |video_csid|\n content_tag(:video,\n content_tag(:source, \"I'm sorry; your browser doesn't support HTML5 video in MP4 with H.264.\",\n src: \"https://webapps.cspace.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
serve X3D directy via apache (apache needs to be configured to serve nuxeo repo) | def render_x3d_directly options={}
# render x3d player
content_tag(:div) do
options[:value].collect do |x3d_md5|
l1 = x3d_md5[0..1]
l2 = x3d_md5[2..3]
content_tag(:video,
content_tag(:source, "I'm sorry; your browser doesn't support HTML5 video in MP4 with H.264.",
... | [
"def render_x3d_directly options = {}\n # render x3d player\n content_tag(:div) do\n options[:value].collect do |x3d_md5|\n l1 = x3d_md5[0..1]\n l2 = x3d_md5[2..3]\n content_tag(:x3d,\n content_tag(:scene,\n content_tag(:inline, '',\n url: \"https://csp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a field and an array of child fields, we need to recurse through them to get the last one | def get_child_entity_from_path_by(field, children)
# the next child in the path
child_value = children.shift
# get the child entity
child = self.send(:children).find {|child| child.send(field) == child_value}
if child && children.size > 0
# we have some recursion to do - we're not ... | [
"def last_field(*args)\n fields(*args)[-1]\n end",
"def getNestedField(doc, field)\n subdoc = doc\n field.split('.').each { |fieldpart|\n subdoc = subdoc[fieldpart] unless subdoc==nil\n }\n return subdoc;\nend",
"def getFieldWithSubfields(fields)\n f = fields.sample(1).first\n if f[1][:subfield... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a field (and optional delimiter), return a path to the current object. e.g. you'd end up with /path/to/page (where this object is 'page') | def nested_path_by(field, opts = {})
options = {delimiter: "/", prefix: ""}
options.merge!(opts)
delimiter = options[:delimiter]
prefix = options[:prefix].empty? ? "" : "#{options[:prefix]}#{delimiter}"
path = ([self] + ancestors).reverse.collect {|a| a.send(field)}.join(delimiter).gsub(pr... | [
"def field_path *fields\n FieldPath.new(*fields)\n end",
"def path\n position = document.atomic_position\n position.blank? ? field : \"#{position}.#{field}\"\n end",
"def path\n raise NWN::Gff::GffError, \"field not bound to a parent\" unless @parent\n parent_path ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.