query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Returns the current context for this thread, or nil if none exists. | def current
all_contexts[Thread.current.object_id]
end | [
"def current_thread_context; end",
"def context\n @context || contexts.current\n end",
"def thread_context\n Thread.current[:runshell_context] ||= Context.new(main_context.to_h)\n end",
"def get_thread_context(thread_id)\n send(Command::GET_THREAD_CONTEXT, [thread_id].pack(\"Q<\")).wait_ok.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assigns a context instance to the current thread. | def current=(context)
all_contexts[Thread.current.object_id] = context
end | [
"def set_thread_context(thread_id)\n raise \"nyi\"\n end",
"def local=(ctx)\n Thread.current[@key] = ctx\n end",
"def thread_context\n Thread.current[:runshell_context] ||= Context.new(main_context.to_h)\n end",
"def setContext(context)\n @context = context\n end",
"def context=(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clears the assigned context for the current thread. | def clear_current
all_contexts.delete(Thread.current.object_id)
end | [
"def clear_context\n @current_context = nil\n end",
"def clear_context\n end",
"def clear!\n context_manager.clear!\n end",
"def clear!\n @context = ContextStack.new\n nil\n end",
"def reset_context\n @context = nil\n end",
"def clear_current!\n Thread.current[self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cmd[0] : name of currNode cmd[1] : name of destNode cmd[2] : ip of currNode cmd[3] : time edge was made | def edgeb_network(cmd)
node = $node_info.new
$lock.synchronize{
node.src = $hostname
node.dst = cmd[1]
node.cost = 1
node.nexthop = cmd[1]
$rt[cmd[1]] = node
if $local_ip == nil then $local_ip = cmd[2] end
$network.undir_connection($hostname, c... | [
"def edgeuExt(cmd)\n\n\t#get commands\n\tdst = cmd[0]\n\tcost = cmd[1].to_i\n\t\n\t#update cost hash with the new cost to get to the neighbor\n\t$cost[dst] = cost\nend",
"def edgeu(cmd)\n time = nil\n $lock.synchronize{\n time = $clock.to_i\n $network.update_cost($hostname, cmd[0], cmd[1].to_i,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cmd[0] : DEST cmd[1] : COST | def edgeu(cmd)
time = nil
$lock.synchronize{
time = $clock.to_i
$network.update_cost($hostname, cmd[0], cmd[1].to_i, time)
if $rt.has_key? cmd[0]
$rt[cmd[0]][:cost] = cmd[1].to_i
end
}
client = TCPSocket.open($local_ip, $nodesFile[cmd[0]]["PORT"])
client... | [
"def edgeu_network(cmd)\n $lock.synchronize{\n $network.update_cost($hostname, cmd[0], cmd[1].to_i,cmd[2].to_i)\n \n if $rt.has_key? cmd[0]\n $rt[cmd[0]][:cost] = cmd[1].to_i\n end\n }\nend",
"def edgeuExt(cmd)\n\n\t#get commands\n\tdst = cmd[0]\n\tcost = cmd[1].to_i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cmd[0] : DEST cmd[1] : COST cmd[2] : Time of updated edge | def edgeu_network(cmd)
$lock.synchronize{
$network.update_cost($hostname, cmd[0], cmd[1].to_i,cmd[2].to_i)
if $rt.has_key? cmd[0]
$rt[cmd[0]][:cost] = cmd[1].to_i
end
}
end | [
"def edgeu(cmd)\n time = nil\n $lock.synchronize{\n time = $clock.to_i\n $network.update_cost($hostname, cmd[0], cmd[1].to_i, time)\n\n if $rt.has_key? cmd[0]\n $rt[cmd[0]][:cost] = cmd[1].to_i\n end\n } \n\n client = TCPSocket.open($local_ip, $nodesFile[cmd[0]][\"P... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /liners GET /liners.json | def index
@liners = Liner.all
end | [
"def index\n @lines = ReportingForms::LaborLine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lines }\n end\n end",
"def index\n @litters = Litter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /liners POST /liners.json | def create
company_name = params[:liner][:company_name]
company = Company.find_or_create_by name: company_name
@liner = company.liners.new(liner_params)
respond_to do |format|
if @liner.save
format.html { redirect_to @liner, notice: 'Liner was successfully created.' }
format.json ... | [
"def create\n @liner = Liner.new(params[:liner])\n\n respond_to do |format|\n if @liner.save\n format.html { redirect_to(@liner, :notice => 'Liner was successfully created.') }\n format.xml { render :xml => @liner, :status => :created, :location => @liner }\n else\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /liners/1 PATCH/PUT /liners/1.json | def update
respond_to do |format|
liner = Liner.find_by(liner_reference: liner_params["liner_reference"])
original_thickness = liner.original_thickness.to_i
current_thickness = liner_params["current_thickness"].to_i
thickness_loss_per_day = original_thickness - current_thickness
liner_... | [
"def update\n respond_to do |format|\n if @liner.update(liner_params)\n format.html { redirect_to @liner, notice: 'Liner was successfully updated.' }\n format.json { render :show, status: :ok, location: @liner }\n else\n format.html { render :edit }\n format.json { render js... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /liners/1 DELETE /liners/1.json | def destroy
@liner.destroy
respond_to do |format|
format.html { redirect_to liners_url, notice: 'Liner was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @liner = Liner.find(params[:id])\n @liner.destroy\n\n respond_to do |format|\n format.html { redirect_to(liners_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tabulation Min cost for a stair is the min for either of the last 2, plus itself O(N) time, O(N) space (table) | def min_cost_climbing_stairs(cost)
cost = cost + [0]
table = Array.new(cost.length) { nil }
table[0] = cost[0]
table[1] = cost[1]
table.each_with_index do |_val, i|
next if i < 2
table[i] = [table[i-1], table[i-2]].min
table[i] += cost[i]
end
table.last
end | [
"def min_cost_climbing_stairs(cost)\n [step(cost, 0), step(cost, 1)].min\nend",
"def min_cost_climbing_stairs(cost)\n i = 2\n \n while i < cost.length\n cost[i] += [cost[i-1], cost[i-2]].min\n i += 1\n end\n\n return [cost[-1], cost[-2]].min\nend",
"def min_cost(cost, m, n)\n if n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Build a list of 'file' objects (same as used when showing the loglist(s)) and return the items that are related to the current post (specified by the 'title' parameter). Params: title Title of article to compare with filelist to find current. pre Boolean indicating whether this is a finished or workinprogress (... | def related_logs(title, pre=false)
logs = begin
if pre
with_cache('log-pre-file-list') {
log_list(LOG_PRE_META[:path], LOG_PRE_META[:regex], pre)
}
else
with_cache('log-file-list') {
log_list(LOG_META[:path], LOG_META[:regex])
}
end
end
... | [
"def file_by_title(title)\n if title.is_a?(Array)\n return self.root_collection.file_by_title(title)\n else\n return files(\"q\" => [\"title = ?\", title], \"maxResults\" => 1)[0]\n end\n end",
"def file_by_title(title)\n return file_by_title_with_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The visibility of a post to users user => nil can everyone see this post? user => User can a specific user see this post? | def visible?(user=nil)
return true if author == user and not deleted?
return false unless category.allow_viewing? user
return false unless available?
true
end | [
"def visible?(user=nil)\n post.visible?(user)\n end",
"def public_posts\n user.present? ? user.public_posts : false\n end",
"def visibility_check\n user.present? || !is_private?\n end",
"def visible_liked_posts(other_user)\n if self.followers.include?(other_user) || !self.private?\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
if this is a video and playable? | def playable?
video_source
end | [
"def video?\n media_type == :video\n end",
"def video?\n self.type == \"Assetabler::Video\"\n end",
"def video?\n content_type.start_with?(\"video\")\n end",
"def video?\n is_a?(OEmbed::Response::Video)\n end",
"def video?\n !!( content_type =~ Transit.config.video_regexp )\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /bbhks GET /bbhks.json | def index
@bbhks = Bbhk.all
end | [
"def index\n @bhks = Bhk.all\n end",
"def index\n @bks = Bk.all\n end",
"def show\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kb }\n end\n end",
"def get_blasts()\n exec_get(\"#{@base_path}/api/v2/custome... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /bbhks POST /bbhks.json | def create
@bbhk = Bbhk.new(bbhk_params)
respond_to do |format|
if @bbhk.save
format.html { redirect_to @bbhk, notice: 'Bbhk was successfully created.' }
format.json { render action: 'show', status: :created, location: @bbhk }
else
format.html { render action: 'new' }
... | [
"def create\n @kkb = Kkb.new(kkb_params)\n #TODO\n @kkb.kkb_type = :bbs\n @kkb.posted_by_id = current_user.id\n\n respond_to do |format|\n if @kkb.save\n format.html { redirect_to kkbs_path, notice: 'Kkb was successfully created.' }\n format.json { head :created }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /bbhks/1 PATCH/PUT /bbhks/1.json | def update
respond_to do |format|
if @bbhk.update(bbhk_params)
format.html { redirect_to @bbhk, notice: 'Bbhk was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @bbhk.errors, status: :unproce... | [
"def update\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n if @kb.update_attributes(params[:kb])\n format.html { redirect_to @kb, :notice => 'Kb was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /bbhks/1 DELETE /bbhks/1.json | def destroy
@bbhk.destroy
respond_to do |format|
format.html { redirect_to bbhks_url }
format.json { head :no_content }
end
end | [
"def destroy\n @bhk.destroy\n respond_to do |format|\n format.html { redirect_to bhks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kb = Kb.find(params[:id])\n @kb.destroy\n\n respond_to do |format|\n format.html { redirect_to kbs_url }\n format.json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method will enable/disable strong password policy for users. | def set_strong_password(handle:, enable: false)
mos = handle.query_classid(class_id: "AaaUserPolicy")
user_policy = mos[0]
enable ? user_policy.set_prop(:user_password_policy, "enabled") : user_policy.set_prop(:user_password_policy, "disabled")
handle.set_mo(mo: user_policy)
return handle.query_dn(... | [
"def disable_password_restrictions\n end",
"def allow_users_to_change_password\n data.allow_users_to_change_password\n end",
"def enable_authentication(password)\n @enablepwd = password\n end",
"def disable_account\n self.email = \"\"\n self.blocked = true\n self.location_i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method will check if strong password policy is enabled. | def is_strong_password_set(handle:)
mos = handle.query_classid(class_id: "AaaUserPolicy")
if mos.size == 0
raise ImcOperationError.new("Check Password Strength", "MO does not exist")
end
return (mos[0].user_password_policy == "enabled")
end | [
"def is_passwordless_capable\n return @is_passwordless_capable\n end",
"def password_required?\n @password_required\n end",
"def check_strength\n return if errors.any? || password.nil?\n\n res = {}\n return true if self.class.password_strong_enough(password, result... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method will check if the password expiration policy exists | def password_expiration_exists(handle:, **kwargs)
mo = AaaUserPasswordExpiration.new(parent_mo_or_dn: "sys/user-ext")
mo = handle.query_dn(dn: mo.dn)
if mo.nil?
return false, nil
end
return mo.check_prop_match(**kwargs), mo
end | [
"def expire_password_on_demand?\n expire_password_after.present? && expire_password_after == true\n end",
"def password_never_expires?\n userAccountControl.to_i & UAC_PASSWORD_NEVER_EXPIRES != 0\n end",
"def check_password_expired?\n !days_to_password_expiry.nil? && days_to_password_expiry <=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /logincms GET /logincms.json | def index
@logincms = Logincm.all
end | [
"def getLogin( login_id)\n params = Hash.new\n params['login_id'] = login_id\n return doCurl(\"get\",\"/login\",params)\n end",
"def index\n @logininfos = current_user.logininfos.all\n @key = session[:key]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /logincms POST /logincms.json | def create
@logincm = Logincm.new(logincm_params)
respond_to do |format|
if @logincm.save
format.html { redirect_to @logincm, notice: 'Logincm was successfully created.' }
format.json { render :show, status: :created, location: @logincm }
else
format.html { render :new }
... | [
"def login\n @rest.headers[:content_type] = \"application/json\"\n\n response = api_request { @rest[\"login\"].post({:username => @username, :password => @password}) }\n\n @rest.headers[:x_opsview_token] = response[:token]\n @rest.headers[:x_opsview_username] = @username\n\n response\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /consultationcharges/1 GET /consultationcharges/1.xml | def show
@consultationcharge = Consultationcharge.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @consultationcharge }
end
end | [
"def show\n @diabetes_consultation = DiabetesConsultation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @diabetes_consultation }\n end\n end",
"def show\n @consultation = Consultation.find(params[:id])\n\n respond_to do |format|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /consultationcharges POST /consultationcharges.xml | def create
@consultationcharge = Consultationcharge.new(params[:consultationcharge])
respond_to do |format|
if @consultationcharge.save
format.html { redirect_to(@consultationcharge, :notice => 'Consultationcharge was successfully created.') }
format.xml { render :xml => @consultationcha... | [
"def create\n @consultationform = Consultationform.new(params[:consultationform])\n respond_to do |format|\n if @consultationform.save\n\t\t@n=Number.find_by_names(\"consultation\")\n\t\t@n.value=@consultationform.consultation_no\n\t\t@n.update_attributes(params[:n])\n\t\t@n=Number.find_by_names(\"reciep... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /consultationcharges/1 PUT /consultationcharges/1.xml | def update
@consultationcharge = Consultationcharge.find(params[:id])
respond_to do |format|
if @consultationcharge.update_attributes(params[:consultationcharge])
format.html { redirect_to(@consultationcharge, :notice => 'Consultationcharge was successfully updated.') }
format.xml { head... | [
"def update\n @consultation = Consultation.find(params[:id])\n\n respond_to do |format|\n if @consultation.update_attributes(params[:consultation])\n format.html { redirect_to(@consultation, :notice => 'Consultation was successfully updated.') }\n format.xml { head :ok }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /consultationcharges/1 DELETE /consultationcharges/1.xml | def destroy
@consultationcharge = Consultationcharge.find(params[:id])
@consultationcharge.destroy
respond_to do |format|
format.html { redirect_to(consultationcharges_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @consultation = Consultation.find(params[:id])\n @consultation.destroy\n\n respond_to do |format|\n format.html { redirect_to(consultations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pfs_consultation = PfsConsultation.find(params[:id])\n @pfs_consul... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Challenge II: Hash with Data shipping_manifest returns a hash with key/value pairs describing oldtimey items set a variable called `the_manifest`, equal to a hash fill that hash with key/value pairs that describe the following information: We have 5 whale bone corsets, 2 porcelain vases and 3 oil paintings | def shipping_manifest
the_manifest = {"whale bone corsets" => 5, "porcelain vases" => 2, "oil paintings" => 3}
end | [
"def shipping_manifest\n shipping_manifest = {\n \"whale bone corsets\" => 5,\n \"porcelain vases\" => 2,\n \"oil paintings\" => 3\n }\nend",
"def retrieval\n shipping_manifest = {\"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"oil paintings\" => 3}\n shipping_manifest[\"oil paintings\"]\nen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Challenge III: Retrieving Data retrieval operates on the shipping_manifest hash to return the value of the 'oil paintings' key Look up the value of the "oil paintings" key in the shipping_manifest hash below | def retrieval
shipping_manifest = {"whale bone corsets" => 5, "porcelain vases" => 2, "oil paintings" => 3}
shipping_manifest["oil paintings"]
end | [
"def retrieval\n shipping_manifest['oil paintings']\nend",
"def shipping_manifest\n shipping_manifest = {\n \"whale bone corsets\" => 5,\n \"porcelain vases\" => 2,\n \"oil paintings\" => 3\n }\nend",
"def shipping_manifest\n the_manifest = {\"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Challenge IV: Adding Data adding operates on the shipping_manifest hash to add a key/value pair add 2 muskets to the shipping_manifest hash below add 4 gun powder to the shipping_manifest hash below return the shipping_manifest hash below | def adding
shipping_manifest = {"whale bone corsets" => 5, "porcelain vases" => 2, "oil paintings" => 3}
shipping_manifest["muskets"] = 2
shipping_manifest["gun powder"] = 4
shipping_manifest
end | [
"def adding\n shipping_manifest = {\"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"oil paintings\" => 3}\n\n shipping_manifest[\"pearl necklace\"] = 1\n return shipping_manifest\nend",
"def shipping_manifest\n the_manifest = {\"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"oil paintings\" =>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A panel has been refreshed Parameters:: iPanel (Wx::Panel): The panel just refreshed | def notifyRefresh(iPanel)
if (!@DuringInit)
# Find the Tab containing this Panel
lIdx = @DependencyPanels.index(iPanel)
lDepUserChoice = @DepsUserChoices[lIdx]
lIconName = "#{@IconsDir}/Dependency.png"
if (lDepUserChoice.Locate)
if (lDe... | [
"def refresh_window\n end",
"def repaint\n $log.debug \" form repaint:#{self}, #{@name} , r #{@row} c #{@col} \" if $log.debug? \n @widgets.each do |f|\n next if f.visible == false\n #f.repaint \n # changed on 2018-03-21 - so widgets don't need to do this.\n if f.repaint_required\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate the numerical identifier of the report based on the 01/06/2020 report, which was 91 | def day_identifier
day_baseline = Date.parse("2020-06-01")
number_baseline = 91
baseline_shift = date.mjd - day_baseline.mjd
number_baseline + baseline_shift
end | [
"def report_name\n return 'Report ID'\n end",
"def generate_risk_no\n pro = Project.find(self[:project_id])\n if(pro.risk_registers.count == 0)\n last_risk_id = 1000;\n else\n last_risk_id = pro.risk_registers.last.risk_no.last(4).to_i\n end\n self[:risk_no] = two_digit(projec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /informacoes GET /informacoes.json | def index
@informacoes = Informacao.all
end | [
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def index\n @codigos = Codigo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @codig... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /informacoes POST /informacoes.json | def create
@informacao = Informacao.new(informacao_params)
respond_to do |format|
if @informacao.save
format.html { redirect_to @informacao, notice: 'Informacao was successfully created.' }
format.json { render action: 'show', status: :created, location: @informacao }
else
f... | [
"def create\n @taco = Taco.new(taco_params)\n\n if @taco.save\n render json: @taco, status: :created, location: @taco\n else\n render json: @taco.errors, status: :unprocessable_entity\n end\n end",
"def create\n @oferta_academica = OfertaAcademica.new(params[:oferta_academica])\n\n if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns annual rate of return given an initial value, and final value and number of years (may be fractional) NB answer is expressed as percentage Reference Wikipedia: ERV == P (1 + T) ^ n where P == a hypothetical initial payment of $1,000 T == average annual total return n == number of years Solving for T gives T == ... | def annual_ror(initial_value, final_value, years)
if years <= 0
0
elsif initial_value == 0
# BigDecimal::INFINITY
Float::INFINITY
else
100.to_d * if final_value < 0 # fudge if final value is less than zero
(((initial_value.to_d - final_value.to_d) / initial_v... | [
"def annualized_rate_of_return(rate)\n\t\t\t(1+rate)**12 - 1\n\t\tend",
"def required_annual_savings\n needed_amount_less_savings / years_to_retirement\n end",
"def calculate_annuity(loan_amount, interest_percent_rate, months)\n interest_rate = interest_percent_rate.to_f / 100.0\n monthly_interest_rate = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
NOTE: We call redirect_params AFTER super in these methods intentionally the OAuth2 strategy uses the authorize_params and token_params methods to set up some state for testing that we need in redirect_params | def authorize_params
params = super
params = params.merge(request_params) unless OmniAuth.config.test_mode
redirect_params.merge(params)
end | [
"def authorize_params\n params = super\n params = params.merge(request.params) unless OmniAuth.config.test_mode\n redirect_params.merge(params)\n end",
"def authorize_params\n super.tap do |params|\n %w(scope team redirect_uri).each do |v|\n if !request.params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This job will alert the user when they've been invited to a contest | def perform(inviter, user_id, contest_id, email = nil)
@inviter = inviter
@user = User.joins("JOIN email_preferences ON email_preferences.user_id = users.id").select(:id, :email, :name, :token_1, :token_2, :contest_invitation, :email_validated).where(id: user_id).first
if @user
@contest = Contest.find(contest_... | [
"def alert_email(client)\n @testId = client.identification\n mail(to: client.email, subject: 'Early Test Result')\n end",
"def invite\n associate_or_create_identity\n self.update!(approval_state: ApprovalState::APPROVED)\n send_invited_email\n end",
"def send_invites\n true\n end",
"def i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write a function that accepts a positive number N. The function should console log a step shape with N levels using the character. Make sure the step has spaces on the right hand side! Examples steps(2) ' ' '' steps(3) ' ' ' ' '' steps(4) ' ' ' ' ' ' '' | def steps(n)
end | [
"def steps1(n)\n (1..n).each { |step_length|\n puts ('#' * step_length) + (' ' * (n - step_length))\n }\n nil\nend",
"def steps (n, row = 0, stair = '')\n return if n == row\n\n if n == stair.length\n puts stair\n return steps(n, row + 1)\n end\n\n stair.length <= row ? stair += '#... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
helper to decide if a user is online student or normal student | def is_a_online_student?
current_user.mode == "Online" ? true : false
end | [
"def is_student?\n current_user.user_type_id == 1\n end",
"def current_user_is_student?\n if current_user.user_type == \"student\"\n true\n else\n redirect_to user_path(@current_user)\n end\n end",
"def this_is_studente?(user)\n user.class.to_s == \"UserStudente\"\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the fft_geomancy feature exists | def has_geomancy_feature?
!features(:geomancy_element_shift).empty?
end | [
"def has_features?\n return ! features.nil?\n end",
"def has_spatial_features_hash?\n column_names.include? 'features_hash'\n end",
"def has_spatial_features_hash?\n owner_class_has_loaded_column?('features_hash')\n end",
"def aperture?\n !aperture.nil?\n end",
"def float_dtype?\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines if the supplied user is an owner of the account. | def has_owner? user
self.account_users.where(user: user, is_owner: true).count > 0
end | [
"def owned_by?(user)\n if user.nil?\n false\n else\n organization == user.organization\n end\n end",
"def is_owner?(username)\n User.get_user(username).eql?(self.owner)\n end",
"def is_owner?\n Account.current ? Account.current.has_owner?(self) : false\n end",
"def owned_by... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define where we can find the header files to parse Can give an array of directories, a glob, or just a string. All file names should be full paths, not relative. Options can be any or all of the following: :include_paths Path(s) to be added as I flags :library_paths Path(s) to be added as L flags :libraries Path(s) to ... | def sources(dirs, options = {})
parser_options = {
:includes => [],
:cxxflags => [
# Force castxml into C++ mode
"-x c++",
# Allow things like `<::`
"-fpermissive"
]
}
if (code_dir = options.delete(:include_source_dir))
options[:... | [
"def header_include_paths\n cmd = RbConfig::MAKEFILE_CONFIG[\"CC\"]\n args = %w{-Wp,-v -xc /dev/null -fsyntax-only}\n paths = []\n reading_paths = false\n run_command(cmd, *args) do |line|\n line.chomp!\n if reading_paths\n if line == 'End of search list.'\n reading_paths = false\n elsif... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Specify the mode with which to write out code files. This can be one of two modes: :multiple (default) Each class and module gets it's own set of hpp/cpp files :single Everything gets written to a single file | def writer_mode(mode)
raise "Unknown writer mode #{mode}" unless [:multiple, :single].include?(mode)
@writer_mode = mode
end | [
"def push_mode(mode)\n if ModeTag[mode] then\n output_indentation\n css_class = \"\"\n css_class = \" class=\\\"src\\\"\" if mode == :src\n css_class = \" class=\\\"example\\\"\" if (mode == :example || mode == :inline_example)\n @logger.debug \"#{mode}: <#{ModeTag[mode]}#{cs... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compile the extension. This will create an rbpp_compile.log file in +working_dir+. View this file to see the full compilation process including any compiler errors / warnings. | def compile
Logger.info "Compiling. See rbpp_compile.log for details."
require 'rbconfig'
ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["RUBY_INSTALL_NAME"])
FileUtils.cd @working_dir do
system("#{ruby} extconf.rb > rbpp_compile.log 2>&1")
system("rm -f *.so")
... | [
"def compile\n\tsystem(\"rake\", \"compile\", chdir: extensions_directory)\nend",
"def compile\n @rest.each do |py|\n begin\n Compiler.compile_file py, nil, @print\n rescue Compiler::Error => e\n e.show\n end\n end\n end",
"def compile\n cmd = \"java -jar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check ARGV to see if someone asked for "console" | def requesting_console?
@requesting_console
end | [
"def console?\n defined?(::Rails::Console) && $stdout.isatty && $stdin.isatty\n end",
"def validate_argv\n if ARGV.empty? then\n ARGV << \"start\"\n else\n if not %w{start stop restart zap status}.include? ARGV.first then\n $stderr.puts \"ERROR: invalid command '#{ARGV.first}'\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Start up a new IRB console session giving the user access to the RbGCCXML parser instance to do realtime querying of the code they're trying to wrap | def start_console
puts "IRB Session starting. @parser is now available to you for querying your code. The extension object is available as 'self'"
IRB.start_session(binding)
end | [
"def start_irb_session( b )\n\t\tIRB.setup(nil)\n\n\t\tworkspace = IRB::WorkSpace.new( b )\n\n\t\tif IRB.conf[:SCRIPT]\n\t\t\tirb = IRB::Irb.new( workspace, IRB.conf[:SCRIPT] )\n\t\telse\n\t\t\tirb = IRB::Irb.new( workspace )\n\t\tend\n\n\t\tIRB.conf[:IRB_RC].call( irb.context ) if IRB.conf[:IRB_RC]\n\t\tIRB.conf[:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If the working dir doesn't exist, make it and if it does exist, clean it out | def prepare_working_dir
FileUtils.mkdir_p @working_dir unless File.directory?(@working_dir)
FileUtils.rm_rf Dir["#{@working_dir}/*"] if @force_rebuild
end | [
"def clean_up\n FileUtils.rm_rf \"#{@path}\" unless create_in_current_directory?\n FileUtils.rm_rf \"#{@cache}\"\n end",
"def clear_working_dir\n log\n FileUtils.rmtree(WORKING) if File.exist?(WORKING)\n end",
"def clean_working_directory\n @process_runner.execute!(\"rm -rf #{@working_dir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make sure that any files or globs of files in :include_source_files are copied into the working directory before compilation | def process_other_source_files
files = @options[:include_source_files].flatten
files.each do |f|
FileUtils.cp Dir[f], @working_dir
end
end | [
"def copy_source_files_to_scratch\n source_directories.each do |dir|\n Origen.file_handler.resolve_files(dir) do |file|\n subdir = file.relative_path_from(Pathname.new(dir)).dirname.to_s\n cpydir = \"#{ungenerated_dir}/#{subdir}\"\n FileUtils.mkdir_p(cpydir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /desinfectantes GET /desinfectantes.json | def index
@desinfectantes = Desinfectante.all
end | [
"def destroy\n @desinfectante.destroy\n respond_to do |format|\n format.html { redirect_to desinfectantes_url, notice: 'Desinfectante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n Deputado.all\n respond_to do |format|\n format.json {}\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /desinfectantes POST /desinfectantes.json | def create
@desinfectante = Desinfectante.new(desinfectante_params)
respond_to do |format|
if @desinfectante.save
format.html { redirect_to @desinfectante, notice: 'Desinfectante was successfully created.' }
format.json { render :show, status: :created, location: @desinfectante }
el... | [
"def destroy\n @desinfectante.destroy\n respond_to do |format|\n format.html { redirect_to desinfectantes_url, notice: 'Desinfectante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @desinfectantes = Desinfectante.all\n end",
"def desde_para\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /desinfectantes/1 PATCH/PUT /desinfectantes/1.json | def update
respond_to do |format|
if @desinfectante.update(desinfectante_params)
format.html { redirect_to @desinfectante, notice: 'Desinfectante was successfully updated.' }
format.json { render :show, status: :ok, location: @desinfectante }
else
format.html { render :edit }
... | [
"def update\n\n @cliente = find_cliente\n @descuento_cliente = @cliente.descuento_clientes.find(params[:id])\n\n respond_to do |format|\n\n if @descuento_cliente.update_attributes(params[:descuento_cliente])\n #format.html { redirect_to redirigir(@contelefono), :notice => 'El telefono fue actua... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /desinfectantes/1 DELETE /desinfectantes/1.json | def destroy
@desinfectante.destroy
respond_to do |format|
format.html { redirect_to desinfectantes_url, notice: 'Desinfectante was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @detalleapuestum = Detalleapuestum.find(params[:id])\n @detalleapuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to detalleapuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Using your is_prime? method, write a new method, primes that takes a (nonnegative, integer) number max and returns an array of all prime numbers less than max. | def primes(max)
array = []
i = 2
while i < max.abs
if is_prime?(i)
array << i
end
i += 1
end
array
end | [
"def primes max\n array_of_primes = []\n for num in 2..(max)\n if is_prime?(num)\n array_of_primes << num\n end\n end\n return array_of_primes\nend",
"def primes(max)\n\ti = 2 \n\tprime_arry = []\n\n\twhile i < max \n\t\tif is_prime?\n\t\t\tprime_arry << i\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create one or more CSV files (one CSV file per survey_schema) and archive it with ZIP | def create_zip_file(destination_file_name, csv_filenames_prefix, survey_schemas, administration_id)
raise 'empty survey_schemas are unsupported' if survey_schemas.empty?
working_dir = create_unique_dir
csv_filepaths = create_csv_files(working_dir, csv_filenames_prefix, survey_schemas, administration_id)
... | [
"def generate_csv(survey)\n responses = Course::Survey::Response.\n where.not(submitted_at: nil).\n includes(answers: [:options, :question]).\n where(survey: survey)\n questions = survey.questions.\n merge(Course::Survey::Section.order(:w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
removing all stored nodes and edges with this node for a particular node | def remove_node(node)
@nodes_being_worked_on.delete(node)
@nodes.delete(node)
# the last edge keeps getting ignored when you remove this, so handling the final case
assign_node(@edges[0][1]) if @edges.size == 1
@edges.reject! { |edge| edge.include?(node) }
end | [
"def delete a\n # delete connections from node a\n @edges.delete a\n \n # delete connection to node a\n @edges.each{|x,l| l.delete_if{|e| e.include? a}}\n \n # delete node\n @nodes.delete a\n end",
"def delete_from_graph(node)\nend",
"def remove_nonsense_nodes\n _clear_cache\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
First assign nodes to workers, and then count the seconds off each worker | def process_second
@seconds += 1
assign_nodes
process_workers
end | [
"def worker_node_count\n @worker_node_count ||= kube_client.api('v1').resource('nodes').list(labelSelector: 'node-role.kubernetes.io/master!=').size\n end",
"def worker_count\n workers.count(&:alive?)\n end",
"def live_worker_count\n worker_counts[:alive]\n end",
"def counts\n tasks.zip(wor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this a start state. | def start_state?
@state_type == :start
end | [
"def at_start?\n @state == @stateMachine.start_state\n end",
"def started?\n state == :started\n end",
"def started?\n @state == STATE_STARTED\n end",
"def started?\n state?(STATE_STARTED)\n end",
"def started?\n @mutex.synchronize do\n @state == :started\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this an end state. | def end_state?
@state_type == :end
end | [
"def at_end?\n FinalState === @state || # UML\n @state == @stateMachine.end_state # not UML\n end",
"def isEnd?\n\t\t\treturn @end != nil\n\t\tend",
"def ended?\n !!@finished && !transition?\n end",
"def ended?\n end_time < Time.now.utc\n end",
"def final_state?\n current_sta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this State matches x or is a substate of x. | def === x
# $stderr.puts "#{self.inspect} === #{x.inspect}"
case x
when self.class
self.is_a_substate_of?(x)
else
super
end
end | [
"def is_a_substate_of? x\n self.ancestors.include?(x)\n end",
"def is_a_superstate_of? x\n x.ancestors.include?(self)\n end",
"def state_is_active? s\n return false unless s && @state\n x = to_state(s)\n return ArgumentError, \"no State #{x.inspect}\" unless x\n x.is_a_supers... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this State is a substate of x. All States are substates of themselves. | def is_a_substate_of? x
self.ancestors.include?(x)
end | [
"def is_a_superstate_of? x\n x.ancestors.include?(self)\n end",
"def === x\n # $stderr.puts \"#{self.inspect} === #{x.inspect}\"\n case x\n when self.class\n self.is_a_substate_of?(x)\n else\n super\n end\n end",
"def isSubmachineState\n ! ! @submachine\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this State is a superstate of x. All States are superstates of themselves. | def is_a_superstate_of? x
x.ancestors.include?(self)
end | [
"def is_a_substate_of? x\n self.ancestors.include?(x)\n end",
"def === x\n # $stderr.puts \"#{self.inspect} === #{x.inspect}\"\n case x\n when self.class\n self.is_a_substate_of?(x)\n else\n super\n end\n end",
"def state_is_active? s\n return false unless ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A state with isOrthogonal=true is said to be an orthogonal composite state. An orthogonal composite state contains two or more regions. Default value is false. | def isOrthogonal
raise Error::NotImplemented, :message => :isOrthogonal, :object => self
end | [
"def orthogonal?\n @colt_property.isOrthogonal(@colt_matrix)\n end",
"def orthogonal?\n return true if ((self.is_square) && (self.transposed == self.inversed))\n false\n end",
"def orthogonal?\n temp = self.transpose\n multiply_mat4(temp, temp) == IDENTITY\n end",
"def compshape?\n se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A state with isSubmachineState=true is said to be a submachine state. Such a state refers to a state machine (submachine). Default value is false. | def isSubmachineState
! ! @submachine
end | [
"def superstatemachine\n @submachineState && @submachineState.stateMachine\n end",
"def submachine opts = { }, &blk\n raise ArgumentError, \"submachine only valid inside a state\" unless State === @current\n raise ArgumentError, \"submachine only valid once inside a state\" if @current.submachin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a NamedArray of all ancestor States. self is the first element. | def ancestors
@ancestors ||=
begin
x = [ self ]
if ss = superstate
x.push(*ss.ancestors)
end
NamedArray.new(x.freeze, :state)
end
end | [
"def ancestors\n each_ancestor.to_a\n end",
"def ancestors\n each_ancestor.to_a\n end",
"def all_active_states\n return [] unless __is_current__?\n return [self] if @substates.empty?\n\n @substates.reduce([]) do |arr, substate|\n arr.concat(substate.all_active_states) if substa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called after this State is added to the StateMachine. | def state_added! statemachine
transitions_changed!
end | [
"def after_state(state)\n end",
"def after_appending( state )\n\t\t# Nothing to do\n\t\treturn nil\n\tend",
"def after_initialize\n\t\tself.current_history = History.new( :parent_class => self.class.name, :parent_id => self.id, :state_in => self.state )\n\tend",
"def extra_state; end",
"def enter_state\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called after a State removed from its StateMachine. | def state_removed! statemachine
transitions_changed!
end | [
"def remove_state! s\n _log { \"remove_state! #{s.inspect}\" }\n\n transitions = s.transitions\n\n remove_ownedMember!(s)\n @states.delete(s)\n s.stateMachine = nil\n\n s.transitions.each do | t |\n remove_transition! t\n end\n\n # Notify.\n s.state_removed! self\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a data attribute to each option of the select to indicate which category the choice is linked to, if any. This allows us to show and hide appropriate fields in JavaScript based on the category. | def options_for_select
choices.map do |choice|
data = {}
data["choice-category"] = choice.category_id if choice.category_id
content_tag(
:option,
choice.short_name,
:value => choice.id,
:selected => selected_choice?(item, choice),
:data => data
)
... | [
"def cats_for_landing\n select_tag 'filter_category', options_for_select(get_cats_for_model.map { |cat| [cat.long_name, cat.id] }.insert(0, ''), get_cats_search_id.to_i), { :style => \"width:180px\", :onchange => \"crm.search_categorized(crm.get_category_filter(), '#{self.controller_name.to_s}')\" }\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new Item Record. | def new_item(opts={})
defaults = {:number => @items.count + 1}
@items << ItemRecord.new(defaults.merge(opts))
end | [
"def create_item(params = nil, headers = nil)\n post(\"/api/v1/items\", params, headers)\n end",
"def create_item(params = nil, headers = nil)\n post(\"/api/v2/items\", params, headers)\n end",
"def create\n @item_record = ItemRecord.new(params[:item_record])\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Verbosely checks if file should be processed filename file whose existance will be checked step name of pipeline step | def skip_step?(filename, step)
if File.exist?(filename) && !@force_overwrite
print_e "SKIPPED #{step}: #{filename} already exists."
true
else
print_e "RUN #{step} => #{filename}"
false
end
end | [
"def step_file_missing\n puts 'Step file missing: please run --generate first!'\n .colorize(:light_red)\n false\n end",
"def file_fixture_exists?(filename, step = '')\n return true if File.exist?(Rails.root.join(UPLOADED_FILES_DIR, filename))\n\n raise \"ERROR in step: '#{step}'\\n\" +\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Quality filters reads minlen discard all shorter reads Returns nothing | def filter(minlen)
return if skip_step?(@names.get('filter'), 'filtering')
# Only filter input files from Illumina CASAVA 1.8 pipeline
if `head -n 1 #{@names.get('reads')} | cut -d ' ' -f 3`.empty?
run_cmd(
'fastq_illumina_filter' \
" --keep N -v -l #{minlen} "... | [
"def filter_quality(min_quality)\n mode_lines = @raw_data.scan(/harminv.*:, (\\d.*)/).join \"\\n\"\n CSV.parse(mode_lines,\n :converters => :numeric).find_all {|nums| nums[2].abs > min_quality}\n end",
"def truncate_samples\n @samples.sort!{|a,b| a.duration <=> b.duration}\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clips linker from 3' linker string to be clipped from 3' software clipping software (fastx, cutadapt) error_rate allowed error rate (only for cutadapt) minlen discard all shorter reads Returns nothing. | def clip(linker, software, error_rate, minlen)
return if skip_step?(@names.get('clip'), 'clipping')
clipper_cmd = {
fastx: \
'fastx_clipper' \
' -Q33 -c -n -v' \
" -a #{linker}" \
" -l #{minlen}" \
" #{@names.base}" \
" -... | [
"def spelling_penalty\n chars.inject_with_index(0) do |penalty, char, i| \n if i < @options[:target].size\n # add to penalty the differences between ascii values in the two strongs * the multiplier\n penalty + ((@options[:target][i] - char[0]).abs * @options[:spelling_multiplier])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PreComputes index if it does not exist ref path to reference ref_base path to reference without file extension software alignment software (bowtie1, bowtie2, bwa, star) annotation path to GTF annotation (only star) Returns nothing | def index(ref, ref_base, software, annotation = '')
index_suffix = {
bowtie1: '4.ebwt',
bowtie2: '4.bt2',
bwa: '.sa',
star: '.star'
}
index_cmd = {
bowtie1: "bowtie-build -p #{ref} #{ref_base}",
bowtie2: "bowtie2-build -p #{ref} #{ref_b... | [
"def genome_annotation_index_link\n if self.genome_assembly.present? && self.genome_assembly.current_annotation.present?\n self.genome_assembly.current_annotation.public_annotation_index_link\n else\n nil\n end\n end",
"def configure_defaults_for_file_reference(ref)\n if ref.path.in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Performs alignment ref path to genomic reference ref_base path to reference without file extension software alignment software (bowtie1, bowtie2, bwa, star, tophat) opts stepspecific options :annotation path to genomic annotation :mismatches max num of mismatches in alignment :seedlen seed length for ncRNA alignment :t... | def align(ref, ref_base, software, opts = {})
if software == :tophat
bt_flag =
opts[:tophat_aligner] == :bowtie1 ? '--bowtie1' : ''
gap_flag =
opts[:mismatches] < 2 ? "--read-gap-length #{opts[:mismatches]}" : ''
end
aln_cmd = {
bowtie1:
... | [
"def unbucketized_alignment\n align(\n @ref, @ref_base, @software,\n { annotation: @annotation,\n tophat_aligner: @tophat_aligner,\n mismatches: @mismatches\n }\n )\n mapped_all = @software == :star ? \\\n @names.get('mapped_all_star') :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes genomic alignment parameters annotation genomic annotation, needed for splicing awareness tophat_aligner software that Tophat uses (bowtie2 or bowtie1) mismatches max number of allowed mismatches in Tophat alignment err error rate for STAR / bucketizing | def initialize(names, force_overwrite, ref, software,
annotation, tophat_aligner, mismatches, err_rate)
super(names, force_overwrite, ref, software)
@annotation = annotation
@tophat_aligner = tophat_aligner
@mismatches = mismatches
@err_rate = err_rate
... | [
"def initialize(graph, assembly_options={})\n @graph = graph\n @assembly_options = assembly_options\n @assembly_options[:max_tip_length] ||= DEFAULT_MAX_TIP_LENGTH\n @assembly_options[:min_contig_size] ||= DEFAULT_MIN_CONTIG_SIZE\n @assembly_options[:min_confirming_recoherence_kmer_reads] ||= DEFAULT... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Performs genomic alignment with relative error rate (buckets) | def bucketized_alignment
# split reads into buckets according to their size and err_rate
@buckets = bucketize(@err_rate)
# perform alignment on each bucket
@buckets.reverse_each do |lower, upper, mismatches|
@names.set_bucket(lower, upper)
mapped, unmapped = align(
... | [
"def unbucketized_alignment\n align(\n @ref, @ref_base, @software,\n { annotation: @annotation,\n tophat_aligner: @tophat_aligner,\n mismatches: @mismatches\n }\n )\n mapped_all = @software == :star ? \\\n @names.get('mapped_all_star') :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Performs genomic alignment with fixed number of allowed mismatches | def unbucketized_alignment
align(
@ref, @ref_base, @software,
{ annotation: @annotation,
tophat_aligner: @tophat_aligner,
mismatches: @mismatches
}
)
mapped_all = @software == :star ? \
@names.get('mapped_all_star') : @names.get('ma... | [
"def recalculate_mismatches_from_alignments\n calculate_mismatches = lambda do |seq, primer|\n mismatches = 0\n (0..(seq.length-1)).each do |position|\n regex = Bio::Sequence::NA.new(primer[position].downcase).to_re\n seqp = seq[position].downcase\n mismatch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Splits reads into several files containing a read length range to allow for seperate alignments with a relative number of errors. error rate = num of errors / read length Returns array. | def bucketize(error_rate)
buckets = []
run_cmd(
"fastq-bucketize #{@names.get('fp')} #{error_rate} " \
"2> #{@names.get('buckets')}"
)
# parse buckets and compute corresponding absolute number of errors
File.readlines(@names.get('buckets')).each do |line|
... | [
"def sub_chunks(data_offset: 0, sub_chunk_size_length: @size_length, sub_chunk_header_size: @header_size, sub_chunks_format: @chunks_format, warnings: @warnings, debug: @debug, &callback)\n data_size = self.size\n data_size > 0 ? Riffola.read(@file_name,\n offset: @offset + 4 + @size_length + @head... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merges bucketed alignments into single bam file infiles array of filenames outfile merged file | def unbucketize(infiles, outfile)
run_cmd("samtools merge -f #{outfile} #{infiles.join(' ')}")
end | [
"def bucketized_alignment\n # split reads into buckets according to their size and err_rate\n @buckets = bucketize(@err_rate)\n\n # perform alignment on each bucket\n @buckets.reverse_each do |lower, upper, mismatches|\n @names.set_bucket(lower, upper)\n mapped, unmappe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extracts uniquely mapping reads | def extract_uni
# Extract all uniquely mapping reads
run_cmd(
"samtools view -H #{@names.get('mapped_merged')} " \
"> #{@names.get('mapped_uniq')}"
)
run_cmd(
"samtools view -h #{@names.get('mapped_merged')} " \
"| grep -P 'NH:i:1(\t|$)' " \
... | [
"def remapped_reads(input_file, output_file, read_length, sequencing_type, mm=2)\n\t\tremapped = {}\n\n\t\t# Filter remapped reads\n\t\tinput_file.each do |line|\n\t\t\tmdz = line.match(/MD:Z:\\S*/).to_s\t\t\t\n\t\t\tline = line.strip.split(/\\s+/)\n\t\t\tqname, mate = line[0].split('/')[0..1].join('/'), line[0].sp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /apps/exists.xml POST /apps/exists.json | def exists
@record = Record.new
app = App.find_by_packageName(params[:packageName], :select => :id)
if app.nil?
@record.exists = false
else
@record.id = app.id
@record.exists = true
end
respond_to do |format|
format.xml {render :xml => @record}
format.json {... | [
"def exists\n @record = Record.new\n @record.exists = AppTarget.exists?(params[:app_target])\n\n respond_to do |format|\n format.xml {render :xml => @record}\n format.json {render :json => @record} \n end\n end",
"def app_exists?(host_id, app_name)\n\n message = {\n 'method... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subclassification of the packaging type for this deposit, such as a METS profile. | def deposit_package_subtype
'https://jats.nlm.nih.gov/publishing/'
end | [
"def deposit_package_subtype\n 'ProQuest'\n end",
"def subtype\n return nil if @values[:subtype].nil?\n self.class.subtype @values[:subtype].to_sym\n end",
"def getClassificationType\r\n\t\t\t\t\treturn @classificationType\r\n\t\t\t\tend",
"def maintype\n type = Bettype.find(self.main... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new server connection FluidDB::Connection.new(:test) will use the sandbox Params: __username__ __password__ __server__ __schema__ Could be 'http' or 'https' __port__ Change default port (443 for https and 80 for http) | def initialize(args)
@params = args == :test ? SANDBOX : DEFAULT.merge(args)
@params[:port] ||= @params[:scheme] == 'https' ? 443 : 80
connect
end | [
"def connect(options={})\n if @options.include? '--skip-networking'\n output 'Skipping connection attempt because server started with --skip-networking'\n return nil\n end\n \n options[:user] ||= app_credentials[:user]\n options[:schema] ||= app_schema\n \n retur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /uang_masuks/1 GET /uang_masuks/1.json GET /uang_masuks/new | def new
@uang_masuk = UangMasuk.new
end | [
"def new\n @mak = Mak.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mak }\n end\n end",
"def new\n @manga = Manga.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manga }\n end\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /uang_masuks POST /uang_masuks.json | def create
@uang_masuk = UangMasuk.new(uang_masuk_params)
respond_to do |format|
if @uang_masuk.save
format.html { redirect_to uang_masuks_path, notice: 'Uang masuk was successfully created.' }
else
format.html { render :new }
format.json { render json: @uang_masuk.errors, s... | [
"def create\n @obat_masuk = ObatMasuk.new(obat_masuk_params)\n\n respond_to do |format|\n if @obat_masuk.save\n format.html { redirect_to obat_masuks_path, notice: 'Obat masuk was successfully created.' }\n# format.json { render :show, status: :created, location: @obat_masuk }\n else\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /uang_masuks/1 PATCH/PUT /uang_masuks/1.json | def update
respond_to do |format|
if @uang_masuk.update(uang_masuk_params)
format.html { redirect_to @uang_masuk, notice: 'Uang masuk was successfully updated.' }
format.json { render :show, status: :ok, location: @uang_masuk }
else
format.html { render :edit }
format.jso... | [
"def update\n respond_to do |format|\n if @obat_masuk.update(obat_masuk_params)\n format.html { redirect_to @obat_masuk, notice: 'Obat masuk was successfully updated.' }\n format.json { render :show, status: :ok, location: @obat_masuk }\n else\n format.html { render :edit }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /uang_masuks/1 DELETE /uang_masuks/1.json | def destroy
@uang_masuk.destroy
respond_to do |format|
format.html { redirect_to uang_masuks_url, notice: 'Uang masuk was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @obat_masuk.destroy\n respond_to do |format|\n format.html { redirect_to obat_masuks_url, notice: 'Obat masuk was successfully destroyed.' }\n format.json { he... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ensure that every criterion that is supposed to be in this level is selectable, and that every criterion that is not supposed to be in this level is not selectable. rubocop:disable Metrics/MethodLength | def only_correct_criteria_selectable(level)
Criteria.keys do |query_level|
Criteria[query_level].each do |criterion|
if query_level == level
assert_select '#' + criterion.to_s
assert_select "#project_#{criterion}_status_met"
elsif !Criteria[level].key?(criterion)
... | [
"def ensure_option_missions\n # go in through optionings association in case these are newly created options via nested attribs\n optionings.each{|oing| oing.option.mission_id ||= mission_id if oing.option}\n end",
"def actual_level_of_effort_only_on_completion\n if actual_level_of_effort.nil? && ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:section: Basics Some commands sometimes cause side effects. When evaluating arguments, if you discover that undoing doesn't make sense, and will be confusing to the user, call dont_undo, and the interpreter will ignore the call for purposes of undoing | def dont_undo
@should_undo = false
return nil
end | [
"def undo\n end",
"def edit_undo\n execute_only('edit', 'undo')\n end",
"def undo!\n Execute.task_popen3(*override_a, \"undo\") do |i, o, e, t|\n return t.value\n end\n end",
"def undo(&block)\n define_method(:undo, &block)\n define_method(:undoable?) do\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /user_biographies/1 GET /user_biographies/1.json | def show
@user_biography = UserBiography.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user_biography }
end
end | [
"def index\n @biographies = Biography.all\n end",
"def show\n @bio = Bio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bio }\n end\n end",
"def show\n @biography = Biography.find(params[:id])\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /user_biographies/new GET /user_biographies/new.json | def new
@user_biography = UserBiography.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user_biography }
end
end | [
"def new\n @bio = Bio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bio }\n end\n end",
"def new\n @biography = Biography.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @biography }\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /user_biographies/1 PUT /user_biographies/1.json | def update
@user_biography = UserBiography.find(params[:id])
respond_to do |format|
if @user_biography.update_attributes(params[:user_biography])
format.html { redirect_to @user_biography, notice: 'User biography was successfully updated.' }
format.json { head :no_content }
else
... | [
"def update\n bio = user_params[:bio]\n\n if bio.blank?\n flash[:alert] = 'Bio cannot be blank'\n redirect_to users_profile_path current_user.username\n return\n end\n\n current_user.bio = bio\n current_user.save\n flash[:notice] = 'Bio has been updated'\n red... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /user_biographies/1 DELETE /user_biographies/1.json | def destroy
@user_biography = UserBiography.find(params[:id])
@user_biography.destroy
respond_to do |format|
format.html { redirect_to user_biographies_url }
format.json { head :no_content }
end
end | [
"def destroy\n @biography = Biography.find(params[:id])\n @biography.destroy\n\n respond_to do |format|\n format.html { redirect_to biographies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @biography.destroy\n respond_to do |format|\n format.html { redire... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /instructors GET /instructors.json | def index
@instructors = Instructor.all(:order => :name)
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @instructors }
end
end | [
"def instructors(term:)\n fetch_and_parse('/instructors', term: term)\n end",
"def index\n @instructors = Instructor.all\n render json:@instructors\n end",
"def index\n @instructors = Instructor.all\n end",
"def show\n @instructor = Instructor.find(params[:id])\n\n respond_to do |for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /instructors/1 DELETE /instructors/1.json | def destroy
@instructor = Instructor.find(params[:id])
@instructor.destroy
respond_to do |format|
format.html { redirect_to instructors_url }
format.json { head :ok }
end
end | [
"def destroy\n @instructor = Instructor.find(params[:id])\n @instructor.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n end",
"def destroy\n @instructor.destroy\n respond_to do |format|\n format.html { redirect_to instructors_url }\n format.json { head :no_c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
dscl . read /Groups/ladmins | def group_get_info(attribs, dir_info)
attribs = group_record_name_alternatives(attribs)
check_critical_attribute( attribs, :record_name )
command = {action: 'read', scope: 'Groups', value: nil}
user_attrs = attribs.merge(command)
dscl( user_attrs, dir_info )
end | [
"def get_group(fullpath)\n returnval = nil\n group_list = JSON.parse(rpc(\"getHostGroups\", {}))\n if group_list[\"data\"].nil?\n puts(\"Unable to retrieve list of host groups from LogicMonitor Account\")\n else\n group_list[\"data\"].each do |group|\n if group[\"fullPath\"].eql?(fullpath.sub(\"/\", ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
dscl . delete /Groups/yourGroupName | def group_delete(attribs, dir_info)
attribs = group_record_name_alternatives(attribs)
check_critical_attribute( attribs, :record_name )
command = {action: 'delete', scope: 'Groups', attribute: nil, value: nil}
user_attrs = attribs.merge(command)
dscl( user_attrs, dir_info )
end | [
"def delete\n client.delete_group(:group_name => name)\n nil\n end",
"def delete_group(group)\n\t\t\tend",
"def group_absent(name, &block)\n execute(\"if dscl . -list /Groups/#{name}; then dscl . -delete /Groups/#{name}; fi\", {}, &block)\n end",
"def destroy\n Group.rebuild! if nil.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /charts/new GET /charts/new.xml | def new
@chart = Chart.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @chart }
end
end | [
"def new\n @chart = Chart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chart }\n end\n end",
"def new\n @chart = Chart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chart }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the connection that corresponds to the given EMS identifier and options. The connection will be created if doesn't exist yet. If the connection already exists, but the given options are different to the options that were used to create it, then it will be closed and created again. This is intended to support up... | def get(id, opts)
# Purge connections if needed:
purge if purge?
# Find the entry for the given id and return it if the options are compatible:
entry = @registry[id]
return entry.connection if entry && entry.compatible?(opts)
# If there is an entry but it isn't compatible, then close and remov... | [
"def create_new_connection(options, &block)\n if @connection\n logger.debug(\"[WinRM] shutting previous connection #{@connection}\")\n @connection.close\n end\n\n @connection_options = options\n @connection = Connection.new(options, &block)\n end",
"def build_connection(option... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Closes the connection associated to the given EMS id. | def close(id)
entry = @registry.delete(id)
return unless entry
begin
$rhevm_log.info("Closing connection for EMS with identifier '#{id}' and URL '#{entry.options[:url]}'.")
entry.connection.close
rescue OvirtSDK4::Error => error
$rhevm_log.warn(
"Error while closing connection ... | [
"def close(id)\n wf_event_id?(id)\n api.post([id, 'close'].uri_concat)\n end",
"def event_loop_connection_close\n @em_connection.close_connection if @em_connection\n end",
"def disconnect\n $emsConnections.close\n end",
"def close\n @connection.close # Close the... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the this entry is compatible with the given options. A connection is compatible if it the options that were used to create it are exactly the same than the given options. | def compatible?(opts)
opts == @options
end | [
"def compatible_with?(other_option)\n self.is_a? other_option.class\n end",
"def compatible?\n true\n end",
"def check_options_against_database\n # extract the keys from the options hash as strings\n option_keys = @options.stringify_keys.keys\n # fetch the names of the C... | {
"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.