query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
If user is logged in, returns them as json object else returns null TODO: (performance) don't need to return full user object | def get_cur_user
@user = nil
if is_logged_in session
@user = User.find_by_sunet(session[:user_hash]["username"])
end
render json: @user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logged_in\n #checks to see if a current user is available \n \n if @current_user\n render json: {\n logged_in: true,\n user: @current_user\n }\n else \n render json: {\n logged_in: false\n }\n end \n\n end",
"def check_for_user\n if current_user\n ... | [
"0.75193197",
"0.73531914",
"0.7243217",
"0.7226272",
"0.7189483",
"0.7155826",
"0.7095808",
"0.70825005",
"0.70557064",
"0.70433116",
"0.7018541",
"0.6986694",
"0.6966792",
"0.69597805",
"0.6919595",
"0.6919595",
"0.6900745",
"0.68041307",
"0.6800998",
"0.67803276",
"0.67249... | 0.7386238 | 2 |
must be either asc or desc | def sort_direction
%w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_ordering?\n name =~ /^(ascend_by|descend_by)/ || arguments.blank?\n end",
"def define_order(s_order)\n s_order=='Crescente' ? :asc : :desc\n end",
"def ascending?\n direction == :asc\n end",
"def validate_sort_field( value )\n if [ 'title', 'code', 'created_at' ].include?(... | [
"0.6949707",
"0.6460089",
"0.63926715",
"0.6380408",
"0.6289623",
"0.61716545",
"0.61716545",
"0.61716545",
"0.61716545",
"0.61716545",
"0.61716545",
"0.61337364",
"0.6039866",
"0.60315996",
"0.60315996",
"0.60315996",
"0.59485936",
"0.59479296",
"0.5913768",
"0.58829355",
"0... | 0.5742629 | 32 |
support just UTC or local timezone to avoid DST correct handling issues (as DATE values are converted to TIMESTAMP using current UTC offset) | def ocitimestamp_to_time(ary)
year, month, day, hour, minute, sec, fsec, tz_hour, tz_min = ary
if year >= 139
timezone = tz_hour == 0 && tz_min == 0 ? :utc : :local
begin
# Ruby 1.9 Time class's resolution is nanosecond.
# But the last argument type is millisecond.
# 'fsec' is converted to a Float to pass sub-millisecond part.
return ::Time.send(timezone, year, month, day, hour, minute, sec, fsec / 1000.0)
rescue StandardError
end
end
ocitimestamp_to_datetime(ary)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_date_time\n # d = [:year, :mon, :day, :hour, :min, :sec].map{|q| @local_date_time.send(q)}\n # d << (utc_offset/24).to_f\n # #puts d\n # DateTime.new(*d) \n tz0 = utc_offset.to_s.split('.')\n tz = (tz0[0][0]=='-' ? '-' : '+')+('00'+tz0[0].to_i.abs.to_s)[-2,2]+':'\n tz += tz0.count>1 ... | [
"0.67126626",
"0.64517707",
"0.6406952",
"0.63443404",
"0.6301246",
"0.6301246",
"0.6301246",
"0.6288526",
"0.62506497",
"0.6237231",
"0.6231796",
"0.61841106",
"0.61491674",
"0.6107699",
"0.6107699",
"0.6107699",
"0.6107699",
"0.6107699",
"0.6062283",
"0.60533774",
"0.605053... | 0.0 | -1 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def viewable?(user)\n !deleted && !hidden?\n end",
"def visible?(user=User.current)\n user.allowed_to?(:view_pulls, self.project)\n end",
"def preview_only?(user)\n !listed && !author?(user)\n end",
"def visible?(user=User.current)\n true\n end",
"def viewable?(user=:false)\n (user !... | [
"0.7126053",
"0.69971746",
"0.69805413",
"0.693687",
"0.68877417",
"0.68426013",
"0.6834691",
"0.6696283",
"0.6695636",
"0.66778594",
"0.6672065",
"0.6569134",
"0.6543863",
"0.653839",
"0.65341496",
"0.65249795",
"0.65151787",
"0.64947087",
"0.6493367",
"0.6474173",
"0.646922... | 0.71227986 | 1 |
Is the post still available (not deleted) | def available?
return false if deleted?
return false if karma < app_settings(:post_karma_barrier)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_request?(post)\n post[:post_id] != posts\n end",
"def posted?\n post.present?\n end",
"def check_for_posts\n if self.posts.any?\n errors[:base] << \"cannot delete Topic tag when posts are using it!\"\n return false\n else\n return true\n end\n end",
"def ready_to_post... | [
"0.74019",
"0.7044312",
"0.70027137",
"0.69858414",
"0.6934177",
"0.6896584",
"0.6896584",
"0.6896584",
"0.6896584",
"0.6896584",
"0.6884174",
"0.68457264",
"0.6787995",
"0.67482674",
"0.67015463",
"0.6692337",
"0.6681942",
"0.668012",
"0.6644733",
"0.66373414",
"0.66373414",... | 0.62506413 | 71 |
if this is a video and playable? | def playable?
video_source
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def video?\n self.type == \"Video\"\n end",
"def video?\n self.type == \"Assetabler::Video\"\n end",
"def has_video?\n false\n end",
"def video?\n !!( content_type =~ Transit.config.video_regexp )\n end",
"def video?\n !!video_stream\n end",
"def is_video_type?\n file_conte... | [
"0.83826864",
"0.82667106",
"0.7903742",
"0.7889886",
"0.78727937",
"0.7813366",
"0.77756286",
"0.7705342",
"0.76434153",
"0.7614785",
"0.7571292",
"0.74946797",
"0.7446947",
"0.7446692",
"0.7424836",
"0.7242139",
"0.7026879",
"0.7007215",
"0.6989685",
"0.69199246",
"0.691845... | 0.87688667 | 0 |
if an id refers to a comment/post in current thread | def thread_contains?(cid)
id == cid or cid =~ /\A#{id}_/
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_comment?(user_id)\n @current_user.id == user_id\n end",
"def show_comment_on_comment(id)\n if session[:shown_reply_to_comment].nil? ||\n\tsession[:shown_reply_to_comment].empty?\n session[:shown_reply_to_comment] = [ id ]\n else\n session[:shown_reply_to_comment] << id unless session... | [
"0.6769683",
"0.6527905",
"0.64404404",
"0.6253728",
"0.6173363",
"0.6137364",
"0.6131735",
"0.60899293",
"0.60822713",
"0.60634106",
"0.60122716",
"0.5983107",
"0.59741807",
"0.59417033",
"0.5923514",
"0.59014297",
"0.58922756",
"0.58908457",
"0.5883245",
"0.5880391",
"0.587... | 0.64547956 | 2 |
Creates information about a diff between two trees. | def initialize(files_added, files_removed, files_modified)
@files_added = files_added.to_a.dup.freeze
@files_removed = files_removed.to_a.dup.freeze
@files_modified = files_modified.to_a.dup.freeze
freeze
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_diff\n print_tree(DiffEditor, nil, true)\n end",
"def diff_tree(a, b=\"^#{a}\")\n sandbox do |git,w,i|\n output = git.run('', :diff_tree, '', {:r => true, :name_status => true}, [a, b])\n \n diff = {'A' => [], 'D' => [], 'M' => []}\n output.split(\"\\n\").each do |lin... | [
"0.6711389",
"0.6629702",
"0.63976043",
"0.6205352",
"0.6175841",
"0.61481845",
"0.60910344",
"0.59595007",
"0.59220314",
"0.5914852",
"0.5860484",
"0.5846582",
"0.58203024",
"0.5816054",
"0.5815961",
"0.5809467",
"0.57994175",
"0.5772613",
"0.57670355",
"0.57664347",
"0.5748... | 0.0 | -1 |
Remove the next option and return it. Return nil when there are no more options. | def next_argument
if @remaining.empty?
return nil
else
return @remaining.shift
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_options!\n last_options.tap { @last_options = nil }\n end",
"def pop_solution\n return nil if @pb_list.empty?\n return nil if not @pb_list[0].complete?\n return @pb_list.shift\n end",
"def pop\n old = @tail\n if @tail == nil\n return nil\n else\n ... | [
"0.5816347",
"0.5725699",
"0.5577512",
"0.55603254",
"0.55255824",
"0.55032474",
"0.5483357",
"0.5470601",
"0.5467944",
"0.54475003",
"0.54406375",
"0.5439845",
"0.5436025",
"0.54314",
"0.54233813",
"0.5420547",
"0.53885144",
"0.53851235",
"0.5382035",
"0.5374562",
"0.5366350... | 0.5416033 | 16 |
And ... action! Run "svn" puts args_to_svn.inspect puts args_to_less.inspect | def quote(*args)
arr = args.map {|x| '"' + x + '"'}
return arr.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def svn command, *args\n run 'svn', command.to_s, *args\nend",
"def svn(*args)\n output = `svn #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}`\n fail \"SVN command failed with status #{$?.exitstatus}\" unless $?.exitstatus == 0\n return output\n end",
"def use_svn(opts)\n # Th... | [
"0.80046654",
"0.70792806",
"0.65683395",
"0.6053351",
"0.5842421",
"0.58190924",
"0.5779616",
"0.56481946",
"0.5575322",
"0.55661416",
"0.5555579",
"0.5555579",
"0.55423915",
"0.55001616",
"0.5496722",
"0.5475467",
"0.54720044",
"0.5455578",
"0.54499626",
"0.54152143",
"0.53... | 0.0 | -1 |
GET /bbhks GET /bbhks.json | def index
@bbhks = Bbhk.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 index\n @kbs = Kb.search(params[:q]).page(params[:page]).order(\"id desc\")\n\n respond_to do |format|\n format.html # index.html.... | [
"0.6529878",
"0.6384841",
"0.62493914",
"0.61285436",
"0.60566956",
"0.60449934",
"0.5923724",
"0.5897469",
"0.5897469",
"0.5850435",
"0.5835839",
"0.57870173",
"0.5773025",
"0.57696986",
"0.57627964",
"0.5758721",
"0.57558113",
"0.57492137",
"0.5688765",
"0.56869996",
"0.567... | 0.6896141 | 0 |
GET /bbhks/1 GET /bbhks/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 index\n @bbhks = Bbhk.all\n end",
"def index\n @kbs = Kb.search(params[:q]).page(params[:page]).order(\"id desc\")\n\n respond_to... | [
"0.6844717",
"0.66777617",
"0.64586234",
"0.6373156",
"0.62842",
"0.6134402",
"0.6102686",
"0.6085675",
"0.60681903",
"0.6062093",
"0.6049354",
"0.6040844",
"0.59891576",
"0.5899847",
"0.5887247",
"0.5885147",
"0.5879753",
"0.5864894",
"0.5861494",
"0.58447564",
"0.584181",
... | 0.0 | -1 |
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' }
format.json { render json: @bbhk.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @kb = Kb.new(params[:kb])\n\n respond_to do |format|\n if @kb.save\n format.html { redirect_to @kb, :notice => 'Kb was successfully created.' }\n format.json { render :json => @kb, :status => :created, :location => @kb }\n else\n format.html { render :action => \"n... | [
"0.65196216",
"0.6079189",
"0.60184276",
"0.5886781",
"0.5866635",
"0.5811435",
"0.5782131",
"0.57805413",
"0.5707289",
"0.56398",
"0.5636428",
"0.5621697",
"0.56122386",
"0.5609455",
"0.5607152",
"0.5572045",
"0.5535471",
"0.5514561",
"0.5513518",
"0.5503112",
"0.5487763",
... | 0.6793989 | 0 |
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: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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... | [
"0.64221394",
"0.6211864",
"0.62026685",
"0.6200728",
"0.6144037",
"0.61410624",
"0.6128951",
"0.6025062",
"0.59966755",
"0.59834015",
"0.5965815",
"0.59571236",
"0.59554297",
"0.59436226",
"0.59330934",
"0.5911566",
"0.58994687",
"0.58981985",
"0.5878253",
"0.5878253",
"0.58... | 0.65022373 | 0 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 { head :ok }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @hk.d... | [
"0.6856093",
"0.6775672",
"0.6773763",
"0.67693406",
"0.6764606",
"0.6667239",
"0.66556567",
"0.66301256",
"0.65291506",
"0.65151274",
"0.6487478",
"0.6487478",
"0.6487478",
"0.6487478",
"0.64871603",
"0.6428292",
"0.6417436",
"0.6410501",
"0.6404583",
"0.63994753",
"0.639735... | 0.72690946 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_bbhk
@bbhk = Bbhk.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def bbhk_params
params.require(:bbhk).permit(:hall_size, :bed1_size, :bed2_size, :kitchen_size, :floor, :sold_out, :status)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
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(dn: user_policy.dn)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_users_to_change_passwords?\n @policy.allow_users_to_change_password\n end",
"def apply_password_policy\n build_password_policy.apply\n end",
"def skip_password!\n # Securely remove all password fields, otherwise user cannot confirm.\n self.password = nil\n self.password_confirmat... | [
"0.63576",
"0.6284358",
"0.62140554",
"0.61868924",
"0.61498594",
"0.61363536",
"0.6079338",
"0.6014652",
"0.5957391",
"0.5901183",
"0.58850247",
"0.58391345",
"0.5820849",
"0.58182645",
"0.58035684",
"0.58035684",
"0.58035684",
"0.5801583",
"0.5789339",
"0.57699084",
"0.5749... | 0.7639294 | 0 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_required?\n @password_required\n end",
"def require_password?\n if self.new_record?\n APP_CONFIG[:auto_activate] or self.password\n else\n true and !self.password.nil?\n end\n end",
"def validate_password?\n active? && (password_hash.blank? || password.present?... | [
"0.65472996",
"0.65444314",
"0.6535785",
"0.65058935",
"0.65026397",
"0.6471411",
"0.64578056",
"0.6443475",
"0.64409345",
"0.64409345",
"0.6432411",
"0.6424905",
"0.6424799",
"0.6417333",
"0.6415642",
"0.6405205",
"0.6405205",
"0.6361693",
"0.6346202",
"0.6346202",
"0.632689... | 0.76257044 | 0 |
This method sets up the password expiration policy for local users | def password_expiration_set(handle:,
password_expiry_duration:,
password_history: 0,
password_notification_period: 15,
password_grace_period: 0)
mo = AaaUserPasswordExpiration.new(parent_mo_or_dn: "sys/user-ext")
args = {
:password_expiry_duration => password_expiry_duration.to_s,
:password_history => password_history.to_s,
:password_notification_period => password_notification_period.to_s,
:password_grace_period => password_grace_period.to_s
}
mo.set_prop_multiple(**args)
handle.set_mo(mo: mo)
return handle.query_dn(dn: mo.dn)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_password_policy\n build_password_policy.apply\n end",
"def need_change_password!\n return unless password_expiration_enabled?\n\n need_change_password\n save(validate: false)\n end",
"def need_change_password\n return unless password_expiration_enabled?\n\n self.pa... | [
"0.6864609",
"0.668734",
"0.6328767",
"0.6137945",
"0.6082789",
"0.59794456",
"0.5977116",
"0.5895528",
"0.5891783",
"0.5891783",
"0.5891783",
"0.5891783",
"0.58833766",
"0.58698803",
"0.5853244",
"0.5841299",
"0.5838842",
"0.58146673",
"0.58000684",
"0.57996625",
"0.5792369"... | 0.6358911 | 2 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expire_password_on_demand?\n expire_password_after.present? && expire_password_after == true\n end",
"def password_expires?\n @password_expires\n end",
"def check_password_expiration\n # check inactive mins\n if current_user && current_user.password_expires_at && current_user.pass... | [
"0.7371907",
"0.72259814",
"0.718002",
"0.7102107",
"0.7082474",
"0.70229137",
"0.68210095",
"0.67888993",
"0.67438114",
"0.6703612",
"0.6703612",
"0.669852",
"0.6686004",
"0.6649779",
"0.66445786",
"0.6641466",
"0.6601076",
"0.6600784",
"0.6540958",
"0.6496776",
"0.6492925",... | 0.7295262 | 1 |
This method will create a new local user and setup it's role. | def local_user_create(handle:, name:, pwd:, priv: "read-only")
user = _get_local_user(handle, name)
if !user.nil?
return local_user_modify(handle: handle, name: name, :priv => priv, :account_status => AaaUserConsts::ACCOUNT_STATUS_ACTIVE)
end
available_user_id = _get_free_user_id(handle)
new_user = AaaUser.new( parent_mo_or_dn: "sys/user-ext", id: available_user_id)
args = {:name => name,
:pwd => pwd,
:priv => priv,
:account_status => AaaUserConsts::ACCOUNT_STATUS_ACTIVE}
new_user.set_prop_multiple(**args)
handle.set_mo(mo: new_user)
#return new_user
return handle.query_dn(dn: new_user.dn)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_local\n uuid = @data[:id]\n\n log_event \"[I] Creating local user #{uuid}\"\n\n @entity = User.new(uuid: uuid)\n @entity.agent = Agent.named(@data.dig(:meta, :agent_name).to_s)\n\n apply_for_create\n\n @entity.save\n @entity\n end",
"def setup_user\n user = create(:user)\n ... | [
"0.7387777",
"0.72308457",
"0.7163344",
"0.7130941",
"0.7059115",
"0.7043294",
"0.7030763",
"0.6997465",
"0.6979949",
"0.6960953",
"0.69037014",
"0.6899519",
"0.68781",
"0.68759614",
"0.6812599",
"0.6790734",
"0.67841697",
"0.67789215",
"0.6777278",
"0.67709756",
"0.6769678",... | 0.7044467 | 5 |
This method will modify the user with the username specified | def local_user_modify(handle:, name:, **kwargs)
found_user = _get_local_user(handle, name)
if found_user.nil?
raise ImcOperationError.new("Modify Local User", "User doesn't exist")
end
found_user.set_prop_multiple(**kwargs)
handle.set_mo(mo: found_user)
return handle.query_dn(dn: found_user.dn)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_username(username)\n @username = username\n end",
"def edit_username(user, username)\n manager = UserManager.new\n if manager.user_exists?(username)\n return false\n else\n manager.remove( :username => user.username )\n user.username = username\n... | [
"0.78716147",
"0.7823836",
"0.7442999",
"0.74086004",
"0.72497815",
"0.72497815",
"0.72497815",
"0.7208261",
"0.7208261",
"0.7193359",
"0.7181561",
"0.71658754",
"0.7140313",
"0.70669776",
"0.70609844",
"0.705566",
"0.70283574",
"0.7007235",
"0.6992635",
"0.6992635",
"0.69876... | 0.7371988 | 4 |
This method checks if a user exists with attributes passed | def local_user_exists(handle: nil, **kwargs)
users = _get_local_users(handle)
users.each do |user|
if user.check_prop_match(**kwargs)
return true, user
end
end
return false, nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_exists?(username)\n users(username: username).present?\n end",
"def user_exists?\n \t\tself.errors.add(:name, \"does not exist!\") unless self.user_id.present?\n \tend",
"def user_exists?(filter)\n not(user_tuple(filter, false).nil?)\n end",
"def has_user?(name, options={})\n ... | [
"0.73523635",
"0.7290885",
"0.72592443",
"0.72361",
"0.723594",
"0.72062635",
"0.7183617",
"0.71822983",
"0.7174621",
"0.71717006",
"0.71655554",
"0.71623045",
"0.71515745",
"0.71074444",
"0.71017236",
"0.7095231",
"0.70929945",
"0.7080989",
"0.70613754",
"0.70435816",
"0.702... | 0.6942355 | 25 |
s=spicelist(b) c : spice set check(b,s,c) : return point(minus) myspicelist(s,c) hoge1(b,s) : return c, &puts point blendlist() & spicelist(b) | def read() #read each lines
a=[]
f=open("blendlist.txt")
f.each_line {|line|
a[a.length] = line.chomp} #add line to a's last,cutting enter
f.close
return a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_subset_extend_interp_spokes(shiftx, shifty, color, ibegin, iend, srep_index)\n\n iend.each_with_index do |p, i|\n#\tif p.size >= 4 and (p[3].is_a? Integer) and p[3] >= 0 and p[3] < 3 \n#\t @app.stroke $sreps[p[3]].color\n if srep_index == 0\n if $subset_index.include? i\n ... | [
"0.5867874",
"0.5625464",
"0.54316103",
"0.5350838",
"0.5312374",
"0.52832705",
"0.5278998",
"0.52604115",
"0.52431065",
"0.5236236",
"0.5231217",
"0.52173835",
"0.51902956",
"0.51677024",
"0.5162017",
"0.5160616",
"0.51587653",
"0.51474094",
"0.5146269",
"0.5130203",
"0.5113... | 0.0 | -1 |
Question 4 Using shift in the loop returns [1,3] Using pop in the loop returns [1,2]. Question 5 | def factors(number)
dividend = number
divisors = []
number.times do
divisors << number / dividend if number % dividend == 0
dividend -= 1
end
divisors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop()\n (@arr1.size-1).times { @arr2.push(@arr1.shift) }\n result = @arr1.shift\n @arr1, @arr2 = @arr2, @arr1\n result\n end",
"def pop\r\n @arr.shift\r\n end",
"def shift\n @arr.shift\n end",
"def pop\n while @q1.length > 1\n @q2.push(@q1.shift)\n end\n\n ... | [
"0.7117184",
"0.7054701",
"0.7001405",
"0.67946655",
"0.67830074",
"0.67653257",
"0.67512155",
"0.6745025",
"0.6728771",
"0.67045116",
"0.67045116",
"0.67045116",
"0.67045116",
"0.67045116",
"0.67045116",
"0.67045116",
"0.67045116",
"0.67045116",
"0.67045116",
"0.67045116",
"... | 0.0 | -1 |
GET /comments GET /comments.json def index | def index
@comments = @post.comments
@limitcomments = Comment.where(post_id: 1).limit(2).order("id DESC").reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @comments = @commentable.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n render json: @comments\n end",
"def index\n @comments = Comment.all\n\n respond_... | [
"0.83178943",
"0.82964265",
"0.829394",
"0.829394",
"0.829394",
"0.8202435",
"0.80578905",
"0.80145353",
"0.80028224",
"0.7984797",
"0.79781526",
"0.7868182",
"0.78367954",
"0.78183204",
"0.77816516",
"0.7734998",
"0.7731345",
"0.77272856",
"0.7708667",
"0.77036566",
"0.77036... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def load_article
@postsall = Post.all
#@post = Post.find(params[:post_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def comment_params
params.require(:like).permit(:user_id, :post_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
PATCH/PUT /answers/1 def update | def auto_complete
q = params[:term].gsub(/\s/, "").gsub(" ", "")
uri = Addressable::URI.parse("https://www.googleapis.com/books/v1/volumes?q=#{q}&country=JP&maxResults=40&orderBy=relevance")
begin
response = Net::HTTP.get_response(uri)
result = JSON.parse(response.body)
book_result = result["items"]
.select{|item| item.has_key?("volumeInfo") && item["volumeInfo"].has_key?("title")}
.take(40)
.map{|item|
{
title: item["volumeInfo"]["title"],
subtitle: item["volumeInfo"]["subtitle"],
authors: item["volumeInfo"]["authors"],
categories: item["volumeInfo"]["categories"],
google_books_id: item["id"],
info: item["volumeInfo"]["industryIdentifiers"]
}
}
@results = Book.auto_complete_map(book_result)
render json: @results.to_json
rescue => e
p e.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @answer = current_user.answers.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.json { head :no_content }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
... | [
"0.8243493",
"0.81722856",
"0.816276",
"0.816276",
"0.8112311",
"0.8106613",
"0.8101315",
"0.80886626",
"0.80577314",
"0.8039944",
"0.8014571",
"0.7978505",
"0.79637265",
"0.7962886",
"0.7960491",
"0.7936517",
"0.7936517",
"0.7936517",
"0.7919692",
"0.7904783",
"0.7896381",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. def set_answer | def save_title_query
@query = TitleQuery.new(user_id: current_user.try(:id), query: params[:term])
@query.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ask(question)\n ui.ask question\n end",
"def ask_question\n\n end",
"def set_answer\n\t\t#@answer = Survey.find(params[:id])\n\tend",
"def set_answer\n @answer = Answer.find(params[:id])\n @question = @answer.question\n end",
"def set_answer\n @answer = Discovery::Answer.find(param... | [
"0.630475",
"0.6207",
"0.6164153",
"0.6143247",
"0.61074156",
"0.610059",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.6087265",
"0.60... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def answer_params
params.require(:answer).permit(:user_id, :question_id, :content, :book_id, :title, :is_tweet, :is_anonymous)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
GET /logincms GET /logincms.json | def index
@logincms = Logincm.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @login = Login.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @login }\n end\n end",
"def getLogin( login_id)\n params = Hash.new\n params['login_id'] = login_id\n return doCurl(\"get\",\"/login\",params)\n end",
... | [
"0.62309784",
"0.62117326",
"0.6147455",
"0.6121151",
"0.6116952",
"0.6116952",
"0.61017126",
"0.6091954",
"0.60704756",
"0.5985689",
"0.59348506",
"0.5892269",
"0.58425117",
"0.58425117",
"0.58358234",
"0.5807124",
"0.58065164",
"0.5777034",
"0.5775717",
"0.57529545",
"0.574... | 0.6821947 | 0 |
GET /logincms/1 GET /logincms/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @logincms = Logincm.all\n end",
"def show\n @login = Login.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @login }\n end\n end",
"def auto_login\n render json: @user\n end",
"def login\n @users = Use... | [
"0.69324327",
"0.64393204",
"0.610745",
"0.61062604",
"0.6088195",
"0.6061601",
"0.6044134",
"0.6044134",
"0.6029762",
"0.5989709",
"0.59347856",
"0.5916991",
"0.5885574",
"0.5885574",
"0.5877869",
"0.58426505",
"0.5820806",
"0.5793826",
"0.57879686",
"0.5749836",
"0.5716764"... | 0.0 | -1 |
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 }
format.json { render json: @logincm.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logincm_params\n params.require(:logincm).permit(:content)\n end",
"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]... | [
"0.6122274",
"0.60951006",
"0.6030115",
"0.6030039",
"0.60276663",
"0.60276663",
"0.6020652",
"0.597549",
"0.5950285",
"0.5947875",
"0.5947875",
"0.5901616",
"0.5900529",
"0.5899142",
"0.58969116",
"0.58904505",
"0.58904505",
"0.5859339",
"0.5847378",
"0.58425814",
"0.5826458... | 0.62735856 | 0 |
PATCH/PUT /logincms/1 PATCH/PUT /logincms/1.json | def update
respond_to do |format|
if @logincm.update(logincm_params)
format.html { redirect_to @logincm, notice: 'Logincm was successfully updated.' }
format.json { render :show, status: :ok, location: @logincm }
else
format.html { render :edit }
format.json { render json: @logincm.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def update\n @login = Login.find(params[:id])\n\n respond_to do |format|\n if @login.update_attributes(params[:login])\n format.html { redirect_to @login, notice: 'Login alterado com su... | [
"0.6281074",
"0.6264895",
"0.61071366",
"0.60869557",
"0.6045298",
"0.6028609",
"0.6028609",
"0.6028609",
"0.5985509",
"0.59574085",
"0.59443176",
"0.59024346",
"0.58505386",
"0.58505046",
"0.5846989",
"0.5846014",
"0.5846014",
"0.5803889",
"0.5761116",
"0.57595867",
"0.57572... | 0.6159547 | 2 |
DELETE /logincms/1 DELETE /logincms/1.json | def destroy
@logincm.destroy
respond_to do |format|
format.html { redirect_to logincms_url, notice: 'Logincm was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteLogin( login_id)\n params = Hash.new\n params['login_id'] = login_id\n return doCurl(\"delete\",\"/login\",params)\n end",
"def destroy\n @cm = Cm.find(params[:id])\n @cm.destroy\n\n respond_to do |format|\n format.html { redirect_to cms_url }\n format.json { head :no_conte... | [
"0.6961133",
"0.6807306",
"0.67606527",
"0.671734",
"0.66927934",
"0.66713095",
"0.6598289",
"0.65765536",
"0.6546038",
"0.65314114",
"0.65314114",
"0.65314114",
"0.65314114",
"0.6528346",
"0.6521348",
"0.6506641",
"0.65030587",
"0.64994496",
"0.6493587",
"0.6491942",
"0.6472... | 0.6756537 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_logincm
@logincm = Logincm.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def logincm_params
params.require(:logincm).permit(:content)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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|... | [
"0.67220753",
"0.671936",
"0.6691476",
"0.6628015",
"0.6534748",
"0.6488349",
"0.64504176",
"0.6445887",
"0.62742025",
"0.6259485",
"0.6259485",
"0.6259485",
"0.6177886",
"0.6176701",
"0.61440873",
"0.61200315",
"0.61176187",
"0.6111644",
"0.61042196",
"0.6098044",
"0.6094731... | 0.7296233 | 0 |
GET /consultationcharges/new GET /consultationcharges/new.xml | def new
@consultationcharge = Consultationcharge.new
@doctormasters = Doctormaster.find(:all)
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @consultationcharge }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @consultation = Consultation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @consultation }\n end\n end",
"def new\n @pfs_consultation = PfsConsultation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.x... | [
"0.7425562",
"0.7412985",
"0.7143969",
"0.7136843",
"0.713356",
"0.70367885",
"0.70367885",
"0.70361596",
"0.7020366",
"0.7018939",
"0.70175475",
"0.6998301",
"0.69875675",
"0.6929025",
"0.6909028",
"0.6881998",
"0.6880217",
"0.68776387",
"0.68712234",
"0.6860995",
"0.6858003... | 0.7220086 | 2 |
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 => @consultationcharge, :status => :created, :location => @consultationcharge }
else
format.html { render :action => "new" }
format.xml { render :xml => @consultationcharge.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def charge(attrs = {})\n post :charges, {}, attrs.to_xml(:root => :charge)\n end",
"def create\n @consultation = Consultation.new(params[:consultation])\n\n respond_to do |format|\n if @consultation.save\n format.html { redirect_to(@consultation, :notice => t(\"flash.notices.model.consu... | [
"0.66658425",
"0.60315293",
"0.58918804",
"0.5879767",
"0.5838339",
"0.5794557",
"0.5782371",
"0.57703924",
"0.5766089",
"0.5759834",
"0.56913656",
"0.5675829",
"0.56500065",
"0.5647769",
"0.5589518",
"0.55893445",
"0.5588488",
"0.55737865",
"0.5572595",
"0.5501081",
"0.54945... | 0.6697496 | 0 |
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 :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @consultationcharge.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @pfs_consultation = PfsConsultation.find(params[:id])\n\n respond_to do |format|\n if @pfs_consultation.update_attributes(params[:pfs_consultation])\n format.html { redirect_to(@pfs_consultation, :notice => 'Pfs consultation was successfully updated.') }\n format.xml { head :... | [
"0.6245957",
"0.62359864",
"0.6153786",
"0.59262246",
"0.591418",
"0.58875775",
"0.5866888",
"0.5866888",
"0.58563316",
"0.58557457",
"0.57737565",
"0.5761195",
"0.573807",
"0.5726965",
"0.57141674",
"0.56835145",
"0.56654924",
"0.56565315",
"0.5629517",
"0.5614929",
"0.56103... | 0.6577601 | 0 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n @consultation = Consultation.find(params[:id])\n @consultation.destroy\n\n respond_to do |format|\n format.html { redirect_to(cons... | [
"0.6980386",
"0.6904357",
"0.68982357",
"0.6822708",
"0.6690675",
"0.66335124",
"0.66335124",
"0.6594275",
"0.6512669",
"0.6512026",
"0.64318705",
"0.6375002",
"0.63468033",
"0.6345942",
"0.634269",
"0.633389",
"0.63335264",
"0.63291353",
"0.63254994",
"0.62756485",
"0.626538... | 0.7276909 | 0 |
my_hash uses the literal constructor to create a hash that contains key/value pairs use the literal constructor to set the variable, my_hash, equal to a hash with key/value pairs of your choice. | def my_hash
my_name = {"name" => "Loren"}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize hash\n @hash = hash\n end",
"def set_hash(hash, hash_type = 'SHA256')\n @hash = hash\n @hash_type = hash_type\n end",
"def initialize\n @h = new_hash\n end",
"def _hash=(_hash)\n if !_hash.nil? && _hash.to_s.length > 40\n fail ArgumentError, 'invalid value for ... | [
"0.68278867",
"0.6704111",
"0.6697266",
"0.64653933",
"0.6379613",
"0.63791376",
"0.6326546",
"0.63047826",
"0.62858886",
"0.6254126",
"0.6254126",
"0.6243375",
"0.62301403",
"0.622225",
"0.62056303",
"0.61594737",
"0.6151692",
"0.6151692",
"0.61068255",
"0.60926086",
"0.6085... | 0.65267617 | 3 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shipping_manifest\n the_manifest = {\"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"oil paintings\" => 3}\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 shippi... | [
"0.78442127",
"0.7546124",
"0.7546124",
"0.7457613",
"0.6570351",
"0.6488464",
"0.64694744",
"0.64540035",
"0.6430159",
"0.6420317",
"0.6230764",
"0.62144035",
"0.61396486",
"0.5907613",
"0.5788022",
"0.5510948",
"0.542372",
"0.5393345",
"0.5367835",
"0.5365915",
"0.5342259",... | 0.77538717 | 1 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieval\n shipping_manifest = { \"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"oil paintings\" => 3 }\n\n shipping_manifest[\"oil paintings\"]\nend",
"def retrieval\n shipping_manifest['oil paintings']\nend",
"def retrieval\n shipping_manifest = {\n \"whale bone corsets\" =... | [
"0.81601053",
"0.8157861",
"0.8017714",
"0.7990587",
"0.79893243",
"0.724268",
"0.724268",
"0.7154802",
"0.71107197",
"0.68546134",
"0.5993058",
"0.59607154",
"0.59378505",
"0.58808833",
"0.5747803",
"0.56566864",
"0.5654441",
"0.56174874",
"0.5582411",
"0.55625093",
"0.55487... | 0.81682825 | 0 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 adding\n shipping_manifest = {\"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"oil paintings\" => 3}\n ... | [
"0.7171773",
"0.716788",
"0.69416595",
"0.691989",
"0.6856666",
"0.67448306",
"0.67448306",
"0.65470046",
"0.5821235",
"0.57083327",
"0.5674804",
"0.5561942",
"0.55503345",
"0.5329685",
"0.5328865",
"0.5328451",
"0.5315217",
"0.5299678",
"0.5147505",
"0.51407367",
"0.51326483... | 0.72442776 | 0 |
This is used when an user register in the application, in order to confirm his registration | def confirmation_email(user)
# email header info MUST be added here
@recipients = user.email
@from = "#{Site.current.email}"
@subject = "SIR Information:: Welcome to SIR"
# email body substitutions go here
@body["name"] = user.login
@body["hash"] = user.activation_code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def registration_confirmation\n\t\tuser = User.new\n\t\tuser.generate_token(:email_confirmation_token)\n\t\tUserMailer.registration_confirmation(user)\n end",
"def confirm_registration\n @user = User.find_by_confirmation_key(params[:id])\n @user or flash.now[:error] = 'Sorry, but there is no such conf... | [
"0.7376688",
"0.73676324",
"0.72646177",
"0.72108877",
"0.7183842",
"0.7164327",
"0.71558166",
"0.71549356",
"0.71135366",
"0.7068447",
"0.6993467",
"0.6931157",
"0.69210505",
"0.6916072",
"0.690486",
"0.68920255",
"0.68788964",
"0.68666476",
"0.683368",
"0.6833013",
"0.68080... | 0.0 | -1 |
This method compose the email used when a user is deleted from the system | def byebye (user, sent_at = Time.now)
@subject = "SIR Information::User Deleted"
@from = "#{Site.current.email}"
@recipients = user.email
@sent_on = sent_at
@body = "Your user in SIR has been deleted. Please contact the administrator for more information"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_deleted\n UserMailer.user_deleted\n end",
"def after_destroy\n\n UserMailer.deliver_deleted_message(user)\n\n end",
"def account_deleted(user)\n setup_email(user)\n @subject += head_encode(\"%s's account was deleted\" / user.login)\n @body[:user] = user\n end",
"def c... | [
"0.76268005",
"0.7436916",
"0.7251764",
"0.71380574",
"0.7031096",
"0.68742925",
"0.6869542",
"0.68219435",
"0.67850935",
"0.6746352",
"0.6746352",
"0.6690385",
"0.66850585",
"0.6681179",
"0.6678106",
"0.66530687",
"0.65828204",
"0.6572052",
"0.65576535",
"0.6510099",
"0.6500... | 0.6995199 | 5 |
This is used when a user ask for his password. | def forgot_password(user)
@recipients = user.email
@from = "#{Site.current.email}"
@subject = 'Request to change your password'
@body ["name"] = user.login
@body["url"] = "http://#{Site.current.domain}/reset_password/#{user.reset_password_code}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prompt_for_user_password!\n e.execute_as_user('')\n end",
"def ask_for_password(prompt)\n ui.ask_for_password prompt\n end",
"def password_request\n password_input = @prompt.mask(\"Please enter your password, or type quit.\")\n if password_input == @user.password\n puts \"Success... | [
"0.8067323",
"0.8061341",
"0.79349613",
"0.7866177",
"0.7862022",
"0.7825949",
"0.7778268",
"0.7778268",
"0.77772963",
"0.7756054",
"0.7756054",
"0.7756054",
"0.7756054",
"0.7756054",
"0.7756054",
"0.7753881",
"0.7743778",
"0.7699569",
"0.7623561",
"0.7586095",
"0.756135",
... | 0.0 | -1 |
this methd is used when a user have asked for his old password, and then he reset it. | def reset_password(user)
@recipients = user.email
@from = "#{Site.current.email}"
@body ["name"] = user.login
@subject = 'Your password has been reset'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def old_password\n nil\n end",
"def reset_password!\n reset_password\n save_without_session_maintenance(validate: false)\n end",
"def reset_password!\n reset_password\n save_without_session_maintenance(false)\n end",
"def reset_password!\n @ses... | [
"0.78614545",
"0.77321494",
"0.7715256",
"0.76039815",
"0.7531487",
"0.7503903",
"0.7493811",
"0.74758923",
"0.7464055",
"0.746393",
"0.74554664",
"0.7444039",
"0.74331623",
"0.7411153",
"0.73947316",
"0.7384288",
"0.7376962",
"0.7337486",
"0.7308829",
"0.73014045",
"0.729741... | 0.0 | -1 |
Make and extra method for complete ride | def complete
@ride = Ride.find(params[:ride_id])
@ride.completed = true
@ride.save
UserMailer.complete_ride(@ride).deliver_later
redirect_to user_path(current_user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_ride\n if low_tickets && too_short\n \"Sorry. You do not have enough tickets to ride the #{self.attraction.name}. \" + \"You are not tall enough to ride the #{self.attraction.name}.\"\n elsif low_tickets\n \"Sorry. You do not have enough tickets to ride the #{self.attraction.name}.\"\n ... | [
"0.58599484",
"0.57906806",
"0.578735",
"0.5757679",
"0.5753981",
"0.5751848",
"0.574599",
"0.57423574",
"0.5697406",
"0.56748",
"0.5664264",
"0.56622356",
"0.55995595",
"0.5596619",
"0.5592215",
"0.5572896",
"0.5555092",
"0.5527187",
"0.5493985",
"0.548761",
"0.5462371",
"... | 0.0 | -1 |
number The Integer that will be cubed Examples cube(5) => '125' Returns the cubed Integer. | def square(number)
return number*number*number
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cube(number)\n number.to_i\n return number**3\nend",
"def cube(number)\n return number ** 3\nend",
"def cube(number)\n return number * number * number\nend",
"def cube(number)\n return number * number * number\nend",
"def cube(number)\n return number**3\nend",
"def cube(number)\n ... | [
"0.8213973",
"0.777724",
"0.7711808",
"0.7711808",
"0.7662522",
"0.7644898",
"0.76436865",
"0.75690955",
"0.75690955",
"0.7566075",
"0.7502475",
"0.74812263",
"0.74648935",
"0.7462398",
"0.7462398",
"0.74083155",
"0.7388654",
"0.7325691",
"0.7306227",
"0.73051494",
"0.7191174... | 0.5364962 | 94 |
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 (lDepUserChoice.ResolvedTesters.size == lDepUserChoice.DepDesc.Testers.size)
# Complete
lIconName = "#{@IconsDir}/ValidOK.png"
else
# Incomplete
lIconName = "#{@IconsDir}/ValidKO.png"
end
elsif (lDepUserChoice.Ignore)
lIconName = "#{@IconsDir}/Ignore.png"
else
# Get the icon of the selected Installer
lInstallerName = lDepUserChoice.DepDesc.Installers[lDepUserChoice.IdxInstaller][0]
# TODO: Accept more data formats
lInstallerIconName = "#{@Installer.RDILibDir}/Plugins/Installers/Icons/#{lInstallerName}.png"
if (File.exists?(lInstallerIconName))
lIconName = lInstallerIconName
end
end
lIdxImage = @NBImageListManager.getImageIndex(lIconName) do
lIcon, lError = getBitmapFromURL(lIconName)
if (lIcon == nil)
lIcon, lError = getBitmapFromURL("#{@IconsDir}/Dependency.png")
end
next lIcon
end
@NBDeps.set_page_image(lIdx, lIdxImage)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refreshUI; @apPanel.redrawwin; @entryPanel.redrawwin; @entryListBox.refresh; @apListBox.refresh end",
"def _draw_panel\n @apotomo_emit_raw_view = true\n render :view => param(:panel)\n end",
"def refresh!; end",
"def refresh; end",
"def refresh!\n refresh\n @window.refresh\n end",
"def ... | [
"0.5962467",
"0.59367937",
"0.5551284",
"0.552696",
"0.54813856",
"0.5412496",
"0.5412432",
"0.53638077",
"0.53235126",
"0.53016245",
"0.52987516",
"0.5287404",
"0.5279883",
"0.5279396",
"0.52771014",
"0.5269382",
"0.5237463",
"0.5237463",
"0.5221807",
"0.5219583",
"0.5207147... | 0.61301386 | 0 |
def merge(left, right) merged = [] until left.empty? || right.empty? case left.first.length right.first.length when 1 merged << left.first when 0 merged << left.first when 1 merged << right.first end end merged.concat(left) merged.concat(right) end def merge_sort(arr) return arr if arr.length < 2 midpoint = arr.length / 2 left = arr.take(midpoint) right = arr.drop(midpoint) sorted_left = merge_sort(left) sorted_right = merge_sort(right) merge(sorted_left, sorted_right) end | def dominant_octopus(arr)
sorted = merge_sort(arr)
arr[-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mergeSort(arr, left, right)\n mid = left + ((right - left) / 2)\n if left >= right\n return arr[left..right]\n end\n left_arr = mergeSort(arr, left, mid)\n right_arr = mergeSort(arr, mid + 1, right)\n #puts \"arrays to be merged = #{left_arr} with #{right_ar... | [
"0.90674186",
"0.90447277",
"0.8975917",
"0.8961295",
"0.89249915",
"0.8922382",
"0.8916301",
"0.8897854",
"0.88973314",
"0.8884182",
"0.88831365",
"0.88764215",
"0.88762003",
"0.88667613",
"0.8866313",
"0.88596076",
"0.8856798",
"0.8856418",
"0.8829725",
"0.8820784",
"0.8814... | 0.0 | -1 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ref_number\n batch = check.batch\n facility_name = facility.name.upcase\n if (facility_name == 'AHN' || facility_name == 'SUBURBAN HEALTH' ||\n facility_name == 'UWL' || facility_name == 'ANTHEM')\n file_number = batch.file_name.split('_')[0][3..-1] rescue \"0\"\n date = batch.date.... | [
"0.6702216",
"0.6660935",
"0.6379788",
"0.62252164",
"0.60224944",
"0.5978005",
"0.5799169",
"0.5764095",
"0.5642951",
"0.5611011",
"0.55981743",
"0.5590689",
"0.55649954",
"0.5564428",
"0.55217636",
"0.55108225",
"0.548926",
"0.5482215",
"0.54808813",
"0.54787314",
"0.546298... | 0.671612 | 0 |
Never trust parameters from the scary internet, only allow the white list through. | def user_params
params.require(:user).permit(:email, :first_name, :last_name, :sms_number, :time_zone, :api_endpoint, :email_notification_frequency, :sms_notification_frequency, :email_notification_hour, :sms_notification_hour, :password_confirmation, :password)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Define your play method below | def play(board)
until over?(board) == true
turn(board)
break if won?(board) != false
end
puts "Congratulations #{winner(board)}!" if won?(board) != false
puts "Cats Game!" if draw?(board) == true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play\n \n end",
"def play; end",
"def play \n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n\tend",
"def play\n #calls to all the methods that produce game!\n end",
"def play\n self\n end",
"def get_play(... | [
"0.91277385",
"0.9031555",
"0.90065134",
"0.900332",
"0.900332",
"0.900332",
"0.900332",
"0.8978301",
"0.88647234",
"0.8184945",
"0.80578035",
"0.79240173",
"0.78456163",
"0.7765175",
"0.77345335",
"0.76989305",
"0.7611273",
"0.7611273",
"0.7528091",
"0.74453044",
"0.74384725... | 0.0 | -1 |
FIXME [specs]: it looks like the error is occuring because of the lack of the deadlines, not because of the year becoming nil (at least, not anymore; but I can try adding the binding.pry back in to see what's wrong). try starting from a fresh test database and creating the years and then the quarters. we're getting stopped by the all_fields_present? before filter, but this renders 'new', which renders the view without calling the get_years_form_hash before filter. so we'll instead add a method to the academic_year model that grabs the same hash that get_years_form_hash was getting for us. | def index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @acedemic_year = AcedemicYear.new(acedemic_year_params)\n acedemic_year_last = AcedemicYear.try(:last)\n respond_to do |format|\n if @acedemic_year.save\n if @acedemic_year.present?\n if acedemic_year_last.present?\n list_grades = acedemic_year_last.grades.map{... | [
"0.6009845",
"0.5981427",
"0.5612071",
"0.56035954",
"0.5588575",
"0.55849165",
"0.55576694",
"0.5552235",
"0.55222046",
"0.55044025",
"0.5484386",
"0.5467337",
"0.5418024",
"0.53917205",
"0.5362859",
"0.53558177",
"0.5354223",
"0.53499496",
"0.53434473",
"0.5319332",
"0.5310... | 0.0 | -1 |
GET /informacoes GET /informacoes.json | def index
@informacoes = Informacao.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @acoes = Acao.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @acoes }\n end\n 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 ... | [
"0.6734839",
"0.67044973",
"0.6600473",
"0.65711117",
"0.6565081",
"0.65589184",
"0.65585595",
"0.6537309",
"0.65300554",
"0.6513718",
"0.6507799",
"0.6490077",
"0.64828587",
"0.64579546",
"0.6457692",
"0.6450913",
"0.640981",
"0.6407589",
"0.63979065",
"0.63931197",
"0.63851... | 0.7033731 | 0 |
GET /informacoes/1 GET /informacoes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @indicativo = Indicativo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicativo }\n end\n end",
"def show\n @indicacao = Indicacao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.701355",
"0.6954598",
"0.6938939",
"0.6932047",
"0.68274456",
"0.68122447",
"0.6790883",
"0.6786332",
"0.6780297",
"0.6771523",
"0.67550176",
"0.674346",
"0.67333555",
"0.67333555",
"0.67173594",
"0.67131746",
"0.6711438",
"0.6710891",
"0.67026955",
"0.6690215",
"0.6680572... | 0.0 | -1 |
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
format.html { render action: 'new' }
format.json { render json: @informacao.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @oferta_academica = OfertaAcademica.new(params[:oferta_academica])\n\n if @oferta_academica.save\n render json: @oferta_academica, status: :created, location: @oferta_academica\n else\n render json: @oferta_academica.errors, status: :unprocessable_entity\n end\n end",
"def cre... | [
"0.62956244",
"0.6102647",
"0.60587376",
"0.60551256",
"0.5969321",
"0.59630847",
"0.59245616",
"0.5913291",
"0.59069043",
"0.58761394",
"0.587593",
"0.5864844",
"0.58629566",
"0.58441293",
"0.58415395",
"0.5834704",
"0.5833787",
"0.5833706",
"0.5833143",
"0.5828265",
"0.5828... | 0.61918765 | 1 |
PATCH/PUT /informacoes/1 PATCH/PUT /informacoes/1.json | def update
respond_to do |format|
if @informacao.update(informacao_params)
format.html { redirect_to @informacao, notice: 'Informacao was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @informacao.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :a... | [
"0.65530336",
"0.64548326",
"0.6431989",
"0.64108175",
"0.63808995",
"0.6363888",
"0.6317398",
"0.6305271",
"0.62981606",
"0.62940466",
"0.628917",
"0.6281836",
"0.6280173",
"0.6278274",
"0.62768215",
"0.6264136",
"0.6253898",
"0.6251042",
"0.6234598",
"0.6232322",
"0.6231642... | 0.64500946 | 2 |
DELETE /informacoes/1 DELETE /informacoes/1.json | def destroy
@informacao.destroy
respond_to do |format|
format.html { redirect_to informacoes_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @indicacao = Indicacao.find(params[:id])\n @indicacao.destroy\n\n respond_to do |format|\n format.html { redirect_to indicacoes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :... | [
"0.71005356",
"0.7096328",
"0.70790756",
"0.70409703",
"0.7025177",
"0.6982031",
"0.695777",
"0.6938149",
"0.6936932",
"0.69367534",
"0.69202936",
"0.6895812",
"0.68925494",
"0.68925494",
"0.6887302",
"0.68849933",
"0.6875819",
"0.68735415",
"0.68686163",
"0.6864227",
"0.6857... | 0.7091066 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_informacao
@informacao = Informacao.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def informacao_params
params[:informacao]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Reponds with a deflection and cycles through two responses | def respond(savedIndex)
@context.printName
if @context.is_a? HappyChatbot
if @happy_deflection == 0
puts "I'd love to answer that for you, but what do you think about that?"
@happy_deflection += 1
elsif @happy_deflection == 1
puts "What was that?"
@happy_deflection = 0
end
elsif @context.is_a? DepressedChatbot
if @depressed_deflection == 0
puts "It hurts me to answer a question you already know the answer to."
@depressed_deflection += 1
elsif @depressed_deflection == 1
puts "Why ask me, man? I don't know the answer, but I can bet that you do though."
@depressed_deflection = 0
end
elsif @context.is_a? AngryChatbot
if @angry_deflection == 0
puts "I don't know, why don't you tell me!"
@angry_deflection += 1
elsif @angry_deflection == 1
puts "I bet you know the answer to that yourself, don't you?"
@angry_deflection = 0
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dispatch_responders\n self.full_response, self.responder_ids = try_responding_in_full\n end",
"def parse_response(body)\n # Handling first response\n if INITIAL_FEELINGS.include? body\n @answers.push(body)\n create_response(create_second_text_message(body))\n # ... | [
"0.6026438",
"0.5841394",
"0.55439067",
"0.5446502",
"0.542719",
"0.5337887",
"0.5318762",
"0.5269692",
"0.52479583",
"0.52070737",
"0.51787245",
"0.5172349",
"0.5171549",
"0.5166503",
"0.5166503",
"0.5166503",
"0.5166503",
"0.5166503",
"0.5166503",
"0.5166503",
"0.5166503",
... | 0.0 | -1 |
GET /links/1 GET /links/1.json | def show
@link = Link.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @link }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n render json: @links\n end",
"def index\n links = all_links\n render json: { success: true, links: links }\n end",
"def index\n @links = Link.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @links }\n end\n end",
"def sho... | [
"0.7350112",
"0.7120274",
"0.7025738",
"0.69635993",
"0.6938119",
"0.6838034",
"0.6833723",
"0.6815706",
"0.68135786",
"0.6781963",
"0.6781963",
"0.6624377",
"0.65752435",
"0.6487915",
"0.6386929",
"0.6386929",
"0.6386929",
"0.6386929",
"0.6386929",
"0.6386929",
"0.6386929",
... | 0.6990482 | 3 |
GET /links/new GET /links/new.json | def new
@link = Link.new
@links_a=ManRsc.all
@links_b=@links_a
respond_to do |format|
format.html # new.html.erb
format.json { render json: @link }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @link }\n end\n end",
"def new\n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @link }\n end\n end",
"d... | [
"0.7882237",
"0.7882237",
"0.7882237",
"0.7882237",
"0.7882237",
"0.7807135",
"0.7548326",
"0.7494255",
"0.7478307",
"0.73248",
"0.71945024",
"0.714992",
"0.7140056",
"0.7139754",
"0.7139754",
"0.70566434",
"0.7049113",
"0.70003074",
"0.6975316",
"0.6975316",
"0.6975316",
"... | 0.647648 | 70 |
POST /links POST /links.json | def create
@link = Link.new(params[:link])
puts "////////////////////////////"
puts params
respond_to do |format|
if @link.save
format.html { redirect_to links_url, notice: t('links.create.notice') }
format.json { render json: @link, status: :created, location: @link }
else
@links_a=ManRsc.all
@links_b=linksb(params[:link][:link_a])
format.html { render action: "new" }
format.json { render json: @link.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n if @link.save\n render json: @link, status: :created, location: @link\n else\n render json: @link.errors, status: :unprocessable_entity\n end\n end",
"def test_should_create_link_via_API_JSON\r\n get \"/logout\"\r\n post \"/links.json\", :api_key => 'testapikey',\r\n ... | [
"0.7279239",
"0.7042173",
"0.6892667",
"0.6849184",
"0.67824477",
"0.67146206",
"0.6708206",
"0.66861737",
"0.66628766",
"0.66427463",
"0.66249496",
"0.65540344",
"0.6506658",
"0.64941686",
"0.6478123",
"0.6459337",
"0.64366543",
"0.64365256",
"0.6423571",
"0.64210635",
"0.64... | 0.6231388 | 31 |
DELETE /links/1 DELETE /links/1.json | def destroy
@link = Link.find(params[:id])
@link.destroy
respond_to do |format|
format.html { redirect_to links_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @link = Link.find(params[:id])\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format.... | [
"0.75310004",
"0.74690264",
"0.73705393",
"0.73705393",
"0.73637277",
"0.7292658",
"0.7263792",
"0.7260787",
"0.72489226",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.723125",
"0.72103757",
"0.72103304",
"... | 0.74529105 | 2 |
GET /categories GET /categories.json | def index
parametersarray = Array.new
params[:pubIds].nil? ? parametersarray : params[:pubIds].each {|p| parametersarray << p}
parametersarray.empty? ? @categories = Category.all : @categories= self.getPublicationCategories(parametersarray)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend",
"def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter:... | [
"0.83888507",
"0.8327856",
"0.83211476",
"0.78072983",
"0.7742051",
"0.75669324",
"0.75111455",
"0.74151826",
"0.7386452",
"0.7369945",
"0.7369187",
"0.73691803",
"0.73691803",
"0.73457074",
"0.73304063",
"0.7316772",
"0.72851175",
"0.72663945",
"0.72275496",
"0.7220998",
"0.... | 0.0 | -1 |
GET /categories/1 GET /categories/1.json | def show; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end",
"def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end",
"def GetCategory id\n\n ... | [
"0.7877691",
"0.7865133",
"0.78486437",
"0.78422695",
"0.7414923",
"0.74083245",
"0.73075056",
"0.7306919",
"0.7306919",
"0.7282217",
"0.7235693",
"0.7186931",
"0.7158298",
"0.7133119",
"0.7122198",
"0.70659566",
"0.70442134",
"0.7036961",
"0.70349413",
"0.70324004",
"0.70126... | 0.0 | -1 |
POST /categories POST /categories.json | def create
@category = Category.new(category_params)
respond_to do |format|
if @category.save
format.html { redirect_to '/publications/new', notice: 'Category was successfully created.' }
format.json { render :show, status: :created, location: @category }
else
format.html { render :new }
format.json { render json: @category.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n json_create(category_params, Category)\n end",
"def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATE... | [
"0.7738549",
"0.74339235",
"0.72349083",
"0.71634054",
"0.7124031",
"0.70645165",
"0.705568",
"0.695861",
"0.6956783",
"0.6903891",
"0.6838659",
"0.6821712",
"0.68190134",
"0.6807838",
"0.678525",
"0.66138625",
"0.6566919",
"0.65661913",
"0.65567696",
"0.6523676",
"0.65186286... | 0.0 | -1 |
PATCH/PUT /categories/1 PATCH/PUT /categories/1.json | def update
respond_to do |format|
if @category.update(category_params)
format.html { redirect_to @category, notice: 'Category was successfully updated.' }
format.json { render :show, status: :ok, location: @category }
else
format.html { render :edit }
format.json { render json: @category.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n json_update(category,category_params, Category)\n end",
"def update_categories(categories, options = {} )\n options.merge!(:docid => self.doci... | [
"0.7692541",
"0.76002717",
"0.72122926",
"0.69430083",
"0.69147646",
"0.68174535",
"0.6781423",
"0.6712822",
"0.66981524",
"0.66931385",
"0.66563374",
"0.66518235",
"0.6651313",
"0.66455007",
"0.6606881",
"0.65994096",
"0.6570957",
"0.6570957",
"0.6554447",
"0.65348464",
"0.6... | 0.6298676 | 68 |
DELETE /categories/1 DELETE /categories/1.json | def destroy
@category.destroy
respond_to do |format|
format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @category.destroy\n render json: @category, status: :ok\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |f... | [
"0.78272814",
"0.77353686",
"0.76392984",
"0.7488916",
"0.74731207",
"0.74233276",
"0.7399541",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7378597",
"0.7378597"... | 0.708277 | 70 |
Use callbacks to share common setup or constraints between actions. | def set_category
@category = Category.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def category_params
params.require(:category).permit(:name, :layer_id, :description, :infolink)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
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 == ( (ERV / P) ^ (1 / n) ) 1 | 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_value.to_d) ** (1 / years.to_d)) * -1
else
((final_value.to_d / initial_value.to_d) ** (1 / years.to_d)) - 1
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mortgage_calc principle, annual_interest, years\n n = years * 12\n r = (annual_interest / 100)/ 12 #since this is usually expressed as a percentage\n return (principle * r * (1 + r)**n / ((1 + r)**n - 1)).round(2)\nend",
"def total_amount_owed(principal, interest_rate_percentage, number_of_years)\n annua... | [
"0.71803",
"0.7060131",
"0.7031164",
"0.69293207",
"0.69113183",
"0.6909753",
"0.67350924",
"0.6611021",
"0.6590617",
"0.6555558",
"0.6550064",
"0.65337557",
"0.6530538",
"0.64723784",
"0.6447123",
"0.64417917",
"0.6412424",
"0.6351784",
"0.63419807",
"0.6322064",
"0.6322064"... | 0.7825729 | 0 |
GET /consultants GET /consultants.json | def index
@query_params = {}
build_query_params(params)
build_query_consultant_params
@conditions = []
@conditions << Consultant.arel_table[:name].matches("%#{@query_params[:name]}%") if @query_params[:name]
if @conditions.length > 0
conditions = @conditions[0]
@conditions.each_with_index do |item, index|
conditions = conditions.or(item) if index > 0
end
@conditions = conditions
end
respond_to do |format|
format.html { set_consultants_grid(@conditions) }
format.json { render json: Consultant.where(@conditions) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @consultant = Consultant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consultant }\n end\n end",
"def show\n @consulta = Consulta.find(params[:id])\n\n render json: @consulta\n end",
"def show\n @consultum = Co... | [
"0.75846744",
"0.7204897",
"0.70457065",
"0.6866017",
"0.67175376",
"0.67175376",
"0.6444148",
"0.6442286",
"0.6309417",
"0.6304749",
"0.6271234",
"0.6249053",
"0.62414575",
"0.6240441",
"0.62339216",
"0.6203447",
"0.6193156",
"0.6191092",
"0.61681986",
"0.61602193",
"0.61529... | 0.0 | -1 |
GET /consultants/1 GET /consultants/1.json | def show
@tabs = TABS
@current_tab = params[:tab]
@current_tab ||= TABS.first.to_s
@current_tab = @current_tab.to_sym
if @current_tab == :products
@products_grid = initialize_grid(Product.where(consultant_id: @consultant.id))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @consultant = Consultant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consultant }\n end\n end",
"def show\n @consulta = Consulta.find(params[:id])\n\n render json: @consulta\n end",
"def show\n @consultum = Co... | [
"0.77284175",
"0.73945004",
"0.73266983",
"0.697947",
"0.68124306",
"0.6610418",
"0.6610418",
"0.6554576",
"0.6535854",
"0.64771265",
"0.6434937",
"0.636616",
"0.63231885",
"0.6313312",
"0.62996775",
"0.62882704",
"0.6246237",
"0.6245923",
"0.6240435",
"0.62399286",
"0.619741... | 0.0 | -1 |
POST /consultants POST /consultants.json | def create
@consultant = Consultant.new(consultant_params.except(:department_attributes))
@consultant.department_id = consultant_params[:department_attributes][:id]
respond_to do |format|
if @consultant.save
set_consultants_grid
format.html { redirect_to @consultant, notice: t('activerecord.success.messages.created', model: Consultant.model_name.human) }
format.js
else
format.html { render :new }
format.js { render :new }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @consulta = Consulta.new(params[:consulta])\n\n if @consulta.save\n render json: @consulta, status: :created, location: @consulta\n else\n render json: @consulta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @consultation = current_user.consultations.new... | [
"0.7297487",
"0.7130123",
"0.6880817",
"0.6829281",
"0.679948",
"0.67819154",
"0.67055196",
"0.66422904",
"0.6362503",
"0.6276895",
"0.6231227",
"0.6210812",
"0.61969227",
"0.6196808",
"0.6190428",
"0.6160402",
"0.60289246",
"0.6023749",
"0.5976119",
"0.59737074",
"0.5923343"... | 0.6256312 | 10 |
PATCH/PUT /consultants/1 PATCH/PUT /consultants/1.json | def update
respond_to do |format|
@consultant.department_id = consultant_params[:department_attributes][:id]
if @consultant.update(consultant_params.except(:department_attributes))
set_consultants_grid
format.html { redirect_to @consultant, notice: t('activerecord.success.messages.updated', model: Consultant.model_name.human) }
format.js
else
format.html { render :edit }
format.js { render :edit }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @consulta = Consulta.find(params[:id])\n\n if @consulta.update(params[:consulta])\n head :no_content\n else\n render json: @consulta.errors, status: :unprocessable_entity\n end\n end",
"def update\n @consultum = Consultum.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.68250626",
"0.67603624",
"0.6703207",
"0.65662676",
"0.6527295",
"0.6520575",
"0.65140396",
"0.6512651",
"0.6466661",
"0.64252913",
"0.63861287",
"0.63631815",
"0.63631815",
"0.6239034",
"0.6235277",
"0.61142397",
"0.6109616",
"0.6091964",
"0.6091964",
"0.6091658",
"0.6079... | 0.6086605 | 20 |
DELETE /consultants/1 DELETE /consultants/1.json | def destroy
@consultant.destroy
respond_to do |format|
set_consultants_grid
format.html { redirect_to consultants_url, notice: t('activerecord.success.messages.destroyed', model: Consultant.model_name.human) }
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @consultum = Consultum.find(params[:id])\n @consultum.destroy\n\n respond_to do |format|\n format.html { redirect_to consulta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @consult.destroy\n respond_to do |format|\n format.html { redirect_to... | [
"0.7340677",
"0.72465384",
"0.72465384",
"0.7235835",
"0.7078425",
"0.70709074",
"0.7062798",
"0.70406264",
"0.7026597",
"0.70027065",
"0.6966685",
"0.6952975",
"0.6922758",
"0.68865496",
"0.68865496",
"0.6855391",
"0.6803215",
"0.6789495",
"0.67832017",
"0.6754852",
"0.67259... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_consultant
@consultant = Consultant.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def consultant_params
params.require(:consultant).permit(
:name,
:department_id,
:department,
:short_name,
:institution_type,
:capital,
:person_in_charge_name,
:is_qualified_3rd_party_institution,
:company_address,
:department_attributes => [
:name,
:id
]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Loading in the whole sections association could be expensive if there were a lot of records, but I'm not expecting that to be an issue in this case. If it is, we can address it later. But think about it if I make a general form object based on this one. | def initialize(gym = nil)
@gym = gym || Gym.new
@sections = @gym.sections.to_a
if @sections.empty?
@sections << Section.new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _section_fields\n {\n 'article' => ['r:Title', 'o:Author', 'o:DOI'],\n 'journal' => ['r:Title', 'o:ISSN', 'r:Volume', 'o:Issue', 'r:Year', 'r:Pages'],\n 'host' => ['o:Title', 'o:ISSN or ISBN', 'o:Volume', 'o:Issue', 'r:Year', 'o:Pages'],\n 'auto-cancel' => ['o:Automatic cancellation... | [
"0.63628656",
"0.6341061",
"0.6259934",
"0.6041568",
"0.5989928",
"0.58925945",
"0.5811854",
"0.58063555",
"0.5792181",
"0.5792181",
"0.5771394",
"0.57219064",
"0.5715661",
"0.57023704",
"0.56941557",
"0.56915575",
"0.5685478",
"0.5669038",
"0.5662726",
"0.56544596",
"0.56215... | 0.0 | -1 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize_params\n super.tap do |params|\n %w(scope team redirect_uri).each do |v|\n if !request.params[v].to_s.empty?\n params[v.to_sym] = request.params[v]\n end\n end\n log(:debug, \"Authorize_params #{params.to_h}\")\n end\n e... | [
"0.7227562",
"0.7089455",
"0.69590807",
"0.6955094",
"0.68463266",
"0.6838749",
"0.67946094",
"0.65502334",
"0.6477877",
"0.64064735",
"0.6325004",
"0.62828195",
"0.6242743",
"0.61860657",
"0.61687076",
"0.6152864",
"0.6129026",
"0.61270374",
"0.6091774",
"0.602243",
"0.60042... | 0.77745366 | 0 |
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_id)
MainMailer.contest_invite_with_account(@user, @inviter.name, @contest.contest_title).deliver_now if (@user.contest_invitation == 1 && @user.email_validated == true)
else
MainMailer.contest_invite_no_account(email, @inviter.name, @contest.contest_title).deliver_now
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accept_candidate\n authorize(@job_candidate)\n @job_candidate.accepted!\n tracker = Mixpanel::Tracker.new(ENV[\"NT_MIXPANEL_TOKEN\"])\n tracker.track('employer-' + current_employer.email, 'accepted candidate')\n CandidateMailer.send_job_hire(@job_candidate.candidate.email, @job_candidate.job).de... | [
"0.6265306",
"0.62034196",
"0.61915934",
"0.61722887",
"0.6166607",
"0.6158446",
"0.61425185",
"0.61394966",
"0.613072",
"0.6121585",
"0.610391",
"0.610049",
"0.6031447",
"0.6030711",
"0.6020831",
"0.59820503",
"0.59682935",
"0.5959971",
"0.5951934",
"0.5947938",
"0.59401923"... | 0.6614172 | 0 |
GET /implementations/1 GET /implementations/1.js | def show
render layout: 'wide_content'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @implement = Implement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @implement }\n end\n end",
"def interface\n respond_to do |format|\n format.json {}\n end\n end",
"def new\n @implement = Implement.new\n\... | [
"0.6346865",
"0.5797082",
"0.5680824",
"0.5619362",
"0.55823195",
"0.55374527",
"0.54910177",
"0.5477331",
"0.5459867",
"0.5449342",
"0.54267836",
"0.5401884",
"0.53583854",
"0.53281885",
"0.53062326",
"0.52835166",
"0.5271254",
"0.52643394",
"0.523734",
"0.523734",
"0.523450... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def implementation_params
p = params.permit(:scenario_id)
p.merge params.require(:implementation).permit(:library_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 += '#' : stair += ' '\n\n steps(n, row, stair)\nend",
"def how_many_steps?\n puts \"Left\"\n puts \"Right\"\n puts \"/1\\n... | [
"0.72871125",
"0.66319036",
"0.6181501",
"0.6157394",
"0.6135781",
"0.608254",
"0.60357237",
"0.59547776",
"0.59492236",
"0.59403527",
"0.5890433",
"0.58537525",
"0.5842024",
"0.5811479",
"0.5797087",
"0.5797031",
"0.5795863",
"0.57883704",
"0.5744695",
"0.57434213",
"0.57240... | 0.69546527 | 1 |
helper to decide if a user is online student or normal student | def is_a_online_student?
current_user.mode == "Online" ? true : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 logged_in_as_student?\n !current_student.nil?\n end",
"def student?\n return logged_in? && (current_user.class == Student)\n end",
"def s... | [
"0.7305143",
"0.72661877",
"0.7209433",
"0.719262",
"0.7156094",
"0.6969046",
"0.6910181",
"0.68802935",
"0.6865148",
"0.68130404",
"0.6788277",
"0.6705275",
"0.6654445",
"0.66370004",
"0.65740055",
"0.65714514",
"0.6562667",
"0.65451485",
"0.65362275",
"0.65109736",
"0.64291... | 0.84800327 | 0 |
Returns true if the fft_geomancy feature exists | def has_geomancy_feature?
!features(:geomancy_element_shift).empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_feat ( f )\n return false\n end",
"def feature?(feature)\n definition[:features]&.include?(feature)\n end",
"def aperture?\n !aperture.nil?\n end",
"def float_dtype?\n [:float32, :float64].include?(dtype)\n end",
"def is_mag?(); @type == GRT_MAG; end",
"def focal_length?\n... | [
"0.6759936",
"0.64259964",
"0.6272171",
"0.62395585",
"0.59958404",
"0.5974579",
"0.5963551",
"0.5955584",
"0.5871518",
"0.586599",
"0.5791189",
"0.5754336",
"0.5753596",
"0.5734952",
"0.56590253",
"0.56559",
"0.5640304",
"0.5625225",
"0.55964494",
"0.5590869",
"0.5571228",
... | 0.7363119 | 0 |
Apply "element rate rotation" for geomancy feature. Takes the base element rate. You can change these rules as you see fit. | def geomancy_element_shift(rate)
# absorb -> null
if rate < 0
return 0
# null -> resist (half)
elsif rate < 0.5
return 0.5
# resist (half) -> normal
elsif rate < 1
return 1
# normal -> weak (double)
elsif rate == 1
return 2
# weak -> absorb
elsif rate > 1
return -(rate-1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numberOfRotations(element)\n\nend",
"def draw_element_rate(x, y, width)\n draw_rates(x, y, width, $data_system.magic_elements, BestiaryConfig::ELEMENTS)\n end",
"def accelerate strength = 1.0\n self.speed += self.rotation_vector * strength/SUBSTEPS\n end",
"def apply_rotation\n if @rotatio... | [
"0.5348168",
"0.52889127",
"0.5103568",
"0.5092335",
"0.50058794",
"0.4998371",
"0.4994613",
"0.4979399",
"0.49764386",
"0.49746865",
"0.48339677",
"0.48143652",
"0.47985113",
"0.47170138",
"0.47086063",
"0.46895397",
"0.46819085",
"0.4680437",
"0.4656197",
"0.46462533",
"0.4... | 0.52708966 | 2 |
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 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner?(user)\n user == owner || owners.include?(user)\n end",
"def owner? (user)\n user == owner\n end",
"def is_owner?(user)\n !user.nil? && (self.user_id == user.id)\n end",
"def is_owner?(this_user)\n user == this_user\n end",
"def is_owner?(user)\n user.id == self... | [
"0.82786024",
"0.8251542",
"0.8152414",
"0.79650974",
"0.7939119",
"0.79154015",
"0.7902074",
"0.7867498",
"0.78300935",
"0.7815641",
"0.77649164",
"0.77649164",
"0.76464283",
"0.7631401",
"0.75297576",
"0.75031",
"0.749518",
"0.7440216",
"0.7437757",
"0.74172765",
"0.7387799... | 0.8629043 | 0 |
Helper sets all defaults on the current model prior to VALIDATIONS | def set_defaults
self.state ||= 'NEW'
self.account_id ||= Gizmo::Util::Uuid.generate
self.account_name ||= self.subdomain
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_model_defaults\n end",
"def set_default_attributes\n self.attributes = default_attributes\n self.attributes.each do |key, value|\n # Scrub the attributes if there's no value\n attr_clean!(key) unless value\n end\n end",
"def set_default_values\n # s... | [
"0.75367063",
"0.71556914",
"0.7081816",
"0.70598847",
"0.7058594",
"0.7058594",
"0.7046246",
"0.7046246",
"0.7046246",
"0.7046246",
"0.7046246",
"0.7046246",
"0.7029176",
"0.68784803",
"0.68392223",
"0.6712017",
"0.67078304",
"0.66635025",
"0.66589546",
"0.6647051",
"0.66224... | 0.61093056 | 99 |
Creates a new instance of ProviderObject. | def initialize(namespace, name)
super(namespace, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new(*args)\n obj = super\n @provider_instances << obj\n obj\n end",
"def new\n @provider = Provider.new\n end",
"def new\n self.default_provider.new\n end",
"def create_provider_object(config, logger, metrics, redis_connection_pool, provider_class, provider_name, options)\n ... | [
"0.78455746",
"0.78283596",
"0.69544303",
"0.69298184",
"0.69125503",
"0.6667507",
"0.6649598",
"0.656836",
"0.65661025",
"0.63434196",
"0.6251624",
"0.6163938",
"0.6163938",
"0.6163938",
"0.6163938",
"0.6160409",
"0.61305153",
"0.6118858",
"0.60745317",
"0.6073427",
"0.60621... | 0.0 | -1 |
Constructs class name for the lightweight provider. | def long_name
name = ''
if @name.to_s =~ /_/
@name.to_s.split('_').each do |str|
name << str.to_s.capitalize
end
else
name = @name.to_s.capitalize
end
namespace = @namespace.to_s.split('::').map { |str| str.capitalize }
"#{namespace.join('::')}::#{name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_name\n @class_name ||= derive_class_name\n end",
"def generate\n base_name = camel_case identifier.to_s\n decorate_klass_name base_name\n end",
"def name(_prefix = false)\n 'Providers'\n end",
"def human_name(klass = T.unsafe(nil)); end",
"def human_name(klass =... | [
"0.70328695",
"0.6860561",
"0.6818218",
"0.6748444",
"0.6748444",
"0.67236894",
"0.6694454",
"0.6684767",
"0.6684767",
"0.66553134",
"0.66353357",
"0.66215926",
"0.6589678",
"0.6589678",
"0.6564907",
"0.6564422",
"0.65578777",
"0.6556292",
"0.6549831",
"0.6542467",
"0.6503894... | 0.6152973 | 51 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.